skills/absolute-deflake/SKILL.md
Flaky test fixes: detect nondeterministic tests empirically (repeat/shuffle/parallel runs), diagnose the root cause, fix it — never retry/skip/sleep — and verify across many randomized runs. Triggers on "absolute deflake", "fix flaky tests", "CI is flaky", "this test fails randomly/intermittently".
npx skillsauth add absolutelyskilled/absolutelyskilled absolute-deflakeInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Start your first response with the 🧪 emoji.
Find tests that pass and fail nondeterministically, diagnose the root cause of each, and fix it — not by retrying or skipping, but by removing the source of nondeterminism. Output is evidence (failure rate per test) → cause → fix, verified by repeated runs.
Runs the shared engine in references/health-engine.md — read it for the
DETECT → SCAN → TRIAGE → FIX → VERIFY → REPORT loop and the safety contract. This file
covers only what's specific to flaky tests.
retry/skip-marked tests that mask real flakiness.Not for tests that fail deterministically — that's a real bug or a real regression
(/absolute work for a fix, or just fix it). deflake targets nondeterministic failures.
Establish flakiness empirically — a test isn't flaky because someone said so. Use
preferences.health.deflakeRuns from config as the default N for repeat-runs (else 20):
| Ecosystem | Repeat-run / detect |
|---|---|
| Jest/Vitest | run suite N× (--run loop), randomize order (--shuffle / testSequencer) |
| pytest | pytest-randomly + pytest --count=N (pytest-repeat); -p no:randomly to A/B |
| Go | go test -count=N -shuffle=on ./..., -race |
Also mine signals: existing retry/flaky/skip annotations, CI history if reachable, and
run the suite both in isolation and in full/parallel — order- and concurrency-
dependent failures only show one way. Record a failure rate per suspect test.
| Cause | Tell | Fix |
|---|---|---|
| Test-order / shared state | passes alone, fails in suite (or vice versa) | isolate state; reset/teardown between tests |
| Time / clock | fails near midnight, DST, or under load | fake timers / inject clock; no real sleep |
| Async race / missing await | fails under parallelism or slow CI | await the actual condition; no fixed timeouts |
| Randomness | fails ~X% with no pattern | seed the RNG; fix the seed in tests |
| Network / external I/O | fails offline or on slow links | mock/stub the boundary |
| Unordered collections | fails on map/set iteration order | sort before asserting |
| Resource leak / port reuse | fails on repeat or parallel runs | unique resources; clean up |
| Wave | Class | Default | |---|---|---| | 1 | clear, isolated cause (seed, await, fake clock, sort) | fix now | | 2 | shared-state / ordering — needs fixture refactor | fix this pass, per test | | 3 | flakiness pointing at a real product race, not just the test | gated — surface; may be a genuine bug to fix in code |
A flaky test sometimes means the code has a race, not the test. Don't "stabilize" the test into hiding a real concurrency bug — flag wave-3 cases for a real fix.
-race) — green once is not deflaked; green across N randomized runs is.retry/skip/flaky annotation that was masking it once the cause is fixed.sleep, or skipping the test —
that hides flakiness, doesn't remove it.sleep to dodge a race. Slows the suite and still flakes under load. Await the condition./absolute upgrade — a flaky suite makes upgrade verification unreliable; deflake first./absolute debt — flaky-test annotations are test debt; this clears them at the root./absolute work — when the flake is a genuine product-code race needing real design.development
Use when the user wants to simplify, clean up, refactor, tidy, or refine code — their staged/unstaged git changes or a target file/path. Reduces complexity, flattens nesting, removes redundancy and dead code, scores each change by value (holding low-value churn), then runs tests to prove nothing broke. Invoke on: "simplify", "simplify this", "simplify my code/changes", "clean up", "clean this up", "clean up my changes", "refactor this", "make this cleaner", "tidy this up", "reduce complexity", "flatten this", "remove dead code", "make it more readable", "polish before commit", or "absolute simplify". Acts on your working diff; for repo-wide dead code use absolute-prune; for lint/type debt use absolute-debt.
testing
Dependency upgrades: outdated/vulnerable deps planned into semver waves (patch/minor batched, majors gated and changelog-read), applied incrementally with lockfiles regenerated and tests green after each. Runs on green main. Triggers on "absolute upgrade", "upgrade our dependencies", "bump deps", "update packages", "move off the deprecated X", "clear the Dependabot backlog".
development
Lightweight standalone design spec for AI coding agents: codebase scan → bounded clarify pass (3–5 questions, not a grill) → reviewed design doc written to docs/plans/ → independent scored review → stop. No task board, no build. Use when you want a spec to discuss, hand off, or review before committing to implementation. Chains into absolute-work when ready to build. Triggers on "absolute spec", "write a spec", "spec out this feature", "draft a design doc", "I want a spec to hand off / review, don't build it yet".
tools
Dead code and dependency cleanup, repo-wide: unused deps, unreferenced exports, unreachable code, orphaned files — removed only with tool evidence, in reversible waves. Runs on green main. For diff-scoped cleanup use absolute-simplify. Triggers on "absolute prune", "remove dead code", "find unused deps/exports", "what can we delete", "clean up orphaned files".