Git Workflow
Use this skill to keep git operations safe, reviewable, and easy to understand.
When to Use
- The user wants a commit or PR
- The worktree is dirty and you need to understand what changed
- You need to split work into atomic commits
- You need to summarize a branch before review
- You need to avoid dangerous git history edits
Core Rules
- Prefer read-first commands before any commit action
- Never rewrite history unless the user explicitly asks
- Never use destructive commands by default
- Group commits by real feature or fix boundary, not by file count
- Summarize the meaningful change before committing
Standard Flow
- Inspect the repo state:
git status --short
git diff --stat
git diff -- <path>
- Separate your changes from unrelated ones:
- identify files touched for the current task
- do not revert unrelated work
- if the same file has mixed concerns, split carefully or ask
- Stage intentionally:
git add <file1> <file2>
git diff --cached
- Write an atomic commit:
- one feature, fix, or refactor per commit
- use a direct message that says what changed
- if the repo uses conventions, follow them
Example:
git commit -m "feat: add repo-scan start routing"
- For PR prep, summarize:
- what changed
- main files
- tests run
- notable risks
PR Review Prep
Before opening or reviewing a PR:
git diff --stat origin/main...
git log --oneline --decorate --max-count=10
Use that to produce:
- a short change summary
- a risk list
- exact files worth reviewer attention
Safe Defaults
Prefer:
git status --short
git diff --stat
git diff --cached
git log --oneline --decorate --max-count=15
Avoid by default:
git reset --hard
git checkout --
git push --force
git rebase -i
Commit Quality Checklist
- only task-relevant files are staged
- diff matches one coherent change
- commit message reflects the actual change
- no accidental debug artifacts
- tests or verification are noted
Related
feature-code-review— review the code before or after commitsession-management— recover prior intent before preparing a commit