{"id":124051,"plugin_id":"plugin_asdk_app_6b03edd3823c8191b9801ee570cb327b","kind":"skill","collection_source":"plugin_package","comparison_source":null,"observed_at":"2026-11-29T18:19:30.291Z","digest":"eb84bea112cfe9c69b88dd131165bfd05d27ddb8871a3684dbfbea094ba5b18a","against":null,"payload":{"description":"Use when encountering any bug, test failure, build break, or unexpected behavior — runs a 4-phase systematic debugging process before proposing any fix. Iron Law: NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST. Produces a `.orchestrator/debug/` artifact the fixer agent must reference.","included_files":[{"relative_path":"soul.md","size_in_bytes":2260}],"name":"debug","skill_md_contents":"---\nname: debug\ndescription: >-\n  Use when encountering any bug, test failure, build break, or unexpected behavior — runs a 4-phase\n  systematic debugging process before proposing any fix. Iron Law: NO FIXES WITHOUT ROOT CAUSE\n  INVESTIGATION FIRST. Produces a `.orchestrator/debug/` artifact the fixer agent must reference.\nmodel: inherit\ncolor: red\nuser-invocable: true\nargument-hint: \"[bug-description-or-issue-ref]\"\n---\n\n# Debug Skill\n\n> 4-phase root-cause investigation. Iron Law: no fix without root cause.\n\n## Invocation\n\nThe user invokes `/debug` with arguments: **$ARGUMENTS**.\n\nThe optional argument is a short bug description or issue reference (e.g. `\"test timeout in CI\"` or `#408`). If absent, inspect recent errors and `git log` to surface the most likely candidate, then confirm it with the user before starting Phase 1.\n\nThe four phases (Root Cause → Pattern → Impact → Solution) run in order, and the Phase-1 artifact at `.orchestrator/debug/<session-id>-<sequence>.md` is written before any fix code exists — it is a prerequisite for Phase 4, not optional documentation.\n\n## When to use\n\n- Any test failure (unit, integration, E2E)\n- Build break or compile error\n- Runtime exception in production code\n- Performance regression\n- Integration issue between modules\n- \"It worked yesterday\" bugs\n\n## When NOT to use\n\n- Feature implementation (use `/plan` or wave-executor)\n- Pure refactoring with no broken behavior\n- Style/lint fixes with no behavioral impact\n\n## Phase 0: Bootstrap Gate (Session Orchestrator only)\n\nThe gate belongs to the Session Orchestrator plugin. First look for its gate file at `../_shared/bootstrap-gate.md`, resolved against this skill's base directory (the directory that contains this SKILL.md), never against the project working directory. The project you work on is usually a different repo, so a lookup relative to the working directory proves nothing. Inside the plugin the same file is named `skills/_shared/bootstrap-gate.md` from the plugin root.\n\n- **The file exists** (this skill runs as part of Session Orchestrator): read it and execute the gate check. If the gate is CLOSED, invoke `skills/bootstrap/SKILL.md` and wait for completion before proceeding. If the gate is OPEN, continue to Phase 1.\n- **The file does not exist** (this skill was installed on its own, without the plugin): there is nothing to bootstrap. Skip Phase 0 and continue to Phase 1.\n\n<HARD-GATE>\nWhen the gate file exists, do NOT proceed past Phase 0 if GATE_CLOSED. There is no bypass. Refer to `skills/_shared/bootstrap-gate.md` for the full HARD-GATE constraints. A gate file missing from this skill's base directory (checked as above) is the only reason to skip Phase 0; urgency, a small bug or a request to skip are not.\n</HARD-GATE>\n\n## The Iron Law\n\n> **NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.**\n\nNo matter how obvious the fix looks, complete Phase 1 (Root Cause Investigation) and produce the artifact BEFORE writing any fix code. This is non-negotiable.\n\nThe \"2-hour obviously a typo\" case has been the root cause of every multi-day debugging session in every project's history. Treat the obvious fix as a hypothesis to verify, not a conclusion to act on.\n\n## Phase 1: Root Cause Investigation\n\n### 1.1 Read the error carefully\n\nQuote the exact error message, full stack trace, and exit code in the artifact. Do not paraphrase. Paraphrasing introduces your assumptions before investigation begins.\n\n### 1.2 Reproduce reliably\n\nDocument the exact command and environment that triggers it. If reproduction is flaky, that itself is a data point — write down the failure rate.\n\n```bash\n# minimum reproduction attempt\n<exact command>\n# env: Node version, OS, env vars relevant to the failure\n```\n\n### 1.3 Check recent changes\n\n```bash\ngit log --oneline -20\ngit diff HEAD~5..HEAD -- <affected paths>\n```\n\nIdentify the smallest set of commits that could have introduced this. Do not assume the most recent commit is the culprit without checking.\n\n### 1.4 Instrument every component boundary\n\nAdd temporary logging at each input/output point along the failing path's modules. Capture actual values, not assumptions about what they should be. Run with instrumentation in place and record results.\n\n### 1.5 Trace data flow backward\n\nStart from the failure point and walk upstream. At each step, verify what you think is true with an actual Read or Bash call. \"I assume X is Y\" is not data.\n\n### Phase 1 artifact\n\nWrite to `.orchestrator/debug/<session-id>-<sequence>.md` (sequence = 1, 2, 3 within session). Without a Session Orchestrator session there is no session id: use today's date (`YYYY-MM-DD`) in its place.\n\n**Artifact MUST be written before proceeding to Phase 2.** See \"Artifact contract\" section below.\n\n## Phase 2: Pattern Identification\n\nAfter the Phase 1 artifact is written:\n\n- Is this a recurrence of a previously fixed bug? Search `git log --all --grep=\"<symptom keyword>\"`.\n- Is there a class of bug this exemplifies (race condition, off-by-one, null check, encoding, async ordering)?\n- Is there a missing test that would have caught this? Identify what the test would look like.\n- Search the codebase for similar patterns:\n  ```bash\n  grep -rn \"<suspect pattern>\" --include=\"*.ts\" --include=\"*.mjs\"\n  git grep \"<symbol>\"\n  ```\n\nRecord findings in the artifact's Phase 2 section.\n\n**Optional operator-side companion:** `/tmux-layout --layout debug` renders a 4-pane layout (scratch shell + `npm test --watch` + `tail -F .orchestrator/debug/*.md` + `watch -n 2 'git diff --stat'`) so you can observe hypothesis tests, debug artifacts, and diff progression peripherally. Pure observability — the `/debug` skill works identically with or without the layout (per ADR-0007 + GitLab #562).\n\n## Phase 3: Impact Analysis\n\n- What else does the root-caused code touch?\n  ```bash\n  grep -rn \"<function or symbol name>\"\n  ```\n- What other code paths could share the same root cause?\n- Will the fix break anything else? Identify callers, dependents, transitive effects.\n- List the affected files explicitly in the artifact.\n\n## Phase 4: Solution\n\nOnly after Phases 1-3 are complete and the artifact is written:\n\n1. Propose the minimal fix — the smallest code change that addresses the confirmed root cause\n2. Identify test cases that would have caught this; write them alongside or before the fix if appropriate\n3. Document the fix decision in the artifact under a \"Resolution\" section\n4. Verify the fix: run the project's test command (in Session Orchestrator: `test-command` from Session Config) and confirm the failure no longer reproduces\n\nDo not gold-plate the fix. Scope creep during a bugfix introduces new bugs.\n\n## Artifact contract\n\n`.orchestrator/debug/<session-id>-<sequence>.md`:\n\n```markdown\n# Debug session: <topic>\nCreated: <ISO timestamp>\nSession: <session-id>\n\n## Phase 1 — Root Cause\n\n### Error\n[exact error message + stack trace + exit code — verbatim]\n\n### Reproduction\n[exact command]\n[environment: Node version, platform, relevant env vars]\n[frequency: always | intermittent (~N/10)]\n\n### Suspect commits\n- <sha> <subject> — reason\n\n### Instrumentation data\n[per-boundary observations with actual values]\n\n### Hypothesized root cause\n[ONE sentence] · Confidence: [low|medium|high]\n\n## Phase 2 — Pattern\n\n[recurrence? class? missing test? similar code paths?]\n\n## Phase 3 — Impact\n\n[affected files, callers, dependents]\n\n## Phase 4 — Solution\n\n[proposed fix + test cases identified]\n\n## Resolution\n\n[commit SHA, files changed, tests added — filled in after fix lands]\n```\n\n**Rules for the artifact:**\n- \"Hypothesized root cause\" is always ONE sentence. Multiple hypotheses signal you have none — pick the most evidence-backed one and lower confidence if uncertain.\n- Do not write fix code in Phase 1-3 sections. Those sections are investigation only.\n- The artifact is the deliverable — not an optional note.\n\n## Integration with wave-executor (Session Orchestrator only)\n\nWhen `wave-executor` classifies a task as `bugfix`, it routes through this skill. `code-implementer` agents handling bugfix-classified tasks must reference an existing Phase-1 artifact path in their task description before editing any production code. Wire-up happens in wave-executor's routing layer (Wave 3 P1 cross-reference).\n\n## Anti-Patterns\n\n- **Skipping Phase 1 because \"it's obviously a typo\"** — see Iron Law. The obvious hypothesis goes in Phase 1 as a hypothesis to verify, not a fix to apply.\n- **Multiple hypotheses in \"Hypothesized root cause\"** — pick ONE. Lower confidence rating if uncertain. \"Either X or Y\" means you don't know yet.\n- **Writing fix code in Phase 1** — fixes belong in Phase 4. Investigation and implementation are separate acts.\n- **Skipping the artifact write** — the artifact IS the work product. No artifact = no investigation.\n- **Fixing the symptom** — the error location is the symptom; the root cause may be several frames upstream. Trace backward.\n- **Assuming the most recent commit is the cause** — check `git log -20` and the diff before assuming recency.\n\n## See Also (Session Orchestrator only)\n\n- `skills/discovery/SKILL.md` — discovery surfaces problems; debug investigates them\n- `.claude/rules/verification-before-completion.md` — once fixed, verify fresh (issue #38)\n- `agents/code-implementer.md` — references this skill for bugfix-classified tasks\n"},"changes":[],"summary":"First saved snapshot. No earlier version is available for comparison.","summary_kind":"deterministic","summary_metadata":{}}