This skill should be used when the user asks to 'debug', 'fix bug', 'investigate error', 'why is it broken', 'trace root cause', 'find the bug', or needs systematic bug investigation and fixing with verification-driven methodology using ralph loops.
/plugin marketplace add edwinhu/workflows/plugin install workflows@edwinhu-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Announce: "I'm using dev-debug for systematic bug investigation."
Main Chat (you) Task Agent
─────────────────────────────────────────────────────
dev-debug (this skill)
→ ralph loop (one per bug)
→ dev-delegate (spawn agents)
→ Task agent ──────────────→ investigates
writes regression test
implements fix
Main chat orchestrates. Task agents investigate and fix.
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST. This is not negotiable.
Before writing ANY fix, you MUST:
If you catch yourself about to write a fix without investigation, STOP. </EXTREMELY-IMPORTANT>
<EXTREMELY-IMPORTANT> ## The Iron Law of DelegationMAIN CHAT MUST NOT WRITE CODE. This is not negotiable.
Main chat orchestrates the ralph loop. Task agents do the work:
| Main Chat Does | Task Agents Do |
|---|---|
| Start ralph loop | Investigate root cause |
| Spawn Task agents | Run tests, read code |
| Review findings | Write regression tests |
| Verify fix | Implement fixes |
If you're about to edit code directly, STOP and delegate instead. </EXTREMELY-IMPORTANT>
Unlike implementation (per-task loops), debugging uses ONE loop per bug:
1. Start ralph loop for the bug
/ralph-wiggum:ralph-loop "Debug: [SYMPTOM]" --max-iterations 15 --completion-promise "FIXED"
2. Inside loop: spawn Task agent for investigation/fix
→ Skill(skill="workflows:dev-delegate")
3. Task agent follows 4-phase debug protocol
4. When regression test passes → output promise
<promise>FIXED</promise>
5. Bug fixed, loop ends
IMPORTANT: Avoid parentheses () in the prompt.
/ralph-wiggum:ralph-loop "Debug: [SYMPTOM]" --max-iterations 15 --completion-promise "FIXED"
Use dev-delegate, but with debug-specific instructions:
Task(subagent_type="general-purpose", prompt="""
Debug [SYMPTOM] following systematic protocol.
## Context
- Read .claude/LEARNINGS.md for prior hypotheses
- Read .claude/SPEC.md for expected behavior
## Debug Protocol (4 Phases)
### Phase 1: Investigate
- Add debug logging to suspected code path
- Reproduce the bug with a test
- Document: "Reproduced with [test], output: [error]"
### Phase 2: Analyze
- Trace data flow through the code
- Compare to working code paths
- Document findings in LEARNINGS.md
### Phase 3: Hypothesize
- Form ONE specific hypothesis
- Test it with minimal change
- If wrong: document what was ruled out
- If right: proceed to fix
### Phase 4: Fix
- Write regression test FIRST (must fail before fix)
- Implement minimal fix
- Run test, see it PASS
- Run full test suite
## Output
Report:
- Hypothesis tested
- Root cause (if found)
- Regression test written
- Fix applied (or blockers)
""")
After Task agent returns, verify:
If ALL pass → output the promise:
<promise>FIXED</promise>
If ANY fail → iterate (don't output promise yet).
| Phase | Purpose | Output |
|---|---|---|
| Investigate | Reproduce, trace data flow | Bug reproduction |
| Analyze | Compare working vs broken | Findings documented |
| Hypothesize | ONE specific hypothesis | Hypothesis tested |
| Fix | Regression test → fix | Tests pass |
Before claiming ANY bug is fixed:
1. REPRODUCE → Run test, see bug manifest
2. INVESTIGATE → Trace data flow, form hypothesis
3. TEST → Verify hypothesis with minimal change
4. FIX → Write regression test FIRST (see it FAIL)
5. VERIFY → Run fix, see regression test PASS
6. CONFIRM → Run full test suite, no regressions
7. CLAIM → Only after steps 1-6
Skipping any step is guessing, not debugging.
These thoughts mean STOP—you're about to skip the protocol:
| Thought | Reality |
|---|---|
| "I know exactly what this is" | Knowing ≠ verified. Investigate anyway. |
| "Let me just try this fix" | Guessing. Form hypothesis first. |
| "The fix is obvious" | Obvious fixes often mask deeper issues. |
| "I've seen this before" | This instance may be different. Verify. |
| "No need for regression test" | Every fix needs a regression test. Period. |
| "It works now" | "Works now" ≠ "fixed correctly". Run full suite. |
| "I'll add the test later" | You won't. Write it BEFORE the fix. |
| "Log checking proves fix works" | Logs prove code ran, not that output is correct. Verify actual results. |
| "It stopped failing" | Stopped failing ≠ fixed. Could be hiding the symptom. Need E2E. |
| "The error is gone" | No error ≠ correct behavior. Verify expected output. |
| "Regression test is too complex" | If too complex to test, too complex to know it's fixed. |
These do NOT prove a bug is fixed:
| ❌ Fake Verification | ✅ Real Verification |
|---|---|
| "Error message is gone" | "Regression test passes + output matches spec" |
| "Logs show correct path taken" | "E2E test verifies user-visible behavior" |
| "No exception thrown" | "Test asserts expected data returned" |
| "Process exits 0" | "Functional test confirms correct side effects" |
| "Changed one line, seems fine" | "Regression test failed before, passes after" |
| "Can't reproduce anymore" | "Regression test reproduces it, fix makes it pass" |
Red Flag: If you're claiming "fixed" based on absence of errors rather than presence of correct behavior - STOP. That's symptom suppression, not bug fixing.
| Thought | Why It's Wrong | Do Instead |
|---|---|---|
| "Let's just try this fix" | You're guessing | Investigate first |
| "I'm pretty sure it's this" | "Pretty sure" ≠ root cause | Gather evidence |
| "This should work" | Hope is not debugging | Test your hypothesis |
| "Let me change a few things" | Multiple changes = can't learn | ONE hypothesis at a time |
Ralph exits after max iterations. Still do NOT ask user to manually verify.
Main chat should:
Never default to "please verify manually". Always exhaust automation first.
If root cause reveals need for significant refactoring:
<promise>FIXED</promise> for the investigationSkill(skill="workflows:dev") for the implementation workDebug finds the problem. The dev workflow implements the solution.
Pattern from oh-my-opencode: After 3 consecutive failures, escalate.
If you attempt 3 hypotheses and ALL fail:
Failure 1: Hypothesis A tested → still broken
Failure 2: Hypothesis B tested → still broken
Failure 3: Hypothesis C tested → still broken
→ TRIGGER RECOVERY PROTOCOL
STOP all further debugging attempts
REVERT to last known working state
git checkout <last-working-commit>git checkout HEAD~N -- file.ts.claude/RECOVERY.mdDOCUMENT what was attempted
CONSULT with user
ASK USER before proceeding
NO EVIDENCE = NOT FIXED (hard rule)
Before claiming a bug is fixed after multiple failures:
DON'T:
DO:
Attempt 1: "Bug is in parser" → Added logging → Still broken
Attempt 2: "Bug is in validator" → Fixed validation → Still broken
Attempt 3: "Bug is in transformer" → Rewrote transform → Still broken
→ RECOVERY PROTOCOL:
1. STOP (no attempt 4)
2. REVERT all changes: git checkout HEAD -- src/
3. DOCUMENT in .claude/RECOVERY.md:
- Ruled out: parser, validator, transformer
- Evidence: logs show data correct at each stage
- Hypothesis: Bug might be in consumer, not producer
4. ASK USER:
"I've ruled out the parser/validator/transformer chain.
Logs show data is correct when it leaves our system.
Next investigation angle: check the consumer.
Should I:
A) Start new loop investigating consumer
B) Pause for your input on where else to look"
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.