flaky-test
Skill2 starsChanged 4 months agoMITView on GitHub
Track down and stabilize a flaky test — one that passes and fails non-deterministically — by finding the source of nondeterminism (timing, ordering, shared state, randomness, real I/O) and fixing the root cause, not by adding retries. Use when the user says "this test is flaky", "fix the flaky test", "the test passes sometimes", "stabilize this test", "why does this test fail intermittently", or "the suite is non-deterministic".
6 other projects use a version of this.
Adopted by
Most recently taken up by
- ychampion/ystacktheir own version, first seen Nov 15, 2026
- moah0911/aftermaththeir own version, first seen Nov 1, 2026
- kitloomlk-stack/testing-debugging-kittheir own version, first seen Oct 15, 2026
- ArthurC02/SkillHubtheir own version, first seen Oct 13, 2026
- gravitational/teleporttheir own version, first seen Oct 8, 2026
- Jinbae10/skillstheir own version, first seen Jul 7, 2026
Other versions6 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 6
- gravitational/teleport★ 21ksame name
- moah0911/aftermath★ 14same name
- ychampion/ystack★ 4same name
- ArthurC02/SkillHub★ 1same name
- Jinbae10/skills★ 0same name
- kitloomlk-stack/testing-debugging-kit★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository68 other files it gives its agents.
- a11ySkill
- api-docsSkill
- audit-logSkill
- benchmarkSkill
- bisectSkill
- cacheSkill
- changelogSkill
- cherry-pickSkill
- ci-setupSkill
- codeownersSkill
- commit-messageSkill
- connection-poolSkill
- contributingSkill
- coverageSkill
- db-migrateSkill
- dead-codeSkill
- debugSkill
- depsSkill
- diagramSkill
- dockerizeSkill
- docstringSkill
- e2eSkill
- env-exampleSkill
- error-handlingSkill
- explainSkill
- feature-flagSkill
- gitignoreSkill
- graceful-shutdownSkill
- graphqlSkill
- healthcheckSkill
- i18nSkill
- idempotencySkill
- licenseSkill
- lint-fixSkill
- loggingSkill
- migrateSkill
- mockSkill
- onboardSkill
- optimizeSkill
- paginationSkill
- pr-descriptionSkill
- pre-commitSkill
- profileSkill
- prune-branchesSkill
- rate-limitSkill
- readmeSkill
- rebaseSkill
- refactorSkill
- regexSkill
- releaseSkill
- resolve-conflictsSkill
- retrySkill
- review-diffSkill
- scaffoldSkill
- secrets-scanSkill
- security-headersSkill
- seedSkill
- soft-deleteSkill
- sqlSkill
- squashSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 3 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 5 edited versions we read keep these.
3
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 30
Retry is a last resort, not the fix: Only after the root cause is genuinely environmental and outside the test's control (and you've said …
- Distinctive: line 37
Keep the test's intent intact — stabilizing must not weaken what it asserts or turn it into a test that can no longer fail.
- Distinctive: line 38
After fixing, summarize the root cause, the fix, the before/after failure rate, and whether any documented retry remains and why.
“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Test setup signals
!grep -rilE "jest|vitest|mocha|playwright|cypress|pytest|unittest|rspec|go test|junit|testng" package.json pyproject.toml go.mod Gemfile pom.xml 2>/dev/null | grep -vE 'node_modules|\.git' | head -6
!grep -rlnE "setTimeout|sleep|Date\\.now|new Date\\(\\)|Math\\.random|time\\.sleep|datetime\\.now|waitFor|page\\.wait" --include='*test*' --include='*spec*' . 2>/dev/null | grep -vE 'node_modules|\.git' | head -8
Instructions
Stabilize the flaky test in $ARGUMENTS. The goal is to find and remove the source of nondeterminism — not to mask it with a retry or a longer sleep. If you can't reproduce or identify the cause, say so and propose how to surface it rather than guessing.
Method
- Reproduce the flake. Run the test in a loop and, where relevant, with randomized order and parallelism to surface it (e.g. repeated runs,
--shuffle/random seed,-p/concurrency). A flake you can't trigger you can't confirm fixed — note the failure rate before and after. - Classify the root cause. Common sources:
- Timing/async — fixed
sleeps and races; the test asserts before the work settles. - Order/shared state — tests leak state (DB rows, globals, files, env) and depend on run order.
- Time/randomness — real
Date.now()/Math.random()/UUIDs not frozen or seeded. - Real I/O/network — hitting a live service, real clock, or unmocked dependency.
- Floating-point / unordered collections — comparing maps/sets or floats by exact equality.
- Timing/async — fixed
- Fix the cause, not the symptom. Replace sleeps with deterministic waits on a condition/event; freeze time (fake timers/clock) and seed randomness; isolate state with proper setup/teardown so each test is independent of order; mock external I/O. Make assertions order-independent for unordered data.
- Verify it's actually fixed. Re-run the loop (and shuffled/parallel) many times — the failure rate should go to zero. Don't declare victory on a single green run; a flake by definition passes sometimes.
- Retry is a last resort, not the fix. Only after the root cause is genuinely environmental and outside the test's control (and you've said so) should you fall back to a bounded, documented retry — never as a substitute for fixing real test logic.
Rules
- Find and remove the source of nondeterminism; never paper over a flake with a longer sleep or a blanket test-retry as the primary fix.
- Reproduce the flake first (loops, shuffled order, parallelism) and measure the failure rate before/after — don't claim a fix from one passing run.
- Replace sleeps with condition-based waits, freeze time and seed randomness, mock real I/O, and make tests order-independent with clean setup/teardown.
- Keep the test's intent intact — stabilizing must not weaken what it asserts or turn it into a test that can no longer fail.
- After fixing, summarize the root cause, the fix, the before/after failure rate, and whether any documented retry remains and why.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

