Write a Conventional Commits message from staged git changes, with a read-only helper script that gathers the staged diff and recent commit style.
---
name: git-commit
description: Writes a Conventional Commits message for the changes that are already staged in git, using the staged diff, file list and the repository's recent commit style. Use when the user asks for a commit message, a conventional commit, or "commit this" after staging. Does not stage, commit or push unless explicitly asked.
compatibility: Requires git and a POSIX shell (bash) for the bundled generate.sh helper.
metadata:
version: "1.2.0"
---
# Git Commit Message Generator
Turns the **staged** changes into one clear commit message that follows
[Conventional Commits 1.0.0](https://www.conventionalcommits.org/en/v1.0.0/).
## When to use
- The user staged changes and wants a message, or asks you to commit what is staged.
- Not for splitting a messy working tree into several commits, rewriting history or pushing.
## Files in this skill
- `SKILL.md` (this file)
- `generate.sh` — read-only helper that prints the branch, staged file list, change size,
the last 10 commit subjects and the first N lines of the staged diff. It never stages,
commits or pushes. Exit codes: `2` not a git work tree, `3` nothing staged, `64` bad argument.
## Workflow
1. From the repository root, collect context:
```bash
bash <skill-dir>/generate.sh # default: first 400 diff lines
bash <skill-dir>/generate.sh 1000 # larger limit for bigger changes
```
Without the helper, run the same read-only commands yourself:
`git diff --cached --name-status`, `git diff --cached --stat`, `git log -n 10 --format=%s`,
`git diff --cached`.
2. If the helper exits with code 3, stop and tell the user nothing is staged. Do not run
`git add` on their behalf unless they name the files.
3. If the output says the diff was truncated, read the remaining files with
`git diff --cached -- <path>` before describing them. Never summarise code you did not read.
4. Choose the **type** from what the diff actually does:
- `feat` new user-facing capability (SemVer MINOR), `fix` bug fix (SemVer PATCH).
These two are the only types the specification defines.
- Common additional types (from the Angular convention / commitlint config-conventional):
`docs`, `style`, `refactor`, `perf`, `test`, `build`, `ci`, `chore`, `revert`.
If the recent commit subjects show a different house style, follow the house style.
5. Choose an optional **scope**: the package, module or directory most of the change touches
(for example `auth`, `api`). Omit it when the change is broad.
6. Write the **description**: imperative mood, lower-case start, no trailing period,
about 72 characters or fewer for the whole header line.
7. Add a **body** only when the why is not obvious from the header: what was wrong or missing
and why this approach. Wrap at about 72 characters.
8. Add **footers** only from facts you have: `Refs: #123` / `Closes #123` when the user or branch
name gives an issue number; `BREAKING CHANGE: <what breaks and how to migrate>` (or `!` after
the type/scope) when a public API, config key, CLI flag or data format changes incompatibly.
9. If the staged changes contain several unrelated changes, say so and suggest how to split
them instead of writing a vague combined message.
10. Show the message. Only run `git commit` if the user asked you to commit; use
`git commit -F <file>` (or a heredoc) so multi-line bodies are preserved. Never add
`--no-verify`, `--amend` or push unless explicitly requested.
## Output format
```
<type>(<scope>)!: <description>
<body: why, in wrapped prose or short bullets>
<footer(s)>
```
## Limitations
- Message quality depends on the diff; generated or minified files and binary changes should be
described by purpose (for example "regenerate lockfile") rather than content.
- Issue numbers, ticket IDs and test results must come from the user or the repository. Do not
invent them.
## Example
Staged: `src/api/users.ts` adds a null check before reading `user.profile`, plus a new test in
`src/api/users.test.ts`. Recent subjects use `fix(api): ...`.
```
fix(api): handle null user in profile fetch
The handler read user.profile without checking for a missing user,
so a deleted account returned a 500 instead of a 404.
Refs: #482
```
(`Refs: #482` only because the user said the bug is issue 482.)
Draft a PR title and description from the branch's real commits and diff, fill the repo's PR template, and leave unverified checklist items unticked.
Turn an issue title or ticket ID into a consistent, git-valid branch name like fix/JIRA-123-login-button-not-working, with explicit type, case and length rules.
Work on multiple branches simultaneously
Illustrative input and expected result. This example is a verification guide, not a recorded model run.
Content reviewed .
A developer has staged a bug fix and its regression test and wants a commit message that matches the repository's existing fix(api) style.
I've staged my changes. Write the commit message. The bug is issue #482: deleted users made GET /users/:id/profile return 500. Staged (from generate.sh): M src/api/users.ts (adds `if (!user) return res.status(404)...` before reading user.profile) A src/api/users.test.ts (new test: returns 404 for a deleted user) Recent subjects: fix(api): reject empty email on signup | feat(auth): add magic-link login
One message, shown before any commit is made, for example: fix(api): return 404 for deleted user profile The profile handler read user.profile without checking for a missing user, so deleted accounts produced a 500 instead of a 404. Adds a regression test. Refs: #482 Type is fix (behaviour correction), scope api matches the house style, no BREAKING CHANGE footer because the response contract does not change incompatibly, and the issue reference comes from the user's message.
AI Agent Skills are reusable workflow packages that extend your AI coding assistant with multi-step capabilities. Install git-commit by following these steps.
SKILL.md inside, in the location documented by your client. Do not assume every AI application reads the same directory.Requires an Agent Skills-compatible client; supported locations and activation vary by version. Read the SKILL.md setup guide. MCP connects tools and data and does not, by itself, install a skill.
Draft a PR title and description from the branch's real commits and diff, fill the repo's PR template, and leave unverified checklist items unticked.
Turn an issue title or ticket ID into a consistent, git-valid branch name like fix/JIRA-123-login-button-not-working, with explicit type, case and length rules.
Work on multiple branches simultaneously