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.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Flaky Tests?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/gabrielmoreira-flaky-tests-f89e430a)
---
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
```