Debug — Root-Cause Fix with Proof
Purpose
Turn a symptom into a proven root cause and a verified fix. Covers three entry
points: a failing test, a production error report, and a build error.
This skill follows a strict bug-handling methodology — do not skip its
phases; in particular never fix without a failing-state proof, and never declare
fixed without a green proof.
Fundamental rule: don't trust the report — reproduce and prove it first.
Language: explanations in Hebrew; code in English.
Mode 1 — Failing test → red → green + explanation
Trigger: "the UserAuth test is failing, find out why and fix it".
- Reproduce — run that test, read the full failure output (message, stack,
assertion diff). Confirm it fails now (this is your RED evidence).
- Root cause — trace backwards from the failing assertion to the origin. Read
the code under test and the test itself. Apply the 5 Whys. Check
git log/blame:
did a recent change break it? Is the test asserting the right thing?
- Decide who's wrong — the code or the test — with a reason, not a guess.
- Surgical fix — smallest change at the root cause; no scope-widening refactors.
- Verify GREEN — re-run the test (must pass), then the full suite for
regressions, then build/lint. A regression is a new bug — block on it.
- Explain in Hebrew: root cause in one sentence, the fix, RED→GREEN evidence,
files touched, and whether the same pattern exists elsewhere.
Mode 2 — Production symptom → investigation → diagnosis
Trigger: "users are seeing 500 errors on /checkout. investigate and tell me what is going on".
- Pin the symptom — exact endpoint/flow, error code, when it started, blast
radius (all users / subset / one tenant).
- Follow the request path from entry to failure: route handler → services →
DB/external calls. Read logs/stack traces if available; grep the codebase for the
error and the code path.
- Form hypotheses, then confirm/refute each with evidence (a failing test, a log
line, a reproduced request) — don't stop at the first plausible one.
- Reproduce locally if at all possible; write a failing test that captures the
bug (RED) before fixing.
- Report the diagnosis clearly even before fixing if the fix is risky:
most-likely cause, evidence, blast radius, and the proposed fix. For high-risk
areas (auth, payments, data) present the plan before applying.
- Fix → verify → prevent (regression test + check for the same pattern elsewhere).
If the symptom is really a live incident (latency spike, ongoing outage) needing
correlation across logs, recent deploys, and config changes — if you also have the
incident-response skill, hand off to it; otherwise correlate those signals
manually before diagnosing further.
Mode 3 — Build error → root-cause fix → verified build
Trigger: "here is a build error. fix the root cause and verify the build succeeds".
- Read the whole error, not just the last line — the first error is often the
real one; the rest are cascades. Note file, line, and error type.
- Find the root cause: type error, missing/mismatched dependency version, bad
import path, config/tsconfig issue, generated-code drift, env var. Reproduce the
failing build locally.
- Fix at the source — e.g. correct the type rather than casting to
any, fix the
version constraint rather than deleting the lockfile. Don't paper over it.
- Verify — run the full build to completion (not just the failing step) and
confirm it succeeds. Run tests/lint too if the fix touched logic.
- If the same class of error can recur, note the guard (a tsconfig strictness, a CI
check) that would catch it.
Core rules
- Never guess-fix; no reproduction = no understanding.
- Never fix without a failing-state proof; never declare fixed without a passing one.
- Never widen scope — a bug fix is not a refactor license.
- Reproduction fails after ≥2 tries → stop, request env details, don't fix blind.
- Fix the same broken pattern wherever else it appears, or flag it.
1---2name: debug3description: Systematically debug a failing test, a production symptom, or a build error — find the ROOT cause (not the symptom), fix it minimally, and verify. TRIGGER when the user says 'the <X> test is failing, find out why and fix it', 'users are seeing 500 errors on /checkout, investigate and tell me what's going on', 'here is a build error, fix the root cause and verify the build succeeds', 'why is this broken', 'debug this'. Hebrew: 'הטסט נכשל, תמצא למה ותתקן', 'יש שגיאות 500 ב..., תחקור', 'תתקן את שגיאת הבנייה מהשורש', 'תדבג', 'למה זה נשבר'. Follows a strict reproduce → prove RED → root-cause → surgical fix → GREEN methodology. NOT for adding new tests to passing code (that's a job for a test-writing skill like test-loop, if you have one), NOT for live production incident triage across logs/deploys/config (that's incident-response's job, if you have it).4---56# Debug — Root-Cause Fix with Proof78## Purpose9Turn a symptom into a proven root cause and a verified fix. Covers three entry10points: a **failing test**, a **production error report**, and a **build error**.11This skill follows a strict bug-handling methodology — do not skip its12phases; in particular **never fix without a failing-state proof, and never declare13fixed without a green proof**.1415**Fundamental rule:** don't trust the report — reproduce and prove it first.1617**Language:** explanations in Hebrew; code in English.1819---2021## Mode 1 — Failing test → red → green + explanation22Trigger: "the UserAuth test is failing, find out why and fix it".23241. **Reproduce** — run that test, read the full failure output (message, stack,25 assertion diff). Confirm it fails now (this is your RED evidence).262. **Root cause** — trace backwards from the failing assertion to the origin. Read27 the code under test *and* the test itself. Apply the 5 Whys. Check `git log`/blame:28 did a recent change break it? Is the test asserting the right thing?293. **Decide** who's wrong — the code or the test — with a reason, not a guess.304. **Surgical fix** — smallest change at the root cause; no scope-widening refactors.315. **Verify GREEN** — re-run the test (must pass), then the **full suite** for32 regressions, then build/lint. A regression is a new bug — block on it.336. **Explain** in Hebrew: root cause in one sentence, the fix, RED→GREEN evidence,34 files touched, and whether the same pattern exists elsewhere.3536---3738## Mode 2 — Production symptom → investigation → diagnosis39Trigger: "users are seeing 500 errors on /checkout. investigate and tell me what is going on".40411. **Pin the symptom** — exact endpoint/flow, error code, when it started, blast42 radius (all users / subset / one tenant).432. **Follow the request path** from entry to failure: route handler → services →44 DB/external calls. Read logs/stack traces if available; grep the codebase for the45 error and the code path.463. **Form hypotheses**, then confirm/refute each with evidence (a failing test, a log47 line, a reproduced request) — don't stop at the first plausible one.484. **Reproduce locally** if at all possible; write a failing test that captures the49 bug (RED) before fixing.505. **Report the diagnosis** clearly even before fixing if the fix is risky:51 most-likely cause, evidence, blast radius, and the proposed fix. For high-risk52 areas (auth, payments, data) present the plan before applying.536. Fix → verify → prevent (regression test + check for the same pattern elsewhere).5455> If the symptom is really a *live incident* (latency spike, ongoing outage) needing56> correlation across logs, recent deploys, and config changes — if you also have the57> **incident-response** skill, hand off to it; otherwise correlate those signals58> manually before diagnosing further.5960---6162## Mode 3 — Build error → root-cause fix → verified build63Trigger: "here is a build error. fix the root cause and verify the build succeeds".64651. **Read the whole error**, not just the last line — the first error is often the66 real one; the rest are cascades. Note file, line, and error type.672. **Find the root cause**: type error, missing/mismatched dependency version, bad68 import path, config/tsconfig issue, generated-code drift, env var. Reproduce the69 failing build locally.703. **Fix at the source** — e.g. correct the type rather than casting to `any`, fix the71 version constraint rather than deleting the lockfile. Don't paper over it.724. **Verify** — run the **full build** to completion (not just the failing step) and73 confirm it succeeds. Run tests/lint too if the fix touched logic.745. If the same class of error can recur, note the guard (a tsconfig strictness, a CI75 check) that would catch it.7677---7879## Core rules80- Never guess-fix; no reproduction = no understanding.81- Never fix without a failing-state proof; never declare fixed without a passing one.82- Never widen scope — a bug fix is not a refactor license.83- Reproduction fails after ≥2 tries → stop, request env details, don't fix blind.84- Fix the same broken pattern wherever else it appears, or flag it.