Sign in
Explore
Prompts · PromptTesting & SecurityUnit tests & TDDReviewed

testing/flaky-test-triage

Finds, isolates and fixes flaky tests by repeated runs and root-cause analysis.

Kind
Prompt
Works with
Claude Code
Source
Claude Code Templates @ 72e5f237f64d
Path
cli-tool/components/commands/testing/flaky-test-triage.md
Jobs
Testing, Debugging
Topics
Unit tests & TDD

Credit

Made by
davila7
Original
github.com/davila7/claude-code-templates/blob/72e5f237f64d70a…
License
MIT

Listed by Skill Manifest; not made by us.

InstallCopy it from the source repository, or sign in and let the assistant adapt it for your project.
Install factsScanned 3 Nov 2026
Adds
  • .claude/commands/flaky-test-triage.md (run as /flaky-test-triage)
Runs scripts
Yes
  • allowed-tools includes Bash
  • shell block in the text
Uses the network
Yes
  • downloads npm packages
Needs secrets
None found
Source revision
72e5f237f64d
Licence
MIT
Last activity
26 Nov 2026
Source changed after the scan
Yes
  • Last push 26 Nov 2026, scanned 3 Nov 2026; read it again before you rely on this scan
Review
Reviewed

Found by a static scan of the stored text; nothing is run. “None found” is not a guarantee, so read what you install before you run it.

# Flaky Test Triage

Investigate and eliminate non-deterministic behavior for: **$ARGUMENTS**

## Purpose

Isolate tests that pass and fail intermittently without code changes, determine the underlying source of non-determinism (race conditions, order coupling, timing drift, or leaked state), and apply robust deflaking fixes.

## Pre-flight

1. Confirm working tree cleanliness before running repeated test runs:
   ```bash
   test -z "$(git status --porcelain)" || { echo "Working tree is dirty; commit or stash changes first."; exit 1; }
   ```
2. Identify the target test file or test case from `$ARGUMENTS`.
3. Detect the test framework in use (e.g., Jest, Vitest, Pytest, Go test, Cargo test) from project configuration.

## Triage & Stabilization Workflow

### 1. Stress Repetition to Measure Flake Frequency

Run the target test for 20 iterations without breaking early on first error so the full pass/fail ratio and flake frequency can be accurately quantified:

- **Vitest**:
  ```bash
  passes=0; fails=0
  for i in $(seq 1 20); do
    if npx vitest run <path-to-test>; then ((++passes)); else ((++fails)); fi
  done
  echo "Vitest Results: $passes passed, $fails failed out of 20 runs"
…