Skip to content
Back to skills

Flaky Test Diagnosis

ASecurity

Reproduces an intermittent test failure, finds the shared state or timing cause and fixes it, rather than hiding it behind retries or longer waits.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added November 15, 2026
ai-agentsdatabase

Security analysis

A100/100

Scanned November 15, 2026

npx -y skills add workspace-templates/ai-agent-templates --skill flaky-test-diagnosis --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flaky Test Diagnosis?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Flaky Test Diagnosis
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/workspace-templates-flaky-test-diagnosis/badge)](https://www.skillsdirectory.com/skills/workspace-templates-flaky-test-diagnosis)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: flaky-test-diagnosis
description: Reproduces an intermittent test failure, finds the shared state or timing cause and fixes it, rather than hiding it behind retries or longer waits.
---

# Flaky test diagnosis

A flaky test is a real bug in the test or the code. Never "fix" it with a retry, a longer timeout or a skip.

## Steps

1. Get the exact test name and one failing log. Note the runner and whether CI runs tests in parallel.
2. Measure. Run the single test 50 times in a loop and count failures. Then run the whole file, then the whole suite, and compare. Failing only in the suite points to shared state or ordering.
3. Force the suspected cause: run in random or reversed order, with one worker and with many, under CPU load (`stress-ng` or a busy loop), and with the clock frozen or shifted.
4. Classify the cause: leaked global or database state, real time or timezone, unawaited promise or thread, shared port or temp file, unseeded randomness, network call, or dependence on map or set ordering.
5. Fix the cause: isolate state per test, inject the clock, await the work, use ephemeral ports and unique temp dirs, seed the random generator and print the seed on failure, sort before asserting.
6. Rerun the 50-iteration loop. Done only at zero failures.

## Rules

- Never add sleeps. Wait on a condition or an event.
- Change one thing between measurements.
- If the production code is racy, say so and fix it there.

## Report

Failure rate before and after, the classified cause, the diff, and any sibling tests with the same pattern.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.