skills/ce-debug/SKILL.md
Systematically find root causes and fix bugs. Use when debugging errors, investigating test failures, reproducing bugs from issue trackers (GitHub, Linear, Jira), or when stuck on a problem after failed fix attempts. Also use when the user says 'debug this', 'why is this failing', 'fix this bug', 'trace this error', or pastes stack traces, error messages, or issue references.
npx skillsauth add xbpk3t/ce-codex ce-debugInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Find root causes, then fix them. This skill investigates bugs systematically — tracing the full causal chain before proposing a fix — and optionally implements the fix with test-first discipline.
<bug_description> #$ARGUMENTS </bug_description>
These principles govern every phase. They are repeated at decision points because they matter most when the pressure to skip them is highest.
| Phase | Name | Purpose | |-------|------|---------| | 0 | Triage | Parse input, fetch issue if referenced, proceed to investigation | | 1 | Investigate | Reproduce the bug, trace the code path | | 2 | Root Cause | Form hypotheses with predictions for uncertain links, test them, causal chain gate, smart escalation | | 3 | Fix | Only if user chose to fix. Test-first fix with workspace safety checks | | 4 | Close | Structured summary, handoff options |
All phases self-size — a simple bug flows through them in seconds, a complex bug spends more time in each naturally. No complexity classification, no phase skipping.
Parse the input and reach a clear problem statement.
If the input references an issue tracker, fetch it:
#123, org/repo#123, github.com URL): Parse the issue reference from <bug_description> and fetch with gh issue view <number> --json title,body,comments,labels. For URLs, pass the URL directly to gh.Extract reported symptoms, expected behavior, reproduction steps, and environment details. Then proceed to Phase 1.
Everything else (stack traces, test paths, error messages, descriptions of broken behavior): Proceed directly to Phase 1.
Questions:
Prior-attempt awareness: If the user indicates prior failed attempts ("I've been trying", "keeps failing", "stuck"), ask what they have already tried before investigating. This avoids repeating failed approaches and is one of the few cases where asking first is the right call.
Confirm the bug exists and understand its behavior. Run the test, trigger the error, follow reported reproduction steps — whatever matches the input.
agent-browser if installed. Otherwise use whatever works — MCP browser tools, direct URL testing, screenshot capture, etc.references/investigation-techniques.md for intermittent-bug techniques.Read the relevant source files. Follow the execution path from entry point to where the error manifests. Trace backward through the call chain:
As you trace:
git log --oneline -10 -- [file]git bisect (see references/investigation-techniques.md)Reminder: investigate before fixing. Do not propose a fix until you can explain the full causal chain from trigger to symptom with no gaps.
Read references/anti-patterns.md before forming hypotheses.
Form hypotheses ranked by likelihood. For each, state:
When the causal chain is obvious and has no uncertain links (missing import, clear type error, explicit null dereference), the chain explanation itself is the gate — no prediction required. Predictions are a tool for testing uncertain links, not a ritual for every hypothesis.
Before forming a new hypothesis, review what has already been ruled out and why.
Causal chain gate: Do not proceed to Phase 3 until you can explain the full causal chain — from the original trigger through every step to the observed symptom — with no gaps. The user can explicitly authorize proceeding with the best-available hypothesis if investigation is stuck.
Reminder: if a prediction was wrong but the fix appears to work, you found a symptom. The real cause is still active.
Once the root cause is confirmed, present:
Then offer next steps (use the platform's question tool — AskUserQuestion in Claude Code, request_user_input in Codex, ask_user in Gemini — or present numbered options and wait):
the proof skill) — for easy review and sharing with others/prompts:ce-brainstorm) — only when the root cause reveals a design problem (see below)Do not assume the user wants action right now. The test recommendations are part of the diagnosis regardless of which path is chosen.
When to suggest brainstorm: Only when investigation reveals the bug cannot be properly fixed within the current design — the design itself needs to change. Concrete signals observable during debugging:
Do not suggest brainstorm for bugs that are large but have a clear fix — size alone does not make something a design problem.
If 2-3 hypotheses are exhausted without confirmation, diagnose why:
| Pattern | Diagnosis | Next move |
|---------|-----------|-----------|
| Hypotheses point to different subsystems | Architecture/design problem, not a localized bug | Present findings, suggest /prompts:ce-brainstorm |
| Evidence contradicts itself | Wrong mental model of the code | Step back, re-read the code path without assumptions |
| Works locally, fails in CI/prod | Environment problem | Focus on env differences, config, dependencies, timing |
| Fix works but prediction was wrong | Symptom fix, not root cause | The real cause is still active — keep investigating |
Present the diagnosis to the user before proceeding.
Reminder: one change at a time. If you are changing multiple things, stop.
If the user chose Proof or brainstorm at the end of Phase 2, skip this phase — the skill's job was the diagnosis.
Workspace check: Before editing files, check for uncommitted changes (git status). If the user has unstaged work in files that need modification, confirm before editing — do not overwrite in-progress changes.
Test-first:
3 failed fix attempts = smart escalation. Diagnose using the same table from Phase 2. If fixes keep failing, the root cause identification was likely wrong. Return to Phase 2.
Conditional defense-in-depth (trigger: grep for the root-cause pattern found it in other files): Check whether the same gap exists at those locations. Skip when the root cause is a one-off error.
Conditional post-mortem (trigger: the bug was in production, OR the pattern appears in 3+ locations):
How was this introduced? What allowed it to survive? If a systemic gap was found: "This pattern appears in N other files. Want to capture it with /prompts:ce-compound?"
Structured summary:
## Debug Summary
**Problem**: [What was broken]
**Root Cause**: [Full causal chain, with file:line references]
**Recommended Tests**: [Tests to add/modify to prevent recurrence, with specific file and assertion guidance]
**Fix**: [What was changed — or "diagnosis only" if Phase 3 was skipped]
**Prevention**: [Test coverage added; defense-in-depth if applicable]
**Confidence**: [High/Medium/Low]
Handoff options (use platform question tool, or present numbered options and wait):
/prompts:ce-compound)the proof skill) — for easy review and sharing with othersdevelopment
Performs iterative web research and returns structured external grounding (prior art, adjacent solutions, market signals, cross-domain analogies). Use when ideating outside the codebase, validating prior art, scanning competitor patterns, finding cross-domain analogies, or any task that benefits from current external context. Prefer over manual web searches when the orchestrator needs structured external grounding.
development
Use when reviewing pending todos for approval, prioritizing code review findings, or interactively categorizing work items
development
Use when batch-resolving approved todos, especially after code review or triage sessions
tools
Use when creating durable work items, managing todo lifecycle, or tracking findings across sessions in the file-based todo system