The Unit Test Time Traveler — Write the Tests That Would Have Prevented Every Revert
Read every git revert in this repo's history. Now write the unit test that would have caught each one before merge. Cite the commit each test prevents.
Why this exists
Most test suites are written aspirationally. Engineers write tests for the code they wish they had, the invariants they hope hold, the edge cases they imagine at desk-time. The tests that would actually save the team are the ones that would have caught the failures the team has already paid for. The git log knows what your tests don't. Every revert is a confession that something shipped, broke, and got pulled back — and that the test suite never saw it coming. Mine that history. It is a free, ranked, evidence-backed specification of every test you should have written.
What you get back
- A ranked list of generated tests, each annotated with the exact revert commit it would have prevented.
- The failure pattern each test protects against — the shape of the bug, not just the symptom.
- A triage by ROI: which tests to add first based on how many similar reverts they would have caught.
- The tests in mergeable form — runnable in your existing framework, scoped to the modules that actually break.
When to reach for this pattern
Reach for this after a string of reverts has made it clear the suite is not catching the class of bugs that ships. Reach for it pre-launch, when you are hardening a release and need to know what the codebase has historically been bad at. Reach for it when auditing test coverage on a legacy codebase whose original authors are gone but whose history is intact. Reach for it when you have time to add five tests, not five hundred, and you need the five that pay for themselves on day one.
Read every git revert in this repo's history. For each one, write
the unit test that would have caught the bad change before it
merged. Cite the exact commit each test prevents. Sort by frequency
of similar failures — the tests that prevent the most reverts go
first. Treat the git log as a specification for what the test
suite was missing.
Paste this into Claude, Cursor, or Copilot. Change one thing that matters to you.
What I learned shipping it
- Every revert is a missing test made retroactively obvious.
- The test suite a codebase needs is the one its history demands, not the one its architects imagined.
- Bug history is the cheapest test prioritization signal you have — and almost nobody uses it.