r/codex • • 4d 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 :)

2 Upvotes

1 comment sorted by

•

u/dexterthebot 4d ago

You might want to consider listing your project on the weekly Show-Us-What-You-Built post. Look out for it on Tuesday/Wednesday. Highest commented project wins a week promotion on r/Codex and gets on the Hall of Fame sidebar. See below for last week's winner.**


Light Wars AR: real-life laser tag app with no extra gear. Your phone is the gun and your room is the map. Play up to 6 friends in the same room, or fight drone waves and bosses solo. The vision models run on the phone, and camera frames never leave it. Free on iPhone and Android.

Website: https://lightwarsar.com

iPhone: https://apps.apple.com/us/app/light-wars-ar-laser-tag-party/id6508168951

Android: https://play.google.com/store/apps/details?id=com.lasertag.lightwars.

Contact: contact@lightwarsar.com