Skip to content
Back to skills

Flaky Tests

ASecurity

Use this skill when the user wants to find which tests are flaky from CI results where the same tests were run several times per commit, e.g. a list of runs with commit, test and pass/fail outcome in input.json, and wants a flaky-tests.csv report ranked by failures. Not for fixing tests or analysing a single run.

  • 24 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 6, 2026
toolsapi

Works with

  • api

Security analysis

A100/100

Scanned December 6, 2026

npx -y skills add gabrielmoreira/agent-skills-mirror --skill flaky-tests --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flaky Tests?

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

Security grade badge for Flaky Tests
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/gabrielmoreira-flaky-tests-f89e430a/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-flaky-tests-f89e430a)

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: flaky-tests
description: "Use this skill when the user wants to find which tests are flaky from CI results where the same tests were run several times per commit, e.g. a list of runs with commit, test and pass/fail outcome in input.json, and wants a flaky-tests.csv report ranked by failures. Not for fixing tests or analysing a single run."
---

# Flaky test report

Produce `flaky-tests.csv` from `input.json` by reading and counting by hand. No commands are needed.

## Inputs
- `input.json` in the working folder: `{"runs": [{"commit": "...", "test": "...", "outcome": "pass"|"fail"}, ...]}`. Order of runs is irrelevant.
- If `input.json` is missing or has no `runs` array, stop and tell the user. Do not invent data.

## Definitions
- A test is **flaky on a commit** if, among the runs with that exact commit and test, there is at least one `pass` AND at least one `fail`.
- `flaky_commits` = number of distinct commits on which the test is flaky.
- `failures` = number of ALL `fail` runs of that test, across ALL commits (including commits where it is not flaky).
- A test is **listed** only if `flaky_commits >= 1`. Tests that always fail, always pass, or pass on one commit and fail on another (never both on the same commit) are NOT listed.

## Steps
1. Read `input.json`. Group runs by (commit, test). Compare commit and test strings exactly (case-sensitive, no trimming beyond what is in the data).
2. For each group, note whether it contains a pass, a fail, or both; count its fails.
3. For each test, compute `flaky_commits` (groups with both) and `failures` (sum of fail counts over all its groups).
4. Drop tests with `flaky_commits = 0`.
5. Sort the remaining tests by `failures` descending; break ties by `test` name ascending (plain character order, e.g. `alpha_sync` before `net_retry`). Do NOT sort by `flaky_commits`.
6. Write `flaky-tests.csv` next to `input.json`, exactly:
   - First line: `test,flaky_commits,failures`
   - One line per listed test: `name,flaky_commits,failures`
   - Plain integers, no quotes or spaces, `\n` line endings, trailing newline after the last line.
   - If no test is flaky, write only the header line.
7. Re-check: every listed test has both outcomes on at least one commit; `failures` counts non-flaky commits too; ordering is correct.

## Edge cases
- Outcome values other than `pass`/`fail`: ignore those runs and mention it to the user.
- Test names containing commas or quotes: quote the field per CSV rules (`"a,b"`, inner quotes doubled).
- Duplicate runs are real runs; count each one.

## Worked example
Runs: c1 api pass, c1 ui fail, c1 api fail, c1 ui pass, c1 db fail, c2 db pass, c2 ui fail, c2 api pass.
- api: c1 both → flaky_commits 1; fails 1.
- ui: c1 both → 1; fails 2 (c1 and c2).
- db: c1 only fail, c2 only pass → not flaky, dropped.

```csv
test,flaky_commits,failures
ui,1,2
api,1,1
```

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 tools →

Comments

Loading comments…

Newsletter

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