| name | systematic-debugging |
| description | Investigate root cause before fixing bugs or unexpected behavior. Requires the Mnemosyne knowledge backend through advise and fails closed when it cannot be prepared. |
| argument-hint | <description of the bug or failure> |
| allowed-tools | ["Read","Write","Edit","Bash","Grep","Glob","Agent"] |
Systematic Debugging
Overview
Random fixes waste time and create new bugs. Quick patches mask underlying issues.
Core principle: ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
Violating the letter of this process is violating the spirit of debugging.
Before Starting
Run advise with the error description. Failure to prepare the required knowledge backend is a
blocking error, not permission to skip prior-knowledge search.
The Iron Law
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
If you haven't completed Phase 1, you cannot propose fixes.
When to Use
Use for ANY technical issue:
- Test failures
- Bugs in production
- Unexpected behavior
- Performance problems
- Build failures
- Integration issues
Use this ESPECIALLY when:
- Under time pressure (emergencies make guessing tempting)
- "Just one quick fix" seems obvious
- You've already tried multiple fixes
- Previous fix didn't work
- You don't fully understand the issue
The Four Phases
You MUST complete each phase before proceeding to the next.
Phase 1: Root Cause Investigation
BEFORE attempting ANY fix:
-
Read Error Messages Carefully
- Don't skip past errors or warnings
- They often contain the exact solution
- Read stack traces completely
- Note line numbers, file paths, error codes
-
Reproduce Consistently
- Can you trigger it reliably?
- What are the exact steps?
- Does it happen every time?
- If not reproducible → gather more data, don't guess
-
Check Recent Changes
- What changed that could cause this?
git diff, recent commits
- New dependencies, config changes
- Environmental differences
-
Gather Evidence in Multi-Component Systems
WHEN system has multiple components:
BEFORE proposing fixes, add diagnostic instrumentation:
For EACH component boundary:
- Log what data enters component
- Log what data exits component
- Verify environment/config propagation
- Check state at each layer
Run once to gather evidence showing WHERE it breaks
THEN analyze evidence to identify failing component
THEN investigate that specific component
-
Trace Data Flow
When error is deep in call stack:
- Where does the bad value originate?
- What called this with the bad value?
- Keep tracing up until you find the source
- Fix at source, not at symptom
Phase 2: Pattern Analysis
Find the pattern before fixing:
- Find working examples of similar code in the same codebase
- Read reference implementations completely — don't skim
- List every difference between working and broken code
- Identify all dependencies, config, environment assumptions
Phase 3: Hypothesis and Testing
Scientific method:
- Form single hypothesis: "I think X is the root cause because Y"
- Test minimally: Make the SMALLEST possible change to test the hypothesis
- One variable at a time: Don't fix multiple things at once
- Verify before continuing: If it worked → Phase 4. Didn't work → new hypothesis
- When stuck: Say "I don't understand X" — don't pretend to know
Phase 4: Implementation
Fix the root cause, not the symptom:
-
Create failing test case using the test-driven-development skill — it must exist before fixing
-
Implement single fix addressing the root cause
-
Verify fix: Test passes? No other tests broken? Issue actually resolved?
-
If fix doesn't work:
- STOP
- Count: How many fixes have you tried?
- If < 3: Return to Phase 1 with new information
- If ≥ 3: STOP and question the architecture
-
If 3+ fixes failed — Question Architecture:
Pattern indicating architectural problem:
- Each fix reveals new shared state/coupling/problem elsewhere
- Fixes require massive refactoring to implement
- Each fix creates new symptoms elsewhere
STOP and discuss with user before attempting more fixes.
This is not a failed hypothesis — this is a wrong architecture.
Red Flags — STOP and Follow Process
- "Quick fix for now, investigate later"
- "Just try changing X and see if it works"
- "Add multiple changes, run tests"
- "It's probably X, let me fix that"
- "I don't fully understand but this might work"
- "One more fix attempt" (when already tried 2+)
- Each fix reveals a new problem in a different place
ALL of these mean: STOP. Return to Phase 1.
Common Rationalizations
| Excuse | Reality |
|---|
| "Issue is simple, don't need process" | Simple issues have root causes too. |
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check. |
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Don't fix again. |
Repository command discovery
Before running a check, discover the target repository's commands from AGENTS.md, task runners,
manifests, lockfiles, and CI. Prefer the command used by required CI. If sources conflict or no safe
command is discoverable, ask the user rather than substituting Athena's own tooling.
Keep the target repository as the current working directory. Resolve
scripts/repository_evidence.py against this installed skill directory and invoke that absolute
helper path with PATTERN --source-root SOURCE_ROOT to collect the latest ten commits, a diff
bounded to that revision window, and matching source locations as JSON. Run the
discovered repository-focused test and type-check commands directly through the host execution
tool, retaining their complete output as evidence.
After Resolution
Verify with fresh runnable evidence per the evidence-integrity policy before claiming the bug is
fixed; rerun the failing reproduction and the repository-defined checks.
Offer to invoke learn when the session produced durable debugging knowledge. An indirect Learn
invocation does not authorize its branch, commit, push, or pull-request writes; follow Learn's
external-write checkpoint and obtain explicit authority before mutation. Useful lessons include:
- Root cause category and symptoms
- What diagnostic steps revealed it
- The fix pattern
- Any architectural issues uncovered
This prevents the same debugging session from being repeated by another agent.
Adapted from obra/superpowers under the MIT License. Copyright (c) 2025 Jesse Vincent.