Amend Staged Changes
Amend the most recent commit by adding currently staged changes to it, without staging new files.
Context
- Current git status: {{GIT_STATUS}}
- Current branch: {{GIT_BRANCH}}
- Recent commits: {{GIT_LOG}}
Safety Checks
Before amending, you MUST verify ALL of these conditions:
-
HEAD commit was created by Claude:
- Run:
git log -1 --format='%an %ae' - Must show: "Claude Sonnet 4.5 noreply@anthropic.com" in Co-Authored-By
- Run:
-
Commit has NOT been pushed:
- Run:
git status - Must show "Your branch is ahead of" (not "up to date")
- If already pushed, WARN user that amend requires force push
- Run:
-
There are staged changes:
- Must have "Changes to be committed" in git status
- If no staged changes, inform user nothing to amend
Your task
Based on the staged changes shown above, amend the last commit.
IMPORTANT:
- Do NOT run
git add. Only amend with already-staged changes. - Use
git commit --amend --no-editto keep the existing commit message - If you need to update the commit message, use
git commit --amendand provide new message
Steps:
- Run safety checks (verify conditions above)
- If all checks pass, run:
git commit --amend --no-edit - Report what was amended
Example:
# Verify HEAD commit author
git log -1 --format='%an %ae'
# Verify not pushed
git status
# Amend with staged changes (keep message)
git commit --amend --no-edit
Notes
- This follows Git Safety Protocol: only amend commits created by Claude in this conversation
- Never amend commits that have been pushed without explicit user request
- If user wants to change commit message, use
git commit --amendwithout--no-edit