CC-301e · Module 2
Commit Hygiene and History
3 min read
Claude's default behavior is to create one commit per task. This is acceptable for simple changes but produces a messy history for complex work. A refactoring session that touches fifteen files should not be a single monolithic commit — it should be three to five atomic commits, each representing a logical step: "Extract interface from concrete class," "Update all callers to use interface," "Remove deprecated methods," "Add tests for new interface."
Teach Claude to create atomic commits by adding a rule to CLAUDE.md: "When making changes that span multiple logical steps, create separate commits for each step. Each commit should compile and pass tests independently." Claude follows this instruction well — it naturally segments work into logical units when asked to do so. The result is a git history that tells a story: each commit is a chapter, and the PR is the complete narrative.