A useful AI coding workflow: make it explain before it modifies.
Here's a workflow I've found worth experimenting with when working on existing codebases.
Instead of immediately asking AI to fix something, separate the process into three stages.
Stage 1: Investigation
Ask:
"Inspect the current implementation and identify the likely cause of this issue. Don't modify anything yet."
Stage 2: Planning
Ask:
"Explain which files need changes, what you're planning to modify, and whether those changes could affect existing functionality."
Stage 3: Implementation
Once the approach makes sense, let AI make the changes.
Why bother with all this?
Because it's much easier to catch a bad approach before any code gets changed than to debug an entire implementation afterward.
It also gives you a better understanding of what's happening in your project.
Replies
I would add a stage zero before investigation: read what the project already knows about that area. My repo has one notes file per area, payments, auth, the music engines, and a rule that the agent reads the matching one before touching that code. A plan can look perfectly reasonable in your stage 2 and still be wrong because of a vendor quirk or a decision made weeks ago for a reason, and the notes are where those live. And the loop closes at the end: anything surprising found while fixing goes back into that file, so the next investigation starts from it.
the planning step naming the exact files is the part that saved us, more than the prose about what it'll do.. the gap we kept hitting was stage 3 editing a file stage 2 never mentioned, the fix for the auth bug quietly touching a config three folders away. so now we hold the change if the diff goes outside the list it gave us. does your stage 2 name the exact files or just describe the change?
We do something similar, but with the rules enforced rather than asked for. Before touching an area, the agent has to read that project's business logic doc, and when a rule changes, the doc gets updated before the code. For the bigger calls I also have the plan run past two or three other models. They often catch what the first one missed.