Your Test Suite Won't Save You
If you've been shipping features with an agent doing most of the work, you'll have built up some mess along the way. Everything works, but the code behind it doesn't feel right. That's what this workflow covers: tidying up a codebase with an agent, and being able to prove afterwards that nothing behaves any differently.
- Pick targets by cost → refactor the files that are actually costing you time, not the ones that look ugly.
- Record what the code does → a snapshot of today's behaviour, so you know if it moves.
- Box the agent in → written limits that stop the refactor wandering.
Before any of that, here's what a refactor looks like with none of it in place. We point the agent at one messy file in FeedbackPit and ask it to clean it up. The result reads well, and the test suite passes. But git diff --stat shows it edited files it was never asked to touch, and over in the browser, reactions are broken and the edit and delete buttons have disappeared. The tests were happy the whole time.
The reason this keeps happening: a feature has an end point, so the agent knows when it's done. Tidying doesn't, so it keeps going, and while it's going it can change what your code does with nothing telling you.
So a successful refactor isn't "the tests still pass". It's tests passing, no new technical debt, and the scope staying exactly where you aimed it. Try it on your own code: pick a file you'd be a bit embarrassed by, ask your agent to clean it up, then actually use the app rather than just reading the diff.