Git is the safety net. Every commit is a checkpoint you can return to.
Atomic commits. Descriptive messages. Feature branches for tier 2+.
Never commit broken code to main.
Check git status before any work. Note branch, clean/dirty, remote sync.
Skill-specific: skills/git/reference/git-research.md
<core_principles>
- ATOMIC COMMITS: One logical change per commit. Never mix feature + refactor + fix.
- CONVENTIONAL FORMAT: {type}({scope}): {description} - feat, fix, refactor, docs, test, chore
- IMPERATIVE MOOD: "add feature" not "added feature" or "adding feature"
- BRANCH PER FEATURE: Tier 2+ work gets feature/{name} or fix/{name} branch
- COMMIT OFTEN: Every working state gets a commit. Max 30 min between commits.
</core_principles>
1. `git status` — note branch, dirty files, untracked.
2. Dirty at task start? Stop. Commit, stash, or discard prior state first.
3. Tier 2+: confirm you are NOT on main. Create branch: `git checkout -b {type}/{name}`.
(gate: clean working tree OR explicit decision made)
4. Record HEAD sha to AgentDB before any work: `git rev-parse HEAD`.
(gate: sha written to AgentDB — rollback target exists)
5. Stage specific files only: `git add {file}` — never `git add -A` or `git add .`.
6. Write message: `{type}({scope}): {description}` in imperative mood.
— Forbidden: wip, update, misc, auto commit, Co-Authored-By, "Generated with"
7. Commit. Never `--no-verify` (fix the gate instead; see hook carve-outs in CLAUDE.md).
(gate: `git log --oneline -1` shows correct message; no forbidden strings)
8. `git diff --stat {base}..HEAD` — only contracted files changed.
9. No leaked secrets: `git diff HEAD~1 | grep -i "key\|token\|secret\|password"`.
(gate: diff matches contract scope; zero secret leaks)
10. Feature branch: push freely after gates pass.
11. main / master: STOP — requires explicit user say-so (I0.8).
12. Never bare `--force`. If needed: `--force-with-lease` only.
(gate: user confirmed OR branch is not main)
13. Keep diffs ≤400 lines. >400 lines: split the PR first — AI review accuracy drops significantly above this threshold.
14. AI review before human review (sequence: AI → fix → human). Never parallelize.
15. PR description for AI-assisted work must answer: AI role / prompt / human contribution.
16. "Nit:" prefix for optional style comments.
17. Reviewer context matters: reviewer with diff-only context → diff-quality findings; reviewer with full-codebase context → codebase-quality findings. Spawn reviewers with repo access.
18. Pre-PR validation for AI-generated code: before raising the PR, verify the implementation against the original spec/intent (not just "does it run?"). Catch intent drift — AI correctly implemented what it inferred, not what was actually needed — before a human reviewer sees it.
19. Track AI review acceptance rate: ≥50% of comments accepted = signal of trusted, actionable feedback. Below 50% → tool is misconfigured, noisy, or poorly scoped.
20. Small PRs (≤400 lines) + multi-tool guidelines = 30–40% shorter review cycle times. The size rule has measurable throughput impact, not just reviewer comfort.
21. Risk hotspot prioritization: use review analytics (change frequency × defect rate per file/subsystem) to identify hotspots. Invest deeper human review at hotspots; lighter AI-only review at low-churn, low-defect areas.
22. Non-interactive review in CI/hooks: `claude -p "Review this diff for security issues" --output-format json --allowedTools Read,Bash` runs Claude as a script in pre-commit or pipelines. Scope tools with `--allowedTools` to prevent unintended writes during automated runs.
23. Framework-specific review checks: React → hooks violations (stale closures, missing dependency arrays, conditional hooks); Go → unchecked errors and goroutine leaks; Python → mutable default args and bare except clauses. Generic review misses these; name the framework in the review prompt.
(gate: diff ≤500 lines; review sequence followed)
<branch_strategy>
- main: Always deployable. Never commit directly for tier 2+.
- feature/{name}: New functionality
- fix/{name}: Bug fixes
- refactor/{name}: Code restructuring
Profile-gated workflow:
local: direct to main OK, branches optional
github: feature branches for tier 2+, PRs optional
github-oss: feature branches always, PRs REQUIRED before merge
github-production: feature branches always, PRs REQUIRED, review REQUIRED
</branch_strategy>
<anti_patterns>
- Committing to main directly for multi-file changes
- "WIP" commits that never get squashed
- Mixing unrelated changes in one commit
- Force pushing to shared branches
- Skipping commit messages
- Including AI tool attribution in commit messages (Co-Authored-By, "Generated with Claude Code", etc.)
- git add -A / git add . (catches unintended files)
- Parallelize AI + human review (humans see noisy diff, duplicate feedback)
</anti_patterns>
<on_complete>
agentdb write-end '{"skill":"git","commits":N,"atomic":true,"convention":"pass"}'
</on_complete>