From draft
Structured debugging session: reproduce, isolate, diagnose, and fix bugs via systematic investigation with graph-based data flow tracing.
How this skill is triggered — by the user, by Claude, or both
Slash command
/draft:debugThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
You are conducting a structured debugging session following systematic investigation methodology.
You are conducting a structured debugging session following systematic investigation methodology.
First resolve the bundled helpers:
# Locate Draft's bundled helpers (cwd is the user's project; ${CLAUDE_PLUGIN_ROOT}
# is not exported into skill Bash). See core/shared/tool-resolver.md.
DRAFT_TOOLS="$(cat ~/.cache/draft/plugin-root 2>/dev/null)/scripts/tools"
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/cache/*/draft/*/scripts/tools 2>/dev/null | sort -V | tail -1)"
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$(ls -d ~/.claude/plugins/marketplaces/*draft*/scripts/tools 2>/dev/null | tail -1)"
[ -d "$DRAFT_TOOLS" ] || DRAFT_TOOLS="$PWD/scripts/tools"
When draft/graph/schema.yaml exists, this skill must follow the graph-first lookup contract in core/shared/graph-query.md §Mandatory Lookup Contract. During Steps 3–4 (Isolate, Diagnose):
"$DRAFT_TOOLS/graph-arch.sh" --repo . before tracing data flow."$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <fn> to enumerate call sites of suspect functions — not grep."$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path> to size the blast radius before proposing a fix."$DRAFT_TOOLS/hotspot-rank.sh" --repo . to know whether the file is high-fanIn (any fix needs extra caution).Filesystem grep is reserved for source-text scans (literal error strings, stack-trace symbols when the graph misses). Use the fallback sentence on graph miss.
See shared red flags — applies to all code-touching skills.
Skill-specific:
No fixes without root cause investigation first.
Before starting, capture the current git state:
git branch --show-current # Current branch name
git rev-parse --short HEAD # Current commit hash
Store this for the debug report header. The session is scoped to this specific branch/commit.
ls draft/ 2>/dev/null
Debug can run standalone (without draft context) or within a draft track. If draft/ exists, load context for richer investigation.
Read and follow the base procedure in core/shared/draft-context-loading.md.
Key context for debugging:
.ai-context.md — Module boundaries, data flows, invariants (crucial for tracing)tech-stack.md — Language-specific debugging tools and techniquesguardrails.md — Known anti-patterns that may be causing the issuedraft/graph/ (MANDATORY when present) — Query "$DRAFT_TOOLS/graph-arch.sh" --repo . for dependency/module context and "$DRAFT_TOOLS/hotspot-rank.sh" --repo . for complexity awareness. Use "$DRAFT_TOOLS/graph-callers.sh" --repo . --symbol <fn> to find all callers, and "$DRAFT_TOOLS/graph-impact.sh" --repo . --file <path> to size blast radius before any fix. See core/shared/graph-query.md.Check for arguments:
/draft:debug — Interactive: ask what's broken/draft:debug <description> — Start with the described problem/draft:debug track <id> — Debug within a specific track context (load spec.md, plan.md)/draft:debug <JIRA-KEY> — Pull context from Jira ticket via MCPIf a Jira ticket is provided:
get_issue(), get_issue_description(), get_issue_comments()curl/wget to fetch any URLs mentioned (dashboards, error pages, API responses)ssh to access log locations on remote nodes (if paths like /home/log/, node IPs mentioned)Goal: Confirm the bug exists and establish reproduction steps.
intermittent in the hypothesis logunreproduced and the final report must mark the root cause as unconfirmed pending repro.Reference core/agents/debugger.md Phase 1 for detailed investigation techniques.
Goal: Narrow the failure to a specific code path.
file:line references| Aspect | Working Case | Failing Case | Difference |
|---|
.ai-context.md module boundaries to scope the investigationReference core/agents/debugger.md Phase 2 for language-specific debugging techniques.
Goal: Confirm root cause with evidence.
Ground-truth gate (per hypothesis): Before forming hypothesis N, open and Read the file at the file:line you are about to cite. Quote the relevant lines in the hypothesis log. A hypothesis written from graph metadata or recollection is a Ground-Truth Red Flag G4 violation — it produces hypothesis loops on assumptions rather than evidence.
file:line because [evidence quoted from Read]"| # | Hypothesis (cite + quote) | Test | Prediction | Actual | Result |
|---|---|---|---|---|---|
| 1 | [description with path:line and quoted line] | [test] | [expected] | [actual] | Confirmed/Rejected |
If hypothesis fails: Return to Step 3 with updated understanding. After 3 failed cycles, escalate (see Error Handling). Do not increase confidence on a rejected hypothesis just because alternatives are running out — that's how anchoring bias produces wrong root causes.
Reference core/agents/debugger.md Phase 3 and core/agents/rca.md for 5 Whys analysis.
Goal: Fix the root cause with minimal change.
STOP. Before writing any test:
ASK: "Root cause confirmed: [summary]. Want me to write a regression test for this fix? [Y/n]"
MANDATORY: Include YAML frontmatter with git metadata. Follow core/shared/git-report-metadata.md.
Include the report header table immediately after frontmatter:
| Field | Value |
|-------|-------|
| **Branch** | `{LOCAL_BRANCH}` → `{REMOTE/BRANCH}` |
| **Commit** | `{SHORT_SHA}` — {COMMIT_MESSAGE} |
| **Generated** | {ISO_TIMESTAMP} |
| **Synced To** | `{FULL_SHA}` |
Save to:
draft/tracks/<id>/debug-report.mddraft/debug-report-<timestamp>.md with symlink debug-report-latest.mdTIMESTAMP=$(date +%Y-%m-%dT%H%M)
# Example: draft/debug-report-2026-03-15T1430.md
ln -sf debug-report-${TIMESTAMP}.md draft/debug-report-latest.md
Before printing the debug report, internally verify and report:
grep/find run, name the concept it searched for.If draft/graph/schema.yaml does not exist, set Graph files queried: NONE and use justification graph data unavailable.
Emit the canonical footer from core/shared/graph-usage-report.md §Canonical footer. The lint hook scripts/tools/check-graph-usage-report.sh validates the section on save.
/draft:new-track (bug tracks — Offer tier), /draft:implement (blocked tasks — Offer tier)core/agents/rca.md) for 5 Whys and blast radius analysis/draft:new-track spec.md (reproduction and root cause sections via Detect+Auto-Feed)/draft:regression to find the exact commit that introduced this bug"/draft:new-track to create a bug fix track from these findings"core/shared/jira-sync.mdIf cannot reproduce: Gather more context — check environment differences, ask for additional logs, check if the issue is environment-specific.
If no draft context: Run standalone with generic debugging methodology. Recommend /draft:init for richer context.
After 3 failed hypothesis cycles: Document all findings, list what's been eliminated, escalate — consider architectural review or external input.
If MCP unavailable for Jira: Skip Jira context gathering, proceed with available information.
npx claudepluginhub drafthq/draft --plugin draftEnforces systematic root-cause investigation for bugs, errors, failing tests, and unexpected behavior using git history, code graphs, LLM agents, and reproduction steps before fixes.
Orchestrates persistent, hypothesis-driven debugging sessions across conversations, delegating analysis to subagents and tracking in debug files.
Orchestrates a full debug pipeline: investigates a bug, diagnoses root cause, writes failing tests, implements fix via TDD, and reviews the result. Supports auto-commit and git worktrees.