CLI
The commands: analyze, config and report, and
four groups: matchers (what runs), registry (where matchers come
from), cache (the local copy) and mcp (coding agents). Every
command's --help ends with examples, and every listing takes
--json for scripts. A broken setup exits 1; once analysis starts,
the exit code is always 0.
Exit codes
| Exit | When |
|---|---|
1 | A broken setup, caught before analysis starts: an invalid or
missing config file, an empty matchers.include, an
unknown registry or name, a registry that cannot be reached or
serves an invalid file, bad CLI usage, a missing log file. Also
any failure of a command other than analyze
(matchers, config, report),
a crash included. |
0 | Everything else. Once analyze starts, an API error,
an LLM failure or a crash still exits 0, so the analyzer never changes
a pipeline's outcome. |
analyze
ci-doctor [-f PATH]... analyze [OPTIONS] [TARGET]
Global options (before the command, for every command):
-f, --config PATH Path to a .ci-doctor.yml. Repeatable — later files
override earlier ones.
--plain Bare text for scripts: no tables, no colour, no pager.
--no-color Disable coloured output (also honours NO_COLOR).
--log-level LEVEL debug, info (the default), warning or error, on stderr.
CI_DOCTOR_LOG_LEVEL sets it without the flag.
Arguments:
TARGET Pipeline/run id, or the path to a raw job log to replay
offline (an existing path means no run is fetched).
Options:
--job-id TEXT Analyze a single job id.
--format [terminal|json]
stdout format. `json` prints the report instead of the
rendered panels. [default: terminal]
--help Show this message and exit.
What the report looks like is on First run.
Machine-readable output
--format json puts the report on stdout instead of the
rendered panels — the same array that lands in report.json,
matching the schema on Evidence.
Everything else the command says goes to stderr, so the pipe carries the
report and nothing else.
# Everything a script or a coding agent needs, on stdout:
ci-doctor analyze --format json "$CI_PIPELINE_ID" | jq '.[0].handoff_prompt'
# Logs and progress go to stderr, so the pipe only ever carries the report.
# report.md and report.json are still written as artifacts either way.
Deterministic mode (no LLM)
# Deterministic report, no model required:
ci-doctor --config .ci-doctor.yml analyze "$CI_PIPELINE_ID"
# with llm.enabled: false (or llm.model/api_base unset)
# It prints the verdict, writes report.md + report.json, and (if configured
# and confidence >= medium) posts/updates one idempotent MR/PR note.
Inspecting your config
Config surprises are almost always a layer you forgot was applied. Ask, rather than guess — the full layering rules are on Configuration:
ci-doctor config # the effective config, every layer merged
ci-doctor config --diff # only what your file/env/flags change vs the defaults
ci-doctor config --schema # the JSON Schema, for editors and CI validation
ci-doctor config --validate # the setup dry run: exit 1 on what analyze would refuse
--validate runs every setup step analyze takes
before analysis: it loads the config, then resolves, fetches and validates
every selected matcher. It exits 1 on the first problem, so it is the step
to run when you change matchers::
$ ci-doctor config --validate
config ok: ci=gitlab, scm=gitlab, 23 matchers from 1 registries.
matchers
Chooses the matchers a project runs, and tests them. How registries and
alias/name refs work is on Matchers.
ci-doctor matchers add ALIAS/NAME... # append to matchers.include
ci-doctor matchers remove ALIAS/NAME... # drop entries from matchers.include
ci-doctor matchers list [--json] # what include resolves to, and via which bundle
ci-doctor matchers search TERM [--registry ALIAS] [--json]
ci-doctor matchers info ALIAS/NAME [--json] # description, tags, each output's role, registry, path; a bundle's members
ci-doctor matchers examine MATCHER LOG [--framing github|gitlab|plain] # what each output selects from LOG
# The global ci-doctor -f PATH adds config files to read. The commands that edit the
# config write your user config (~/.config/ci-doctor/config.yml on Linux), created if
# missing; ci-doctor --write-to FILE matchers ... writes FILE instead, and reads it too.
# Output is a table by default; ci-doctor --plain matchers ... prints one bare line per row.
Commands that change the config touch only its matchers:
block, and fetch before they write: an unknown registry or name exits 1
and leaves the file as it was. add skips a ref that is already
included, directly or through a bundle. remove drops only
entries written in include; to drop a matcher that came in
through a bundle, remove the bundle; to drop one output of a matcher, list
it under matchers.exclude.
search, info, add and
examine read registries through the same cache as
analyze. How the cache works is on Matchers.
examine runs one matcher, a matcher.yaml or an
alias/name, over one log with the same engine
analyze uses. A .github.log or
.gitlab.log has that runner's framing stripped; anything else
is read as plain unless --framing says otherwise. It prints
each output's selection, > on every anchor, with the
variants that fired, and exits 0 even when nothing matches.
Two commands are for matcher authors, run in a registry's own CI.
ROOT is the registry folder and defaults to the current
directory:
ci-doctor matchers verify [ROOT] [--only NAME[.OUTPUT]]... [--update]
[--min-positive N] [--min-negative N] [--exempt FILE] [--cross-fire] [--json FILE]
ci-doctor matchers schema [--version N | --out DIR] # a matcher file's JSON Schema; --out writes every version
verify exits 1 when an output's selection differs from its
.expected file, a variant is proven by no fixture, an output
fires on a runner's own "job failed" line, or an output has fewer fixtures
than --min-positive / --min-negative (3 and 2 by
default; --exempt names a file of matchers held to one).
--cross-fire also fails on an output firing on another
matcher's fixture, and --json writes the whole report to a file.
--update rewrites the .expected files for review.
--only checks just the matchers (NAME) or outputs
(NAME.OUTPUT) it names, with every rule, and with
--update rewrites only their files; an unknown name exits 1.
A mismatch prints a unified diff of the .expected file against
the actual selection, cut at 60 lines with the cut marked.
Writing a registry is on Hosting a registry.
registry
Where matchers come from, and building one. Removing an override of
official falls back to its default address.
registry ping never reads the cache, since it is there to test
the registry.
ci-doctor registry add NAME=LOCATION... # add or override, after fetching its index.yaml
ci-doctor registry remove NAME... # refused while include still uses it
ci-doctor registry list [--json]
ci-doctor registry ping [NAME...] [--json] # reachability, latency, matcher and bundle count
ci-doctor registry index [ROOT] [--check] # validate, then write index.yaml and the ecosystem bundles
ci-doctor registry mirror NAME DIR # copy a whole registry, hash-checked, to serve or use as a path
index is for registry authors: index --check writes
nothing and exits 1 when the committed index.yaml or a generated
ecosystem bundle is stale. mirror writes every file a registry
serves into DIR, the index last, after every file has passed its
hash check; DIR must be empty, missing, or an earlier mirror.
cache
The local copy of registry files that analyze and the
matchers commands read through.
ci-doctor cache info [--json] # where the cache is, its size, each registry's index age and files cached
ci-doctor cache prune # delete files no cached index lists (old versions of changed matchers)
ci-doctor cache clean # delete everything; the next run fetches every file again
ci-doctor cache pull [ALIAS/NAME...] # fetch into the cache without analysing; include when omitted
pull warms the cache ahead of a run (a Docker build, a CI setup
step); it exits 1 when matchers.cache is false.
mcp
ci-doctor mcp serves ci-doctor to a coding agent over
MCP, on stdio. The agent is the
model: analyze_run returns each failed
job's settled phase and redacted evidence, and the agent writes the explanation,
so the llm: block is ignored.
ci-doctor agent install connects it to Claude Code, Cursor, Codex CLI,
opencode, Hermes Agent, Gemini CLI, Antigravity, Kiro and pi (which needs its
pi-mcp-adapter extension for MCP). For each it writes the MCP
server entry and a short instructions block, and for Claude Code it auto-allows the
read-only tools. local (the default) writes this project's files;
global writes yours. Running it again changes nothing, and
--dry-run shows each file and the config it would add, writing nothing.
Run with no flags in a terminal, it asks instead: which agents (detected ones
ticked), this project or all of them, and whether to auto-allow the read-only
tools in Claude Code, then lists the files and asks before writing them. With
flags, or from a script, it writes without asking; --dry-run shows
what it would write first.
agent uninstall removes ci-doctor's entries and any container they
leave empty; an agent's JSON config file is never deleted. Run with no flags in a
terminal, it lists the files and asks first; with flags, or from a script, it
removes without asking. A file it cannot edit
safely is left alone, and the config is printed to add by hand.
ci-doctor mcp [--project DIR] # the server itself, which agents start
ci-doctor agent install [--target auto|all|claude,cursor,...] [--location local|global]
[--no-permissions] [--dry-run]
ci-doctor agent uninstall [--target ...] [--location ...]
| Tool | Does |
|---|---|
list_runs | Lists the project's runs, newest first, with filters. |
analyze_run | Briefs each failed job of a pipeline/run. |
search_matchers | Finds matchers and bundles in the configured registries. |
list_matchers | Shows what the config selects, and via which bundle. |
add_matchers | Adds entries to matchers.include. |
remove_matchers | Drops entries from matchers.include. |
check_setup | Validates the config and loads every selected matcher. |
The two edit tools write only the matchers: block, to
./.ci-doctor.yml unless --write-to names another file.
Nothing else is written: no report files, no MR/PR note.
Reporting a bug
ci-doctor report prints what an issue needs: the ci-doctor, Python and
dependency versions, the installed LLM SDKs, the platform, a summary of the config,
and which proxy and CA variables are set. Paste it into the issue. It holds no
secrets: environment variables show as set or unset, and config files and
endpoints are named, not shown. Pass the same -f files you run with.
Logs: --log-level
Logs go to stderr, so the report on stdout stays clean to pipe. At the
default level, info, a run prints one line per stage: the
config, the matchers loaded, the blamed phase and the rule that settled it,
how much evidence was kept, and how the report was written. No line ever
contains log content, only names, counts and times.
ci-doctor analyze failing-job.log
INFO config: ci gitlab, git host gitlab
INFO matchers: 102 loaded from official in 0.2s
INFO analyzing 1 job(s) from failing-job.log
INFO job failing-job: blamed the script phase (reason script_failure, rule trailer_exit_code, confidence high)
INFO job failing-job: evidence kept 140 of 812 lines, 3 matcher output(s) fired
INFO job failing-job: deterministic report (no LLM configured)
--log-level debug adds the rest: each registry file fetched or
taken from the cache, the section count, and a denoise → extract → fit
line, the one to read when the evidence looks wrong, with how many lines each
stage kept and whether the token budget had to truncate.
CI_DOCTOR_LOG_LEVEL=debug does the same without the flag, for a CI
job you'd rather not edit; the flag wins over it. warning keeps
only problems.
matchers.registries at a
local folder to replay with no network at all.