Trigger
- Keywords: debug, debugging, troubleshoot, diagnose, investigate issues, find bugs, why isn't it working, why doesn't it work, something wrong, not working
When NOT to Use
| Scenario | Alternative |
|---|---|
| GitHub Issue / PR thread analysis | /issue-analyze |
| Known root cause, direct fix | /bug-fix |
| Understand how the code works | /code-explore |
| Need dual-perspective confirmation of logic | /code-investigate |
| Post-deployment read-only functionality verification | /feature-verify |
Prohibited Actions
❌ git add | git commit | git push — per @rules/git-workflow.md
This skill debugs and may fix code but does not commit. /precommit is a quality gate only. To commit, offer the menu per rules/git-workflow.md § Proactive Offer — a commit option on any real branch, a push option only where review-state.js offer allows one — and invoke /smart-commit --execute on selection; never print the command for the user to copy.
Workflow
Phase 0 Phase 1 Phase 2 Phase 3 Phase 4 Phase 5
Intake → Classify → Probe Loop → Root Cause → Fix + → Report
+ Repro (Taxonomy) (max 6) Confirmation Verify
│ │ │ │ │ │
▼ ▼ ▼ ▼ ▼ ▼
Execute refs/ Bash /seek-verdict Edit+test --export
reproduce failure- /codex- /code-investigate /bug-fix (optional)
taxonomy brainstorm (optional)
Phase 0: Intake + Reproduce
| Step | Action | Output |
|---|---|---|
| 0a | Parse the problem description (symptoms, scope, environment) | Structured problem description |
| 0b | Attempt to reproduce (run commands/scripts) | Expected vs actual results |
| 0c | Reproduction successful? | Yes → Phase 1 / No → ⚠️ Need Human |
Repro Contract: Root cause claims must be based on reproducible observations, not on static speculation.
Phase 1: Classify
Based on the observed failure mode, use the Failure Taxonomy to classify and select a first-probe strategy.
See references/failure-taxonomy.md for:
- 6 problem types + detection signals + first-probe commands
- Classification decision tree
- Escalation paths
Phase 2: Probe Loop
Hypothesis-driven interactive probing loop. See references/probe-protocol.md for full rules.
Each probe is a hypothesis test:
1. 定義假設 H
2. 設計探測命令 C
3. 預測「若 H 成立 → 期望 O」
4. 執行 C → 觀察實際結果
5. 更新假設集合
6. 選下一個最具鑑別力的探測
Termination
| Condition | Action |
|---|---|
| Root cause located + ≥1 execution result as supporting evidence | Stop → Phase 3 |
| ≥2 competing hypotheses cannot be distinguished | Brainstorm → /codex-brainstorm adversarial debate |
| 2 consecutive rounds with no new information | Escalate → ⚠️ Need Human |
| Max rounds (6) reached | Escalate → ⚠️ Need Human |
/codex-brainstorm Integration
When ≥2 equally credible hypotheses exist:
- Pause probe loop
- Invoke
/codex-brainstormvia Skill tool — topic = hypothesis comparison - Use Nash equilibrium result as new primary hypothesis
- Resume probe loop to verify
Phase 3: Root Cause Confirmation
| Step | Action | Required |
|---|---|---|
| 3a | Summarize the root cause (What + Why + Impact + Evidence) | ✅ |
| 3b | /seek-verdict --intent confirm — Codex independent verification |
✅ Mandatory |
| 3c | /code-investigate dual-perspective in-depth verification |
Optional |
| 3d | /git-investigate trace the introduction point (if regression) |
Conditional |
/seek-verdict Integration (Step 3b — Mandatory)
Invoke /seek-verdict --intent confirm for independent root cause verification.
Anti-anchoring contract (per @skills/seek-verdict/SKILL.md):
- Fresh thread: a new § Start dispatch, never a § Resume onto an existing thread
- No Claude conclusions: prompt must not contain Claude's probe findings or root cause judgment
- Finding packet only: provide symptoms, files, observed behavior — let Codex judge independently
Result routing:
| Result | Action |
|---|---|
| ACTIONABLE (confirm) | → Phase 4 |
| NON_ACTIONABLE (high confidence) | Re-enter Phase 2 or ⚠️ Need Human |
| UNCERTAIN | → Phase 4 (conservative), note low confidence |
Phase 4: Fix + Verify
| Condition | Path |
|---|---|
| Simple fix (≤3 lines) | Edit + regression test + verify |
| Complex fix (multi-file) | Delegate to /bug-fix |
| Architecture-level change | ⛔ Need Human — report root cause + recommendation |
All fix paths require regression test per @rules/testing.md evidence model. Bug type → test level mapping per @skills/bug-fix/SKILL.md.
Simple fix path:
- Edit fix
- Write regression test
- Re-execute Phase 0 repro command (verify fix)
- If code file changed → enter review loop (auto-loop)
Phase 5: Debug Report
Output format: see references/report-template.md.
Default: conversation-only output. With --export [path], write to file (with redaction per Probe Safety Rules).
Probe Safety Rules
| Rule | Description |
|---|---|
| Read-first default | Probes are read-only by default:cat, curl -s, grep, ls, git log |
| Write-probe gate | Probes that may modify state are marked [WRITE_PROBE], and in non-sandbox environments require user confirmation |
| Timeout | Each probe command has a timeout ≤ 30 seconds |
| Output budget | Single probe output ≤ 500 lines (truncate if exceeded) |
| Redaction | Recording API keys, tokens, passwords is prohibited (per @rules/security.md), replace with [REDACTED] replaced with |
| Deny list | Prohibited:rm, drop, delete, truncate, any destructive operation |
Config
| Key | Default | Description |
|---|---|---|
debug.max_probe_rounds |
6 | Maximum probe loop iterations |
Review Loop
MUST re-review after fix until PASS (per @rules/auto-loop.md)
Fix → Review → Issues found → Fix again → ... → ✅ Pass → Next step
Doc Sync
Doc Sync is governed by @rules/auto-loop.md (behavior-layer rule). After precommit pass, triggers conditionally when changes map to docs/features/.
Output
## Debug Report: <title>
- **Type**: <classification>
- **Root Cause**: <what + why>
- **Fix**: <change description>
- **Verdict**: <seek-verdict result>
- **Probe Rounds**: <N>
Verification
- Phase 0 reproduced the issue
- Problem classified using failure taxonomy
- Probe journal recorded for each round
-
/seek-verdict --intent confirmexecuted (Phase 3) - Root cause has ≥1 execution evidence
- Regression test written (if fix applied)
- Review loop completed (if code changed)
- No
git add/commit/pushexecuted
References
| File | Purpose | When to Read |
|---|---|---|
references/failure-taxonomy.md |
Problem classification + first-probe routing | Phase 1 |
references/probe-protocol.md |
Probe Loop rules + termination criteria | Phase 2 |
references/report-template.md |
Debug Report template + export format | Phase 5 |
Examples
Script Bug
Input: /debug bash scripts/deploy.sh 回傳 exit code 1
Phase 0: 執行 bash scripts/deploy.sh → 確認失敗
Phase 1: Script Bug
Phase 2: R1: bash -x trace → 發現 line 42 curl 失敗
R2: 直接 curl endpoint → 404
R3: 檢查 URL → 路徑缺少 /api prefix → Stop
Phase 3: /seek-verdict confirm → ACTIONABLE
Phase 4: Edit line 42 + regression test
Phase 5: Debug Report
API Error
Input: /debug API 回傳空陣列但資料庫有資料
Phase 0: curl API endpoint → 確認回傳 []
Phase 1: Silent Failure(表面正常但結果錯誤)
Phase 2: R1: 檢查 query filter → 發現 status 欄位名稱不符
R2: 直接 DB query → 有資料 → Stop
Phase 3: /seek-verdict confirm → ACTIONABLE
Phase 4: 修正 field name + unit test
Phase 5: Debug Report
Silent Failure
Input: /debug ks-status.sh 回傳 ready:false 但 deployment 已就緒
Phase 0: 執行 bash ks-status.sh → ready:false, 缺少 replicas 欄位
Phase 1: Silent Failure(404 被 fallback 吞掉)
Phase 2: R1: 直接 curl API → invalid JSON → R2: 原始回應 → 404
R3: 改用 apps/v1 路徑 → 200 + 完整資料 → Stop
Phase 3: /seek-verdict confirm → ACTIONABLE
Phase 4: api/v1 → apps/v1(1 word fix)+ test
Phase 5: Debug Report