--- name: diagnosing-bugs description: "Find the cause of a hard bug, outage or slowdown by building a red-capable feedback loop before forming any theory. Use when something is broken, failing, flaky, slow or keeps recurring, including machine-level problems such as lost logins, restarts or a gate that fails open." license: MIT --- # Diagnosing bugs The whole skill is one discipline: get a command that goes red on this exact bug before you reason about causes. With that command, bisecting, testing hypotheses and verifying the fix are mechanical. Without it, reading code produces confident wrong answers, and the estate has a long record of gates that "worked" until someone tested them. ## Redact first Commands, logs and captured requests carry tokens and account names. Replace secrets with ``, keep credentials in environment variables or Infisical, and quote only the lines that carry the signal. The secret guard will block a tool call that leaks one; do not route around it. ## 1. Build the loop (spend most of the effort here) Pick the first that reaches the bug: 1. A failing test at the seam that hits it (`pnpm test -- `, `uv run pytest -k `, `node --test `). 2. A `curl` or HTTP script against a running dev server or a preview URL. 3. A CLI run on a fixture, diffed against a known-good output. 4. A headless browser script through the shared `browse` Chromium or BrowserOS, asserting on DOM, console or network. 5. A replayed capture: save the real request, event or payload to disk and push it through the code path alone. 6. A minimal harness: one service, mocked dependencies, one call. 7. A property or fuzz loop for "sometimes wrong". 8. A bisection script for "worked at X, broken at Y" (`git bisect run