Skill

git-amend

MANDATORY: Use instead of `git commit --amend` - verifies HEAD and push status first

From cat
Install
1
Run in your terminal
$
npx claudepluginhub cowwoc/cat --plugin cat
Tool Access

This skill uses the workspace's default tool permissions.

Skill Content

Git Amend Skill

Purpose: Safely amend the most recent commit with proper verification checks.

Safety Rules

Only Amend When ALL Conditions Are Met

  1. HEAD commit was created by you in this session
  2. Commit has NOT been pushed to remote
  3. You intend to modify HEAD (not an earlier commit)
# Check if pushed:
git status
# Look for: "Your branch is ahead of 'origin/main' by X commits"
# "up to date" = already pushed (amending creates divergent history)

Quick Workflow

# 1. Verify HEAD is the commit you want to amend
git log --oneline -1

# 2. Verify not pushed to remote
git status  # Must show "ahead of origin"

# 3. Make your changes (edit files, stage new files)
git add <files>

# 4. Amend the commit
git commit --amend

# Or with new message:
git commit --amend -m "New message"

# Or keep same message:
git commit --amend --no-edit

Common Use Cases

Fix a typo in the last commit

# Edit the file
vim file.txt

# Stage and amend
git add file.txt
git commit --amend --no-edit

Add forgotten file to last commit

git add forgotten-file.txt
git commit --amend --no-edit

Change commit message only

git commit --amend -m "Better commit message"

Dangerous Situations

# Only amend unpushed commits
git push origin main
git commit --amend  # Creates divergent history!

# Only amend your own commits
git pull  # Pulls teammate's commit
git commit --amend  # Rewrites their work!

# If you must amend after push (with explicit permission):
git commit --amend
git push --force-with-lease  # Safer than --force

Amending Earlier Commits

To modify a commit that's NOT at HEAD, use interactive rebase:

# 1. Start interactive rebase
git rebase -i <commit>^  # Parent of commit to edit

# 2. Change 'pick' to 'edit' for the target commit

# 3. Make changes when rebase stops
git add <files>
git commit --amend

# 4. Continue rebase
git rebase --continue

Error Recovery

# If amend was wrong, check reflog for original:
git reflog
git reset --hard HEAD@{1}  # Go back to before amend

Success Criteria

  • Verified HEAD is the commit to amend
  • Verified commit not pushed to remote
  • Changes staged before amend
  • Commit message is appropriate
  • No force push required (unless explicitly intended)
Similar Skills
cache-components

Expert guidance for Next.js Cache Components and Partial Prerendering (PPR). **PROACTIVE ACTIVATION**: Use this skill automatically when working in Next.js projects that have `cacheComponents: true` in their next.config.ts/next.config.js. When this config is detected, proactively apply Cache Components patterns and best practices to all React Server Component implementations. **DETECTION**: At the start of a session in a Next.js project, check for `cacheComponents: true` in next.config. If enabled, this skill's patterns should guide all component authoring, data fetching, and caching decisions. **USE CASES**: Implementing 'use cache' directive, configuring cache lifetimes with cacheLife(), tagging cached data with cacheTag(), invalidating caches with updateTag()/revalidateTag(), optimizing static vs dynamic content boundaries, debugging cache issues, and reviewing Cache Component implementations.

138.5k
Stats
Parent Repo Stars78
Parent Repo Forks1
Last CommitFeb 13, 2026