core/capabilities/debugging/systematic-debug/SKILL.md
Four-phase debugging framework that finds root causes before attempting fixes. Use when investigating errors, debugging failures, fixing bugs, analyzing test failures, diagnosing unexpected behavior, examining stack traces, or when the user says "it's broken", "this doesn't work", or "why is this failing".
npx skillsauth add xoai/sage systematic-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 the root cause BEFORE attempting any fix. Random fixes waste hours and create new bugs. Quick patches mask underlying issues.
Core Principle: If you haven't completed Phase 1, you CANNOT propose fixes. Symptom fixes are failure. You MUST complete each phase before proceeding to the next.
Any time something is broken: test failures, runtime errors, unexpected behavior, performance degradation, flaky tests, production incidents, "it works on my machine" issues. Also use when a previous fix didn't hold — that means root cause was wrong.
Before touching anything:
git log, git diff.
The cause is almost always in recent changes.DO NOT skip this phase. DO NOT propose a fix yet. You don't understand the problem yet.
Form 2-3 hypotheses about what could cause the observed behavior.
For each hypothesis:
For multi-component systems, trace data flow across component boundaries:
For each hypothesis, gather evidence. This means adding targeted logging, running specific commands, or inspecting state — NOT making code changes.
Rules:
When you find the root cause:
Now — and ONLY now — you may fix it:
One fix at a time. Don't combine fixes. Don't "also improve" nearby code.
If 3+ fixes have failed for the same issue:
STOP. You're treating symptoms, not the root cause. Return to Phase 1 with fresh eyes. Question whether the architecture itself is the problem, not just the code. Discuss with your human partner before attempting more fixes.
This is NOT a failed hypothesis — it may be wrong architecture.
| Anti-Pattern | What to Do Instead | |-------------|-------------------| | "Let me just try..." | STOP. What's your hypothesis? What evidence supports it? | | Changing 5 things at once | Revert. Change ONE thing. Verify. | | "It works now but I'm not sure why" | DANGER. Find out why or the bug will return. | | Fixing the test instead of the code | Tests are the specification. If the test is wrong, fix it with evidence. If the code is wrong, fix the code. | | Adding a workaround | Find the root cause. Workarounds become permanent. | | "Works on my machine" | The difference between your machine and the failing one IS the bug. |
See references/ for specialized techniques:
root-cause-tracing.md — Backward tracing through call stack to find original triggerdefense-in-depth.md — Adding validation at multiple layers after finding root causetools
Captures agent mistakes, corrections, and discovered gotchas so they are not repeated. Use when: (1) a command or operation fails unexpectedly, (2) the user corrects the agent, (3) the agent discovers non-obvious behavior through debugging, (4) an API or tool behaves differently than expected, (5) a better approach is found for a recurring task. Also searches past learnings before starting tasks to avoid known pitfalls. Activate alongside the sage-memory skill — they share the same MCP backend but serve different purposes (sage-memory = codebase knowledge, sage-self-learning = agent mistakes and gotchas).
development
Typed knowledge graph stored in sage-memory. Use when creating or querying structured entities (Person, Project, Task, Event, Document), linking related objects, checking dependencies, planning multi-step actions as graph transformations, or when skills need to share structured state. Trigger on "remember that X is Y", "what do I know about", "link X to Y", "show dependencies", "what blocks X", entity CRUD, cross-skill data access, or any request involving structured relationships between things.
tools
Integrates sage-memory into Sage workflows. Teaches the agent when to remember (store findings during work), when to recall (search memory at session start and task start), and how to learn (structured knowledge capture via sage learn). Use when the user mentions memory, remember, recall, learn, capture knowledge, onboard to codebase, or when starting any session where sage-memory MCP tools are available.
tools
Captures agent mistakes, corrections, and discovered gotchas so they are not repeated. Use when: (1) a command or operation fails unexpectedly, (2) the user corrects the agent, (3) the agent discovers non-obvious behavior through debugging, (4) an API or tool behaves differently than expected, (5) a better approach is found for a recurring task. Also searches past learnings before starting tasks to avoid known pitfalls. Activate alongside the sage-memory skill — they share the same MCP backend but serve different purposes (sage-memory = codebase knowledge, sage-self-learning = agent mistakes and gotchas).