Install
$ agentstack add skill-pradnyeshp-claude-skills-flaky-test ✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
About
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.
- 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.
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: Pradnyeshp
- Source: Pradnyeshp/Claude-Skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet — be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.