Skip to content
Back to skills

Flaky Tests

ASecurity

Find flaky tests in CI run data. Use whenever the user has an input.json with a "runs" array of {commit, test, outcome} records and wants flaky-tests.csv (columns test,flaky_commits,failures), or asks which tests are flaky, unstable, or intermittently failing across repeated runs per commit. Works by hand, with no scripts.

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

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

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: Find flaky tests in CI run data. Use whenever the user has an input.json with a "runs" array of {commit, test, outcome} records and wants flaky-tests.csv (columns test,flaky_commits,failures), or asks which tests are flaky, unstable, or intermittently failing across repeated runs per commit. Works by hand, with no scripts.
---

# Flaky test report

Input: `input.json` with `runs`: array of `{commit, test, outcome}` (outcome is "pass" or "fail"). Output: `flaky-tests.csv` in the same folder as `input.json`.

## Definitions

- A test is **flaky on a commit** if, among that commit's runs of that test, there is at least one "pass" AND at least one "fail". Judge each (commit, test) pair separately. Runs are grouped by commit hash, regardless of where they appear in the array (they may be interleaved).
- A test that only fails (or only passes) on a commit is not flaky there. Consistent failure is a broken test, not a flaky one.
- A test is **reported** if it is flaky on at least one commit. Tests never flaky are omitted entirely.

## Columns

- `test`: the test name.
- `flaky_commits`: number of distinct commits on which the test is flaky.
- `failures`: total number of "fail" runs of that test across ALL commits and all runs, including commits where it was not flaky (e.g. a commit where it failed every time still counts). Count each fail record once.

## Procedure

1. Read `input.json`.
2. For each distinct test name, make a tally per commit: number of passes and number of fails. Write this out in your notes by walking the array once, record by record, so no record is skipped.
3. For each test, flaky_commits = commits with passes>0 and fails>0; failures = sum of fails over every commit.
4. Keep only tests with flaky_commits >= 1.
5. Sort rows by `failures` descending; break ties by `test` name ascending (plain alphabetical, case-sensitive character order). Do not sort by flaky_commits and do not use input order.
6. Write `flaky-tests.csv` beside `input.json`: header line `test,flaky_commits,failures`, then one row per test, comma-separated, no spaces, no quotes (unless a name contains a comma or quote), newline-separated. If no test is flaky, write only the header line.

## Check against an example

Test `ui_render`: commit A has pass+fail (flaky), commit B has only fail. flaky_commits=1, failures=2. Test `api_login`: flaky on A with one fail, passes on B: 1,1. `db_migrate` fails on A only and passes on B with no mixing: omitted. Order: ui_render (2 fails) before api_login (1 fail). Where failures tie, alphabetical: queue_drain before zip_export.

Before writing, re-verify the counts of any test with many records by recounting its fails directly from the array.

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

Comments

Loading comments…

Newsletter

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