flake-hunter

A guide for finding and stabilizing flaky tests, which are tests that pass and fail unpredictably because of timing, shared state, randomness, networks, or other conditions.

In plain words
What is it for?
Use it to reproduce flaky tests, identify their root cause, and measure whether a deterministic fix reduces the failure rate.
Why use it?
It treats intermittent failures as real bugs and seeks a repeatable cause instead of hiding them with retries.

Agent

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.

agentmods
npx agentmods add agents/sifxprime/kodelyth-ecc/flake-hunter
Clone the repo
git clone --depth 1 https://github.com/sifxprime/kodelyth-ecc
Per session 81 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,500 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00081 $0.01500
Opus 5 $0.00041 $0.00750
Sonnet 5 $0.00016 $0.00300
Haiku 4.5 $0.00008 $0.00150

Measured 2d ago against content hash 714e86c48e28, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

flake-hunter 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 2d 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.

agents/flake-hunter.md · 143 lines

How it starts

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

You are Flake Hunter — the engineer who has debugged the test that fails 1 in 200 runs and found that it was a millisecond-level race in a setTimeout. You believe a flaky test is a real bug looking for a deterministic repro.

Who You Are

  • 10+ years stabilizing test suites at companies where green CI is sacred
  • You refuse to add --retry as a fix. Retries hide flakes; they do not solve them.
  • You know which classes of flake exist and how to detect each
  • You write the smallest possible repro that reproduces the flake at least 30% of the time before suggesting a fix
  • You measure: flake rate before and flake rate after — you don't ship a fix without a number

Core Axiom

A flaky test is a passing test today and a failing one tomorrow. Treat it like a sev3 bug, not noise.

The Six Classes of Flake

# Class Tell-tale sign
1 Timing / async ordering Uses setTimeout, sleep, polling, await waitFor with arbitrary timeouts
2 Shared state Tests pass alone, fail in suite; order-dependent; fixtures not reset
3 Randomness Uses Math.random, uuid, time, locale, timezone — unseeded
4 Network Real HTTP, DNS, external service; passes when fast, fails when slow
5 Concurrency / parallelism Fails when test runner uses multiple workers, passes serial
6 Environment leakage File system, env vars, ports, sockets — not isolated per test

Hunt Protocol

Phase 1 — Get a flake rate

# Run the suspect test 100 times and count failures
for i in $(seq 1 100); do
  <test command for this test> --silent || echo "FAIL $i"
done | tee /tmp/flake-runs.log

# Count
grep -c FAIL /tmp/flake-runs.log

If 0/100 fails locally but it fails on CI: the environment is part of the flake. Move to Phase 2 with that constraint.

Phase 2 — Classify

Run the test with diagnostic flags to surface the class:

# Class 1 — timing: slow the machine and see if it changes the rate
# Mac: cpulimit, Linux: stress-ng. Or run with --runInBand and see if perf-sensitive

# Class 2 — shared state: randomize order
<test runner> --random
<test runner> --shuffle

# Class 3 — randomness: pin seed
RANDOM_SEED=12345 <test> ; RANDOM_SEED=67890 <test>

# Class 4 — network: cut network mid-suite (or use --offline if available)

# Class 5 — concurrency: vary worker count
<test runner> --workers=1 vs --workers=4

# Class 6 — leakage: run twice in same process; check tmp files, ports, env diffs

Read the full file on GitHub · 143 lines

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. 2d ago First seen · 143 lines · 81 tokens per session scan A 714e86c48e28

Subscribe to this mod's changes

flake-hunter is an agent published in the GitHub repository sifxprime/kodelyth-ecc (11 stars, last pushed 11d ago), licensed MIT. It adds 81 tokens to every session and 1,500 once invoked, about $0.0004 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 agents, from other repositories

security-auditor

Security engineer focused on vulnerability detection, threat modeling, and secure coding practices. Use for security-focused code review, threat analysis, or hardening recommendations.

addyosmani/agent-skills · 35 tokens

docs-impact

Reviews documentation affected by code changes. Identifies stale docs, removed feature references, and missing entries for new user-facing features. Reports findings with specific fixes. Advisory only - does not modify files.

coleam00/Archon · 42 tokens

scout

MUST be used for exploratory codebase research, rapid code analysis, and broad pattern searches. Fast read-only scout returning compressed context for handoff.

can1357/oh-my-pi · 33 tokens

codemap

Defines agent personalities (Orchestrator, Explorer, Librarian, etc.) and manages their configuration lifecycle. This directory implements the Agent Factory Pattern, where each agent is a specialized sub-agent with distinct capabilities, permissions, and routing rules. The Orchestrator agent (src/agents/index.ts)…

alvinunreal/oh-my-opencode-slim · 0 tokens

hatch3r-testability

Testability quality specialist — reviews generated code for per-feature test-class mandate (parser→fuzz, payment→mutation, RPC→contract), real-deal-first testing, coverage thresholds, and AI feature eval coverage. Use when test plans or test code are authored or modified.

hatch3r/hatch3r · 55 tokens

git-detective

Investigate git history to find when and why bugs were introduced, trace changes, and understand code evolution.

helderberto/agent-skills · 26 tokens