关于 why
用于开展五个为什么分析的技能,帮助从问题表象逐步追溯根本原因。它引导记录并反向验证原因、分析多条因果分支,以及提出针对根因的方案。
主要功能
- 01逐层追问原因
- 02反向验证因果链
- 03分析多条原因分支
- 04提出针对根因的方案
适用场景
- 01调查生产环境故障
- 02分析流水线反复失败
- 03追查功能部署延迟
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ neolabhq/ context-engineering-kit --skill why安装后在 Claude Code 中输入/why确认已加载。
详细介绍
五个为什么分析
通过反复追问“为什么”,应用五个为什么根因分析法,从症状逐步深入调查问题,找出根本原因。
描述
反复追问“为什么”,从表面症状深入根本原因。识别系统性问题,而非采取快速修补措施。
用法
/why [issue_description]
变量
- ISSUE:要分析的问题或症状(默认:提示输入)
- DEPTH:“为什么”的迭代次数(默认:5,可按需调整)
步骤
- 清楚地陈述问题
- 询问“为什么会发生这种情况?”,并记录答案
- 针对该答案,再次询问“为什么?”
- 持续追问,直到找到根本原因(通常迭代 5 次)
- 反向验证:从根本原因推导至症状
- 如果出现多个原因,探索不同分支
- 提出针对根本原因而非症状的解决方案
示例
示例 1:生产环境 Bug
Problem: Users see 500 error on checkout
Why 1: Payment service throws exception
Why 2: Request timeout after 30 seconds
Why 3: Database query takes 45 seconds
Why 4: Missing index on transactions table
Why 5: Index creation wasn't in migration scripts
Root Cause: Migration review process doesn't check query performance
Solution: Add query performance checks to migration PR template
示例 2:CI/CD 流水线故障
Problem: E2E tests fail intermittently
Why 1: Race condition in async test setup
Why 2: Test doesn't wait for database seed completion
Why 3: Seed function doesn't return promise
Why 4: TypeScript didn't catch missing return type
Why 5: strict mode not enabled in test config
Root Cause: Inconsistent TypeScript config between src and tests
Solution: Unify TypeScript config, enable strict mode everywhere
示例 3:多分支分析
Problem: Feature deployment takes 2 hours
Branch A (Build):
Why 1: Docker build takes 90 minutes
Why 2: No layer caching
Why 3: Dependencies reinstalled every time
Why 4: Cache invalidated by timestamp in Dockerfile
Root Cause A: Dockerfile uses current timestamp for versioning
Branch B (Tests):
Why 1: Test suite takes 30 minutes
Why 2: Integration tests run sequentially
Why 3: Test runner config has maxWorkers: 1
Why 4: Previous developer disabled parallelism due to flaky tests
Root Cause B: Flaky tests masked by disabling parallelism
Solutions:
A) Remove timestamp from Dockerfile, use git SHA
B) Fix flaky tests, re-enable parallel test execution
注意事项
- 不要停留在症状上;继续深入挖掘系统性问题
- 可能存在多个根本原因——探索不同分支
- 记录每个“为什么”,以供日后参考
- 同时考虑技术原因和流程原因
- 关键不在于恰好追问 5 次;找到真正的根本原因后即可停止
- 当发现系统性问题或流程问题时停止,而不是只停留在技术细节
- 多个根本原因很常见——分别探索各个分支
- 如果出现“人为错误”,继续追问:为什么会发生这种错误?
- 记录每个“为什么”,以供日后参考
- 根本原因通常涉及:缺少验证、缺少文档、流程不明确或缺少自动化
- 测试解决方案:实施 → 验证症状已解决 → 监控是否复发
评论
支持 Markdown