ci-triage
CI is red. Which failure matters, and is it a real regression or just flaky?
ci-triage answers that in one page: it fetches a repo's recent failed GitHub Actions runs, reads the failed job logs, groups failures by root cause, and tells you which ones are real regressions and which are flaky — so you fix the one thing that matters instead of reading thousands of log lines by hand.
Before / after
Before: CI is red on 3 runs. You open each run, find the failed job, scroll through the log, and try to remember whether you saw this error yesterday.
After:
$ ci-triage acme/widgets
ci-triage — acme/widgets
Window: 2 recent runs listed, 2 failed examined
Root causes: 1 (1 real, 0 flaky)
#1 test · 2 runs · real regression
FAIL src/components/Button.test.tsx
3 test-runner failure signals in the error lines. fails on every recent run — looks like a real regression, not flakiness.
first seen 2026-11-12 10:00 · last seen 2026-11-12 14:03
runs: #2 (test), #1 (test)
evidence:
FAIL src/components/Button.test.tsx
● Button › renders the disabled state
expect(received).toBe(expected) // Object.is equality
Overall: 1 root cause — 1 real regression, 0 flaky
One root cause, two runs, real regression, with the failing test named. That is the whole triage.
Install
npm install -g ci-triage-cli
Requires Node 22 or newer. No other dependencies — pure Node.js standard library.
Rather not install it by hand? Paste this to your coding agent: "Install ci-triage (npm install -g ci-triage-cli if it's not on PATH), then run ci-triage --skill-generate so you triage red CI before reading any log."
Use
ci-triage <owner/repo> # triage the last 10 failed runs
ci-triage acme/widgets --runs 3 # fewer runs, faster
ci-triage acme/widgets --workflow ci.yml --branch main
ci-triage acme/widgets --json # machine-readable output
ci-triage acme/widgets --top 3 # show only the top 3 root causes
ci-triage acme/widgets --report triage.md # Markdown report to paste into a PR, an issue, or an agent chat
ci-triage acme/widgets --annotations # also emit ::error:: / ::warning:: annotations for GitHub Actions
--report writes the same Markdown the GitHub Action puts in the Step Summary — the ranked report, not machine JSON — so the file, the summary, and the terminal output never disagree. Under --json the confirmation goes to stderr, so stdout stays parseable. --annotations does the same job for the run's annotations panel: one workflow-command line per root cause (::error:: for a real regression, ::warning:: for flaky or unknown), capped at 10 per level — GitHub's own limit. When the log names the failing file with a line (src/utils/format.ts:18:7, a Jest stack frame), the annotation is pinned to that file and line, so it also shows in the PR's changed-files view, one click from the code; a bare filename, an absolute runner path, or a node_modules frame stays unpinned rather than pointing at the wrong file. Under --json the lines go to stderr, so stdout stays parseable.
Exit codes: 0 when no failed job turned up, or when every failure in the window is a recorded known failure; 1 when failures were found (including failures whose logs could not be read — the repo is not clean), 2 for a usage error or an API error.
Known failures
A failure the team already knows about and is living with should not re-alert as a real regression on every triage — it drowns the new regressions. Record it once, then triage against the record:
ci-triage acme/widgets --write-known .ci-triage-known-failures.json
ci-triage acme/widgets --known .ci-triage-known-failures.json
--write-known records the current clusters and merges with entries already in the file; --known marks the clusters the file covers as known failures instead of new regressions. Matching is by failure signature, so a known failure stays known when it moves to another workflow. The file holds signature hashes and headlines only, so it is safe to commit. A recorded failure that stops appearing is listed as "not seen in this window (possibly fixed)" — remove it from the file if it is fixed. The method is Playwright's test.fail(): a known bug that is still exercised, expected to fail, and noticed when it stops failing. In the Action, a triage with only known failures passes the step instead of failing it.
Shell completion for bash, zsh and fish: ci-triage completion bash prints a completion script generated from the same option list the CLI parses, so it can never suggest a flag the CLI rejects. Install it with, e.g. ci-triage completion bash > ~/.bash_completion.d/ci-triage, or source <(ci-triage completion bash) for a one-off session. Mistyped a flag anyway? The CLI suggests the closest match (Did you mean ...?) instead of a bare error.
Auth — read this first
Set GH_TOKEN (or GITHUB_TOKEN). Without a token the triage can list the failed runs and jobs, but it cannot download their logs: GitHub does not allow anonymous job-log downloads, even for public repos. The first refused download stops the rest — the refusal applies to every job, so the triage lists all the failed jobs with the same reason instead of spending the anonymous budget on downloads known to fail. Without a token you get an honest report instead of a triage:
No clusters: 9 failed jobs found, but their logs could not be read.
Failed jobs #41–#49 · 2026-11-14 12:03 – 2026-11-15 08:41
Reason: downloading this job log needs a GitHub token (403) — GitHub does not allow anonymous log downloads; set GH_TOKEN or run `gh auth login`
Overall: UNKNOWN — 9 failed jobs found, logs unreadable
With a token you get 5,000 API requests per hour. gh auth login works too when the GitHub CLI is logged in.
ci-triage doctor checks the setup itself before you triage anything: Node version, ci-triage on PATH, the home directory --skill-generate writes into, installed skills (and whether their frontmatter is valid — a broken one silently never triggers), whether a token is available, and whether the GitHub API answers (one cheap call, which also reports the rate-limit budget left this hour). It is read-only — it changes nothing — and every failure comes with a copy-paste fix. Warnings are for optional wiring (a missing skill, no token, an unreachable API); only failures make it exit 1. --json gives the same checklist as data. The method is Claude Code's claude doctor: one command that answers "is my setup healthy?" instead of debugging each piece by hand.
How it decides
- Signature: the error lines of a failed job, with timestamps, ANSI codes, file paths, hashes, versions and counts stripped — so the same failure on two runs has the same signature even when the paths and timings differ.
- Clustering: failures with the same signature are one root cause, ranked by how many runs they hit.
- Classification: each cluster is a test failure, a build failure, or an infra failure (timeouts and the like), from the error lines themselves.
- Flaky vs real: a cluster is flaky when the same commit passed on a later run, or when failures and successes alternate in the window. Failing on every recent run is a real regression.
- Known failures: a cluster whose signature is recorded in a known-failures file (
--known) is reported as a known failure, not a new regression. A triage with only known failures exits 0.
- Regression window: a real regression names the last green run and the first red one ("broke between #1 (ccc0000) and #2 (aaa0000)");
git log <green>..<red> lists the suspect commits. The method is git bisect's — the good and bad endpoints — answered from the run history instead of a binary search, since CI already ran every commit's build. The report also lists the files that changed between those two commits (GitHub's compare endpoint, capped at 10 with a count of the rest), so the fix starts from the suspect files, not just the suspect range; a compare that fails leaves the window line as it was. A flaky failure has no window; when no passing run precedes the first failure, the report says the regression predates the runs listed.
Logs expire: GitHub keeps job logs for 90 days. A failed job whose log is gone is recorded, not fatal.
For agents
ci-triage --mcp # stdio MCP server: triage_repo, triage_log
ci-triage --skill-generate # write a SKILL.md for this project (never overwrites) and a short section in AGENTS.md
ci-triage --skill-generate --agents # same skill, in .agents/skills/ — the shared location Gemini CLI and Codex discover skills from
triage_log classifies a pasted log without touching the network — useful when you already have the log open. Both tools return the same JSON the CLI's --json produces, as the text block and again as structuredContent, the MCP structured-output channel (each tool declares a loose outputSchema: { type: 'object' }; error results carry none), so a calling application can read the fields typed instead of parsing the text.
The MCP server also serves one prompt, triage_ci (prompts/list / prompts/get): the one-shot "what broke in CI and what do I fix first?" workflow — call triage_repo with the repo (and workflow, if given), report the root causes ranked real regressions first, then flaky, then unknown, then known failures, and do not re-run or fix anything without the user agreeing — for MCP clients that let the user pick a prompt instead of typing a request. The method is FastMCP's: prompts are the third MCP primitive, the user-invoked template next to tools and resources. triage_repo also takes knownFile: a known-failures file to mark recorded clusters as known instead of new regressions.
Claude Code users can install the skill without installing the CLI first: /plugin marketplace add WJDdidi-1/ci-triage, then /plugin install ci-triage@ci-triage. The skill lives in this repo at skills/ci-triage/SKILL.md, so skill indexes can find it too.
Claude Desktop: the repo ships a manifest.json (MCPB, the renamed DXT format) — pack it with npx @anthropic-ai/mcpb pack and drag the .mcpb file onto Settings → Extensions. The bundle is just the server (zero dependencies, so there are no node_modules to bundle), and .mcpbignore keeps tests and tooling out of it.
GitHub Action
Use it from a workflow (it needs a token with actions:read on the repo; the workflow's own GITHUB_TOKEN can read its own repo's runs):
jobs:
triage:
runs-on: ubuntu-latest
steps:
- uses: WJDdidi-1/ci-triage@main
with:
repo: ${{ github.repository }}
runs: 10
The action fails the job when it finds root causes, so the triage report lands in the log and in the run's Step Summary. Add --annotations to surface each root cause on the run's annotations panel too — one ::error:: per real regression, ::warning:: for flaky, unknown, or known — so the cause is visible without opening the log at all. It needs no token and no file, and it works on fork PRs, where the Checks API cannot write; the same trick reviewdog's github-annotations reporter uses. Locally it is a no-op: the lines only become annotations when a step runs in GitHub Actions.
How fast is it
On a real repo with 3 failed runs and 9 failed jobs, the triage took about 8 seconds wall-clock — against opening 9 job logs by hand and reading them. The clustering and classification themselves run in milliseconds; the time is the GitHub API round-trips.
Development
npm test # node:test, no extra dependencies, run serially
node scripts/bump-version.mjs <version> # bump every version pin at once
Coverage uses Node's built-in runner (Node 22+ only — the suite itself runs on Node 22+): node --test --test-concurrency=1 --experimental-test-coverage --test-coverage-include='lib/**/*.mjs' --test-coverage-include='bin/*.js'. The method is vitest's --coverage: measure first, then test the gaps the measurement shows, and leave the defensive paths uncovered on purpose rather than chasing the number.
Releases bump the version with node scripts/bump-version.mjs <version>: it moves every version pin at once — package.json, package-lock.json, server.json and the marketplace metadata — renames the CHANGELOG's ## Unreleased heading, and refuses a drifted tree before writing anything. The method is semantic-release's (one mechanical writer of version strings), without adopting semantic-release itself. The script is shared with dev-diagnosis: files a repo does not have (pre-commit manifest, demo tape) are skipped.
Troubleshooting
- "needs a GitHub token (403)" — set
GH_TOKEN. See Auth.
- "could not reach the GitHub API" — the API is unreachable from here (network or proxy); check connectivity and try again. The triage never reports a clean bill of health when it could not check.
- A failed job's log is gone — GitHub keeps logs 90 days; the job is listed with its reason and the rest of the triage goes on.
npx ci-triage-cli says "ci-triage: not found" inside this repo's own checkout — npm resolves the local package instead of the installed one. Run it from outside the checkout, use node bin/ci-triage.js, or npm link first.
License
Apache-2.0.