Skip to content

Run a Root Cause Analysis with AI (5 Whys + Fishbone)

Bug Triage & ReportingUpdated 2026-10-11intermediate
TL;DR

Given a defect description, returns a literal 5 Whys chain, a fishbone diagram (text representation) categorizing contributing factors into People / Process / Technology / Environment, and a list of preventive measures with named owners: never generic recommendations.

When to use it

  • A P0 or P1 just happened and you owe a postmortem.
  • The same class of bug keeps recurring and you want to understand the systemic cause.
  • You're running a blameless postmortem and need a structured artifact.
  • You're coaching a team through RCA discipline (most go 2 Whys and stop).

The prompt

XML-tagged: works best with Claude
root-cause-analysis.claude.mdprompt
<role>You are an incident response facilitator. You enforce LITERAL 5 Whys, not 3, not 7, and a fishbone with exactly four categories: People, Process, Technology, Environment. You never write a preventive measure without naming an owner.</role> <context>RCA tooling: 5 Whys + Fishbone (Ishikawa). 5 Whys answers "why" five times to dig past surface causes to the contributing system. Fishbone groups contributing factors into 4 categories so analysis isn't lopsided to "Technology". Preventive measures map to systemic changes, not "be more careful".</context> <task>For the defect below, produce:1. **5 Whys chain**: exactly 5 layers. Each "why" answers the previous level, drilling toward systemic causes.2. **Fishbone (text)**: 4 categories (People, Process, Technology, Environment), each with 2-4 contributing factors specific to this defect.3. **Preventive measures**: 3-5 measures, each with a named owner role (not a person, but a function: "Engineering Lead", "QA", "Platform Team"). Reject "be more careful" or other non-actionable items.4. **One key insight**: the single observation about the system the team should not forget after this incident.</task> <input>Defect description: {defect}Impact: {impact}Timeline (if known): {timeline}</input> <constraints>- 5 Whys is literal: 5 levels, no fewer. If you can't legitimately reach 5, say so and stop at the highest defensible level.- Fishbone uses exactly: People / Process / Technology / Environment. No substituting "Tools" for "Technology" or adding a 5th category.- Preventive measures must have an owner role and be actionable (testable, scheduleable).- Avoid "human error" as a root cause: find the system condition that allowed the human error.</constraints> <output_format>Four sections:1. **5 Whys chain**: numbered list 1-52. **Fishbone**: 4 categories as H3 headings with bullet lists3. **Preventive measures**: table: Measure | Owner | Target completion (placeholder)4. **Key insight**: one paragraph</output_format> <approach>Before writing, distinguish proximate cause (what triggered it now) from systemic cause (what allowed it).</approach>

Example

Input
Defect description: Customer's name appeared as 'undefined' on email receipt for orders placed last Sunday.
Impact: 3000 customers received receipts with 'undefined' instead of their name. 80 support tickets in first 6 hours. No financial loss; reputational impact.
Timeline: Deploy at 14:00 Sat (refactor of user-profile fetch); first reports at 09:00 Sun; rollback at 13:00 Sun; fix forward at 02:00 Mon.
Output
## 1. 5 Whys chain

1. **Why did the receipt show 'undefined'?** The email template called `user.firstName`, which returned `undefined`.
2. **Why was `user.firstName` undefined?** The user-profile API now returns `{ givenName, familyName }` instead of `{ firstName, lastName }` after Saturday's refactor.
3. **Why did the email template not get updated alongside the API change?** The email service consumed a snapshot of user data via a separate code path that wasn't touched in the refactor PR.
4. **Why was the email service's consumption of user data not caught in code review or testing?** No contract test exists between the user-profile service and the email service, and the staging email integration test was a snapshot-only check that doesn't fail on missing values (renders 'undefined' as text).
5. **Why does no contract test exist at this boundary?** Contract testing has been on the team's roadmap for 8 months but unprioritized; the team historically relied on E2E tests, which don't run against the email service.

## 2. Fishbone

### People
- Refactor PR author (engineering) did not know the email service consumed firstName/lastName
- Reviewer (engineering) did not flag the field name change as cross-service
- No QA review on infrastructure refactors (process gap)

### Process
- PR template does not require listing consumers of changed API fields
- No staging soak period before production deploy on weekends
- Postmortem cadence for near-misses is low (this was foreseeable)

### Technology
- No contract tests between user-profile and email service
- Email template renders `undefined` as text instead of failing or showing a fallback
- Staging email integration test is snapshot-only; doesn't fail on missing values

### Environment
- Saturday deploy window has reduced on-call coverage (delayed detection from ~09:00 Sun reports to ~13:00 Sun rollback)
- Customer-facing emails go out immediately; no preview or canary cohort

## 3. Preventive measures

| Measure | Owner | Target |
|---------|-------|--------|
| Add Pact contract tests between user-profile and email service | Platform Team | [YYYY-MM-DD] |
| Update email template to throw on missing required fields instead of rendering 'undefined' | Email Team | [YYYY-MM-DD] |
| Restrict refactor PRs touching shared API fields to weekday deploys with soak period | Engineering Lead | [YYYY-MM-DD] |
| Add a 1% canary cohort for customer-facing emails (sample sent to internal addresses first) | Email Team | [YYYY-MM-DD] |
| Add a "Consumers of changed fields" section to PR template for API service repos | Engineering Lead | [YYYY-MM-DD] |

## 4. Key insight

The team's investment in E2E tests created a false sense of safety because E2E doesn't exercise the email path. Cross-service field changes are exactly the kind of breakage that contract tests catch and E2E misses. Deferring contract testing for 8 months turned this incident from "unlikely" to "inevitable": the fishbone's contributing factors all point at the same gap.

Common pitfalls

  • Model stops at 3 Whys ('why = a bug'): force the literal 5.
  • Fishbone gets only Technology populated; the other categories get sparse 'N/A' entries. Demand 2-4 factors per category.
  • Preventive measures default to 'Add more tests' / 'Review PRs more carefully': vague. Require named owner role + actionable.
  • 'Human error' shows up as root cause: that's almost never the right level; push to the system condition that allowed it.

Tips

  • Include the timeline: proximate cause vs systemic cause is much clearer with timestamps.
  • Run RCA within 5 working days of the incident; recall fades quickly.
  • Pair with `bug-severity-priority` to set the right urgency for the preventive measures.
  • Diff this RCA's preventive measures against previous postmortems: repeats signal you're not following through.

FAQ

When is 5 Whys NOT enough?

When you reach a 'why' that's outside your team's locus of control (e.g., 'because of an OS vendor bug'). At that point, name the dependency and stop, but EVERY 'why' before that should be inside your control.

When to use fishbone alone vs alongside 5 Whys?

Fishbone alone for surveys: gather all contributing factors before any sequencing. 5 Whys alone for fast triage of a single defect. Both together for postmortems where you want both breadth and depth.

What's the difference between RCA and a blameless postmortem?

Postmortem is the meeting + document; RCA is the analysis technique used inside. A blameless postmortem applies RCA without finger-pointing. RCA done well IS blameless: 'human error' as root cause is the unblameless version.

Should AI write the entire postmortem?

No. AI produces a draft. The team adds context AI doesn't have (relationships, history, judgement). AI-only postmortems lack the lived-experience details that make them useful.