Skip to content

commandTesting

Triage Test Failure

Diagnoses one failing test from its output and tells you whether the test or the code is wrong, with the evidence.

npx workspacetemplates add triage-test-failure --tool claude-code

Writes 1 file to .claude/commands/

.claude/commands/triage-test-failure.md15 lines · 1.1 KBFile
---
description: Diagnoses one failing test from its output and tells you whether the test or the code is wrong, with the evidence.
argument-hint: "[test name, file or pasted failure output]"
---

Triage this failing test: $ARGUMENTS (a test name, a file, or pasted output).

1. Run the test alone and capture the full output. Run it three times to see if the result is stable. Then run it with the rest of its file to check for order effects.
2. Read the test and the code it exercises. Identify exactly which assertion fails, expected against actual.
3. Check what changed recently: `git log -n 5 --oneline -- <test file> <source file>` and the working tree diff. Name the commit most likely responsible.
4. Look for flake causes: wall-clock time, timezone, random data without a seed, shared global state, network calls, unawaited promises, hash or dict ordering.
5. Reach a verdict: **code bug**, **stale test**, **flaky test**, or **environment**. Give the three strongest pieces of evidence.
6. Do not edit anything.

Report the verdict, the evidence, the smallest fix and where it goes. Ask whether to apply it.

What it does

When a single test is red the real question is who is at fault. This command reads the failure, the test and the code under it, then gives a verdict with the reasoning behind it, instead of jumping to an edit.

It also checks the history for what changed last, and looks for flakiness signs such as shared state or time dependence.

Example

you › /triage-test-failure shipping.test.ts "free shipping over 50"

agent › Verdict: stale test. Stable red on 3 runs, only this test.
Evidence: commit 4fa21c raised the threshold to 60 in shipping.ts; the test still uses a 55 cart; the changelog documents the new limit.
Fix: update the cart total to 65. Apply it?

Questions

Will it change the test or code?
Not before telling you the verdict. It edits only after you approve the proposed fix.
Can it handle CI-only failures?
Yes, if you paste the CI output. It compares environment factors such as timezone, locale and parallel runs.
  • Add Edge Case Tests

    CommandTesting

    Free
  • Add Regression Test

    CommandTesting

    Free
  • Coverage Gaps

    CommandTesting

    Free
  • E2E Scenario

    CommandTesting

    Free