flakiness-concurrency

Diagnose and contain flaky tests caused by concurrency races and inter-test state leakage.

Updated Jun 24, 2026
One-click install
npx skills add https://github.com/Hakkadaikon/hymme --skill flakiness-concurrency-hakkadaikon
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: flakiness-concurrency
Source: https://github.com/Hakkadaikon/hymme/tree/main/skills/flakiness-concurrency
Command: npx skills add https://github.com/Hakkadaikon/hymme --skill flakiness-concurrency-hakkadaikon

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Flaky tests that randomly pass or fail erode trust in CI: real regressions get buried in noise and teams mask failures with retries. This Skill provides a systematic method to find, reproduce, and eliminate flakiness caused by nondeterministic coordination between processes—concurrency races and inter-test ordering/state leakage. ## Core Features & Use Cases - Race detection and containment: Amplify race windows with high parallelism and repetition (vitest --repeat, --no-isolate), then serialize shared-state access via locks, queues, or await chains. - Order/shuffle analysis: Expose state leakage between tests using --sequence.shuffle with varying seeds, and fix it with beforeEach/afterEach initialization and teardown discipline. - Mechanical completion gates: Defines concrete pass criteria (e.g., 200 consecutive green repeats, 30 shuffle seeds green) so containment is closed by evidence, not by a single lucky green run. - Use Case: A CI pipeline fails intermittently on a counter test. Use this Skill to reproduce the race with 1000 parallel invocations, serialize the read-modify-write section, and verify with 200 consecutive green runs. ## Quick Start Ask the AI to diagnose why a specific vitest test is flaky and apply the concurrency and state-leakage containment steps from this Skill.

Frequently Asked Questions about flakiness-concurrency

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix flaky tests caused by race conditions?

Race condition flakiness is fixed by serializing shared-state access so read-modify-write becomes atomic, using locks, queues, or await chains. First reproduce the race by running the test with high parallelism and repetition, such as vitest --repeat=200 --no-isolate, then verify the fix with consecutive green runs.

How to detect test order dependency in vitest?

Test order dependency is detected by enabling vitest's --sequence.shuffle flag and running the suite with many different seeds. A test that passes alone but fails in the full suite, or vice versa, indicates state leakage between tests that must be fixed with beforeEach/afterEach isolation.

Should I use retry to handle flaky tests in CI?

No, retrying flaky tests is explicitly discouraged because it hides nondeterminism and can mask real regressions. The correct approach is to quarantine the flaky test temporarily, identify its root cause, reproduce it with amplified variance, and contain it at the source.

Why do my tests pass locally but fail in CI?

Tests often fail only in CI because higher parallelism and machine load widen race windows that stay hidden locally. Reproduce the failure by increasing worker counts, adding machine load, and repeating the test hundreds of times to expose the timing-dependent behavior.

When should I use model checking instead of flaky test repetition?

Model checking with TLA+ is appropriate when tests cannot cover all interleavings of a concurrent design, since tests only sample finitely many executions. Verify safety and liveness properties exhaustively with a model checker, then convert counterexample traces into regression tests.