| name | systematic-debugging |
| description | Use when encountering bugs, test failures, unexpected behavior, or performance issues before proposing fixes. |
| allowed-tools | ["shell","read_file","apply_patch","update_plan"] |
| metadata | {"short-description":"Root-cause-first debugging workflow"} |
Systematic Debugging
Read these references:
~/.config/agent/core/behavior.md - Evidence-based reasoning
~/.config/agent/core/methodology.md - Problem-solving framework
~/.config/agent/domain/testing/unit.md - Test strategy
Overview
Random fixes waste time. Always find the root cause before fixing symptoms.
Core principle: Root-cause investigation before fixes.
The Iron Law
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
Phase 1: Root Cause Investigation
- Read errors carefully (stack traces, line numbers, error codes)
- Reproduce consistently (steps, frequency, exact conditions)
- Check recent changes (diffs, dependency changes, env changes)
- Gather evidence across boundaries (log inputs/outputs between layers)
- Trace data flow (use
root-cause-tracing.md)
Phase 2: Pattern Analysis
- Find working examples in the codebase
- Compare against references completely
- List every difference (no assumptions)
- Identify dependencies and assumptions
Phase 3: Hypothesis & Testing
- Form a single, explicit hypothesis
- Test minimally (one variable at a time)
- Verify before proceeding
- If uncertain, pause and ask
Phase 4: Implementation
- Create a failing repro test when feasible
- Prefer automated tests; one-off scripts if needed
- If strict TDD is required, invoke
tdd-enforce
- Implement a single fix for the root cause
- Verify the fix (re-run tests, check regressions)
- If 3+ fixes fail, stop and question architecture
Red Flags — STOP
- “Quick fix now, investigate later”
- Multiple fixes at once
- Guessing without evidence
- Skipping the repro test when feasible
Supporting Techniques
root-cause-tracing.md - Trace bugs backward to source
defense-in-depth.md - Layered validation after root cause found
condition-based-waiting.md - Replace arbitrary sleeps with conditions
Arguments
Target: ${ARGUMENTS}