Debugging, Refactoring & Iteration with AI

TODO: Content for Chapter 11 — Debugging, Refactoring & Iteration with AI (focus: Correct)

Topics to cover:

  • AI-assisted debugging: /fix, inline chat, error explanation
  • Legacy code refactoring — time reduced by ~2/3 (McKinsey)
  • Codebase onboarding — using AI to quickly understand unfamiliar projects
  • Iteration strategies (Correct):
    • Effective re-prompting: adding context, providing examples of what’s wrong
    • When to abandon the output: signs that the agent is stuck in a loop
    • Manual override: editing code directly instead of infinite re-prompting
    • Feedback loop for custom instructions
  • Hands-on: take a legacy module, refactor it with an agent, iterate on errors, document corrections