diagnose
Diagnose
A discipline for the bugs that don't yield to a quick read. [[trace]] is the stance — don't guess, find the root cause, trace the bad value back to its origin. This skill is what you run when the reproduce-it step is itself the hard part: the bug is intermittent, environment-specific, or slow to surface. Skip a phase only when you can say out loud why.
Phase 1 — Build a feedback loop
This is the skill. Everything else is mechanical. Give yourself a fast, deterministic, agent-runnable pass/fail signal for the bug and you will find the cause — bisection, hypothesis-testing, and instrumentation all just consume that signal. Without one, no amount of staring at code saves you. Spend disproportionate effort here. Be aggressive, be creative, refuse to give up.
Ways to build one, roughly easiest-first:
- A failing test at whatever seam reaches the bug.
- A curl / HTTP script against a running dev server.
- A CLI invocation on a fixture, diffing stdout against a known-good snapshot.
- A headless-browser script (Playwright/Puppeteer) asserting on DOM/console/network.
- Replay a captured trace — save a real request/payload/event log, replay it through the code path in isolation.
- A throwaway harness — a minimal subset of the system, one function call that hits the bug path.
- A property / fuzz loop for "sometimes wrong output" — 1000 random inputs, look for the failure mode.
- A bisection harness — automate "boot at state X, check, repeat" so
git bisect runcan drive it. - A differential loop — same input through old vs new (or two configs), diff the outputs.