Debugging Loops

Debugging Loops


Prompt Copilot to run the next-step skill and move to the ai-training-debugging-2 branch.

Β 

Intelligent AI + Deterministic Scripts

The core insight behind debugging with Copilot is pairing its intelligence with deterministic tools.

  • Deterministic tools (linters, test runners, type checkers) produce reliable, specific output: file paths, line numbers, exact error messages. They're cheap, fast, and always produce the same output for the same input. You can run them hundreds of times with no LLM cost.

  • AI (Copilot) is intelligent but non-deterministic. It can reason, synthesize, and make targeted edits β€” but it benefits from precise, structured information to act on.

The debug loop that ties these together:

  1. Run a deterministic script (linter, test runner, etc.)

  2. Read the output β€” Copilot extracts what's wrong, where, and why

  3. Fix β€” Copilot makes targeted edits to the affected files

  4. Verify β€” Copilot reruns the same script to confirm the fixes worked

  5. Repeat if any issues remain

This loop is at the heart of all the debugging patterns covered in this section.

Exercise: Fixing Linter Errors

  1. Run npm run lint in terminal

    1. output includes file, line, column, and exact error

  1. Prompt:

    Run the linter and fix any errors
    1. Reads errors β†’ targets the right files β†’ makes fixes

  1. Rerun the linter after fixing to confirm zero errors

fix-tests Skill

  1. Run all tests and capture output

  2. Identify every failing test by file, name, and error message

  3. Pick the first failing test a. Diagnose the failure β€” write out the reasoning in chat (builds LLM context) b. Propose and implement a fix c. Rerun tests to verify the fix passes

  4. Repeat for each remaining failure

  5. Final verification pass

✏️ Exercise: Fixing Failing Tests

  1. Run npm test in the terminal

  2. Inspect fix-tests skill

  3. Prompt Copilot:

    /fix-tests
  4. Observe Copilot in action

Β 


Next: Debugging End-to-End Flows

Β