Fix a bug in code you did not write

1 to 2 hours ยท 7 steps

It is easy to get an agent to patch a symptom in code nobody in the conversation understands. This route makes understanding the first step and ends by making the mistake harder to repeat.

Before you start

  1. Understand the area first

    /pstack:how

    A walkthrough of the subsystem and its runtime flow, before anything changes.

    /pstack:how does the code around this bug work? <describe the bug>

    Done when: You could explain the normal path through this code to someone else.

  2. Diagnose it

    /pocock:diagnosing-bugs

    A diagnosis loop for hard bugs and performance regressions, in place of guessing at fixes until one sticks.

    /pocock:diagnosing-bugs <the symptom and how to reproduce it>

    Done when: You have a root cause backed by evidence, not just a plausible story.

  3. Find out why it is like this

    /pstack:why

    Checks history and whatever evidence sources are connected. Odd code is sometimes odd on purpose, and it is better to learn that before "fixing" it.

    /pstack:why does this code behave this way?

    Done when: You know whether the behavior was a deliberate choice or an accident.

  4. Pin the bug with a failing test

    /addy:test-driven-development

    The test has to fail first. That proves it catches this bug and keeps it from coming back.

    /addy:test-driven-development Write a failing test for this bug, then fix it.

    Done when: The test failed before the fix and passes after it.

  5. Check nothing else moved

    /pstack:blast-radius

    Small fixes in unfamiliar code can break things far away. This is the one to run when you do not fully trust a small diff.

    /pstack:blast-radius of this fix

    Done when: Other callers of the changed code are accounted for.

  6. Review before merging

    /addy:code-review-and-quality

    A multi-axis review, useful here because whoever wrote the fix, human or agent, is the least likely to notice what they assumed.

    /addy:code-review-and-quality Review this fix.

    Done when: Findings are fixed or consciously accepted.

  7. Make the mistake impossible

    /pstack:correct

    Only for mistakes agents keep repeating here. It tries architecture, then types, then a lint, then a test, with docs last, and proves each check fails on a real past mistake.

    /pstack:correct

    Done when: The check fails on the old mistake. Skip this step for a true one-off.

What you end up with

A root-caused fix with a regression test and, where the bug showed a pattern, a check that stops it recurring.

โ† All tutorials Next: run skills in loops โ†’