systematic-debugging
Skill1 starsChanged 57 days agoMITView on GitHub
Structured 4-phase debugging process — reproduce, isolate, identify root cause, verify with test. Use when user says "debug", "investigate", "figure out why", "root cause", "why is this broken", or has a bug that needs systematic analysis rather than quick fixes.
190 other projects use a version of this.
Adopted by
Most recently taken up by
- DemonDamon/AgenticXtheir own version, first seen Nov 9, 2026
- chrysogonus/power-agentstheir own version, first seen Nov 8, 2026
- willy92wins/DayZ-Modding-Knowledge-Packtheir own version, first seen Nov 8, 2026
- roundpilot/superpowers-antigravitytheir own version, first seen Nov 8, 2026
- REPOZY/superpowers-optimizedtheir own version, first seen Nov 8, 2026
- lingyired/status-triotheir own version, first seen Nov 8, 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 · 0
None found.
Wrote their own version · 190
- obra/superpowers★ 314ksame name
- NousResearch/hermes-agent★ 262ksame name
- open-metadata/OpenMetadata★ 16ksame name
- jnMetaCode/superpowers-zh★ 8.4ksame name
- vudovn/ag-kit★ 8.2ksame name
- vudovn/antigravity-kit★ 8.2ksame name
- openai/plugins★ 7.8ksame name
- ChrisWiles/claude-code-showcase★ 6.1ksame name
- farm-fe/farm★ 5.6ksame name
- microsoft/FluidFramework★ 4.9ksame name
180 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 repository27 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- design-craft/CLAUDE.mdCLAUDE.md
- android-emulatorSkill
- audit-branchSkill
- brainstormSkill
- create-devtoolSkill
- create-featureSkill
- create-infrastructureSkill
- execute-tasksSkill
- finish-featureSkill
- frontend-testingSkill
- generate-feature-docSkill
- generate-prdSkill
- git-commitSkill
- ios-simulatorSkill
- modify-featureSkill
- pipeline-helpSkill
- plan-implementationSkill
- prd-clarifierSkill
- prd-to-uxSkill
- prototypeSkill
- react-clean-architectureSkill
- receiving-code-reviewSkill
- refactoring-uiSkill
- setup-daher-skillsSkill
- test-mobile-appSkill
- writing-skillsSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
30 rules. 0 are common, 29 are distinctive, and 1 is very specific to this project.
0
Common
Most of the 177 edited versions we read keep these.
29
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Ask the user (or read from context):
- Distinctive: line 22
When did it start? (recent change, always been there, intermittent)
- Distinctive: line 25
If there's an error message → Grep the codebase for it
- Distinctive: line 26
If there's a failing test → Read it and run it
- Distinctive: line 27
If no test exists → Try to create a minimal one
- Distinctive: line 28
If it's UI-only → Identify the component and its hook
- Distinctive: line 47
Test: Call the function directly with the reproduction input
- Distinctive: line 52
Test: Check response shapes, Zod parsing, mapper output, error mapping
- Distinctive: line 57
Test: Check query keys, mutation logic, state transitions
- Distinctive: line 62
Test: Check conditional rendering, props flow, event handlers
- Distinctive: line 66
Start at the layer closest to the symptom
- Distinctive: line 67
Add assertions or logging at layer boundaries
- Distinctive: line 79
Read the isolated function/component carefully
- Distinctive: line 81
Check common root causes:
- Distinctive: line 90
Read existing tests for the isolated area — what IS tested vs what ISN'T?
- Distinctive: line 102
Run it and read the failure: it must fail on the bug's assertion, not on setup, imports or syntax — a wrong-reason failure proves nothing
- Distinctive: line 104
Follow the project's testing conventions (behavioral focus, query priority)
- Distinctive: line 105
Use shared factories if the type appears in 3+ test files
- Distinctive: line 109
If the fix requires touching multiple files, list them all before starting
- Distinctive: line 110
After the root-cause fix, consider hardening the other layers the bad value passed through: references/defense-in-depth.md
- Distinctive: line 111
If the bug is a flaky/async test (arbitrary timeouts, intermittent failures), fix it with condition-based waiting, never longer sleeps: …
- Distinctive: line 118
If the glob matches 0 test files, that is a FAIL, not a pass — fix the path
- Distinctive: line 119
No regressions in the feature
- Distinctive: line 122
No type errors introduced
- Distinctive: line 128
After each phase, briefly report what you found:
- Distinctive: line 138
Never guess: If you can't reproduce it, say so.
- Distinctive: line 140
Always verify: Don't declare victory until the test confirms the fix.
- Distinctive: line 141
If Phase 2 takes more than 3 isolation attempts at the same layer, step back and try a different layer.
- Distinctive: line 143
If the bug involves runtime state you can't reproduce in tests (e.g., specific API responses, browser-specific behavior), tell the user and …
- Very specific: line 150
Blame the framework: Before assuming React/Next.js/library is buggy, verify your usage is correct.
“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
4-phase root cause process. Each phase has explicit exit criteria — never skip ahead.
First move, before any production edit: reproduce the bug as a new failing test and watch it fail for the right reason. A test that was written but not run is not a reproduction; a fix without one is a tweak you cannot tell apart from luck. Phase 4 turns that test green.
When to use: Bugs that aren't immediately obvious. If a bug can be fixed by reading one file and spotting the issue, just fix it. This process is for when you need to investigate.
Phase 1: Reproduce
Goal: Get a reliable, minimal reproduction of the bug.
- Ask the user (or read from context):
- What happens? (actual behavior)
- What should happen? (expected behavior)
- Steps to reproduce (if known)
- When did it start? (recent change, always been there, intermittent)
- Find the reproduction:
- If there's an error message → Grep the codebase for it
- If there's a failing test → Read it and run it
- If no test exists → Try to create a minimal one
- If it's UI-only → Identify the component and its hook
- Document:
**Expected:** {what should happen} **Actual:** {what happens} **Reproduction:** {steps or test command}
Exit criteria: The bug can be reliably triggered — you can show it happening.
Phase 2: Isolate
Goal: Narrow down WHERE the bug lives using the project's layer architecture.
The project has clear layers. Check them in this order (domain bugs are cheapest to test):
Layer 1: Domain (pure functions)
- Files:
features/{feature}/domain/*.ts - Test: Call the function directly with the reproduction input
- These are pure functions — if the bug is here, it's the easiest to verify and fix
Layer 2: API / Mappers
- Files:
features/{feature}/api/*.ts—*.dto.ts(wire schemas),*.mapper.ts(dto→domain),*.api.ts(adapter); older features may still use*.schemas.ts - Test: Check response shapes, Zod parsing, mapper output, error mapping
- Common bugs: wrong field mapping, missing null handling, schema mismatch, mapper drops/renames a field the UI needs (check
toXagainst the dto)
Layer 3: Hooks (business logic)
- Files:
features/{feature}/hooks/use-*.ts - Test: Check query keys, mutation logic, state transitions
- Common bugs: stale closures, wrong dependency arrays, race conditions
Layer 4: Components (rendering)
- Files:
features/{feature}/components/*.tsx - Test: Check conditional rendering, props flow, event handlers
- Common bugs: wrong props passed, missing loading/error states
Isolation technique:
- Start at the layer closest to the symptom
- Add assertions or logging at layer boundaries
- Binary search: if the data is correct at layer 2 but wrong at layer 3, the bug is in layer 3
- Each check should take 1-2 minutes — don't spend 10 minutes on one layer
- For errors surfacing deep in a call stack (bad value from far away): references/root-cause-tracing.md
- For state that "jumps" (a wizard step resets, a selection clears, a toggle undoes itself) in Zustand stores or multi-step flows — a class the single-symptom trace misses: references/click-path-audit.md builds the store's side-effect map and traces every handler on the screen
Exit criteria: Bug is localized to a specific file and function. You can say: "The bug is in {file}:{function} because {reason}."
Phase 3: Identify Root Cause
Goal: Understand WHY the bug happens, not just WHERE.
- Read the isolated function/component carefully
- Trace the data flow through it — what comes in, what goes out
- Check common root causes:
- Wrong assumption: Code assumes a value is always present, but it can be null/undefined
- Missing edge case: Code handles the happy path but not this specific input
- Stale state: React hook captures an old value due to closure or missing dependency
- Race condition: Two async operations complete in unexpected order
- Type mismatch: Runtime type differs from TypeScript type (often at API boundary)
- Off-by-one: Index, pagination, or range calculation is wrong
- Wrong merge: Recent change introduced a regression (check git blame)
- Read existing tests for the isolated area — what IS tested vs what ISN'T?
- State the root cause in one sentence:
"The bug occurs because
{function}assumes{assumption}, but when{condition}, the value is actually{actual}."
Exit criteria: Root cause can be stated in one sentence with specific code references.
Phase 4: Verify
Goal: Prove the fix works and nothing else broke.
- Write a failing test that captures the bug (if the first move already produced one, reuse it):
- Run it and read the failure: it must fail on the bug's assertion, not on setup, imports or syntax — a wrong-reason failure proves nothing
- The test should fail BEFORE the fix and pass AFTER
- Follow the project's testing conventions (behavioral focus, query priority)
- Use shared factories if the type appears in 3+ test files
- Apply the fix:
- Minimal change — fix the root cause, don't refactor surrounding code
- If the fix requires touching multiple files, list them all before starting
- After the root-cause fix, consider hardening the other layers the bad value passed through: references/defense-in-depth.md
- If the bug is a flaky/async test (arbitrary timeouts, intermittent failures), fix it with condition-based waiting, never longer sleeps: references/condition-based-waiting.md
- Run the test: the project's test command (e.g.
pnpm vitest run {test-file})- Confirm the new test passes
- Confirm existing tests still pass
- Run the feature tests: the project's test command scoped to the feature (e.g.
pnpm vitest run {feature-dir}) — the feature's directory under the features root defined in.claude/rules/project-structure.md- If the glob matches 0 test files, that is a FAIL, not a pass — fix the path
- No regressions in the feature
- Run the build: the project's build command (e.g.
pnpm build)- No type errors introduced
Exit criteria: New test passes, existing tests pass, build passes.
Reporting
After each phase, briefly report what you found:
Phase 1: Reproduced — {description} Phase 2: Isolated to
{file}:{function}Phase 3: Root cause — {one sentence} Phase 4: Fixed — test passes, build passes
Rules
- Never skip phases. A fix without reproduction is a guess. A fix without a test can regress.
- Never guess. If you can't reproduce it, say so. If you can't isolate it, ask for help.
- Minimal fixes. Fix the root cause. Don't refactor, don't "improve" nearby code.
- Always verify. Don't declare victory until the test confirms the fix.
- If Phase 2 takes more than 3 isolation attempts at the same layer, step back and try a different layer.
- If 3 fixes for the same bug have failed, stop patching. The problem is not the code — it's your understanding of the architecture. Re-state what you believe the design is, verify each belief against the code, and question whether the current structure can support the fix at all. Escalate to the user if the answer is "it can't".
- If the bug involves runtime state you can't reproduce in tests (e.g., specific API responses, browser-specific behavior), tell the user and ask for guidance.
Anti-Patterns
- Shotgun debugging: Changing random things and seeing if the bug goes away. Never do this.
- Fix the symptom: Adding a null check without understanding why the value is null. Find the root cause.
- Skip the test: "It works now" without a test means it can break again silently.
- Blame the framework: Before assuming React/Next.js/library is buggy, verify your usage is correct.
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.

