fixing-flaky-tests

fixing-flaky-tests is a skill for Claude Code from rileyhilliard/claude-essentials. It costs 36 tokens per session (984 once invoked), scanned A, original, MIT.

A guide for diagnosing tests that pass alone but fail when run at the same time as other tests. It covers shared data, competing resources, and timing-related race conditions.

In plain words
What is it for?
Use it to investigate concurrent test failures, repeat tests alone and in the full suite, isolate databases and globals, reset singletons, and allocate unique resources per test or worker.
Why use it?
It helps distinguish whether failures come from polluted state, conflicts over ports or files, or asynchronous timing. That points to the appropriate isolation or waiting fix.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions CLAUDE.md.

Part of the ce plugin — 17 skills, 1 command, 4 agents shipped together

Good fit Use it to investigate concurrent test failures, repeat tests alone and in the full suite, isolate databases and globals, reset singletons, and allocate unique resources per test or worker.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/rileyhilliard/claude-essentials/fixing-flaky-tests
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add rileyhilliard/claude-essentials --skill fixing-flaky-tests
Clone the repo
git clone --depth 1 https://github.com/rileyhilliard/claude-essentials

Made for: Claude Code.

Or install ce, the plugin that ships this one along with the rest of its 17 skills, 1 command, 4 agents.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for fixing-flaky-tests

README.md
[![agentmods](https://agentmods.dev/badge/skills/rileyhilliard/claude-essentials/fixing-flaky-tests/github.svg)](https://agentmods.dev/skills/rileyhilliard/claude-essentials/fixing-flaky-tests)
Your own site
<a href="https://agentmods.dev/skills/rileyhilliard/claude-essentials/fixing-flaky-tests"><img src="https://agentmods.dev/badge/skills/rileyhilliard/claude-essentials/fixing-flaky-tests/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for fixing-flaky-tests

Your own site · 80×15
<a href="https://agentmods.dev/skills/rileyhilliard/claude-essentials/fixing-flaky-tests"><img src="https://agentmods.dev/badge/skills/rileyhilliard/claude-essentials/fixing-flaky-tests.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 36 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 984 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00036 $0.00984
Opus 5 $0.00018 $0.00492
Sonnet 5 $0.00007 $0.00197
Haiku 4.5 $0.00004 $0.00098

Measured 9d ago against content hash 1f893063a2ba, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

fixing-flaky-tests scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/ce/skills/fixing-flaky-tests/SKILL.md · 148 lines

How it starts

The opening of the file, as written. The whole thing — 148 lines — stays where its author put it; the contents beside it link to each section on GitHub.

If the current repo has its own rules/skills covering this topic (check .claude/rules/ and repo CLAUDE.md), those take precedence — apply this skill only where they're silent.

Fixing Flaky Tests

Target symptom: Tests pass when run alone, fail when run with other tests.

Diagnose first

Test passes alone, fails with others?
    │
    ├─ Same error every time → Shared state
    │   └─ Database, globals, files, singletons
    │
    ├─ Random/timing failures → Race condition
    │   └─ See async waiting patterns in `writing-tests` skill
    │
    └─ Resource errors (port, file lock) → Resource conflict
        └─ Need unique resources per test/worker

Quick diagnosis:

  1. Run failing test 10x alone - does it always pass?
  2. Run failing test 10x with the suite - same error or different?
  3. Check error message - mentions port/file/connection?

Shared state (deterministic failures)

Tests pollute state that other tests depend on. Fix by isolating state per test.

State Type Isolation Pattern
Database Transaction rollback, savepoints, worker-specific DBs
Global variables Reset in beforeEach/afterEach
Singletons Provide fresh instance per test
Module state jest.resetModules() or equivalent
Files Unique paths per test, temp directories
Environment vars Save/restore in setup/teardown

Database isolation (most common):

# Python: Savepoint rollback - each test gets rolled back
@pytest.fixture
async def db_session(db_engine):
    async with db_engine.connect() as conn:
        await conn.begin()
        await conn.begin_nested()  # Savepoint
        # ... yield session ...
        await conn.rollback()  # All changes vanish
// Jest: Reset mocks between tests
beforeEach(() => {
  jest.clearAllMocks()
  jest.resetModules()  // Clear module cache before test
})

afterEach(() => {
  jest.restoreAllMocks()  // Restore spied functions
})

Read the full file on GitHub · 148 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 148 lines · 36 tokens per session scan A 1f893063a2ba

Subscribe to this mod's changes

fixing-flaky-tests is a skill published in the GitHub repository rileyhilliard/claude-essentials (128 stars, last pushed 21d ago), licensed MIT. It adds 36 tokens to every session and 984 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

testing

Skill validation framework PLUS daily test-suite health and regression intelligence. Validates skill conformance (frontmatter, manifest coverage, resolver coverage). Runs the project test suite in tiered phases (unit / evals / integration / system health), classifies failures, and produces a regression-aware report.

garrytan/gbrain · 63 tokens

verify

Verify that a change really works before you claim completion.

Yeachan-Heo/oh-my-claudecode · 12 tokens

detect-static-dependencies

Scan C# source files for hard-to-test static dependencies — DateTime.Now/UtcNow, File., Directory., Environment., HttpClient, Console., Process., and other untestable statics. Produces a ranked report of static call sites by frequency. USE FOR: find untestable statics, scan for static dependencies, testability audit…

dotnet/skills · 143 tokens

experiment-iterative-coder

Iterative code refinement through plan → code → evaluate → refine cycles. Runs lint checks (ruff), tests (pytest), and structured self-evaluation each cycle, then diagnoses failures and refines. Decomposes complex tasks into sequential phases, iterates up to 3 times per phase (10 total). Use when: the main agent…

EvoScientist/EvoSkills · 145 tokens

testing-blocks

Use this when you have made AEM Edge Delivery Services code changes to blocks, scripts, or styles and need to validate them before opening a pull request. Covers unit testing for utilities and logic, browser testing with Playwright, linting, and guidance on what to test and how.

adobe/skills · 61 tokens

symbolic-execution-assistant

Performs symbolic execution to detect potential errors by exploring execution paths, solving path constraints, and generating test inputs. Use when you need to analyze code for bugs like null dereferences, division by zero, buffer overflows, or assertion violations. Also use to generate test inputs that exercise…

ArabelaTso/Skills-4-SE · 111 tokens