Hard bug spirals into a full refactor
A practical fix and a copyable AI coding prompt. Replace bracketed placeholders with your project details.
1. Check the problem
The urge to refactor is escape, not strategy. Spend 45 minutes with the actual bug: add logging, bisect with `git bisect`, reproduce it in isolation. Nine times out of ten it's a 3-line fix.
2. Use the prompt
Don't refactor. I have a specific bug: [describe it]. Help me debug it in place: suggest log points to add, a way to reproduce it in isolation, and which recent change to bisect first. Find the root cause before proposing any code change, and keep the fix as small as possible.3. Verify the fix
Review the proposed diff, run the relevant checks and exercise the original failing flow before merging.
Continue in the related workflow chapter.