1.5 KiB
1.5 KiB
Commit Changes
Trigger: user asks to commit, or uses /commit
Steps
- Determine what to commit:
- Run
git diff --cached --name-onlyto check for staged changes. - If there are staged changes, commit only those. Tell the user: "Committing staged changes."
- If no staged changes, run
git diff --name-onlyto check for unstaged changes. - If there are unstaged changes, stage all of them (
git addeach file by name) and commit. Tell the user: "Staging and committing all changes." - If no changes at all, tell the user "Nothing to commit." and stop.
- Run
- Run
git diff --cachedto see the full diff of what will be committed. - Write a conventional commit message:
- Format:
<type>: <description> - Types:
feat,fix,refactor,style,chore,docs,test,perf - Description: lowercase, imperative mood, no period, concise
- Pick the type that best fits the change. Use
featfor new features,fixfor bug fixes,refactorfor code restructuring,stylefor visual/CSS-only changes,chorefor maintenance/tooling. - Add a body (separated by blank line) only if the description alone is insufficient to understand the change.
- Format:
- Show the user the proposed commit message and ask for confirmation before committing.
- On confirmation, create the commit. Use a HEREDOC for the message:
git commit -m "$(cat <<'EOF' <type>: <description> Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> EOF )" - Run
git statusafter to verify success.