systematic-debugging
Skill3 starsChanged 53 days agoMITView on GitHub
Find a bug's root cause before changing code: build a tight red-capable feedback loop, gather evidence at component boundaries, rank falsifiable hypotheses, then fix once and prove it with a regression test. Use for any test failure, production bug, unexpected behavior, performance regression or build failure — especially under time pressure or after a fix that did not work. Not for exploratory "make it nicer" refactors, and not for a known mechanical change with an already-proven cause.
190 other projects use a version of this, 118 of them edited.
Adopted by
Most recently taken up by
- metaspartan/cybaratheir own version, first seen Nov 15, 2026
- alexj11324/Mikkaedited, first seen Nov 15, 2026
- mdiri-ai/SoduWorkedited, first seen Nov 15, 2026
- komluk/scaffoldingtheir own version, first seen Nov 15, 2026
- KbWen/agent-virtual-officetheir own version, first seen Nov 15, 2026
- Wenaixi/dsh-superpoweredited, first seen Nov 15, 2026
Used with
Projects with it also use chinese-code-review, chinese-commit-conventions and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Leodorareluctant259Skillchinese-code-review
中文代码审查规范——在保持专业严谨的同时,用符合国内团队文化的方式给出有效反馈
Also in 8 projects that use this
Leodorareluctant259Skillchinese-commit-conventions
中文 Git 提交规范 — 适配国内团队的 commit message 规范和 changelog 自动化
Also in 8 projects that use this
obraSkilldiagnosing-superpowers
Use when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.
Also in 20 projects that use this
mjunaidcaSkillbuilding-chatgpt-apps
Guides creation of ChatGPT Apps with interactive widgets using OpenAI Apps SDK and MCP servers. Use when building ChatGPT custom apps with visual UI components, embedded widgets, or rich interactive experiences. Covers widget architecture, MCP server setup with FastMCP, response metadata, and Developer Mode configuration. NOT when building standard MCP servers without widgets (use building-mcp-servers skill instead).
Also in 4 projects that use this
mjunaidcaSkillbuilding-chat-interfaces
Build AI chat interfaces with custom backends, authentication, and context injection. Use when integrating chat UI with AI agents, adding auth to chat, injecting user/page context, or implementing httpOnly cookie proxies. Covers ChatKitServer, useChatKit, and MCP auth patterns. NOT when building simple chatbots without persistence or custom agent integration.
Also in 4 projects that use this
- +2 more from Leodorareluctant259
- +5 more from mjunaidca
Other versions190 projects use a version of this.
Word for word · 0
None found.
Edited · 118
- obra/superpowers★ 314k55% same
- NousResearch/hermes-agent★ 264k82% same
- openai/plugins★ 7.8k55% same
- farm-fe/farm★ 5.6k54% same
- microsoft/FluidFramework★ 4.9k55% same
- heyitsnoah/claudesidian★ 2.6k44% same
- UniClipboard/UniClipboard★ 2k53% same
- lingyired/status-trio★ 1.8k55% same
- pcvelz/superpowers★ 1.3k55% same
- math-inc/OpenGauss★ 1.3k69% same
108 more not listed
Wrote their own version · 72
- open-metadata/OpenMetadata★ 16ksame name
- jnMetaCode/superpowers-zh★ 8.5ksame name
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- ChrisWiles/claude-code-showcase★ 6.1ksame name
- compozy/compozy★ 2.9ksame name
- GanyuanRan/Aegis★ 1.4ksame name
- SethGammon/Citadel★ 927same name
- KbWen/agentic-os★ 236same name
- linxuan-sys/opencode-skills-chinese★ 200same name
62 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository59 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-harness-settings-paritySkill
- agent-operating-contract-evolutionSkill
- ai-coding-agent-delegationSkill
- arch-improvement-planSkill
- contract-bound-deliverablesSkill
- cross-agent-repair-routingSkill
- define-goalSkill
- delegated-work-acceptanceSkill
- design-an-interfaceSkill
- design-mdSkill
- discord-rich-messageSkill
- dotnet-repo-workflowSkill
- evidence-backed-analytical-writingSkill
- evidence-boundary-disciplineSkill
- find-nearbySkill
- gddSkill
- generated-runtime-repairsSkill
- ghc-searchSkill
- git-auto-sync-pipelinesSkill
- github-code-reviewSkill
- github-repo-managementSkill
- grounded-citationsSkill
- harness-engineeringSkill
- hermes-context-file-loadingSkill
- hermes-modelsSkill
- hermes-updatesSkill
- hoa-introspect-distillSkill
- hoa-introspectSkill
- hoa-skill-reviewSkill
- hoa-skill-workSkill
- html-artifactSkill
- jupyter-live-kernelSkill
- kanban-workflowsSkill
- m365-copilot-cdpSkill
- measurement-campaign-evidenceSkill
- microsoft-officeSkill
- notes-to-prdSkill
- ocr-and-documentsSkill
- official-document-verificationSkill
- omp-headless-orchestrationSkill
- ops-claim-verificationSkill
- package-release-verificationSkill
- plan-to-issuesSkill
- project-phase-closeoutSkill
- report-claim-auditSkill
- research-stream-consolidationSkill
- review-revision-candidatesSkill
- rss-feedsSkill
- skill-library-curationSkill
- skill-porting-and-publishingSkill
- spec-convergenceSkill
- structural-validity-gatesSkill
- subagent-driven-developmentSkill
- teams-cdpSkill
- tmux-agent-controlSkill
- whisperSkill
- writing-plansSkill
- writingSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
36 rules. 7 are common, 27 are distinctive, and 2 are very specific to this project.
7
Common
Most of the 177 edited versions we read keep these.
27
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 25
Core principle: ALWAYS find root cause before attempting fixes.
- Common: line 38
If you haven't completed Phase 1, you cannot propose fixes.
- Distinctive: line 47
When a clean repro is hard, spend disproportionate effort building the loop.
- Distinctive: line 52
Use for ANY technical issue:
- Common: line 87
Don't skip past errors or warnings
- Common: line 89
Read stack traces completely
- Distinctive: line 92
Action: Read the relevant source files at the named lines.
- Common: line 101
If not reproducible → gather more data, don't guess.
- Distinctive: line 111
Property / fuzz loop: when the bug is intermittent wrong output over a broad input space.
- Distinctive: line 114
Human-in-the-loop script: only as a last resort: script the human steps and capture their result so the loop stays structured.
- Distinctive: line 128
Action: Run the tight loop from the shell:
- Distinctive: line 170
Verify environment/config propagation
- Distinctive: line 171
Check state at each layer
- Distinctive: line 173
Run once to gather evidence showing WHERE it breaks.
- Common: line 183
Keep tracing upstream until you find the source
- Distinctive: line 186
Action: Search the codebase for the call sites and assignments:
- Distinctive: line 207
STOP: Do not proceed to Phase 2 until you understand WHY it's happening.
- Distinctive: line 229
Action: Search for the comparable pattern and read the working path end to end.
- Distinctive: line 233
If implementing a pattern, read the reference implementation COMPLETELY
- Distinctive: line 234
Don't skim — read every line
- Distinctive: line 241
Don't assume "that can't matter"
- Distinctive: line 263
If the user is present, show the ranked list before testing.
- Distinctive: line 268
Test the highest-ranked hypothesis with the smallest possible probe.
- Distinctive: line 270
Don't fix multiple things at once.
- Distinctive: line 271
Prefer debugger/REPL inspection when available.
- Very specific: line 272
If you add logs, tag every temporary line with a unique prefix such as [DEBUG-a4f2] so cleanup is a single search.
- Distinctive: line 279
DON'T add more fixes on top
- Distinctive: line 284
Don't pretend to know
- Distinctive: line 285
Ask the user for help
- Distinctive: line 298
MUST have before fixing
- Distinctive: line 299
Follow the project's test-first rule.
- Very specific: line 322
If fewer than ${DEBUG_MAX_FIXES:-3}: return to Phase 1, re-analyze with new information
- Distinctive: line 324
DON'T attempt another fix without an architectural discussion
- Distinctive: line 338
Should we refactor the architecture vs.
- Common: line 348
If you catch yourself thinking:
- Distinctive: line 391
Use the capability, not one product's wrapper name:
“Common” is measured: kept by at least 6 in 10 of the 177 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.
Method adapted from the public superpowers debugging flow (MIT); the feedback-loop rule, ranked
falsifiable hypotheses, and rule-of-three escalation were extended here.
The Iron Law
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRSTIf you haven't completed Phase 1, you cannot propose fixes.
The Feedback Loop Rule
The feedback loop is the debugging work. Before reading code to build a theory, create or identify a tight command that can go red on the user's exact symptom and green when the bug is fixed. A tight loop is fast, deterministic, agent-runnable, and specific enough to catch this bug — not merely "doesn't crash".
When a clean repro is hard, spend disproportionate effort building the loop. Guessing without a red-capable loop is the failure mode this skill exists to prevent.
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
Don't skip when:
- Issue seems simple (simple bugs have root causes too)
- You're in a hurry (rushing guarantees rework)
- Someone wants it fixed NOW (systematic is faster than thrashing)
The Four Phases
You MUST complete each phase before proceeding to the next.
Phase 1: Root Cause Investigation
BEFORE attempting ANY fix:
1. 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
Action: Read the relevant source files at the named lines. Search the codebase for the exact error string; it usually names the function or condition that produced it.
2. Build a Tight Feedback Loop
- Can you trigger the user's exact symptom with one command?
- Does the command fail for this bug and only pass once the bug is fixed?
- Is it fast enough to run repeatedly?
- Is it deterministic? For flaky bugs, can you raise the reproduction rate high enough to debug?
- If not reproducible → gather more data, don't guess.
Ways to construct a loop — try in roughly this order:
- Failing test at the seam that reaches the bug: unit, integration, or end-to-end.
- HTTP script against a running dev server.
- CLI invocation with fixture input, diffing stdout/stderr against expected output.
- Headless browser script asserting on DOM, console, or network.
- Replay a captured trace: HAR, request payload, event log, queue message, or webhook body.
- Throwaway harness that boots the smallest useful slice of the system and calls the failing path.
- Property / fuzz loop when the bug is intermittent wrong output over a broad input space.
- Bisection harness suitable for
git bisect runwhen the bug appeared between two known states. - Differential loop comparing old vs new version, two configs, two providers, or two datasets.
- Human-in-the-loop script only as a last resort: script the human steps and capture their result so the loop stays structured.
Tighten the loop once it exists:
- Make it faster: cache setup, narrow scope, skip unrelated initialization.
- Make the signal sharper: assert the exact symptom, not generic success.
- Make it more deterministic: pin time, seed randomness, isolate filesystem, freeze network.
For non-deterministic bugs, the immediate goal is a higher reproduction rate, not perfection. Run the
trigger repeatedly (DEBUG_STRESS_RUNS, default 100), parallelize, add stress, narrow timing windows,
or inject sleeps. A bug that reproduces at DEBUG_REPRO_FLOOR (default 0.5) is debuggable; below it,
raise the rate first.
Action: Run the tight loop from the shell:
# Run a specific failing test
pytest tests/test_module.py::test_name -v
# Or run a scripted repro
python scripts/repro_bug.py
# Or run a high-repetition flaky repro
for i in $(seq 1 "${DEBUG_STRESS_RUNS:-100}"); do
pytest tests/test_flake.py::test_name -q || break
done3. Check Recent Changes
- What changed that could cause this?
- Diff, recent commits
- New dependencies, config changes
# Recent commits
git log --oneline -10
# Uncommitted changes
git diff
# Changes in specific file
git log -p --follow src/problematic_file.py | head -1004. Gather Evidence in Multi-Component Systems
WHEN the system has multiple components (API → service → database, CI → build → deploy):
BEFORE proposing fixes, add diagnostic instrumentation:
For EACH component boundary:
- Log what data enters the component
- Log what data exits the component
- Verify environment/config propagation
- Check state at each layer
Run once to gather evidence showing WHERE it breaks. THEN analyze evidence to identify the failing component. THEN investigate that specific component.
5. Trace Data Flow
WHEN the error is deep in the call stack:
- Where does the bad value originate?
- What called this function with the bad value?
- Keep tracing upstream until you find the source
- Fix at the source, not at the symptom
Action: Search the codebase for the call sites and assignments:
# Find where the function is called
grep -rn 'function_name(' src/ --include='*.py'
# Find where the variable is set
grep -rnE 'variable_name[[:space:]]*=' src/ --include='*.py'Phase 1 Completion Checklist
- Error messages fully read and understood
- A tight loop command exists and has been run at least once
- Loop is red-capable: it asserts the user's exact symptom, not a nearby failure
- Loop is deterministic, or a flaky bug has a high enough reproduction rate to debug
- Recent changes identified and reviewed
- Evidence gathered (logs, state, data flow)
- Problem isolated to specific component/code
- Root cause hypotheses can be stated and tested
STOP: Do not proceed to Phase 2 until you understand WHY it's happening.
Phase 2: Pattern Analysis
Find the pattern before fixing:
0. Minimize the Reproduction
Once the loop is red, shrink the repro to the smallest scenario that still goes red. Cut inputs, callers, config, data, and steps one at a time, re-running the loop after each cut. Keep only what is load-bearing for the failure.
Done when removing any remaining element makes the loop go green. A minimal repro narrows the hypothesis space and often becomes the cleanest regression test.
1. Find Working Examples
- Locate similar working code in the same codebase
- What works that's similar to what's broken?
Action: Search for the comparable pattern and read the working path end to end.
2. Compare Against References
- If implementing a pattern, read the reference implementation COMPLETELY
- Don't skim — read every line
- Understand the pattern fully before applying
3. Identify Differences
- What's different between working and broken?
- List every difference, however small
- Don't assume "that can't matter"
4. Understand Dependencies
- What other components does this need?
- What settings, config, environment?
- What assumptions does it make?
Phase 3: Hypothesis and Testing
Scientific method:
1. Form Ranked Falsifiable Hypotheses
- Generate 3–5 plausible hypotheses before testing any single one.
- Rank them by likelihood and cheapness to falsify.
- State the prediction each hypothesis makes: "If X is the cause, then changing or observing Y should make Z happen."
- Discard or sharpen any hypothesis that does not make a testable prediction.
If the user is present, show the ranked list before testing. They may have domain knowledge that instantly re-ranks it. If the user is AFK, proceed with your ranking.
2. Test Minimally
- Test the highest-ranked hypothesis with the smallest possible probe.
- Change one variable at a time.
- Don't fix multiple things at once.
- Prefer debugger/REPL inspection when available; one breakpoint beats ten logs.
- If you add logs, tag every temporary line with a unique prefix such as
[DEBUG-a4f2]so cleanup is a single search.
3. Verify Before Continuing
- Did it work? → Phase 4
- Didn't work? → Form NEW hypothesis
- DON'T add more fixes on top
4. When You Don't Know
- Say "I don't understand X"
- Don't pretend to know
- Ask the user for help
- Research more
Phase 4: Implementation
Fix the root cause, not the symptom:
1. Create Failing Test Case
- Simplest possible reproduction
- Automated test if possible
- MUST have before fixing
- Follow the project's test-first rule; if it has none, add the regression test anyway
2. Implement Single Fix
- Address the root cause identified
- ONE change at a time
- No "while I'm here" improvements
- No bundled refactoring
3. Verify Fix
# Run the specific regression test
pytest tests/test_module.py::test_regression -v
# Run full suite — no regressions
pytest tests/ -q4. If Fix Doesn't Work — The Rule of Three
- STOP.
- Count: How many fixes have you tried?
- If fewer than
${DEBUG_MAX_FIXES:-3}: return to Phase 1, re-analyze with new information - If at or above the limit: STOP and question the architecture (step 5 below)
- DON'T attempt another fix without an architectural discussion
5. If 3+ Fixes Failed: Question Architecture
Pattern indicating an architectural problem:
- Each fix reveals new shared state/coupling in a different place
- Fixes require "massive refactoring" to implement
- Each fix creates new symptoms elsewhere
STOP and question fundamentals:
- Is this pattern fundamentally sound?
- Are we "sticking with it through sheer inertia"?
- Should we refactor the architecture vs. continue fixing symptoms?
Discuss with the user before attempting more fixes.
This is NOT a failed hypothesis — this is a wrong architecture.
Red Flags — STOP and Follow Process
If you catch yourself thinking:
- "Quick fix for now, investigate later"
- "Just try changing X and see if it works"
- "Add multiple changes, run tests"
- "Skip the test, I'll manually verify"
- "It's probably X, let me fix that"
- "I don't fully understand but this might work"
- "Pattern says X but I'll adapt it differently"
- "Here are the main problems: [lists fixes without investigation]"
- Proposing solutions before tracing data flow
- "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.
If fix attempts reached the limit (DEBUG_MAX_FIXES, default 3): Question the architecture
(Phase 4 step 5).
Common Rationalizations
| Excuse | Reality |
| "Issue is simple, don't need process" | Simple issues have root causes too. Process is fast for simple bugs. |
| "Emergency, no time for process" | Systematic debugging is FASTER than guess-and-check thrashing. |
| "Just try this first, then investigate" | First fix sets the pattern. Do it right from the start. |
| "I'll write test after confirming fix works" | Untested fixes don't stick. Test first proves it. |
| "Multiple fixes at once saves time" | Can't isolate what worked. Causes new bugs. |
| "Reference too long, I'll adapt the pattern" | Partial understanding guarantees bugs. Read it completely. |
| "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
| "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. Question the pattern, don't fix again. |
Quick Reference
| Phase | Key Activities | Success Criteria |
| 1. Root Cause | Read errors, reproduce, check changes, gather evidence, trace data flow | Understand WHAT and WHY |
| 2. Pattern | Find working examples, compare, identify differences | Know what's different |
| 3. Hypothesis | Form theory, test minimally, one variable at a time | Confirmed or new hypothesis |
| 4. Implementation | Create regression test, fix root cause, verify | Bug resolved, all tests pass |
Harness integration
Use the capability, not one product's wrapper name:
| Need | Capability |
| Read source with line numbers | file-read tool |
| Find an error string, call site, or pattern | codebase search, or grep -rn |
| Run tests, inspect history, reproduce | shell |
| Research an unfamiliar error or library | web search / documentation fetch |
| Investigate a large multi-component failure in parallel | dispatch a read-only investigation subagent; it must report findings and NOT fix |
For complex multi-component debugging, the investigation brief is fixed:
Follow systematic-debugging:
1. Read the error message carefully
2. Reproduce the issue with a tight loop
3. Trace the data flow to find root cause
4. Report findings — do NOT fix yet
Error: <paste full error>
File: <path to failing code>
Test command: <exact command>Configuration
| Key | Env | Default |
max_fixes | DEBUG_MAX_FIXES | 3 — the rule-of-three trigger |
stress_runs | DEBUG_STRESS_RUNS | 100 — repetitions for a flaky repro |
repro_floor | DEBUG_REPRO_FLOOR | 0.5 — reproduction rate worth debugging |
log_tag_prefix | DEBUG_LOG_TAG_PREFIX | [DEBUG- — unique tag for temporary logs |
Resolution order and the config-file path are defined once in skill-porting-and-publishing § Configuration; this skill does not restate them. Commands above show the env form with the default inline, so a reader can run them without the config.
No shortcuts. No guessing. Systematic always wins.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

