Write broken commits for better review

Open original

The author argues for splitting mechanical and “real” changes into separate, even temporarily broken, commits to make code reviews simpler. By using squash-and-merge, you get a clean long-term history while reviewing a step-by-step narrative that’s easier to validate.

  • Splitting mechanical changes (formatting, lint fixes, renames) from real changes into separate commits makes each piece independently verifiable, even if intermediate commits fail tests or don't compile.
  • Squash-and-merge lets you write a detailed step-by-step commit history for reviewers while keeping the main branch history clean as a single atomic commit.
  • Renaming a file/function in its own commit prevents it from looking like a delete-and-recreate in diffs.
  • AI-generated "all-in-one" patches should be broken into narrated, staged commits so reviewers can catch bugs hidden in the bulk of the change.

Tastefully broken commits turn a big change into a clear story. Instead of one giant commit that mixes manual tweaks and automated fixes, you split it into steps that may even fail tests or not compile. First you make the manual edit—say adding a new formatter—then you run it across 3,000 files in a second commit, and finally you fix any leftovers. That way a reviewer can check each piece: rerun the formatter on the parent commit, verify the config tweak, then move on. Mixing those steps hides the intent and buries tiny but important manual edits beneath a wall of machine output. You keep your long-term history clean with “squash and merge.” Locally you write multiple commits—units of review—that guide your teammate through each mechanical shift or file rename. When it’s time to land, those get squashed into a single atomic commit—your unit of persistence. Anyone digging through git log or git blame still finds the pull request and its internal discussion, so nothing useful vanishes even though the main branch shows one neat change. Broken commits shine whenever mechanical and “real” changes collide. Update or add a lint rule? Change the config first, auto-fix next, then tweak the leftovers. Rename a function or file? Commit the rename alone so it doesn’t look like a delete-and-recreate. Big re-indents, code moves or AI-generated patches all benefit. You plan ahead, commit often, and then rebase interactively to forge a logical sequence. And when AI spits out some “all-in-one” patch, you prompt it to pause, commit, and narrate its steps so you don’t miss a stray bug hidden in that wall of code.

Ask about this article