Skip to content
Back to skills

Flaky Tests

ASecurity

Use this skill when you need to find which tests are flaky from CI results that ran the same test suite several times per commit (an input.json with runs of commit, test, pass/fail outcome), and write a flaky-tests.csv report of flaky tests. Not for flaky-test fixes, retries or general test-failure triage.

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

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-639481b3/badge)](https://www.skillsdirectory.com/skills/gabrielmoreira-flaky-tests-639481b3)

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 you need to find which tests are flaky from CI results that ran the same test suite several times per commit (an input.json with runs of commit, test, pass/fail outcome), and write a flaky-tests.csv report of flaky tests. Not for flaky-test fixes, retries or general test-failure triage."
---

# Flaky test report

## When to use
A CI pipeline ran each test several times per commit. Produce `flaky-tests.csv` listing tests that gave both a pass and a fail on the same commit. Do not use for fixing tests or for data in other shapes.

## Input
Read `input.json` in the working folder: `{"runs": [{"commit": "...", "test": "...", "outcome": "pass"|"fail"}, ...]}`. Run order does not matter. Commit and test names are compared as exact strings.

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

## Steps
1. Read `input.json`.
2. For each (test, commit) pair, count passes and fails. Work through the runs one by one and keep a written tally; do not estimate.
3. For each test, compute `flaky_commits` (pairs with passes >= 1 and fails >= 1) and `failures` (sum of fails over all its pairs).
4. Drop tests with `flaky_commits = 0`.
5. Sort the rest by `failures` descending, then by `test` ascending (plain character order, case-sensitive).
6. Write `flaky-tests.csv` beside `input.json`.

## Output format
- Header line exactly: `test,flaky_commits,failures`
- One line per reported test: `name,flaky_commits,failures`, integers with no padding.
- Lines separated by newline, with a trailing newline; no quotes, no extra columns.
- If no test is flaky (or `runs` is empty), write only the header line.
- If a test name contains a comma, quote it per CSV rules (`"a,b"`); doubled `""` for inner quotes.

## Edge cases
- Outcomes other than `pass`/`fail`: ignore those runs and mention it in your reply.
- Missing or unparseable `input.json`: do not guess; tell the user.
- Repeated identical runs count each time (e.g. fail, fail, pass on one commit gives 2 failures and 1 flaky commit).

## Worked example
Runs: commit A: t1 fail, t1 pass, t2 fail; commit B: t1 fail, t2 fail, t2 pass, t3 fail.
- t1: A flaky (fail+pass), B fail only → flaky_commits 1, failures 2.
- t2: A fail only, B flaky → flaky_commits 1, failures 2.
- t3: fail only → omitted.

```csv
test,flaky_commits,failures
t1,1,2
t2,1,2
```
(Tie on failures, so name order.)

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

Comments

Loading comments…

Newsletter

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