|
| 1 | +--- |
| 2 | +description: Stage changes, generate commit message, and commit |
| 3 | +allowed-tools: Bash, Read |
| 4 | +--- |
| 5 | + |
| 6 | +Generate commit message(s) and commit the changes. |
| 7 | + |
| 8 | +## Instructions |
| 9 | + |
| 10 | +1. Check if there are staged files (`git diff --cached --name-only`) |
| 11 | +2. If files are already staged → leave unstaged files alone, commit only what's staged |
| 12 | +3. If nothing is staged → review ALL uncommitted changes (`git diff`, `git status`) |
| 13 | +4. **Group changes into logical chunks** — each commit should represent one coherent change: |
| 14 | + - Separate concerns: e.g., a bug fix and a docs update are two commits, not one |
| 15 | + - Group by purpose: files that work together for the same feature/fix go in one commit |
| 16 | + - Tests belong with the code they test in the same commit |
| 17 | + - Config/CI changes that support a feature can be grouped with that feature OR split out if they're independently meaningful |
| 18 | + - When in doubt, prefer smaller, more focused commits over large ones |
| 19 | +5. For each logical chunk: |
| 20 | + a. Stage the relevant files (`git add <specific files>`) |
| 21 | + b. Analyze the staged changes (`git diff --cached`) |
| 22 | + c. Generate a conventional commit message |
| 23 | + d. Display the commit message in chat |
| 24 | + e. Commit with the generated message (`git commit -m "..."`) |
| 25 | +6. If all changes are tightly related and form a single logical unit, a single commit is fine — don't split artificially |
| 26 | + |
| 27 | +## Output format |
| 28 | +``` |
| 29 | +<type>(<scope>): <concise summary> |
| 30 | +
|
| 31 | +- [bullet points if needed] |
| 32 | +``` |
| 33 | + |
| 34 | +Use conventional commit types: `feat`, `fix`, `refactor`, `docs`, `test`, `chore`, `style`, `perf` |
| 35 | + |
| 36 | +Keep the summary under 72 characters. |
0 commit comments