Skip to content
Back to skills

Fix Flaky Test

ASecurity

Finds why a test passes and fails intermittently and fixes the cause instead of adding retries. Use when a test fails only sometimes, locally or in CI.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added November 26, 2026
ai-agentsgotestingdatabase

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned November 26, 2026

npx -y skills add hermes-hq/hodios-dist --skill fix-flaky-test --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Fix Flaky Test?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Fix Flaky Test
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hermes-hq-fix-flaky-test-hodios-dist/badge)](https://www.skillsdirectory.com/skills/hermes-hq-fix-flaky-test-hodios-dist)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: fix-flaky-test
description: Finds why a test passes and fails intermittently and fixes the cause instead of adding retries. Use when a test fails only sometimes, locally or in CI.
license: CC0-1.0
metadata:
  version: 1.0.1
  kind: prompt
  category: testing
  source: https://hermes-ide.com/prompts/fix-flaky-test
  catalog: 2026.1014.1
---

# Fix a flaky test

## Inputs

- [TEST] (required): Test name, file or failing CI job to investigate.
- [FAILURE_LOG] (optional): Output from a failing run, if you have one.

Take each value from the invocation or the user’s message. If a required value is missing, ask for it once.

<context>
A flaky test passes and fails on the same code. Retries and longer timeouts hide the defect and teach the team to ignore red builds, so the goal is the cause, not a green run. Sometimes the flakiness is in the product code rather than the test, and then it is a real bug that users can hit.
</context>

<task>
Investigate [TEST].
Only if [FAILURE_LOG] was provided: Start from this failing output:
[FAILURE_LOG]
1. Read the test, its fixtures and setup, and the code it exercises before running anything.
2. List the sources of nondeterminism you can see:
   - time: the current date or time, time zones, timers, timeouts that are too tight;
   - randomness: random data, unseeded generators, generated ids;
   - ordering: unordered collections, query results without ORDER BY, parallel tests, test order;
   - shared state: globals, singletons, caches, databases, files or ports used by other tests;
   - concurrency: unawaited promises, background work, sleeps used for synchronisation;
   - the outside world: network, external services, environment variables, locale.
3. Reproduce the failure: run the test repeatedly, in random order, in parallel, or alongside the tests that run before it in CI. Report how often it fails.
4. Fix the cause: wait on the condition instead of a duration, inject the clock or the seed, isolate the state, sort before comparing. If the race is in the product code, fix it there and say so.
5. Run the test enough times to show the failure is gone, using the same method that reproduced it.
</task>

<constraints>
- Never add retries, sleeps or longer timeouts as the fix.
- Never delete, skip or quarantine the test as the fix. If quarantine is needed while the fix lands, say so separately.
- If you cannot reproduce the failure, say so, report the most likely causes ranked with evidence, and do not claim a fix.
- Fix the behaviour, not the test. Never special-case test inputs, weaken assertions or skip tests to make a check pass.
- If a test looks wrong, explain why and ask before changing it.
- Before saying the work is done, run the check that proves it (tests, build, type check or the command the user gave) and report the real result.
- If you could not run a check, say so plainly and say which one.
</constraints>

<output_format>
## Cause
One paragraph: the nondeterminism and how it makes the test fail. Say whether it is in the test or in the product code.
## Fix
The diff, then one sentence on why it removes the cause.
## Evidence
Runs before and after, with the method used and failure counts (for example "7 of 200 failed before, 0 of 200 after").
</output_format>

Files in this skill

  • SKILL.md3.2 KB
  • agents/openai.yaml260 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.