Find flaky tests from a CI run log. Use when input.json holds a "runs" array of {commit, test, outcome} records and the user wants flaky-tests.csv (test, flaky_commits, failures) written beside it. Works by hand, with no scripts needed.
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-agent-skills-mirror)
---
name: flaky-tests
description: Find flaky tests from a CI run log. Use when input.json holds a "runs" array of {commit, test, outcome} records and the user wants flaky-tests.csv (test, flaky_commits, failures) written beside it. Works by hand, with no scripts needed.
---
# Flaky test report
Read `input.json` (in the working folder) and write `flaky-tests.csv` in the same folder. You can't run code, so do the counting carefully by hand, as described below.
## Definitions
- A test is **flaky on a commit** if, within that one commit, it has at least one `"pass"` run AND at least one `"fail"` run. Only the runs for that commit count. A test that fails on every run of a commit, or passes on every run, is not flaky on that commit.
- A test is **reported** if it is flaky on at least one commit. Tests that are never flaky are left out, even if they fail a lot (for example, a test that always fails).
- `flaky_commits` = the number of distinct commits on which the test is flaky.
- `failures` = the total number of `"fail"` runs for that test across ALL commits and all its runs. This includes fails on commits where the test was not flaky. (Example: a test is mixed on commit A and fails every run on commit B. Count the fails from both.)
## Procedure
1. Read `input.json`. Go through `runs` in order. For each test, keep a tally per commit: pass count and fail count. Commits are identified by the exact commit string. Do not assume runs of a commit are contiguous; the same commit can appear in separate places.
2. For each test, compute:
- `failures`: sum of its fail counts over all commits.
- `flaky_commits`: number of commits where both its pass count and its fail count are at least 1.
3. Keep only tests with `flaky_commits >= 1`.
4. Sort the kept tests:
1. `failures`, highest first;
2. then test name, A to Z (plain character order), for ties.
Do NOT sort by `flaky_commits`. Check with the examples: in example 3 `alpha_sync` (1 flaky commit, 2 failures) comes before `net_retry` (2 flaky commits, 2 failures) because the failures tie and the names break it.
5. Write `flaky-tests.csv`:
- First line exactly `test,flaky_commits,failures`
- One line per kept test: `name,flaky_commits,failures`
- Plain integers, no spaces, no quotes, a newline after each line including the last.
- If no test is flaky, the file contains only the header line.
6. Before finishing, re-check each reported row against the input: recount its fails over every commit, and confirm that each commit you counted as flaky really has both a pass and a fail. Also scan for tests you dropped that have a mixed commit.
## Worked check (example)
Runs: commit X: t fail, t pass; commit Y: t fail. Then t is flaky on X only, so `flaky_commits=1`; fails are 1 (X) + 1 (Y) = 2. The row is `t,1,2`.
Test names may be in any case or contain underscores or digits. Copy them exactly as they appear in the input.