OpenClaw AI Agent Skill
name: systematic-debugging description: 4-phase root cause investigation for any bug, test failure, or unexpected behavior. Use when encountering ANY technical issue — bugs, crashes, test failures, performance problems, integration errors. Enforces finding root cause BEFORE attempting fixes. NO random fixes allowed.
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
Random fixes waste time and create new bugs. Symptom fixes mask underlying issues.
Goal: Confirm the bug exists and get exact reproduction steps.
- Get the EXACT error message, stack trace, or unexpected behavior
- Find the MINIMAL reproduction case — strip away everything non-essential
- Confirm it's reproducible (not a flaky/timing issue)
- Document: input → expected output → actual output
Output: Clear reproduction steps anyone can follow.
If you can't reproduce: Gather more context. Check logs, environment differences, timing. Do NOT guess.
Goal: Narrow down to the specific component, file, and line.
- Binary search the codebase — comment out half, does it still fail?
- Check recent changes —
git log --oneline -20,git diff HEAD~5 - Trace the data flow — follow the input from entry point to error
- Add targeted logging — not everywhere, just at decision points
- Check boundaries — input validation, type mismatches, null/undefined
Output: "The bug is in [file], [function], around line [N], triggered when [condition]."
Goal: Understand WHY it breaks, not just WHERE.
Ask these questions:
- Why does this code exist? What was the original intent?
- What assumption is violated? Every bug is a broken assumption
- Is this a design flaw or an implementation bug? Design flaws need different fixes
- Are there other places with the same bug? Pattern-match across the codebase
- What changed? Environment, dependency, data, config, or code?
Output: "The root cause is [X] because [Y]. It was introduced by [Z]."
Only after completing Phases 1-3.
- Write the fix targeting the ROOT CAUSE (not the symptom)
- Verify the original reproduction case now passes
- Check for regressions — did the fix break anything else?
- Add a test that catches this specific bug (prevent recurrence)
- Document what happened and why (for future reference)
Anti-patterns to avoid:
- ❌ "Let me try this" without understanding the problem
- ❌ Fixing the symptom instead of the cause
- ❌ Adding a special case / hack instead of fixing the real issue
- ❌ "It works now" without understanding why
- ❌ Skipping the regression check
| Phase | Question | Output |
|---|---|---|
| Reproduce | Can I make it fail reliably? | Exact reproduction steps |
| Isolate | Where exactly is it breaking? | File, function, line |
| Root Cause | Why is it breaking? | The broken assumption |
| Fix | How do I fix the actual cause? | Tested fix + regression check |
If after 30 minutes of investigation you can't isolate:
- Ask for help — describe what you've tried and ruled out
- It may be an environment issue, not a code issue
- It may be a race condition or timing-dependent bug (hardest to debug)
cp -r systematic-debugging/ ~/.openclaw/workspace/skills/systematic-debugging/MIT © Sentra Technology