Agent skill
debug
[Fix & Debug] Systematic debugging with root cause investigation. Use when bugfix workflow reaches debug step.
Install this agent skill to your Project
npx add-skill https://github.com/duc01226/EasyPlatform/tree/main/.claude/skills/debug-investigate
SKILL.md
[IMPORTANT] Use
TaskCreateto break ALL work into small tasks BEFORE starting — including tasks for each file read. This prevents context loss from long files. For simple tasks, AI MUST ask user whether to skip.
Understand Code First — Search codebase for 3+ similar implementations BEFORE writing any code. Read existing files, validate assumptions with grep evidence, map dependencies via graph trace. Never invent new patterns when existing ones work. MUST READ
.claude/skills/shared/understand-code-first-protocol.mdfor full protocol and checklists.
Evidence-Based Reasoning — Speculation is FORBIDDEN. Every claim needs
file:lineproof. Confidence: >95% recommend freely, 80-94% with caveats, <80% DO NOT recommend — gather more evidence. Cross-service validation required for architectural changes. MUST READ.claude/skills/shared/evidence-based-reasoning-protocol.mdfor full protocol and checklists.
docs/project-reference/domain-entities-reference.md— Domain entity catalog, relationships, cross-service sync (read when task involves business entities/models) (content auto-injected by hook — check for [Injected: ...] header before reading)
Estimation Framework — SP scale: 1(trivial) → 2(small) → 3(medium) → 5(large) → 8(very large, high risk) → 13(epic, SHOULD split) → 21(MUST split). MUST provide
story_pointsandcomplexityestimate after investigation. MUST READ.claude/skills/shared/estimation-framework.mdfor full protocol and checklists. Red Flag STOP Conditions — STOP current approach when: 3+ fix attempts on same issue (root cause not identified), each fix reveals NEW problems (upstream root cause), fix requires 5+ files for "simple" change (wrong abstraction layer), using "should work"/"probably fixed" without verification evidence. After 3 failed attempts, report all outcomes and ask user before attempt #4. MUST READ.claude/skills/shared/red-flag-stop-conditions-protocol.mdfor full protocol and checklists.
Quick Summary
Goal: Investigate and identify root cause of a bug with evidence.
Workflow:
- Reproduce — Understand expected vs actual behavior
- Hypothesize — Form theories about root cause
- Trace — Follow code paths with file:line evidence
- Confirm — Verify root cause with grep/read evidence
- Report — Output root cause with confidence level
Key Rules:
- Debug Mindset: every claim needs file:line proof
- Never assume first hypothesis is correct
- Output: confirmed root cause OR "hypothesis, not confirmed" with evidence gaps
- This is investigation-only — hand off to /fix for implementation
[MANDATORY] Read
.claude/skills/shared/root-cause-debugging-protocol.mdBEFORE proposing any fix. Responsibility attribution and data lifecycle tracing are required.
Debug Mindset (NON-NEGOTIABLE)
Be skeptical. Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence percentages (Idea should be more than 80%).
- Do NOT assume the first hypothesis is correct — verify with actual code traces
- Every root cause claim must include
file:lineevidence - If you cannot prove a root cause with a code trace, state "hypothesis, not confirmed"
- Question assumptions: "Is this really the cause?" → trace the actual execution path
- Challenge completeness: "Are there other contributing factors?" → check related code paths
Confidence & Evidence Gate
MANDATORY IMPORTANT MUST declare Confidence: X% with evidence list + file:line proof for EVERY claim.
| Confidence | Meaning | Action |
|---|---|---|
| 95-100% | Full trace verified | Report as confirmed root cause |
| 80-94% | Main path verified, edge cases uncertain | Report with caveats |
| 60-79% | Partial trace | Report as hypothesis |
| <60% | Insufficient evidence | DO NOT report — gather more evidence |
Workflow Details
Step 1: Reproduce
- Clarify expected vs actual behavior
- Identify trigger conditions (user action, data state, timing)
Step 2: Hypothesize
- Form 2-3 theories about root cause
- Rank by likelihood based on symptoms
Step 3: Trace
- For each hypothesis, trace the code path:
- Find entry point (API, UI, job, event)
- Follow through handlers/services
- Check data transformations and state changes
- Verify error handling paths
- Use grep/read to collect
file:lineevidence
Step 4: Confirm
- Match evidence to a single root cause
- Verify the root cause explains ALL symptoms
- Check for secondary contributing factors
Dependency Tracing (MANDATORY — DO NOT SKIP when graph.db exists)
If .code-graph/graph.db exists, you MUST use structural queries to trace dependencies:
Graph reveals ALL callers and consumers of buggy code — grep alone misses structural relationships.
- Who calls the buggy function:
python .claude/scripts/code_graph query callers_of <function> --json - Who imports the buggy module:
python .claude/scripts/code_graph query importers_of <file> --json - What tests exist:
python .claude/scripts/code_graph query tests_for <function> --json - What does this function call:
python .claude/scripts/code_graph query callees_of <function> --json
Graph-Assisted Debugging
After identifying suspect files, use graph trace to understand the full context:
python .claude/scripts/code_graph trace <suspect-file> --direction both --json— see what calls this code AND what it triggers downstreampython .claude/scripts/code_graph trace <suspect-file> --direction upstream --json— find all callers that could trigger the bug- This reveals implicit connections (MESSAGE_BUS, event handlers) that may propagate the issue across services
Step 5: Report
- Output: confirmed root cause with evidence chain
- Include: affected files, data flow, fix recommendation
- Hand off to
/fixfor implementation
⚠️ MANDATORY: Post-Fix Verification
After /fix applies changes, /prove-fix MUST be run. It builds code proof traces per change with confidence scores. This is non-negotiable in all fix workflows.
Red Flags — STOP (Debugging-Specific)
If you're thinking:
- "I see the problem, let me fix it" — Seeing symptoms is not understanding root cause. Investigate first.
- "Quick fix for now, investigate later" — Quick fixes mask bugs and create debt. Find root cause.
- "Just try changing X and see" — One hypothesis at a time. Scientific method, not trial and error.
- "Already tried 2+ fixes, one more" — 3+ failed fixes = STOP. Question the architecture, not the fix.
- "The error message is misleading" — Read it again carefully. Error messages are usually right.
- "It works on my machine" — Reproduce in the failing environment. Your environment hides bugs.
- "This can't be the cause" — Verify with evidence, not intuition. Unlikely causes are still causes.
IMPORTANT Task Planning Notes (MUST FOLLOW)
- Always plan and break work into many small todo tasks using
TaskCreate - Always add a final review todo task to verify work quality and identify fixes/enhancements
Workflow Recommendation
IMPORTANT MUST: If you are NOT already in a workflow, use
AskUserQuestionto ask the user:
- Activate
bugfixworkflow (Recommended) — scout → investigate → debug → plan → fix → prove-fix → review → test- Execute
/debugdirectly — run this skill standalone
Next Steps
MANDATORY IMPORTANT MUST after completing this skill, use AskUserQuestion to recommend:
- "/fix (Recommended)" — Apply fix based on debug findings
- "/plan" — If fix requires planning
- "Skip, continue manually" — user decides
Standalone Review Gate (Non-Workflow Only)
MANDATORY IMPORTANT MUST: If this skill is called outside a workflow (standalone
/debug), you MUST create aTaskCreatetodo task for/review-changesas the last task in your task list. This ensures all changes are reviewed before commit even without a workflow enforcing it.If already running inside a workflow (e.g.,
bugfix), skip this — the workflow sequence handles/review-changesat the appropriate step.
Closing Reminders
MANDATORY IMPORTANT MUST break work into small todo tasks using TaskCreate BEFORE starting.
MANDATORY IMPORTANT MUST validate decisions with user via AskUserQuestion — never auto-decide.
MANDATORY IMPORTANT MUST add a final review todo task to verify work quality.
MANDATORY IMPORTANT MUST READ the following files before starting:
- MUST READ
.claude/skills/shared/understand-code-first-protocol.mdbefore starting - MUST READ
.claude/skills/shared/evidence-based-reasoning-protocol.mdbefore starting - MUST READ
.claude/skills/shared/estimation-framework.mdbefore starting - MUST READ
.claude/skills/shared/red-flag-stop-conditions-protocol.mdbefore starting
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
fix-parallel
[Implementation] Analyze & fix issues with parallel fullstack-developer agents
ask
[Utilities] Answer technical and architectural questions.
claude-code
[Utilities] Claude Code CLI setup, configuration, troubleshooting, and feature guidance. Triggers on claude code setup, hook not firing, MCP connection, context limit, skill creation, slash command setup.
workflow-deployment
[Workflow] Trigger Deployment & Infrastructure workflow — CI/CD pipelines, Docker, Kubernetes setup and deployment.
workflow-idea-to-pbi
[Workflow] Trigger Idea to PBI workflow — po/ba workflow: capture idea, refine to pbi, create stories, prioritize.
easy-claude-help
[Utilities] Configuration guide for the easy-claude framework — explain settings, guide users through configuring .ck.json.
Didn't find tool you were looking for?