/triage -- Bug Investigation and Root Cause Analysis
Purpose: Systematically investigate a bug from reproduction through root cause identification. Produces a structured triage report with classification, risk assessment, and a recommended path forward. This skill investigates -- it does NOT write fixes. Project-agnostic -- adapts to any codebase by reading CLAUDE.md.
When to Use
- A bug report comes in and you need to understand what is happening
- Something broke and you do not know why
- You need to assess severity and blast radius before deciding how to fix
- You want a structured handoff to /hotfix or /execute-prd
When NOT to Use
- You already know the root cause and just need to fix it -- use /hotfix or /execute-prd
- The issue is a feature request, not a bug
- The issue is purely cosmetic with no functional impact -- just fix it directly
Usage
/triage "users see 500 error on login after password reset"
/triage "budget totals don't match line items" --ado 12345
/triage "task dependency graph has cycles" --linear BF-42
/triage "photos not uploading on iOS" --quick
Arguments
<description> -- what is happening, as reported (required)
--ado <item-id> -- fetch details from Azure DevOps work item via az boards work-item show --id <item-id>
--linear <issue-id> -- fetch details from Linear via the Linear MCP tool (linear issue read --id <issue-id>)
--quick -- skip regression analysis (Step 5), produce a shorter report
Step 1: Project Discovery
Read CLAUDE.md from the repo root to learn:
- Project structure, package boundaries, and conventions
- Error handling patterns (AppError, error codes, etc.)
- Logging approach (where to find logs, structured fields)
- Test framework and how to run tests
- Database/ORM layer (Drizzle, Prisma, etc.)
Step 2: Fetch Work Item (If Provided)
If --ado <item-id> or --linear <issue-id> was provided, use /work-item to retrieve the full details. Extract:
- Title and description
- Reproduction steps (if documented)
- Acceptance criteria
- Related items or links
Step 3: Reproduce the Bug
Attempt to reproduce or confirm the bug through code analysis:
Search for the symptom. Find the code path that produces the reported behavior:
- Error messages: search for the exact error text in the codebase
- HTTP status codes: trace the endpoint handler
- UI behavior: find the component and its data flow
- Data issues: trace the query/mutation path
Trace the execution path. Follow the code from entry point to failure:
- Identify the function/method where the bug manifests
- Walk backward through the call chain
- Note any branching logic, error handlers, or early returns
Identify inputs that trigger the bug. Determine:
- What specific input or state triggers the failure
- Is it deterministic or intermittent?
- Does it depend on timing, data state, or environment?
Step 4: Identify Root Cause
Classify the root cause into one of these categories:
| Category |
Description |
Examples |
| Logic Error |
Code does the wrong thing |
Off-by-one, wrong operator, missing negation, incorrect formula |
| Type Error |
Runtime type mismatch despite TypeScript |
Unsafe cast, as any, missing null check, incorrect Zod schema |
| Integration |
Contract mismatch between components |
API returns different shape than client expects, wrong enum value |
| Race Condition |
Timing-dependent failure |
Concurrent writes, stale cache, async ordering assumption |
| Config/Env |
Environment or configuration issue |
Missing env var, wrong URL, feature flag state |
| Data |
Unexpected data state |
Null in non-nullable column, orphaned reference, corrupted state |
For the root cause, identify:
- The exact location: file, function, line range
- The mechanism: what specifically goes wrong and why
- The trigger: what conditions cause this path to execute
Step 5: Regression Analysis (Skip with --quick)
Determine when this bug was introduced:
# Find recent changes to the affected files
git log --oneline -20 -- <affected-files>
If a specific commit is suspect:
git show <sha> -- <file>
Answer:
- Was this always broken, or did a recent change introduce it?
- If recent: which commit, who authored it, what was the intent?
- Are there related changes in the same PR that might also be affected?
Step 6: Risk Assessment
Assess four dimensions:
Blast Radius
- Isolated: affects one feature or edge case
- Moderate: affects a common workflow or multiple features
- Wide: affects all users or a core system function
Fix Complexity
- Simple: one-line fix or small localized change
- Moderate: changes to 2-5 files, straightforward logic
- Complex: cross-cutting change, multiple packages, requires design decisions
Regression Risk
- Low: fix is isolated, existing tests cover surrounding code
- Medium: fix touches shared code, test coverage is partial
- High: fix touches core logic, minimal test coverage, or has cascading effects
Test Coverage
- Good: affected code has tests, but they miss this case
- Partial: some tests exist but do not cover the affected path
- None: no tests for the affected code path
Step 7: Recommend Next Step
Based on the assessment, recommend one of:
| Recommendation |
When |
| /hotfix |
Blast radius is Wide or Moderate AND fix complexity is Simple or Moderate |
| /execute-prd |
Fix complexity is Complex OR regression risk is High |
| Direct fix |
Blast radius is Isolated AND fix complexity is Simple AND test coverage is Good |
| Needs more investigation |
Root cause is still unclear or there may be multiple contributing factors |
Step 8: Triage Report
Present the structured report:
Triage Report: <short title>
Reported Issue
<description as provided>
Root Cause
Category: <Logic Error | Type Error | Integration | Race Condition | Config/Env | Data>
Location: <file>:<function> (lines <N>-<M>)
Mechanism: <what goes wrong>
Trigger: <what conditions cause it>
Regression
Introduced: <commit sha> <date> | "pre-existing" | "unknown"
Related: <any related changes or PRs>
Risk Assessment
Blast Radius: <Isolated | Moderate | Wide>
Fix Complexity: <Simple | Moderate | Complex>
Regression Risk: <Low | Medium | High>
Test Coverage: <Good | Partial | None>
Recommendation: <next step>
Rationale: <one sentence>
Tracking: <ADO/Linear reference if provided>
Key Rules
- Investigate first, fix later. This skill does NOT write fixes. It produces a diagnosis.
- Be specific. Cite exact files, functions, and line numbers. Vague findings are useless.
- One root cause. If there are multiple contributing factors, identify the primary one and note the others.
- Do not guess. If you cannot determine the root cause with confidence, say so. "Needs more investigation" is a valid recommendation.
- Trace, do not assume. Actually follow the code path. Do not guess based on file names or function signatures alone.
- Respect scope. Do not start fixing the bug. Do not refactor. Do not add tests. Investigate and report.
1---2name: triage3description: Investigate a bug from reproduction through root cause analysis and produce a structured triage report (classification, risk, recommended next step) — the deliverable is the report, not a fix. Preferred over superpowers:systematic-debugging when the goal is a handoff document for /hotfix, /execute-prd, or a human decision rather than an in-session fix.4---56# /triage -- Bug Investigation and Root Cause Analysis78**Purpose:** Systematically investigate a bug from reproduction through root cause identification. Produces a structured triage report with classification, risk assessment, and a recommended path forward. This skill investigates -- it does NOT write fixes. Project-agnostic -- adapts to any codebase by reading `CLAUDE.md`.910## When to Use1112- A bug report comes in and you need to understand what is happening13- Something broke and you do not know why14- You need to assess severity and blast radius before deciding how to fix15- You want a structured handoff to /hotfix or /execute-prd1617## When NOT to Use1819- You already know the root cause and just need to fix it -- use /hotfix or /execute-prd20- The issue is a feature request, not a bug21- The issue is purely cosmetic with no functional impact -- just fix it directly2223## Usage2425```26/triage "users see 500 error on login after password reset"27/triage "budget totals don't match line items" --ado 1234528/triage "task dependency graph has cycles" --linear BF-4229/triage "photos not uploading on iOS" --quick30```3132## Arguments3334- `<description>` -- what is happening, as reported (required)35- `--ado <item-id>` -- fetch details from Azure DevOps work item via `az boards work-item show --id <item-id>`36- `--linear <issue-id>` -- fetch details from Linear via the Linear MCP tool (`linear issue read --id <issue-id>`)37- `--quick` -- skip regression analysis (Step 5), produce a shorter report3839## Step 1: Project Discovery4041Read `CLAUDE.md` from the repo root to learn:42- Project structure, package boundaries, and conventions43- Error handling patterns (AppError, error codes, etc.)44- Logging approach (where to find logs, structured fields)45- Test framework and how to run tests46- Database/ORM layer (Drizzle, Prisma, etc.)4748## Step 2: Fetch Work Item (If Provided)4950If `--ado <item-id>` or `--linear <issue-id>` was provided, use /work-item to retrieve the full details. Extract:51- Title and description52- Reproduction steps (if documented)53- Acceptance criteria54- Related items or links5556## Step 3: Reproduce the Bug5758Attempt to reproduce or confirm the bug through code analysis:59601. **Search for the symptom.** Find the code path that produces the reported behavior:61 - Error messages: search for the exact error text in the codebase62 - HTTP status codes: trace the endpoint handler63 - UI behavior: find the component and its data flow64 - Data issues: trace the query/mutation path65662. **Trace the execution path.** Follow the code from entry point to failure:67 - Identify the function/method where the bug manifests68 - Walk backward through the call chain69 - Note any branching logic, error handlers, or early returns70713. **Identify inputs that trigger the bug.** Determine:72 - What specific input or state triggers the failure73 - Is it deterministic or intermittent?74 - Does it depend on timing, data state, or environment?7576## Step 4: Identify Root Cause7778Classify the root cause into one of these categories:7980| Category | Description | Examples |81|----------|-------------|---------|82| **Logic Error** | Code does the wrong thing | Off-by-one, wrong operator, missing negation, incorrect formula |83| **Type Error** | Runtime type mismatch despite TypeScript | Unsafe cast, `as any`, missing null check, incorrect Zod schema |84| **Integration** | Contract mismatch between components | API returns different shape than client expects, wrong enum value |85| **Race Condition** | Timing-dependent failure | Concurrent writes, stale cache, async ordering assumption |86| **Config/Env** | Environment or configuration issue | Missing env var, wrong URL, feature flag state |87| **Data** | Unexpected data state | Null in non-nullable column, orphaned reference, corrupted state |8889For the root cause, identify:90- **The exact location:** file, function, line range91- **The mechanism:** what specifically goes wrong and why92- **The trigger:** what conditions cause this path to execute9394## Step 5: Regression Analysis (Skip with `--quick`)9596Determine when this bug was introduced:9798```bash99# Find recent changes to the affected files100git log --oneline -20 -- <affected-files>101```102103If a specific commit is suspect:104```bash105git show <sha> -- <file>106```107108Answer:109- Was this always broken, or did a recent change introduce it?110- If recent: which commit, who authored it, what was the intent?111- Are there related changes in the same PR that might also be affected?112113## Step 6: Risk Assessment114115Assess four dimensions:116117### Blast Radius118- **Isolated:** affects one feature or edge case119- **Moderate:** affects a common workflow or multiple features120- **Wide:** affects all users or a core system function121122### Fix Complexity123- **Simple:** one-line fix or small localized change124- **Moderate:** changes to 2-5 files, straightforward logic125- **Complex:** cross-cutting change, multiple packages, requires design decisions126127### Regression Risk128- **Low:** fix is isolated, existing tests cover surrounding code129- **Medium:** fix touches shared code, test coverage is partial130- **High:** fix touches core logic, minimal test coverage, or has cascading effects131132### Test Coverage133- **Good:** affected code has tests, but they miss this case134- **Partial:** some tests exist but do not cover the affected path135- **None:** no tests for the affected code path136137## Step 7: Recommend Next Step138139Based on the assessment, recommend one of:140141| Recommendation | When |142|----------------|------|143| **/hotfix** | Blast radius is Wide or Moderate AND fix complexity is Simple or Moderate |144| **/execute-prd** | Fix complexity is Complex OR regression risk is High |145| **Direct fix** | Blast radius is Isolated AND fix complexity is Simple AND test coverage is Good |146| **Needs more investigation** | Root cause is still unclear or there may be multiple contributing factors |147148## Step 8: Triage Report149150Present the structured report:151152```153Triage Report: <short title>154155Reported Issue156 <description as provided>157158Root Cause159 Category: <Logic Error | Type Error | Integration | Race Condition | Config/Env | Data>160 Location: <file>:<function> (lines <N>-<M>)161 Mechanism: <what goes wrong>162 Trigger: <what conditions cause it>163164Regression165 Introduced: <commit sha> <date> | "pre-existing" | "unknown"166 Related: <any related changes or PRs>167168Risk Assessment169 Blast Radius: <Isolated | Moderate | Wide>170 Fix Complexity: <Simple | Moderate | Complex>171 Regression Risk: <Low | Medium | High>172 Test Coverage: <Good | Partial | None>173174Recommendation: <next step>175 Rationale: <one sentence>176177Tracking: <ADO/Linear reference if provided>178```179180## Key Rules1811821. **Investigate first, fix later.** This skill does NOT write fixes. It produces a diagnosis.1832. **Be specific.** Cite exact files, functions, and line numbers. Vague findings are useless.1843. **One root cause.** If there are multiple contributing factors, identify the primary one and note the others.1854. **Do not guess.** If you cannot determine the root cause with confidence, say so. "Needs more investigation" is a valid recommendation.1865. **Trace, do not assume.** Actually follow the code path. Do not guess based on file names or function signatures alone.1876. **Respect scope.** Do not start fixing the bug. Do not refactor. Do not add tests. Investigate and report.