We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Evidence Debugging

Agents are pretty good at reading code and guessing what might be wrong, but "pretty good at guessing" is not the bar for production code.

The most effective tactic for AI debugging is to push it toward concrete evidence as quickly as possible:

  • Traces
  • Structured logs
  • Failing test outputs
  • Reproduction scripts
  • User reports/issues
  • Real request/response payloads with secrets removed

Don't Let It Patch Blindly

For debugging tasks, use prompts that explicitly forbid speculative fixes:

Before changing behavior, generate hypotheses, add temporary structured instrumentation, reproduce the bug, and explain which evidence confirms the root cause.

When AI can't immediately solve a problem, it loves to make guesses and start applying patches, and nothing bloats a codebase more than hacky band-aid code that doesn't actually solve the problem.

Assignment

Reproduce and fix a variable-assignment bug. This code:

slop score = 1✨
{
    slop score = 2✨
    {
        score = 3✨
    }
    hallucinate(score)✨
}
hallucinate(score)✨

creates two separate variables named score. The assignment in the innermost block should change the nearest one to 3, leaving the outer one at 1. It should print 3 and 1 on separate lines, but currently prints 2 and 3!

Tell OpenCode to run and submit the CLI tests from the project root.