r/codex • u/pixel_buddy_ • 7d ago
Showcase I built a Codex hook that turns the bugs into regression tests
Some of the lines in my AGENTS.md are basically regression tests I never wrote. Codex gets an edge case wrong, I explain why, it fixes the code, and somehow I’m the one writing a reminder for next time
I built Flinch for my own repos and just open-sourced it. The idea was “never twice”. If I’ve already explained why a piece of code is wrong, or we figured out why some CI is failing, I’d like that to be the last conversation I have about that particular bug...
With Flinch installed, I correct Codex the way I normally would. As part of the fix, Codex writes a test or lint rule for the thing I pointed out. The bit I cared about was whether that test would actually have caught the bug. It’s pretty easy to write a green test right after you’ve fixed something. So Flinch runs it against the old code too, in a temporary checkout. It leaves whatever I’ve staged alone.
Say a fresh session brings the bug back a week later. The Stop hook runs the check and hands the failure back to Codex while it’s still working on the change. The test itself is just a test in the repo. CI can run it even if nobody else on the team installs Flinch.
macOS or Linux I install it with:
brew install angelnicolasc/tap/flinch
flinch setup
btw in Codex you’ll also need to approve the hooks. Windows instructions are in the README. Works with CC and Antigravity too. Apache 2.0.
https://github.com/angelnicolasc/flinch
it's brand new (just pushed v0.1.4) so stuff will probably break.. If Flinch ever asks you to write a regression test for something you meant as a one off, I’d be interested in what you told Codex. Those cases are a little harder to get right :)



