Why did CI fail, and is it flaky? One command for GitHub Actions. Zero dependencies, uses the gh CLI you already have.
- Finds the real error. Downloads the raw job log, strips ANSI codes and timestamps, and keeps only the error region:
##[error],Error:,FAIL,not ok, tracebacks, panics, exit codes. - Reads Node test runner output. Shows the failing TAP subtest and the
# ...diagnostic lines the process printed near it, whichgh run view --log-failedoften hides. - Checks every attempt. A job that failed and then passed on re-run is still found.
- Flaky verdict.
flakyif the job passed on a later attempt or on another run of the same commit,new failureif it passed on the previous default branch run, otherwiseunknown. - Re-run and wait.
--rerunre-runs the failed jobs and tells you if they pass this time.
npx @virling/ciwhy
Or npm install -g @virling/ciwhy to get ciwhy on your PATH.
$ ciwhy 45871759993 --repo virling/agentmem
virling/agentmem test run 45871759993 main 93de02f 2 attempts, success
https://github.com/virling/agentmem/actions/runs/45871759993
FAILED test (macos-latest, 18) attempt 1 step: Run npm test
flaky: passed on attempt 2 of this run
https://github.com/virling/agentmem/actions/runs/45871759993/job/140088664991
# warning: --depth is ignored in local clones; use file:// instead.
# agentmem: spawnSync tar ENOTCONN
--
not ok 11 - guard-check cannot be bypassed by removing the guard, renaming, or unusual names
location: 'file:///Users/runner/work/agentmem/agentmem/test/features.test.js:108:1'
failureType: 'testCodeFailure'
error: |-
The input did not match the regular expression /error: src\/gen\/client\.ts/. Input:
''
code: 'ERR_ASSERTION'
...
--
##[error]Process completed with exit code 1.
ciwhy latest failed run on the current branch
ciwhy <run-id|run-url> a specific run (every attempt is checked)
ciwhy --pr <number> latest failed run on the pull request's head commit
ciwhy --branch <name> latest failed run on a branch
--repo owner/name repository (default: the repo in the current folder)
--rerun re-run the failed jobs, wait, and report if they pass
--timeout <minutes> how long --rerun waits (default 30)
--json machine-readable output
--markdown Markdown report, as posted on pull requests by the GitHub Action
--help
Exit code is 0 after a report, even when jobs failed. It is non-zero only for usage errors (2) or gh errors (1).
When CI fails on a pull request, virling/ciwhy@v0 posts the report as a comment on the PR, and updates the same comment on later failures. The report also goes to the job summary.
For pull requests from branches in the same repository, add a job after your tests:
ciwhy: needs: test if: failure() && github.event_name == 'pull_request' runs-on: ubuntu-latest permissions: actions: read pull-requests: write steps: - uses: virling/ciwhy@v0
Pull requests from forks get a read-only token, so they cannot comment. Use a separate workflow that runs after CI instead:
name: ciwhy on: workflow_run: workflows: [test] types: [completed] jobs: ciwhy: if: github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.event == 'pull_request' runs-on: ubuntu-latest permissions: actions: read pull-requests: write steps: - uses: virling/ciwhy@v0
Inputs, all optional:
run-id: the run to explain. Default: the run that triggeredworkflow_run, otherwise the current run.github-token: default${{ github.token }}.comment:falseto only write the job summary. Defaulttrue.
- Node.js 20 or newer
- GitHub CLI (
gh), authenticated withgh auth login
- agentmem: project memory for AI coding agents, shared across Claude Code, Cursor, Codex and other MCP clients.
- ccdoctor: checks your Claude Code setup: hooks, MCP servers and plugins that are registered but not working.
- npmship: releases an npm package and verifies it landed on npm, in CI and on GitHub.
- subagents: reviews what Claude Code subagents did in a session and flags repeated or wasted work.