Install
openclaw skills install @carolz1/debugging-2Systematically investigate root causes of bugs or failures through four phases before fixing, ensuring thorough analysis and preventing symptom-only patches.
openclaw skills install @carolz1/debugging-2A four-phase discipline for finding the root cause of any bug before attempting fixes. / 在尝试修复前,用四阶段纪律找到任何 Bug 的根因。
NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.
没有根因调查,就不能修复。
If you haven't completed Phase 1, you cannot propose fixes. Symptom fixes are failure. / 如果没完成 Phase 1,就不能提修复。症状修复 = 失败。
Violating the letter of this process is violating the spirit of debugging. / 违反字面也违反精神。
Use for ANY technical issue: / 任何技术问题都用:
Use this ESPECIALLY when / 尤其在这些情况:
Don't skip when / 不要跳过:
You MUST complete each phase before proceeding to the next. / 必须按顺序完成每个阶段。
BEFORE attempting ANY fix / 尝试任何修复之前:
git log --since="2 weeks ago" --oneline / git loggit diff HEAD~10 -- path/to/file / git diffWHEN system has multiple components (CI → build → signing, API → service → database) / 当系统有多组件:
BEFORE proposing fixes, add diagnostic instrumentation / 提修复之前,加诊断埋点:
For EACH component boundary:
- Log what data enters component
- Log what data exits component
- Verify environment/config propagation
- Check state at each layer
Run once to gather evidence showing WHERE it breaks
THEN analyze evidence to identify failing component
THEN investigate that specific component
Example (CI → build → signing pipeline) / 示例(CI → 构建 → 签名流水线):
# Layer 1: Workflow / 工作流
echo "=== Secrets available in workflow: ==="
echo "IDENTITY: ${IDENTITY:+SET}${IDENTITY:-UNSET}"
# Layer 2: Build script / 构建脚本
echo "=== Env vars in build script: ==="
env | grep IDENTITY || echo "IDENTITY not in environment"
# Layer 3a: macOS keychain / macOS 钥匙串
echo "=== macOS keychain state: ==="
security list-keychains
security find-identity -v
# Layer 3b: Windows certificate store / Windows 证书存储
echo "=== Windows certificate store: ==="
certutil -store My
# Layer 3c: Linux GPG / Linux GPG
echo "=== Linux GPG keys: ==="
gpg --list-secret-keys
# Layer 4: Actual signing / 实际签名
codesign --sign "$IDENTITY" --verbose=4 "$APP" # macOS
signtool sign /fd SHA256 /a "$APP.exe" # Windows
gpg --detach-sign --armor "$APP.tar.gz" # Linux
This reveals: which layer fails. / 这揭示:哪一层挂了。
WHEN error is deep in call stack / 当错误在调用栈深处:
Backward trace technique: / 反向追踪技术:
Find the pattern before fixing / 修复前先找模式:
Scientific method / 科学方法:
Fix the root cause, not the symptom / 修根因,不修症状:
< 3: Return to Phase 1, re-analyze with new information / 回到 Phase 1,用新信息重新分析≥ 3: STOP and question the architecture / 问架构问题Pattern indicating architectural problem / 架构问题的信号:
STOP and question fundamentals / 停下来问根本问题:
Discuss with your human partner before attempting more fixes. / 继续修前与人类伙伴讨论。
This is NOT a failed hypothesis — this is a wrong architecture. / 这不是失败的假设——是错的架构。
| Phase | Key Activities / 关键活动 | Success Criteria / 成功标准 |
|---|---|---|
| 1. Root Cause / 根因 | Read errors, reproduce, check changes, gather evidence / 读错误、复现、检查变更、收集证据 | Understand WHAT and WHY / 理解是什么、为什么 |
| 2. Pattern / 模式 | Find working examples, compare / 找工作中示例、对比 | Identify differences / 识别差异 |
| 3. Hypothesis / 假设 | Form theory, test minimally / 形成理论、最小测试 | Confirmed or new hypothesis / 确认或新假设 |
| 4. Implementation / 实施 | Create test, fix, verify / 建测试、修、验证 | Bug resolved, tests pass / Bug 解决、测试过 |
If you catch yourself thinking / 如果你发现自己在想:
→ STOP. Return to Phase 1. / 停止。回到 Phase 1。
If 3+ fixes failed: Question the architecture (Phase 4.5) / 3+ 修复失败:问架构
Watch for these redirections from your human partner: / 注意人类伙伴这些反向信号:
When you see these: STOP. Return to Phase 1. / 看到这些:停。回到 Phase 1。
| Excuse / 借口 | Reality / 真相 |
|---|---|
| "Issue is simple, don't need process" / 「简单问题,不要流程」 | Simple issues have root causes too. Process is fast for simple bugs. / 简单问题也有根因。流程对简单 Bug 很快。 |
| "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. / 不能隔离哪个生效。会引入新 Bug。 |
| "Reference too long, I'll adapt the pattern" / 「参考太长,我变通」 | Partial understanding guarantees bugs. Read it completely. / 部分理解保证有 Bug。完整读。 |
| "I see the problem, let me fix it" / 「我看到问题,修」 | Seeing symptoms ≠ understanding root cause. / 看症状 ≠ 理解根因。 |
| "One more fix attempt" (after 2+ failures) / 「再试一次」(2+ 失败后) | 3+ failures = architectural problem. Question pattern, don't fix again. / 3+ 失败 = 架构问题。问模式,不要再修。 |
If systematic investigation reveals issue is truly environmental, timing-dependent, or external: / 如果系统化调查发现真是环境、时序、或外部问题:
But: 95% of "no root cause" cases are incomplete investigation. / 但是:95% 的「无根因」案例是调查不彻底。
These are part of systematic debugging. Read the inline guidance below before reaching for them. / 这些是系统化调试的一部分。下面的内联指南在使用前先读。
When error is deep in call stack: / 当错误在调用栈深处:
After finding root cause, add validation at multiple layers: / 找到根因后,在多层加验证:
One layer catches what another misses. / 一层抓另一层漏的。
Replace arbitrary timeouts with condition polling: / 用条件轮询替换任意超时:
// BAD: arbitrary timeout / 任意超时
await sleep(5000)
// GOOD: poll for condition / 轮询条件
while (!(await checkReady())) {
await sleep(100)
}
When you finish debugging, you have: / 完成调试后,你拥有:
Debugging commands differ per OS. The systematic process is identical; the diagnostic commands adapt. / 调试命令因 OS 而异。系统化过程相同;诊断命令适配。
| OS | File listing | Process list | Logs | Network |
|---|---|---|---|---|
| macOS | ls, find | ps aux, lsof -i | log show --last 5m | lsof -iTCP -sTCP:LISTEN |
| Linux | ls, find | ps aux, ss -tlnp | journalctl -u <svc> --since "5m ago" | ss -tlnp |
| Windows | dir, Get-ChildItem | Get-Process, tasklist | Get-EventLog -LogName Application -Newest 50 | netstat -ano |
Pick the row for your OS. / 选你 OS 那一行。