A gate that only ever passes looks exactly like a gate that cannot fail. ci-kit is a set of CI
checks and PR-automation tools built around that one problem: every gate ships with a must-fire
suite that runs it on real git repositories against a known-bad input, a known-good input, and
one it cannot read, and the suite is part of the kit's own CI.
It is one Python package (ci_kit, zero runtime dependencies, Python 3.11+), exposed four ways: a
composite GitHub Action, reusable workflows, console scripts you can run with uvx, and
pre-commit hooks. Nothing in it knows about your repository; every path, threshold and baseline is
an argument you pass.
| Capability |
What it gives you |
| Gates |
30+ checks across docs, secrets, code shape, structure, SQL and supply chain: doc references that went dead, secrets on a command line, invisible Unicode, new code clones, modules no test reaches, SQL outside the repository layer, OpenAPI breaking changes, and more. |
| Shrink-only ratchets |
Adopt a gate on a messy codebase today. The current debt is frozen in a baseline that can only shrink, so nothing new gets in while the old debt is paid down. |
| PR operations |
A serial PR queue, a merge train that tests N armed PRs once and lands them as N commits with bisect-on-red, and a heal ladder that fixes a red or conflicted PR cheapest-first, from a rerun up to a sandboxed agent. It works with strict branch protection, on a personal account, without a paid merge-queue service. |
| Pre-merge review gate |
A model code review that runs as a required check, so auto-merge waits for the verdict instead of racing it. Two transports (an API key, or a Claude Code subscription over MCP), a tiering policy, and a verdict carried over an unchanged diff. |
| GitHub Apps |
Declare each GitHub App your automation acts as (permissions, events, installed repositories) in a reviewed manifest, and turn any change made on GitHub's settings pages into a red scheduled run. |
| Runner capacity |
Self-hosted runner sizing as a library: schema-checked capacity files, host, guest and runner memory budgets against measured peaks, one JSON render per runner block, and the admission rule a supervisor runs. |
| Library |
The parsers, discovery, site-lint and ratchet primitives the gates are built on, for writing your own gate with the same exit contract. |
Also included: a shared Renovate preset (one line in a consumer's
renovate.json), and 21 reusable workflows, each documented
with every input and a caller stanza.
Run a gate locally, no install:
uvx --from git+https://github.com/mjdevaccount/ci-kit@v1.51.0 ci-doc-lint
Call a reusable workflow from your CI:
jobs:
doc-refs:
uses: mjdevaccount/ci-kit/.github/workflows/doc-refs.yml@v1
gitleaks:
name: gitleaks (secret scan)
permissions: { contents: read }
uses: mjdevaccount/ci-kit/.github/workflows/gitleaks.yml@v1
with: { mode: tree }
Run any console script as a step with the composite action:
- uses: actions/checkout@v4
- uses: mjdevaccount/ci-kit@v1
with:
tool: ci-line-cap
args: --dir src --cap 400 --baseline ci/line_cap_baseline.txt
Add pre-commit hooks (doc-refs, secret-argv, hidden-unicode, dup-code):
repos:
- repo: https://github.com/mjdevaccount/ci-kit
rev: v1.51.0
hooks:
- id: hidden-unicode
Pin workflows and the action to @v1, the moving major, and the library to an immutable
vX.Y.Z tag (versioning). Every way to run a gate is compared in
architecture.
- Three exits, never two. Every tool exits
0 clean, 1 findings, or 2 did not finish
looking. A crashed detector that exits 0 reads as healthy to every caller, and a gate that
scanned nothing has verified nothing, so 2 is never folded into the others
(the exit contract).
- Proven to fire. Each gate has a
selftest and a must-fire suite: bad input → 1, good
input → 0, unreadable input → 2, on real git repositories rather than mocks
(a guard must be able to fire).
- Adoptable on day one. Ratchet gates freeze today's count per file in a baseline that may
shrink and never grow.
- No assumptions about your repo. Paths, thresholds, seams and baselines are arguments. Domain
specifics live in the caller's args files, not in the kit
(nothing is assumed).
- Dependencies are opt-in. The base package has none; heavier gates sit behind extras (
sql,
workflow, cog, runners, review)
(extras).
- Pinned supply chain. Release binaries such as gitleaks and jscpd are pinned by sha256, and the action installs
exactly the source its ref points at.
Every console script, grouped by concern. Each links to its page in docs/.
Documentation (3)
| script |
what it checks or does |
docs |
ci-doc-lint |
a path a doc names existed and is gone (count fell from positive to zero) |
gates/docs |
ci-manual-lint |
every path an agent manual (CLAUDE.md) names resolves today |
gates/docs |
ci-cog |
every cog-generated fact matches what its generator renders now (cog extra) |
gates/docs |
Secrets and hidden content (5)
| script |
what it checks or does |
docs |
ci-secret-argv-lint |
no secret expanded on the host into a docker exec / curl / ssh argv |
gates/secrets |
ci-gitleaks |
secret scan (tree, history or range), gitleaks pinned by sha256 |
gates/secrets |
ci-hidden-unicode |
no invisible, bidi or control character in a tracked text file |
gates/secrets |
ci-declared-literal |
a literal that must live in one declared file appears nowhere else |
gates/secrets |
ci-consumer-words |
no file under the given paths names a word on the caller's digest deny-list |
gates/secrets |
Code-shape ratchets (14)
| script |
what it checks or does |
docs |
ci-line-cap |
no new module over the line cap; one already over may not grow |
gates/ratchets |
ci-function-clones |
no new function that is a structural twin of one in another file |
gates/ratchets |
ci-dup-code |
no new token-level code clone (jscpd) |
gates/ratchets |
ci-test-standins |
no new signature-blind test stand-in |
gates/ratchets |
ci-untested-modules |
no new source module that no test references |
gates/ratchets |
ci-guards-have-tests |
every guard script is named by a test, outside prose |
gates/ratchets |
ci-http-clients |
no new hand-built HTTP client outside the declared seam |
gates/ratchets |
ci-sql-placement |
no new SQL outside the repository layer (sql extra) |
gates/ratchets |
ci-env-reads |
no shell script pulls a key out of a .env file with a hand pipeline |
gates/ratchets |
ci-py-env-reads |
raw os.environ / os.getenv reads in python may not grow outside the config surface |
gates/ratchets |
ci-unread-fields |
a declared config field nothing reads may not be added |
gates/ratchets |
ci-dep-closure |
each image stage's uv.lock dependency closure (dist set, wheel bytes) equals its baseline (lock extra) |
gates/ratchets |
ci-guard-selfproof |
every guard script proves it can fail (selftest()) |
gates/ratchets |
ci-scaffold-coverage |
no new gate script hand-rolls its CLI instead of site_lint.run / check |
gates/ratchets |
Structure and contracts (10)
| script |
what it checks or does |
docs |
ci-blind-parse |
no parse-failure handler answers with a clean file's value |
gates/structure |
ci-quarantine |
every quarantined test carries a reason, an issue and an unexpired date |
gates/structure |
ci-gate-lint |
a job that can skip funnels into one always-run aggregate; --callers: a reusable's caller grants the permissions it declares (workflow extra) |
gates/structure |
ci-setup-uv |
every astral-sh/setup-uv step installs one exact, Renovate-annotated uv from GitHub Releases, never latest (workflow extra) |
gates/structure |
ci-api-diff |
a committed OpenAPI contract may grow, never break (oasdiff) |
gates/structure |
ci-mcp-contract |
an MCP server's tools/list equals its committed snapshot, and every tool is described and annotated (pinned MCP Inspector CLI) |
gates/structure |
ci-image-pr-filter |
every Dockerfile COPY is listed in the image PR build's paths-filter (workflow extra) |
gates/structure |
ci-migration-open-prs |
a migration number is not already taken on the base or by an older open PR |
gates/structure |
ci-stage-imports |
every import an image stage's entrypoints can reach, function scope included, is installed in that stage (lock extra; --installed is stdlib-only) |
gates/structure |
ci-claude-permissions |
a Claude Code permissions.deny list denies every listed destructive command and no routine one |
gates/structure |
SQL (`sql` extra) (5)
| script |
what it checks or does |
docs |
ci-sql-casts |
asyncpg bind/cast footguns in embedded SQL (sql extra) |
gates/sql |
ci-pit-reads |
SQL wall-clock reads (now(), current_date) (sql extra) |
gates/sql |
ci-decimal-reads |
a NUMERIC column projected without a cast (sql extra) |
gates/sql |
ci-phantom-columns |
a statement naming a column its table lacks (sql extra) |
gates/sql |
ci-column-comments |
a column comment that declares a domain has a CHECK enforcing it (sql extra) |
gates/sql |
Supply chain and CI health (4)
| script |
what it checks or does |
docs |
ci-pin-drift |
every exact pin of a kit is its newest release tag |
gates/supply-chain |
ci-green |
fast-forward a ci-green branch to the commit CI just passed |
gates/supply-chain |
ci-tf-seed |
fill terraform's provider cache from the lock file, off GitHub's download path |
gates/supply-chain |
ci-queue-wait |
p90 time a workflow's runs waited for a runner, over a limit |
gates/supply-chain |
Releases (1)
| script |
what it checks or does |
docs |
ci-version-tag |
every version bump gets its tag, every tag its release |
versioning |
PR operations (2)
| script |
what it checks or does |
docs |
ci-pr-autoupdate |
merge main into armed PRs: serial queue, scheduler, queue hold, retries |
pr-ops/autoupdate |
ci-merge-train |
test N armed PRs once on one tree, land them as N commits |
pr-ops/merge-train |
Runner capacity (1)
| script |
what it checks or does |
docs |
ci-runners |
self-hosted runner capacity: schema, budgets, renders, admission (runners extra) |
runners |
GitHub Apps and repository settings (3)
| script |
what it checks or does |
docs |
ci-app-audit |
each declared GitHub App's permissions, events and installations match live (apps extra) |
github-apps |
ci-pr-token-check |
the pr-token record lines in a log or annotation dump parse and are clean |
github-apps |
ci-repo-settings-audit |
every repository of an account is declared and its security settings (secret scanning, Dependabot alerts, CodeQL, immutable releases, ...) match live (apps extra) |
repo-settings |
ci-attest-verify |
a uv.lock's git pins are releases their producer ATTESTED (SLSA provenance, gh attestation verify) from the very commit the lock installs |
attest-verify.md |
Review gate (`review` extra) (6)
| script |
what it checks or does |
docs |
ci-review-tier |
review gate: who is reviewed and why (review extra) |
review-gate |
ci-review-agent |
review gate: the api transport (review extra) |
review-gate |
ci-review-claude |
review gate: the subscription transport (review extra) |
review-gate |
ci-review-verdict |
review gate: the verdict policy (review extra) |
review-gate |
ci-review-carry |
review gate: a verdict carried over an unchanged own diff (review extra) |
review-gate |
ci-review-train |
review gate: a merge train verified instead of re-reviewed (review extra) |
review-gate |
| Start here |
|
| Architecture |
How the kit is put together: the four ways to run a gate, the exit contract, ratchets, extras |
| Gates |
One page per concern, every flag and example |
| PR operations |
Autoupdate, merge train, heal ladder, push token |
| Review gate |
Policy, transports, the caller stanza |
| Runner capacity |
The capacity file, the kit file, the CLI, admission |
| GitHub Apps |
An App's permissions and installations declared and audited against live; reading the pr-token record |
| Reusable workflows |
Every input of every workflow |
| Versioning |
Tags, the moving major, release policy |
| Contributing |
Adding a gate: selftest, must-fire suite, docs |
MIT