A GitHub Action that analyzes commit messages and code comments in a PR diff and posts the developer's emotional state as a PR comment.
Completely useless. Highly accurate.
Add this to your workflow:
name: Code Mood Ring
on:
pull_request:
types: [opened, synchronize]
permissions:
pull-requests: write
jobs:
mood-ring:
runs-on: ubuntu-latest
steps:
- uses: cadamsmith/code-mood-ring@v1That's it. No secrets. No configuration required. The standard GITHUB_TOKEN is used automatically.
On every PR open or push:
- Fetches all commit messages in the PR
- Fetches the raw diff and extracts added comment lines
- Runs sentiment analysis on both (AFINN word list + custom commit/code vocabulary)
- Blends the scores โ commits weighted 60%, code comments 40%
- Posts (or updates) a single PR comment with the diagnosis
| score | mood |
|---|---|
| < -4 | ๐ฅ Fine. Everything Is Fine. |
| -4 to -2 | ๐ Spiraling |
| -2 to -1 | ๐ค Defeated |
| -1 to 0 | ๐ฟ Touch Grass Immediately |
| 0 to 1 | ๐ Meh |
| 1 to 2 | โ Caffeinated |
| 2 to 3 | ๐ฏ In The Zone |
| 3+ | ๐ Zen |
Mood: ๐ Spiraling
The code is crying out for help in multiple formats. Both the commits and the inline comments are in a bad place.
Stability Score:
โโโโโโโโโโ2/10Commits:
-2.3sentiment avg across 4 messages
Code comments:-3.1sentiment avg across 7 comments๐ฌ Most telling commit: "why does this still not work"
๐ Most telling comment: "TODO: figure out why this is broken"
| input | description | default |
|---|---|---|
github-token |
Token for posting PR comments | ${{ github.token }} |
Sentiment scoring uses the sentiment package (AFINN-165 word list) extended with commit-specific vocabulary:
wtf: -4,hotfix: -3,revert: -3,hack: -2,hopefully: -2release: +3,implement: +2,optimize: +2,improve: +2
Code comments are extracted from added lines (+) in the diff across languages: //, #, /*, *, <!--, --, %%, ;.
No external API calls are made. Everything runs in the GitHub Actions runner.
npm install # installs deps + the husky pre-commit hook
npm test # vitest โ covers src/mood.ts
npm run typecheck # tsc --noEmit
npm run build # bundles src/index.ts โ dist/index.js via nccThe pre-commit hook rebuilds dist/ whenever src/ changes and runs the test suite. CI runs typecheck, tests, build, and verifies the committed dist/ matches what npm run build produces.
MIT