logo
29

五个为什么分析法

⏱️ 8分钟

五个为什么分析法

什么是 Five Whys?

"五个为什么"是一种根因分析技术,通过连续追问"为什么"来找到问题的根本原因,而不是只停留在表面症状。

Process

1. Define the Problem

Clearly state the issue or symptom

2. Ask "Why?" Five Times

  • Why did this problem occur? → Answer 1
  • Why did Answer 1 happen? → Answer 2
  • Why did Answer 2 happen? → Answer 3
  • Why did Answer 3 happen? → Answer 4
  • Why did Answer 4 happen? → Answer 5 (Root Cause)

3. Validate Root Cause

  • Verify the logical chain
  • Check if addressing root cause prevents recurrence
  • Consider multiple root causes if applicable

4. Develop Solutions

  • Address the root cause, not just symptoms
  • Create preventive measures
  • Consider systemic improvements

Example: Application Crash

Problem: Application crashes when processing large files

  1. Why? → The application runs out of memory
  2. Why? → It loads entire file into memory at once
  3. Why? → The file parser wasn't designed for streaming
  4. Why? → Initial requirements only specified small files
  5. Why? → Requirements gathering didn't consider future growth

Root Cause: Incomplete requirements gathering process

Solution: Implement streaming parser and improve requirements process

Example: API Response Slow

Problem: API endpoint taking 10+ seconds to respond

  1. Why? → Database query is slow
  2. Why? → No index on the queried column
  3. Why? → Schema migration didn't include index
  4. Why? → No performance review in migration process
  5. Why? → Migration checklist is incomplete

Root Cause: Incomplete migration checklist

Solution: Add performance review step to migration process

Best Practices

  • Focus on process, not people - 避免指责个人
  • Look for systemic issues - 寻找系统性问题
  • Document the analysis - 记录分析过程
  • Involve relevant stakeholders - 让相关人员参与
  • Test solutions address root cause - 验证解决方案

在 Vibe Coding 中的应用

当 AI 生成的代码出现问题时,可以使用 Five Whys 来分析:

Problem: AI generated code doesn't compile

  1. Why? → Using wrong syntax for the framework version
  2. Why? → AI assumed older framework version
  3. Why? → Prompt didn't specify framework version
  4. Why? → No project context provided
  5. Why? → Missing CLAUDE.md or context-prime step

Root Cause: Missing project context

Solution: Always run /context-prime before complex tasks

Five Whys Template

## Problem Statement

[Clear description of the issue]

## Analysis

### Why #1

Q: Why did this happen?
A: [Answer]

### Why #2

Q: Why did [Answer #1] happen?
A: [Answer]

### Why #3

Q: Why did [Answer #2] happen?
A: [Answer]

### Why #4

Q: Why did [Answer #3] happen?
A: [Answer]

### Why #5

Q: Why did [Answer #4] happen?
A: [Answer - Root Cause]

## Root Cause

[Summary of the fundamental issue]

## Proposed Solutions

1. [Solution 1]
2. [Solution 2]

## Preventive Measures

-   [Measure 1]
-   [Measure 2]

下一步

学习 Mermaid 图表生成 来可视化你的分析结果。