-
-
Notifications
You must be signed in to change notification settings - Fork 0
Guard command
commitbrief guard evaluates a review's actionable findings against a
declarative policy (.commitbrief/policy.yml) and exits non-zero when the
policy is breached. It is a richer alternative to the single
--fail-on=<severity> threshold — a per-severity budget — and is aimed at
gating high-volume, often AI-authored pull requests at scale. It pairs with the
MCP server: an agent self-reviews via the review tool, and
guard enforces the bar in CI.
Introduced in v1.10.0 (ADR-0029). Opt-in and additive — it changes nothing
about the existing commands or --fail-on.
.commitbrief/policy.yml — the gate is opt-in: with no file, guard errors
(it never silently passes). Unknown keys are rejected so a typo can't disable the
gate.
version: 1
thresholds: # maximum findings allowed per severity
critical: 0
high: 0
medium: 5
low: ~ # ~ (or omitted) = unlimited
total: 20 # optional overall cap on actionable findingsSeverities are the canonical five (critical, high, medium, low, info).
A severity that is absent — or set to ~ — is unlimited.
Run-mode (default) reviews the diff and evaluates the result. It reuses the
exact review pipeline (runReview) — diff acquisition, filtering, the pre-send
guard + secret scan, cost preflight, cache, the flaky pre-pass, and signal
control — with no --fail-on set, because the policy decides the verdict.
commitbrief guard # staged diff (default)
commitbrief guard --unstaged # working tree
commitbrief guard --diff main...HEADProvider/model/flaky knobs come from the persistent flags
(--provider, --model, --no-flaky).
Consume-mode (--from-json) evaluates a review you already produced —
no provider call. Ideal for gating an agent's self-review (the MCP review
tool's JSON) cheaply in CI:
commitbrief --json --staged > review.json
commitbrief guard --from-json review.json
commitbrief guard --from-json - # read the JSON from stdinguard evaluates the findings that survive baseline + inline suppression
(signal control) — exactly the set that
commitbrief --json emits and that a human reviewer sees. Baselined and
suppressed findings do not count toward the gate.
| Exit | Meaning |
|---|---|
0 |
pass — every threshold (and the total cap) is within budget |
| non-zero | blocked — a threshold was exceeded, or the policy/review could not be loaded or parsed |
A load/parse failure blocks deliberately: a merge gate must not pass when it cannot prove the change is within policy.
By default guard prints a human summary (the verdict, each breached severity,
and the per-severity counts). With --json it emits a machine verdict:
{
"passed": false,
"counts": { "critical": 1, "high": 0, "medium": 8, "low": 3, "info": 0 },
"total": 12,
"violations": [
{ "severity": "critical", "allowed": 0, "actual": 1 },
{ "severity": "medium", "allowed": 5, "actual": 8 }
]
}--fail-on=<severity> is a single all-or-nothing threshold (fail if any finding
meets or exceeds one level). guard is a declarative, version-controlled,
per-severity budget that can also consume a prior review's JSON. They are
independent — use either or both.
| Flag | Default | Meaning |
|---|---|---|
--policy <path> |
.commitbrief/policy.yml |
policy file (resolved relative to the repo root) |
--from-json <file|-> |
— | consume-mode: evaluate a prior schema-v1 review instead of running one |
--unstaged |
false | run-mode: review the working tree instead of the staged index |
--diff <range> |
— | run-mode: review an arbitrary git diff range (repeatable) |
Rule-id-scoped allow/deny lists are not supported: findings carry no stable rule identifier (they are free-form model output), so a name-based list would be unreliable. That awaits a finding rule-id field.
-
Review (default command) — the pipeline
guardruns in run-mode, including signal control. -
MCP server — the
reviewtool whose JSONguard --from-jsonconsumes. -
--fail-onand exit codes — the simpler one-threshold gate.
Home · Installation · Quick start · Troubleshooting · GitHub repo · Issues
CommitBrief — local, LLM-powered code review for git diffs. This wiki documents only what ships in the binary.
Getting started
Commands · reviewing
Commands · summarizing
Commands · committing
Commands · setup
Commands · integration
Commands · inspect
Commands · maintenance
Configuration
Providers
Output
Operations
Reference