원클릭으로
whyspec-debug
Use when encountering any bug, test failure, or unexpected behavior — before proposing fixes.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Use when encountering any bug, test failure, or unexpected behavior — before proposing fixes.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Use when planning a code change, capturing decisions before coding, or setting up the Decision Bridge.
Use after coding to preserve reasoning — resolves the Decision Bridge with actual outcomes.
Use when starting implementation, continuing work, or executing tasks from a WhySpec plan.
Use when looking for why something was built a certain way or finding past decisions.
Use when reviewing the full story of a change — intent, design, tasks, and Decision Bridge delta.
| name | whyspec-debug |
| description | Use when encountering any bug, test failure, or unexpected behavior — before proposing fixes. |
| argument-hint | <bug-description-or-change-name> |
Debug systematically. No fix without root cause.
The investigation is automatically saved as a context file when resolved.
Input: A bug description, error message, or change name for an existing debug session.
NO FIX WITHOUT VERIFIED ROOT CAUSE. Guessing at fixes creates more bugs than it solves. A wrong diagnosis leads to a wrong fix that masks the real problem.
| If you catch yourself thinking... | Reality |
|---|---|
| "The fix is obvious, skip investigation" | Obvious fixes have root causes too. Verify in 30 seconds. |
| "It's just a typo/config issue" | Confirm it. Read the code. Don't assume. |
| "I'll just try this quick fix first" | The first fix sets the pattern. Do it right from the start. |
| "No time for full investigation" | Systematic debugging is FASTER than guess-and-check thrashing. |
| "I already know what's wrong" | Then verification should take 10 seconds. Do it anyway. |
| "It works on my machine" | That's a symptom, not a diagnosis. Find the environmental difference. |
| "The error message tells me exactly what's wrong" | Error messages describe symptoms. Root causes are upstream. |
| "Let me just revert the last change" | Revert is a workaround, not a fix. Why did the change break things? |
| Tool | When to use | When NOT to use |
|---|---|---|
| Grep | Search for error messages, function names, patterns in code | Don't grep before forming hypotheses — symptoms first |
| Read | Read suspect files, stack trace locations, config files | Don't read unrelated files — stay focused on hypotheses |
| Bash | Run tests to reproduce, git log/git diff to find trigger commits, execute test commands for hypotheses | Don't run destructive commands or modify production data |
| Glob | Find files by pattern when error references unknown paths | Don't glob the entire repo — scope to suspect areas |
| Write | Write/update debug.md (investigation state) and ctx_.md (final capture) | Don't write fix code until root cause is verified |
| WebSearch | ONLY for: error messages with no codebase matches, library changelogs, CVE lookups | Never search web for: "how to debug X", generic solutions, or before investigating the codebase |
| AskUserQuestion | Escalation ONLY — after 2 rounds of failed hypotheses, or when root cause is outside codebase | Don't ask before investigating. The codebase has the answers. |
Read the codebase BEFORE considering web search. Web search is justified ONLY when:
Never search the web for: "how to fix X", architecture decisions, or generic debugging advice.
Before investigating, check if someone has reasoned about this domain before:
whyspec search --json "<keywords from bug description>"
If results exist:
If no results: note "No prior context found" and continue.
This takes seconds. It prevents re-investigating solved problems.
Create the debug session:
whyspec debug --json "<bug-name>"
Parse the JSON response:
path: Debug session directorytemplate: debug.md template structurerelated_contexts: Past contexts in the same domainGather symptoms — investigate the codebase directly. Only ask the user if you genuinely can't find the information yourself:
| Symptom | What to capture |
|---|---|
| Expected behavior | What SHOULD happen |
| Actual behavior | What ACTUALLY happens |
| Error messages | Exact text, stack traces, error codes |
| Reproduction steps | Minimal sequence to trigger the bug |
| Timeline | When it started, what changed recently |
| Scope | Who is affected, how often, which environments |
Write debug.md immediately to <path>/debug.md. It persists across context resets.
Form 3 or more falsifiable hypotheses:
### H1: express-validator upgrade broke body parsing middleware order - **Test:** `git diff a1b2c3d -- src/app.ts` — check if middleware registration order changed - **Disproof:** If middleware order is identical pre/post upgrade, this is wrong - **Status:** UNTESTED - **Likelihood:** HIGH (scope matches — all POST endpoints affected, timing matches upgrade)console.log(req.body) before and after validation middleware, compare outputContent-Type: application/json; charset=utf-8 — does it parse?Rank by likelihood. Test the most likely first. Update debug.md before proceeding.
Test each hypothesis one at a time, sequentially:
CONFIRMED, DISPROVED, or INCONCLUSIVERules:
If ALL hypotheses are disproved:
Before proposing ANY fix:
## Root Cause
**Cause:** express-validator v7 switched to async validation, body parsing
now completes AFTER route handler starts executing
**Causal chain:** express-validator upgrade → async body parsing → req.body
undefined when handler reads it synchronously → TypeError
**Verified by:** Adding `await` before validation resolved the issue in test
**Confidence:** HIGH
| Confidence | Criteria | Action |
|---|---|---|
| HIGH | Reliable reproduction, clear causal chain | Proceed to fix |
| MEDIUM | Strong evidence, some uncertainty | Proceed with caution, note risks |
| LOW | Circumstantial evidence | Escalate — do NOT fix |
Once root cause is verified (HIGH or MEDIUM confidence):
Implement the minimal fix — fix the bug, don't refactor surrounding code
Verify the fix — run reproduction steps again, run test suite
Update debug.md — add fix details and prevention measures:
## Fix
**Change:** Added `await` before express-validator `validationResult()` calls
**Files:** src/middleware/validate.ts (3 lines changed)
**Verification:** `npm test` — 47 pass, 0 fail. Manual curl test returns 201.
## Prevention
- Added eslint rule for async validation middleware
- Added integration test: POST with body → verify req.body populated
- Updated UPGRADE.md with express-validator v7 migration notes
Commit atomically with root cause in message
Auto-capture reasoning:
whyspec capture --json "<bug-name>"
Write <path>/ctx_<id>.md with the full investigation story.
Show summary:
## Debug Complete: <bug-name>
Root cause: [one-line summary]
Fix: [what was changed]
Context: ctx_<id>.md
Investigation:
Hypotheses tested: N (M confirmed, P disproved)
Evidence entries: N
Past contexts referenced: N
View full investigation: /whyspec-show <bug-name>
If debug.md already exists for a change:
| Trigger | Action |
|---|---|
| All hypotheses disproved (2 rounds) | Present full evidence, ask for new direction |
| Cannot reproduce | Document symptoms, ask for environment details |
| Root cause outside codebase | Document findings, suggest infrastructure investigation |
| Confidence is LOW | Present evidence, explain uncertainty, do NOT fix |
| Fix introduces significant risk | Present fix + risk assessment, ask for approval |
| 3 failed fix attempts | Stop. Present what was tried. Ask for help. |
Never silently give up. If stuck, present evidence and ask.