C31-debug
Skill1 starsChanged 3 months agoMITView on GitHub
debug, bug, fix, 排查 | 调试阶段:系统化错误追踪,从复现到根因到修复验证
In this repository56 other files it gives its agents.
- C31-1stSkill
- C31-adopt-projectSkill
- C31-brainstormSkill
- C31-coding-disciplineSkill
- C31-compound-refreshSkill
- C31-compoundSkill
- C31-context-engineeringSkill
- C31-curatorSkill
- c31-daily-intelSkill
- c31-devSkill
- C31-grillSkill
- C31-lfgSkill
- C31-planSkill
- C31-researchSkill
- C31-specSkill
- C31-stormSkill
- C31-strategySkill
- C31-workflow-bug-reproductionSkill
- C31-workSkill
- rl-workflowSkill
- C31-cvideoSkill
- c31-loopSkill
- c31-sxsSkill
- teachSkill
- video-content-analysisSkill
- agent-reachSkill
- kimiimSkill
- skillhub-preferenceSkill
- c31-communitySkill
- c31-growSkill
- c31-gutcheckSkill
- c31-marketSkill
- c31-mvpSkill
- c31-priceSkill
- c31-processSkill
- c31-sellSkill
- c31-validateSkill
- c31-valuesSkill
- growth-hackerSkill
- c31-improve-codebase-architectureSkill
- C31-multi-reviewSkill
- C31-review-adversarialSkill
- C31-review-architectureSkill
- C31-review-securitySkill
- C31-reviewSkill
- c31-wizardSkill
- external-privacy-guardSkill
- find-skillsSkill
- gsd-map-codebaseSkill
- gsd-new-projectSkill
- gsd-progressSkill
- gsd-quickSkill
- gsd-shipSkill
- humanize-aiSkill
- time-awarenessSkill
- worker-safetySkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
38 rules. About 0 are common, 26 are distinctive, and 12 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈26
Distinctive · estimate
This author's own choices. Worth a look.
12
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 31
If no active sessions exist, create a new one at memory/.planning/debug/YYMMDD-{brief-desc}.md with frontmatter:
- Very specific: line 44
If resuming, read the session file, update status: active, and continue from the recorded phase.
- Distinctive: line 61
Trivial fast-path: If the cause is immediately obvious (single-file typo, missing import, clear null deref) and verification is shallow, …
- Very specific: line 64
Before analyzing any bug, search memory/solutions/ for relevant prior records:
- Very specific: line 65
Use memory_search to query {error_type} {component} {symptom} (e.g., "cron timeout fix")
- Distinctive: line 66
If ≥1 relevant solution found (score > 0.5):
- Distinctive: line 70
If no match or score < 0.5: proceed normally to Phase 1
- Distinctive: line 72
Prior-attempt awareness: If the user indicates prior failed attempts, ask what was tried first to avoid repetition.
- Very specific: line 74
Update session: phase: 1, status: investigating.
- Distinctive: line 79
Run the test, trigger the error, or follow reproduction steps.
- Distinctive: line 89
No stale build artifacts.
- Distinctive: line 95
Read stack trace bottom-to-top.
- Distinctive: line 102
Update session: record reproduction steps, environment state, traced code path, and boundary observations.
- Distinctive: line 116
When the chain is obvious (missing import, explicit type error), the chain itself is the gate — no prediction needed.
- Very specific: line 119
Check memory/.planning/evolution/signals/*.jsonl for same-type signals in last 7 days
- Distinctive: line 120
If frequency ≥ 3 for same skill/type → severity auto-upgrades to P0
- Distinctive: line 121
Write/update signal file before proposing fix
- Very specific: line 125
If score ≥ 5 → add to memory/.planning/evolution/signals/
- Distinctive: line 128
Causal chain gate: Do not proceed to Phase 3 until the full chain is confirmed.
- Very specific: line 146
Update session: phase: 2, record hypotheses (with ruled-out ones), confirmed root cause, and user decision.
- Distinctive: line 150
If user chose "Diagnosis only" or "Rethink the design", skip to Phase 5.
- Distinctive: line 154
If on default branch (main/master), ask whether to create a feature branch.
- Distinctive: line 157
Write failing test capturing the bug (or use existing failing test).
- Distinctive: line 158
Verify it fails for the right reason — the root cause, not unrelated setup.
- Distinctive: line 161
Run broader test suite for regressions.
- Distinctive: line 167
Add entry validation at public API boundary.
- Distinctive: line 168
Add invariant checks inside affected module.
- Distinctive: line 169
Add diagnostic breadcrumbs for future debugging.
- Very specific: line 172
Update session: phase: 3, status: fixing, record changed files and test additions.
- Distinctive: line 178
If verification fails, return to Phase 2.
- Very specific: line 180
Update session: phase: 4, status: verifying, record verification results.
- Very specific: line 196
If user chose "Diagnosis only", stop after summary.
- Distinctive: line 198
If Phase 3 ran, ask:
- Very specific: line 218
Create knowledge-base.md if it does not exist.
- Distinctive: line 251
When hypotheses are evidence-bottlenecked across clearly independent subsystems, dispatch read-only sub-agents in parallel, each with a …
- Distinctive: line 256
Stop and re-examine if your internal monologue contains: "quick fix for now," "this should work" (untested), or "let me just try..." (no …
- Distinctive: line 257
When stuck, diagnose why — don't just try harder.
- Distinctive: line 258
Default to no questions — investigate first (read code, run tests, trace errors).
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Multilingual Triggers
| Language | Trigger phrases |
| EN | debug, bug, fix, 排查, 为什么会报错, 报错, trace this error, find the root cause, debugger |
| ZH | 调试, 修复bug, 排查 |
| JA | デバッグ, バグ修正, 調査 |
Output language: Respond automatically in the user's conversation language.
C31-debug — Systematic Debug with Session Management
Investigate bugs through reproduction → trace → hypothesis → test-first fix → verify → archive. All active sessions are tracked in memory/.planning/debug/ for resumption and knowledge compounding.
Session Lifecycle
Check Existing Sessions (always first)
List memory/.planning/debug/*.md. If any non-resolved session exists, present it and ask:
- Resume — load the session and continue from the last phase
- New session — archive the old one (move to
resolved/) and start fresh - Ignore — proceed without archiving
If no active sessions exist, create a new one at memory/.planning/debug/YYMMDD-{brief-desc}.md with frontmatter:
---
session_id: YYMMDD-{brief-desc}
status: active # active | investigating | fixing | verifying | resolved | stalled
phase: 0 # 0=triage, 1=investigate, 2=root-cause, 3=fix, 4=verify, 5=archive
created: YYYY-MM-DD HH:MM
target: [file/module/test or issue link]
---Session Resume
If resuming, read the session file, update status: active, and continue from the recorded phase. Preserve all prior hypotheses, ruled-out causes, and evidence in the session file.
Execution Flow
| Phase | Name | Output |
| 0 | Triage | Problem statement + session file created/resumed |
| 1 | Investigate | Reproduction confirmed, environment sanity checked, code path traced |
| 2 | Root Cause | Causal chain confirmed with predictions; session updated |
| 3 | Fix | Test-first patch applied |
| 4 | Verify | Tests pass, no regressions; session marked resolved |
| 5 | Archive | Session moved to resolved/, knowledge-base updated |
Phase 0: Triage
Parse input. If an issue tracker is referenced, fetch it. Extract symptoms, expected behavior, reproduction steps, environment.
Trivial fast-path: If the cause is immediately obvious (single-file typo, missing import, clear null deref) and verification is shallow, present cause + one-line fix, ask whether to apply or diagnose, and skip to Phase 5 if applied. When in doubt, run full framework.
Solutions Search (Mandatory):
Before analyzing any bug, search memory/solutions/ for relevant prior records:
- Use
memory_searchto query{error_type} {component} {symptom}(e.g., "cron timeout fix") - If ≥1 relevant solution found (score > 0.5):
- Inject context: Append the solution's Problem + Solution + Prevention to the session file
- Notify user:
📋 Found prior record: {filename} (compound_score: X) — automatically injected into context - Adjust the Phase 1 investigation direction based on the historical solution (e.g., if the root cause is known to be API timeout, verify directly rather than starting from scratch)
- If no match or score < 0.5: proceed normally to Phase 1
Prior-attempt awareness: If the user indicates prior failed attempts, ask what was tried first to avoid repetition.
Update session: phase: 1, status: investigating.
Phase 1: Investigate
1.1 Reproduce
Run the test, trigger the error, or follow reproduction steps. If the project has testing conventions, apply them; otherwise write a minimal isolated test that fails now and will pass post-fix.
- Cannot reproduce after 2–3 attempts → document conditions tried; note possible timing/state dependency.
- Cannot reproduce at all → document missing conditions and stop.
1.2 Environment Sanity
- Correct branch; no unintended uncommitted changes.
- Dependencies installed and up to date.
- Expected interpreter/runtime version.
- Required env vars present.
- No stale build artifacts.
- Dependent services running when relevant.
1.3 Trace the Code Path
Trace data flow backward from symptom to where valid state first became invalid.
- Read stack trace bottom-to-top; open each frame.
- Identify the first frame where input is already invalid — upper bound.
- Instrument boundaries: targeted logs, assertions, or prints. Assumed values lie; observed values don't.
- Walk boundaries until valid input becomes invalid output. That transition is the root cause site.
While tracing: check git log --oneline -10 -- [file], consider git bisect for regressions, and check logs/metrics for additional evidence.
Update session: record reproduction steps, environment state, traced code path, and boundary observations.
Phase 2: Root Cause
Do not propose a fix until the full causal chain is explained with no gaps.
Assumption audit: List concrete "this must be true" beliefs. Mark each verified (read code, checked state, ran it) or assumed. Assumptions are the most common source of stuck debugging.
Form hypotheses ranked by likelihood. For each state:
- What is wrong and where (file:line)
- At least one concrete supporting observation
- Full causal chain: trigger → symptom, step by step
- For uncertain links: a prediction — something in a different code path or scenario that must also be true
When the chain is obvious (missing import, explicit type error), the chain itself is the gate — no prediction needed.
Pattern detection (before Phase 3):
- Check
memory/.planning/evolution/signals/*.jsonlfor same-type signals in last 7 days - If frequency ≥ 3 for same skill/type → severity auto-upgrades to P0
- Write/update signal file before proposing fix
AEF Trajectory Check (before Phase 3):
- Score the bug: Severity × Frequency × Uniqueness
- If score ≥ 5 → add to
memory/.planning/evolution/signals/ - Include: skill_involved, causal_chain_summary, fix_pattern
Causal chain gate: Do not proceed to Phase 3 until the full chain is confirmed. The user may explicitly authorize proceeding with the best-available hypothesis if stuck.
Smart escalation (2–3 hypotheses exhausted):
| Pattern | Diagnosis | Next move |
| Different subsystems | Architecture/design problem | Rethink design |
| Contradictory evidence | Wrong mental model | Re-read code path without assumptions |
| Local OK, CI/prod fails | Environment problem | Focus on env differences |
| Fix works, prediction wrong | Symptom patch, not root cause | Keep investigating |
Present: root cause (causal chain + file:line), proposed fix, tests to add/modify, whether existing tests should have caught this and why they didn't.
Ask user:
- Fix it now → Phase 3
- Diagnosis only → skip Phase 3, go to Phase 5
- Rethink the design → end skill
Update session: phase: 2, record hypotheses (with ruled-out ones), confirmed root cause, and user decision.
Phase 3: Fix
If user chose "Diagnosis only" or "Rethink the design", skip to Phase 5.
Workspace check:
git status— confirm no unintended uncommitted changes in files to edit.- If on default branch (
main/master), ask whether to create a feature branch. Default to creating one named from the bug.
Test-first:
- Write failing test capturing the bug (or use existing failing test).
- Verify it fails for the right reason — the root cause, not unrelated setup.
- Implement minimal fix: address root cause only. No drive-by refactors or formatting.
- Verify test passes.
- Run broader test suite for regressions.
- Self-review diff: check style, edge cases, adjacent regressions, coverage gaps.
Failed fix: Return to Phase 2. Invalidate current hypothesis with evidence, then form a new one. 3 failed attempts = architectural escalation. After 3 failed fix attempts, STOP. Do not attempt a 4th. The root cause was likely wrong — this is an architectural or design problem, not a hypothesis failure. Escalate to the human: present the 3 attempts, the evidence that invalidated each, and ask whether to rethink the design.
Conditional defense-in-depth (root-cause pattern found in 3+ other files, OR bug would have been catastrophic in production):
- Add entry validation at public API boundary.
- Add invariant checks inside affected module.
- Add diagnostic breadcrumbs for future debugging. Apply only layers that make sense.
Update session: phase: 3, status: fixing, record changed files and test additions.
Phase 4: Verify
- Confirm the original reproduction test passes.
- Confirm no regressions in broader suite.
- If verification fails, return to Phase 2.
Update session: phase: 4, status: verifying, record verification results.
Phase 5: Archive & Knowledge Capture
Structured summary (write to session file before moving):
## Debug Summary
**Problem**: [What was broken]
**Root Cause**: [Full causal chain with file:line]
**Recommended Tests**: [Tests to add/modify to prevent recurrence]
**Fix**: [What changed — or "diagnosis only"]
**Prevention**: [Test coverage; defense-in-depth if applicable]
**Confidence**: [High/Medium/Low]If user chose "Diagnosis only", stop after summary. Mark session status: stalled and leave in debug/ for future resumption.
If Phase 3 ran, ask:
- Commit and open a PR
- Commit the fix locally
- Stop here — user takes over
Archive session: Move memory/.planning/debug/YYMMDD-{desc}.md to memory/.planning/debug/resolved/. Rename to include resolution date: YYMMDD-{desc}-RESOLVED-YYMMDD.md.
Knowledge-base update: Append to memory/.planning/debug/knowledge-base.md only when:
- The pattern appears in 3+ locations, OR
- The root cause reveals a wrong assumption about a shared dependency/framework/convention that other code is likely to repeat.
KB entry format:
## YYYY-MM-DD — {brief pattern name}
**Symptom**: ...
**Root Cause**: ...
**Fix Pattern**: ...
**Files Affected**: ...Create knowledge-base.md if it does not exist.
Error Handling
This skill follows the AGENTS/error-handling.md standard.
Common Error Codes
| Error Code | Trigger | Handling Strategy |
API_TIMEOUT | exec test run timed out | Wait 4s and retry, max 2 times |
RATE_LIMITED | API rate limit hit | Wait 10s and retry |
VALIDATION_FAILED | Test parameter / environment validation failed | Fix parameters and retry |
RESOURCE_NOT_FOUND | Test file / source code not found | Check path; escalate if unrecoverable |
CONTEXT_OVERFLOW | Long call chain / large stack | Compress and retry, or process in chunks |
SUBAGENT_FAILED | Parallel investigation subagent failed | Check subagent logs; retry max 1 time |
Escalation Conditions
- Same error_code 2 consecutive times → force escalate on the 3rd
- retry_count reaches max_retries → escalate
- Non-recoverable errors (PERMISSION_DENIED, SECURITY_BLOCKED, etc.) → escalate immediately
Fallback Chain
| Primary | Fallback | Condition |
exec (run tests) | read manually inspect test file | API_TIMEOUT / RESOURCE_NOT_FOUND |
browser (browser bug) | web_fetch | API_TIMEOUT |
kimi_fetch | web_fetch | API_TIMEOUT / NETWORK_ERROR |
Parallel Investigation (Optional)
When hypotheses are evidence-bottlenecked across clearly independent subsystems, dispatch read-only sub-agents in parallel, each with a single explicit hypothesis and structured evidence-return format. No code edits by sub-agents. If parallel dispatch is unavailable, run sequentially in ranked-likelihood order.
Rules
- One change at a time. If you're changing multiple things to "see if it helps," stop — that's shotgun debugging.
- Stop and re-examine if your internal monologue contains: "quick fix for now," "this should work" (untested), or "let me just try..." (no hypothesis).
- When stuck, diagnose why — don't just try harder.
- Default to no questions — investigate first (read code, run tests, trace errors). Ask one specific question only when a genuine ambiguity blocks investigation and cannot be resolved by reading code or running tests.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
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.

