When Claude Code is doing most of the implementation, git history gets messy fast. You end up with commits like "fix the thing", "actually fix the thing", "revert fix and try different approach".
Here's the workflow I settled on.
Work on branches, always
Never let Claude commit directly to main. This is more important with AI-assisted development because Claude will confidently make changes that seem reasonable but need review.
git checkout -b feature/[what-we're-building]
Tell Claude the commit message style before starting
Add to your CLAUDE.md:
When committing: use conventional commits format.
feat: for new features
fix: for bug fixes
refactor: for refactoring
test: for test-only changes
Keep subjects under 72 chars. No period at end.
Without this, Claude writes commit messages that are paragraphs.
Atomic commits
Claude's default is to batch everything into one commit. Prompt: "Commit each logical change separately. If you're changing the data model and updating the UI, those are two commits."
Review before push
Always run git diff main before pushing, even when you watched Claude make the changes. This catches:
- Accidental deletions Claude didn't mention
- Debug code that wasn't cleaned up
- Changes to files that were out of scope
- Hardcoded values that should be config
PR descriptions
Write a PR description for this branch.
Include:
- What changed (bullet points, not prose)
- Why it changed
- How to test it
Audience: the person reviewing this who didn't see our conversation.
The last line is key. Without it you get PR descriptions that reference "what we discussed" — meaningless to a reviewer looking at it cold.
The CLAUDE.md git config
## Git rules
- Never commit to main directly
- Always use conventional commits
- Atomic commits — one logical change per commit
- Run tests before committing
- No "WIP" commits on branches that will be PRed
Having this in CLAUDE.md means Claude follows the same workflow every session without reminders.
This and 49 other prompts are in the Agent Prompt Playbook. $29.
Top comments (0)