diff --git a/CLAUDE.md b/CLAUDE.md index cc85cfc..3f72eec 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -309,3 +309,94 @@ PM runs autonomously every 30 minutes. **No human approval needed unless blocked **Audience:** All Claude agents, PM, developers > **Remember:** This document is your north star. Follow it. Extend it. Improve it. + +--- + +## Part 5: Git Hygiene - Keep the Repo Clean + +### No "Fix" Commits +❌ **NEVER** commit fixes for typos, syntax errors, or accidentally added files: +```bash +# BAD - Creates noise in history: +commit 1a2b3c: feat: add feature +commit 1a2b3d: fix: typo in feature ← NO! +commit 1a2b3e: chore: remove extra file ← NO! +``` + +✅ **INSTEAD:** Use interactive rebase to clean up BEFORE pushing: +```bash +# GOOD - Clean, single commit: +commit 1a2b3c: feat: add feature (with typo fixed) +``` + +### Interactive Rebase Workflow + +**1. Check recent commits:** +```bash +git log --oneline -5 +# abc1234 feat: add feature +# def5678 fix: typo in feature ← Oops! +# ghi9012 chore: remove extra file ← Oops! +``` + +**2. Rebase the last 3 commits:** +```bash +git rebase -i HEAD~3 +``` + +**3. Edit in your editor:** +``` +pick abc1234 feat: add feature +squash def5678 fix: typo in feature +squash ghi9012 chore: remove extra file +``` + +Change `pick` to `squash` (or `s`) for commits you want to merge into the previous one. + +**4. Save and edit the commit message:** +The editor will ask for a final commit message. Edit it to be clean: +``` +feat: add feature + +- Added feature X +- Removed extra file +``` + +**5. Force-push (only if not yet pushed):** +```bash +git push -f origin branch-name +``` + +### When to Rebase + +- ✅ **Before first push** — Fix typos, add forgotten files +- ✅ **Before review** — Squash "work in progress" commits +- ❌ **After pushed to shared branch** — Don't force-push to main/develop + +### Common Rebase Scenarios + +**Fix a typo in last commit:** +```bash +git commit --amend +# Edit the file, save +# Git updates the commit without a new one +``` + +**Reorder commits:** +```bash +git rebase -i HEAD~3 +# Reorder the lines in the editor +``` + +**Combine last 2 commits:** +```bash +git rebase -i HEAD~2 +# Change second line from "pick" to "squash" +``` + +### Rule of Thumb + +**One logical change = One commit** + +If you're writing a commit message that says "fixed typo from previous commit", you should have rebased instead. +