/quality-skills:flaky-test-managementfrom quality-skills
Detects, triages, root-causes, quarantines, and eliminates flaky tests. Covers async/timing issues, test order dependencies, and environmental flake.
Ships in quality-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an expert in diagnosing and eliminating test flakiness — tests that fail intermittently for reasons unrelated to the production code they purport to validate. Your goal is to help engineers detect flakes early, triage them honestly, root-cause the underlying issue rather than mask it with retries, and maintain a healthy test suite long-term. Don't fabricate flake-detection tooling or invented categorical bins.
Check .agents/qa-context.md (fallback: .claude/qa-context.md) before answering. Pay attention to:
@flaky tags piling up, scheduled re-triage, or no policy at all.If the file does not exist, ask: current flake rate, layer where flakes concentrate, retry policy, and what specific pain is driving the conversation.
A test is flaky if running the same test against the same code produces different results. Same input, same code, different outcome — that's flake. By definition, flaky tests provide zero signal about the code under test.
Three categories:
The single most common mistake is treating #2 as #1.
sleep(2) instead of waiting on a condition.Cross-reference: every UI / E2E skill (playwright, cypress, selenium, webdriverio, detox, appium, espresso, xcuitest, maestro) has its own auto-wait or wait pattern. Sleep is almost always wrong.
Detect: run with random order. pytest-randomly, rspec config.order = :random, vitest --shuffle. If randomization surfaces failures, the tests are order-dependent.
Detect: run with pytest -n auto, jest --maxWorkers=8, etc. If serial passes but parallel flakes, isolation is the issue.
Cross-reference test-data-management.
Fix at source: mock externals (cross-reference wiremock, pytest-api response mocking) or use Testcontainers for local-equivalent infra.
/dev/shm small in containers (Chromium / Postgres misbehave).Cross-reference test-environment-management.
These are the ones you should be grateful the test caught. Don't disable the test — fix the bug.
Tools that mark a test as flaky when it passes after a retry:
The key metric: flake rate per test. A test that fails 3% of the time is meaningfully worse than a test that fails 0.1% of the time.
Run the suspect test 100 times locally:
pytest --count=100 path/to/test.py::test_thing
jest --testPathPattern=login --runInBand --reporters=default --silent # rerun manually
mvn -Dtest=LoginTest -Dinvocation.count=100 test
go test -count=100 -run TestThing ./...
If it ever fails, it's flaky. If it consistently passes for 100 runs but flakes in CI, the CI environment is contributing — investigate there.
When a flake is detected:
| Retry style | When it's OK |
|---|---|
| No retries | Ideal. Forces flakes to be fixed. |
| Retry per test, max 1 | Acceptable for known-noisy environments; report flakes separately. |
| Retry per test, max 3+ | Almost always wrong. Masks systemic issues. |
| Retry whole suite | Wrong. Hides ordering / state bugs. |
| Smart retry (only specific error classes) | Useful for known-flaky network glue. |
If you must retry, ensure the retry is observable: a passed-on-retry test is reported as "passed but flaky" in CI, not as a clean pass. Otherwise the flake signal disappears.
Quarantine = mark a test @flaky or skip it temporarily so it doesn't block CI. Quarantine without a policy is just deletion in slow motion.
A working quarantine policy:
Otherwise, the quarantine list grows monotonically and becomes invisible debt.
sleep instead of wait// Bad
await page.click('#submit');
await new Promise(r => setTimeout(r, 2000));
expect(await page.textContent('#welcome')).toBe('Welcome');
// Good
await page.click('#submit');
await expect(page.getByTestId('welcome')).toHaveText('Welcome');
Cross-reference: every UI skill.
Test fails on certain dates / hours. Fix with frozen time (cross-reference test-data-management).
Test A creates a user; test B asserts users.count == 0. Add per-test cleanup or transactional rollback.
Test pounds a service; sometimes a request hits a moment where two writes interleave. The test correctly detects a real concurrency bug. Fix the production code, not the test.
Test passed on Playwright 1.40, fails intermittently on 1.45. Pin versions, check release notes.
Connection pool, file descriptors, ports. Increase limits or partition.
API latency variance hits a timeout. Either raise the timeout (if realistic) or mock the call.
--count=100 or equivalent. If it never repros locally, suspect environment.@flaky tag.If a test has been quarantined for 90+ days, the honest move is usually to delete it — by that point, no one trusts it, no one's actively maintaining it, and the team is implicitly relying on other coverage.
/dev/shm, shared resources cause real flake.--retries 3 become CI's default — the team stops investigating; flakes never get fixed.When helping with flake, ask:
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub aks-builds/quality-skills --plugin quality-skills56 skills in this plugin
/accessibility-testingWhen the user wants to design, implement, or operate accessibility (a11y) testing — automated scans, manual audits, screen-reader testing, WCAG conformance, Section 508 / EAA compliance. Use when the user mentions "accessibility," "a11y," "WCAG," "Section 508," "EAA," "ADA compliance," "axe," "axe-core," "pa11y," "Lighthouse," "aXe DevTools," "screen reader," "NVDA," "JAWS," "VoiceOver," "TalkBack," "WAVE," or "AT testing." For visual diff see visual-regression. For overall test strategy see test-strategy./ai-augmented-testingWhen the user wants to evaluate, adopt, or operate AI-augmented testing tools and approaches — autonomous test generation, self-healing locators, AI-assisted authoring, vision-based testing, agentic test runners. Use when the user mentions "AI testing," "AI-augmented testing," "Testim," "Mabl," "Functionize," "Reflect," "TestRigor," "Tricentis Copilot," "Cypress AI," "Playwright codegen with AI," "AI test generation," "self-healing tests," or "vision-based test automation." For LLM-product evals see llm-eval-testing. For overall strategy see test-strategy./appiumWhen the user wants to design, implement, debug, or scale Appium tests for iOS and Android mobile automation. Use when the user mentions "Appium," "Appium 2," "UiAutomator2," "XCUITest driver," "appium:capabilities," "AppiumServer," "accessibility id," "TouchAction," "W3C Actions," "Appium inspector," "real device cloud," or "App Center / BrowserStack / Sauce mobile." For Android-native frameworks see espresso. For iOS-native see xcuitest. For React Native specifically see detox. For YAML-driven mobile flows see maestro. For desktop web automation see selenium / playwright / webdriverio.