diagnose
GitHub针对项目测试失败或构建错误的结构化调试技能。遵循复现、隔离、假设、注入、修复、验证及回归测试的闭环流程,确保在修改代码前准确定位问题根源,并防止回归。
触发场景
安装
npx skills add Totoro-jam/battle-tested-patterns --skill diagnose -g -y
SKILL.md
Frontmatter
{
"name": "diagnose",
"description": "Structured debugging loop for exercise tests or build failures. Reproduce → isolate → hypothesize → fix → verify."
}
Diagnose a Failure
You are debugging a test failure or build error in this project. Follow the structured loop — do NOT jump to a fix without reproducing first.
Loop
1. Reproduce
Run the failing command and capture the exact error:
pnpm test # All tests (docs + exercises in TS/Rust/Go/Python)
pnpm test:rust # Rust only
pnpm test:go # Go only
pnpm test:python # Python only (auto-finds Python ≥ 3.10)
pnpm build # VitePress
2. Isolate
Narrow down to the smallest failing unit:
- Which test file?
- Which test case?
- Which assertion?
3. Hypothesize
State your hypothesis in one sentence before changing any code.
4. Instrument
Add minimal logging or assertions to confirm/deny your hypothesis. Do NOT change production code yet.
5. Fix
Apply the minimal fix. Change as little as possible.
6. Verify
Run the full test suite, not just the failing test:
pnpm test && pnpm build
If it still fails, return to step 1 with what you learned.
7. Regression Test
If the bug was non-trivial, add a test that would have caught it.
版本历史
- 0307be9 当前 2026-07-05 14:53


