cagr

cagr checks what a coding agent does (its commands, edits, stops and pull requests) and makes it run and obey your linters. One cagr.toml sets the guardrails for Claude Code, Codex and, through git hooks, any other agent or human. It denies slips before they happen (the wrong package manager, a push to main, an edit to .env, --no-verify), runs your formatters, linters and code rules after each edit, keeps the agent from finishing while your checks fail, and gates pull requests on a review by a reviewer agent in a fresh context. Every block message says what to do instead, so the agent fixes the slip on its next try.

Quick start

# Install the binary (macOS, Linux)
curl -fsSL https://github.com/krtinshet/cagr/releases/latest/download/install.sh | sh
# or add it to a JavaScript repo
bun add -d @krtinshet/cagr        # or: npm i -D @krtinshet/cagr

# Set up a repo
cd your-repo
cagr init              # detects your stacks, writes cagr.toml and the hook files
cagr doctor            # checks the wiring, the tools, and how long each hook takes

Commit cagr.toml, .claude/settings.json, .codex/hooks.json and .githooks/. Codex asks you to trust project hooks once: open Codex in the repo and approve them with /hooks. The getting started page has the details.

A first config

extends = ["recommended"]

[git]
protected_branch = "main"

[[stack]]
language = "typescript"
package_manager = "bun"
paths = ["**"]
on_edit = ["biome check --write {files}"]
on_turn_end = ["bun run lint", "bunx tsc --noEmit"]

[[commands.blocked]]
match = "prisma db push"
reason = "Use `bun run db:migrate --name <change>`."

After you change the config, run cagr sync to rewrite the hook files. Every key is in configuration.

Pages

  • How cagr differs: what cagr checks that linters cannot, and how it compares with pre-commit hooks, CI, AGENTS.md, hand-written hooks, review bots and sandboxes.
  • Getting started: install, cagr init, cagr doctor, the files to commit, and the Codex trust step.
  • Configuration: every key in cagr.toml, presets and extends, placeholders, cagr sync, and the JSON schema.
  • Guards: every built-in guard, what it blocks, its message, and how to configure or turn it off.
  • Hooks and events: the five events, how Claude Code and Codex map onto them, time budgets, fail-open, and the git hooks.
  • Code rules: ast-grep rules in .cagr/rules/*.yml, cagr rules test, cagr check and cagr explain.
  • Review: cagr review, effort levels, findings, rounds, answers, stats, evals, the PR gate, the review guide and risk tiers.
  • CI: cagr ci, cagr review --ci, the generated workflow, PR template and CODEOWNERS, and cagr doctor --github.
  • CLI reference: every command and flag.
  • Limits and troubleshooting: what cagr is not, and what to do when something goes wrong.
  • Releasing: how a new version gets to GitHub and npm, for maintainers.

Source on GitHub. Package on npm. MIT license.


MIT license. Copyright 2026 Krtin Shet.