Git Commit Message Skill
Generate and create Git commit messages following the project's strict formatting rules.
The message is always shown to the user for approval before any commit is made.
Commit Message Format
[TAG] Short summary opening with a capital
Detailed description of the change, written in prose and wrapped at
72 characters.
Tags
[BUG FIX] = A bug fix
[FEATURE] = New feature code
[REFACTOR] = A code refactor
[TEST CODE] = Added test code
[TIDY] = A tidy up action such as reformatting or spelling fixes
Special Case
If this is the very first commit of a project (no prior commits exist), the entire commit message must be exactly:
Initial commit
No tag, no body.
Summary Line Rules
- Must begin with a tag in square brackets (except "Initial commit")
- Must open with a capital letter; the words after it are free, so a lower case
tool or file name (
ps, pgrep, lproj) stays as it is written
- Must be short and concise
- Must NOT end with a period
Body Rules
- One blank line between the summary line and the body
- Body must be written in prose (complete sentences, paragraph form)
- Body must NOT use bullet points or lists
- Wrap all lines at 72 characters
- No mention of claude session or AI assistant should be included
Workflow
- Run
git status to see what has changed
- Run
git diff --cached to see staged changes; if nothing is staged, run git diff to see unstaged changes
- Check
git log --oneline -1 to determine if this is the first commit (if it errors, it is the first commit)
- Analyze the changes to determine the appropriate tag and write a clear summary and description
- Check for a README file at the repo root (
README.markdown (preferred), README.md, README, README.rst, README.txt). If one exists, read it and determine whether the changes make any part of it stale or incomplete (features added/removed, usage changed, install steps, options, file layout, etc.). If so, update the README in the same commit. If the README is unaffected, proceed without changes.
- Stage files if needed (prefer staging specific files over
git add -A)
- Write the message to
.git/COMMIT_EDITMSG using a quoted HEREDOC:cat > "$(git rev-parse --git-dir)/COMMIT_EDITMSG" <<'EOF'
[TAG] Short summary opening with a capital
Detailed description of the change.
EOF
- Run the Approval Step below. Do not commit until it returns approved text.
- Commit from the file — never re-type the approved text into
-m:git commit -F "$(git rev-parse --git-dir)/COMMIT_EDITMSG"
Approval Step
Print the full proposed message in the response, then call AskUserQuestion
with one question, header Commit msg, and these options:
- Approve — commit with the message as written
- Edit — open the message in the editor and commit what comes back
- Cancel — make no commit
On Approve
Proceed to the commit. Change nothing about the text.
On Edit
- Resolve the editor, in this order, taking the first non-empty value:
git config core.editor, then $VISUAL, then $EDITOR.
Ignore $GIT_EDITOR — Claude Code sets it to true in the environment,
so it silently makes no edit. If none of the three is set, tell the user and
fall back to the manual path below.
- Launch the editor on
.git/COMMIT_EDITMSG from Bash with a 600000 ms
timeout, and only with an option that makes it block until the file is
closed (--wait, -w, --block). A GUI editor such as bbedit --wait
blocks correctly this way.
- A terminal editor (
vim, nano, emacs -nw, hx) has no TTY under the
Bash tool and will fail or return instantly. When the resolved editor is one
of those — or the launch errors, or returns with the file unchanged — do not
retry: ask the user to run it themselves by typing
! <editor> .git/COMMIT_EDITMSG at the prompt, then wait for them to say
they are done.
- Read the file back. Strip lines beginning with
# and any trailing blank
lines.
- If what remains is empty or whitespace only, the commit is aborted — same as
Git's own behavior. Say so and stop.
- Use the edited text verbatim. Do not reformat it, re-wrap it, re-tag it, or
correct it against the rules above — the user's edit is final. If it violates
a formatting rule, commit it anyway and note the discrepancy in one line
after the commit.
- Commit with
git commit -F as in step 9.
On Cancel
Make no commit. Leave the index exactly as it is — do not unstage anything that
was staged in step 6. Say what remains staged.
Argument Handling
- If
$ARGUMENTS is provided, treat it as a description of the changes to help craft the commit message
- If no arguments, analyze the diff to determine the appropriate message
- Always review the actual changes before committing — do not rely solely on the user's description
1---2name: commit3description: Generate Git commit messages following project conventions. Use when the user wants to commit changes or asks for a commit message. Analyzes staged/unstaged changes and produces properly formatted commit messages with tags, capitalized summaries, and prose bodies.4---56# Git Commit Message Skill78Generate and create Git commit messages following the project's strict formatting rules.9The message is always shown to the user for approval before any commit is made.1011## Commit Message Format1213```14[TAG] Short summary opening with a capital1516Detailed description of the change, written in prose and wrapped at1772 characters.18```1920## Tags2122- `[BUG FIX]` = A bug fix23- `[FEATURE]` = New feature code24- `[REFACTOR]` = A code refactor25- `[TEST CODE]` = Added test code26- `[TIDY]` = A tidy up action such as reformatting or spelling fixes2728## Special Case2930If this is the very first commit of a project (no prior commits exist), the entire commit message must be exactly:3132```33Initial commit34```3536No tag, no body.3738## Summary Line Rules3940- Must begin with a tag in square brackets (except "Initial commit")41- Must open with a capital letter; the words after it are free, so a lower case42 tool or file name (`ps`, `pgrep`, `lproj`) stays as it is written43- Must be short and concise44- Must NOT end with a period4546## Body Rules4748- One blank line between the summary line and the body49- Body must be written in prose (complete sentences, paragraph form)50- Body must NOT use bullet points or lists51- Wrap all lines at 72 characters52- No mention of claude session or AI assistant should be included5354## Workflow55561. Run `git status` to see what has changed572. Run `git diff --cached` to see staged changes; if nothing is staged, run `git diff` to see unstaged changes583. Check `git log --oneline -1` to determine if this is the first commit (if it errors, it is the first commit)594. Analyze the changes to determine the appropriate tag and write a clear summary and description605. Check for a README file at the repo root (`README.markdown` (preferred), `README.md`, `README`, `README.rst`, `README.txt`). If one exists, read it and determine whether the changes make any part of it stale or incomplete (features added/removed, usage changed, install steps, options, file layout, etc.). If so, update the README in the same commit. If the README is unaffected, proceed without changes.616. Stage files if needed (prefer staging specific files over `git add -A`)627. Write the message to `.git/COMMIT_EDITMSG` using a quoted HEREDOC:63 ```64 cat > "$(git rev-parse --git-dir)/COMMIT_EDITMSG" <<'EOF'65 [TAG] Short summary opening with a capital6667 Detailed description of the change.68 EOF69 ```708. Run the **Approval Step** below. Do not commit until it returns approved text.719. Commit from the file — never re-type the approved text into `-m`:72 ```73 git commit -F "$(git rev-parse --git-dir)/COMMIT_EDITMSG"74 ```7576## Approval Step7778Print the full proposed message in the response, then call `AskUserQuestion`79with one question, header `Commit msg`, and these options:8081- **Approve** — commit with the message as written82- **Edit** — open the message in the editor and commit what comes back83- **Cancel** — make no commit8485### On Approve8687Proceed to the commit. Change nothing about the text.8889### On Edit90911. Resolve the editor, in this order, taking the first non-empty value:92 `git config core.editor`, then `$VISUAL`, then `$EDITOR`.93 **Ignore `$GIT_EDITOR`** — Claude Code sets it to `true` in the environment,94 so it silently makes no edit. If none of the three is set, tell the user and95 fall back to the manual path below.962. Launch the editor on `.git/COMMIT_EDITMSG` from Bash with a 600000 ms97 timeout, and only with an option that makes it block until the file is98 closed (`--wait`, `-w`, `--block`). A GUI editor such as `bbedit --wait`99 blocks correctly this way.1003. A terminal editor (`vim`, `nano`, `emacs -nw`, `hx`) has no TTY under the101 Bash tool and will fail or return instantly. When the resolved editor is one102 of those — or the launch errors, or returns with the file unchanged — do not103 retry: ask the user to run it themselves by typing104 `! <editor> .git/COMMIT_EDITMSG` at the prompt, then wait for them to say105 they are done.1064. Read the file back. Strip lines beginning with `#` and any trailing blank107 lines.1085. If what remains is empty or whitespace only, the commit is aborted — same as109 Git's own behavior. Say so and stop.1106. Use the edited text verbatim. Do not reformat it, re-wrap it, re-tag it, or111 correct it against the rules above — the user's edit is final. If it violates112 a formatting rule, commit it anyway and note the discrepancy in one line113 after the commit.1147. Commit with `git commit -F` as in step 9.115116### On Cancel117118Make no commit. Leave the index exactly as it is — do not unstage anything that119was staged in step 6. Say what remains staged.120121## Argument Handling122123- If `$ARGUMENTS` is provided, treat it as a description of the changes to help craft the commit message124- If no arguments, analyze the diff to determine the appropriate message125- Always review the actual changes before committing — do not rely solely on the user's description