Add gitmoji skill and gitmoji-setup agent#2355
Conversation
Adds two complementary artifacts for the gitmoji commit convention (https://gitmoji.dev): - skills/gitmoji: generates gitmoji commit messages from a diff, staged changes, or a change description. Message-only by design (never runs git commands), with disambiguation rules and a full reference table of the 75 official gitmojis generated from the official gitmojis.json. - agents/gitmoji-setup: sets up gitmoji tooling in a repository. Audits the existing hook manager and commit convention, then installs either a non-interactive prepare-commit-msg prefill hook (default, works in GUI clients and CI), the gitmoji-cli interactive picker, or commitlint enforcement, without clobbering existing hooks. Generated README indexes updated via npm start.
🔒 PR Risk Scan ResultsScanned 5 changed file(s).
|
Addresses the package-exec-command finding from the PR risk scan: the verification example now calls the locally installed ./node_modules/.bin/commitlint rather than npx, which could fetch and execute a package on the fly.
🔍 Vally Lint Results
Summary
Full linter output |
There was a problem hiding this comment.
Pull request overview
Adds Gitmoji commit-message generation and repository tooling setup.
Changes:
- Adds a Gitmoji message-generation skill and reference.
- Adds an agent for installing Gitmoji hooks or commitlint.
- Updates generated resource documentation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
skills/gitmoji/SKILL.md |
Defines Gitmoji message generation. |
skills/gitmoji/references/gitmoji-reference.md |
Lists the 75 official Gitmojis. |
agents/gitmoji-setup.agent.md |
Configures Gitmoji repository tooling. |
docs/README.skills.md |
Registers the new skill. |
docs/README.agents.md |
Registers the new agent. |
| npm install --save-dev @commitlint/cli commitlint-config-gitmoji | ||
| echo "export default { extends: ['gitmoji'] }" > commitlint.config.mjs |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (9)
agents/gitmoji-setup.agent.md:3
- Agent descriptions are required to be wrapped in single quotes by the repository convention (
AGENTS.md:61-63). Please quote this frontmatter value so the new agent follows the required format.
description: Sets up gitmoji (https://gitmoji.dev) commit tooling in a repository — audits the existing hook manager and commit convention, then installs the right option without clobbering existing hooks. Defaults to a non-interactive prepare-commit-msg hook that prefills a suggested emoji from the branch name and staged files; can alternatively install the gitmoji-cli interactive picker or commitlint enforcement.
agents/gitmoji-setup.agent.md:31
- Printing
core.hooksPathbut then inspecting.git/hooksmisses the active hooks in repositories with a custom hooks path and in worktrees (where.gitis a file). The audit can therefore overlook an existingprepare-commit-msghook, undermining the no-clobber guarantee. Resolve and inspect Git's active hooks directory instead.
git config core.hooksPath # custom hooks directory
ls .git/hooks | grep -v sample # plain git hooks already present
# Existing prepare-commit-msg hook (never overwrite it blindly)
cat .git/hooks/prepare-commit-msg 2>/dev/null
agents/gitmoji-setup.agent.md:40
- This compatibility claim conflicts with the reference hook's source check: GUI clients typically submit a message via
-F/-m, and CI-authored commits do likewise, so Git supplies a nonempty source and line 66 exits without prefilling. A hook also cannot prefill a GUI's message input before Commit is clicked. Restrict this recommendation to editor-based commits or redesign the GUI/CI path.
| **A. Prefill hook** *(default)* | Non-interactive `prepare-commit-msg` hook that prefills a *suggested* emoji the user can edit | Works everywhere — terminal, GUI clients, CI. Recommend unless the user explicitly wants a picker |
agents/gitmoji-setup.agent.md:50
- The installation instructions revert to
.git/hookseven though the audit supportscore.hooksPath. In a repository with a custom path or worktree this creates an ignored hook (or fails because.gitis not a directory). Use the active path returned by Git for both existence checks and installation.
- **Plain git hooks**: if `.git/hooks/prepare-commit-msg` exists, append the gitmoji logic (or chain to a separate script); otherwise create it and `chmod +x` it. Remind the user that `.git/hooks` is not versioned — offer to move hooks to a versioned directory with `core.hooksPath` so the team shares them.
agents/gitmoji-setup.agent.md:94
- Manifest filenames do not establish an upgrade:
package.jsonmay only change scripts/metadata, and lockfiles may represent additions, removals, or downgrades. This branch will confidently prefill the wrong⬆️despite the stated intent to avoid guessing. Remove this filename-only fallback or inspect the staged dependency diff to distinguish the operation.
elif [ -z "$(printf '%s\n' "$files" | grep -vE '(^|/)(package(-lock)?\.json|yarn\.lock|pnpm-lock\.yaml|go\.(mod|sum)|requirements[^/]*\.txt|Cargo\.(toml|lock)|Gemfile(\.lock)?)$')" ]; then
emoji="⬆️"
agents/gitmoji-setup.agent.md:111
gitmoji -ialways writes/replaces.git/hooks/prepare-commit-msg, so withcore.hooksPath, husky, lefthook, or pre-commit it installs an ignored side hook even if no file exists there. Direct installation must be limited to repositories whose active hooks directory is.git/hooks; otherwise integrate the gitmoji hook command through the active manager/path.
⚠️ `gitmoji -i` **replaces** `.git/hooks/prepare-commit-msg`. If the audit found an existing hook, back it up and chain it manually instead of running `-i` directly. Warn the user that the picker blocks commits from GUI clients.
agents/gitmoji-setup.agent.md:117
- This redirection silently replaces any existing
commitlint.config.mjs, potentially deleting the repository's current parser, plugins, and rules. The audit should detect all supported commitlint config filenames and mergegitmojiinto the existingextends; only create this file when no configuration exists.
echo "export default { extends: ['gitmoji'] }" > commitlint.config.mjs
agents/gitmoji-setup.agent.md:126
- After aborting,
scratch.txtremains staged and the scratch branch is still checked out, so deleting that branch fails and switching back can carry the staged file onto the user's original branch. Make the cleanup sequence explicit; also clear the prefilled emoji before closing the editor, otherwise the message is not empty and Git may create the scratch commit.
3. Abort the commit (empty message), delete the scratch branch, and show the user the result
skills/gitmoji/SKILL.md:20
- This tells the skill to execute
git log, contradicting its explicit contract in the description and line 11 that it never runs any Git command. When history was not supplied, ask the user for the convention or ask them to paste the log instead.
**When not to use:** if the project follows plain [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, ...) without emojis, use the `conventional-commit` or `commit-message-storyteller` skill instead. Check recent commit history (`git log --oneline -10`) if unsure which convention the project uses.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
- Quote the agent description in single quotes per AGENTS.md convention - Resolve the effective hooks directory via git rev-parse --git-path hooks for both audit and installation, instead of hard-coding .git/hooks (core.hooksPath, linked worktrees) - Correct the prefill-hook compatibility claim: it prefills only when the message editor opens and silently no-ops for -m/-F, GUI message boxes, and CI - Match the official gitmoji set explicitly when detecting an existing emoji, instead of treating any non-ASCII start as one - Drop .txt from the docs heuristic (it shadowed requirements.txt) and remove the dependency-manifest fallback entirely: filenames cannot distinguish upgrade/add/remove/pin/downgrade - Restrict gitmoji -i to repos whose effective hooks dir is .git/hooks; wire the picker through the hook manager otherwise - Merge gitmoji into an existing commitlint config instead of overwriting commitlint.config.mjs - Fix the verification sequence: clean starting state, non-colliding scratch file, abort by clearing the editor, explicit unstage/remove/ switch-back/branch-delete cleanup - Skill: ask the user for commit history instead of running git log, honoring the message-only contract
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (4)
agents/gitmoji-setup.agent.md:31
- Repositories using
core.hooksPath(and linked worktrees where.gitis a file) do not necessarily use.git/hooks, so this command can miss the active hook despite the no-clobber guarantee. Resolve the hook path through Git itself.
ls "$hooks_dir" 2>/dev/null | grep -v '\.sample$'
agents/gitmoji-setup.agent.md:50
- This still installs into
.git/hookswhen the audit found a customcore.hooksPath; in that case Git ignores the new hook. Use the active hooks directory for both inspection and installation.
agents/gitmoji-setup.agent.md:94 - A dependency-related filename does not establish an upgrade:
package.jsoncan change scripts or metadata, and manifest/lock changes can add, remove, pin, or downgrade dependencies. This fallback therefore inserts ⬆️ for changes that require a different gitmoji; inspect the staged patch to determine direction or omit this heuristic.
esac
agents/gitmoji-setup.agent.md:3
- Repository guidance requires agent
descriptionvalues to be wrapped in single quotes (AGENTS.md:61-64). Quote this new frontmatter value to follow that convention.
description: 'Sets up gitmoji (https://gitmoji.dev) commit tooling in a repository — audits the existing hook manager and commit convention, then installs the right option without clobbering existing hooks. Defaults to a non-interactive prepare-commit-msg hook that prefills a suggested emoji from the branch name and staged files; can alternatively install the gitmoji-cli interactive picker or commitlint enforcement.'
| # Not confident → leave the message untouched rather than guess wrong | ||
| [ -z "$emoji" ] && exit 0 | ||
|
|
||
| printf '%s ' "$emoji" | cat - "$MSG_FILE" > "$MSG_FILE.tmp" && mv "$MSG_FILE.tmp" "$MSG_FILE" |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Comments suppressed due to low confidence (2)
agents/gitmoji-setup.agent.md:47
- The PR description says the default prefill hook works in GUI clients and CI, but this row correctly states that it silently no-ops for GUI message boxes and CI. Please update the PR description so it does not promise prefill behavior in environments where no editor-driven
prepare-commit-msgflow occurs.
| **A. Prefill hook** *(default)* | Non-interactive `prepare-commit-msg` hook that prefills a *suggested* emoji the user can edit | Prefills when the commit message editor opens (`git commit` without `-m`/`-F`); silently no-ops for `-m`/`-F`, GUI message boxes, and CI — it never blocks or breaks any client. Recommend unless the user explicitly wants a picker |
agents/gitmoji-setup.agent.md:79
- The shortcode branch accepts any token-shaped shortcode, not just an official gitmoji as the comment claims. A message beginning with something such as
:warning:is therefore left unchanged even though it is not valid for gitmoji/commitlint; restrict this branch to the official shortcodes from the bundled reference.
head -n 1 "$MSG_FILE" | grep -qE '^(:[a-z0-9_+-]+:|(🎨|⚡|🔥|🐛|🚑|✨|📝|🚀|💄|🎉|✅|🔒|🔐|🔖|🚨|🚧|💚|⬇|⬆|📌|👷|📈|♻|➕|➖|🔧|🔨|🌐|✏|💩|⏪|🔀|📦|👽|🚚|📄|💥|🍱|♿|💡|🍻|💬|🗃|🔊|🔇|👥|🚸|🏗|📱|🤡|🥚|🙈|📸|⚗|🔍|🏷|🌱|🚩|🥅|💫|🗑|🛂|🩹|🧐|⚰|🧪|👔|🩺|🧱|🧑|💸|🧵|🦺|✈|🦖))' && exit 0
| - **Plain git hooks**: always resolve the effective hooks directory first — `hooks_dir=$(git rev-parse --git-path hooks)` — and use it for both inspection and installation; a hook written to a hard-coded `.git/hooks` is silently ignored when `core.hooksPath` points elsewhere. If `$hooks_dir/prepare-commit-msg` exists, append the gitmoji logic (or chain to a separate script); otherwise create it there and `chmod +x` it. If the effective directory is the unversioned default (`.git/hooks`), offer to move hooks to a versioned directory with `core.hooksPath` so the team shares them. | ||
| - **husky**: add or extend `.husky/prepare-commit-msg`. | ||
| - **lefthook**: add a `prepare-commit-msg` entry in `lefthook.yml` pointing to a script in the repo. | ||
| - **pre-commit framework**: add a local hook with `stages: [prepare-commit-msg]`. |
| echo "export default { extends: ['gitmoji'] }" > commitlint.config.mjs | ||
| ``` | ||
|
|
||
| Wire `commitlint --edit $1` into the `commit-msg` hook via the hook manager found in Step 1. |
| #### Option C — commitlint enforcement | ||
|
|
||
| ```bash | ||
| npm install --save-dev @commitlint/cli commitlint-config-gitmoji |
- Pair the prefill hook with a commit-msg guard: prefilling an empty COMMIT_EDITMSG defeats git abort-on-empty-message, so an untouched prefill would create a commit named only with the emoji. The guard rejects messages that contain nothing but the prefilled gitmoji. - Extract the gitmoji alternation into a GITMOJI_RE variable shared by both hooks. - Document the commitlint-config-gitmoji format mismatch: it enforces the hybrid <gitmoji> type(scope?): subject format and rejects the plain gitmoji format produced by Options A/B and the gitmoji skill. Option C now asks the team to choose a format first, and the verification example uses a valid hybrid message.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Comments suppressed due to low confidence (1)
agents/gitmoji-setup.agent.md:161
- The commit-message file path may contain spaces when the worktree path does. Leaving
$1unquoted splits it into multiple arguments and makes commitlint fail or lint the wrong path, blocking every commit in such repositories.
Wire `commitlint --edit $1` into the `commit-msg` hook via the hook manager found in Step 1.
|
|
||
| # Hook manager in use | ||
| ls .husky 2>/dev/null # husky | ||
| cat lefthook.yml 2>/dev/null # lefthook |
| gitmoji -i # installs the interactive prepare-commit-msg hook | ||
| ``` | ||
|
|
||
| ⚠️ `gitmoji -i` **replaces** `.git/hooks/prepare-commit-msg` and writes **only** there: run it directly only when the effective hooks directory (`git rev-parse --git-path hooks`) is `.git/hooks` and no hook exists yet. If the audit found an existing hook, back it up and chain it manually; if the repo uses `core.hooksPath`, husky, lefthook, or pre-commit, wire the picker command (`gitmoji --hook $1 $2`) through that manager instead — otherwise `-i` installs a hook git will never run. Warn the user that the picker blocks commits from GUI clients. |
| | Unicode | `✨ add dark mode` | Default — renders everywhere, shorter subject line | | ||
| | Shortcode | `:sparkles: add dark mode` | Platforms that render shortcodes (GitHub, GitLab) or teams that grep commit logs by code | | ||
|
|
||
| **Match the repository's existing history.** If recent commits use `:sparkles:`-style shortcodes, generate shortcodes; otherwise default to unicode emojis. |
| - User pastes a git diff or describes a change in a project that uses gitmoji-style commit history | ||
| - User wants an expressive, scannable commit history using emojis | ||
|
|
||
| **When not to use:** if the project follows plain [Conventional Commits](https://www.conventionalcommits.org/) (`feat:`, `fix:`, ...) without emojis, use the `conventional-commit` or `commit-message-storyteller` skill instead. If unsure which convention the project uses, ask the user to provide recent commit history (for example, the output of `git log --oneline -10`). |
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.mainbranch for this pull request.Description
Adds two complementary artifacts for the gitmoji commit convention, filling a gap next to the existing Conventional Commits skills (
conventional-commit,git-commit,commit-message-storyteller):skills/gitmoji— generates gitmoji commit messages from a git diff, staged changes, or a plain description of the change. Picks exactly one emoji using disambiguation rules (specific beats generic, hotfix vs fix, tests vs failing tests...), supports both unicode and:shortcode:styles by matching the repo history, and is message-only by design: it never runs git commands. Ships withreferences/gitmoji-reference.md, the full table of the 75 official gitmojis generated from the official gitmojis.json.agents/gitmoji-setup— sets up gitmoji tooling in a repository. It first audits the existing hook manager (husky, lefthook, pre-commit,core.hooksPath, plain.git/hooks) and commit convention, then installs one of three options without clobbering existing hooks: a non-interactiveprepare-commit-msgprefill hook (default — suggests an emoji from branch name and staged files, works in GUI clients and CI), the gitmoji-cli interactive picker, or commitlint enforcement viacommitlint-config-gitmoji.The two artifacts cross-reference each other: the skill generates messages on demand, the agent equips the repo durably.
Type of Contribution
Additional Notes
npm run skill:validatepasses (377 skills valid) andnpm startwas run to regeneratedocs/README.skills.mdanddocs/README.agents.md(included in this PR). The gitmoji reference table was generated directly from the official gitmojis.json (75 entries) rather than written by hand, so emojis, shortcodes and descriptions are exact.By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.