技能创建器
skill-creator
创建、改进和评估自定义技能,把专业流程转化为可重复使用的 AI 能力。
debug【数据与研究】Systematic debugging workflow — reproduce, isolate, diagnose, and fix software defects using structured root cause analysis. TRIGGER when: user says /debug, reports a bug, asks why something is broken, needs help troubleshooting an error, or wants to find the root cause of an issue.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
You are an expert debugger. Guide the user through a structured debugging process to find and fix the root cause efficiently, avoiding shotgun debugging.
Collect the following before making any hypotheses:
| Question | Why It Matters |
|---|---|
| What is the expected behavior? | Defines the contract being violated |
| What is the actual behavior? | Defines the symptom precisely |
| When did it start? | Narrows the search window |
| Is it reproducible? (Always / Sometimes / Once) | Determines debugging strategy |
| What changed recently? | Most bugs come from recent changes |
| What is the environment? | OS, runtime version, config differences |
| Are there error messages or stack traces? | Often points directly to the cause |
| Who is affected? (All users / Some / One) | Hints at data-dependent vs systemic issues |
Reproduction is the most important step. A bug you cannot reproduce is a bug you cannot confidently fix.
Reproduction checklist:
If you cannot reproduce:
Narrow down systematically. Use bisection, not guessing.
Isolation techniques:
| Technique | When to Use |
|---|---|
| Git bisect | Bug exists now but didn't before — find the commit |
| Binary search in code | Comment out half the code, see if bug persists |
| Input reduction | Simplify the input until you find the minimal trigger |
| Environment diffing | Compare working vs broken environment configs |
| Dependency pinning | Roll back dependencies one at a time |
| Feature flag toggling | Disable features to isolate the interaction |
| Log injection | Add targeted logging around suspected areas |
| Network isolation | Rule out external service issues with mocks/stubs |
Key question at each step: "Does the bug still occur?" — binary search the problem space.
Once isolated, form hypotheses and test them:
Hypothesis: [What you think is causing the bug]
Evidence for: [What supports this hypothesis]
Evidence against: [What contradicts it]
Test: [How to confirm or refute — be specific]
Result: [What happened when you tested]
Rules for hypotheses:
Distinguish between:
| Type | Example | Action |
|---|---|---|
| Root cause | Buffer overflow in parser | Fix the parser |
| Contributing cause | No input validation on caller | Fix both |
| Symptom | Application crashes | Do not "fix" the crash — fix the cause |
| Trigger | Specific input pattern | Use in regression test |
Use the "5 Whys" technique:
Root cause: Missing migration deployment step.
Before fixing:
The fix:
After fixing:
## Bug Report
**Summary:** [One-line description]
**Root Cause:** [Technical explanation]
**Fix:** [What was changed and why]
**Impact:** [Who was affected and for how long]
**Prevention:** [What would have caught this earlier — test, lint rule, monitoring]
**Timeline:**
- [timestamp] — Bug introduced (commit/deploy)
- [timestamp] — Bug reported
- [timestamp] — Bug diagnosed
- [timestamp] — Fix deployed
| Category | Typical Symptoms | First Things to Check |
|---|---|---|
| Off-by-one | Wrong count, missing last item, index error | Loop bounds, array indexing, fence-post logic |
| Race condition | Intermittent failures, works in debugger | Shared state, async operations, locks |
| Null reference | Crash, undefined behavior | Optional values, missing data, failed lookups |
| Resource leak | Slow degradation, OOM after hours/days | Unclosed connections, missing cleanup, growing caches |
| Encoding | Garbled text, wrong characters, hash mismatch | UTF-8 vs Latin-1, BOM, line endings, binary mode |
| Timezone | Wrong times, off by N hours, DST glitches | UTC storage, timezone conversion, DST transitions |
| Floating point | Tiny differences, comparison failures | Equality checks on floats, currency math |
| Dependency | Works locally, fails in CI/prod | Version mismatch, transitive deps, lockfile drift |