Guardrails, a hard budget cap, and a self-fixing PR loop for your AI coding agent.
eval-gated guardrails 100/100 Β· a budget cap that actually halts Β· you always merge
the guided tour β live demos, clickable architecture, one-click install
Real session, no edits: the cost climbs to $0.35, then the next action is HALTED at the $0.05 cap β before it spends more.
compass is a local-first config layer for Claude Code, Codex & Gemini that stops your agent from doing three things it shouldn't β burning your budget, running unsafe commands, and merging unverified code. Set COMPASS_MAX_USD=5 and the session hard-stops at the cap; catastrophic commands are blocked before they run β and the guardrail policy is scored 100/100 in CI against a labeled corpus, not asserted. You install it once, and you always merge.
# no curl|sh, fully reversible β then just open any repo in your agent
git clone https://github.com/dshakes/compass ~/compass && cd ~/compass && ./quickstart.sh
# or, inside Claude Code: /plugin marketplace add dshakes/compassπ Site Β Β·Β Why it's different Β Β·Β The self-fixing PR loop Β Β·Β Loops Β Β·Β Install Β Β·Β What's in the box Β Β·Β π Docs
Open a PR and compass reviews it, security-checks it, runs the tests, cross-audits it with two more models β three cross-model gates (Claude review Β· Codex audit Β· Gemini audit) β then pushes its own fixes until it's green. You merge. β That's a real PR β every event above is inspectable.
The idea in one line: the loop is the unit of work. A one-shot agent stops at its first wrong answer. compass loops β generate β test β critique β fix β repeat against a gate β so quality comes from iteration, not one lucky prompt. β how the loop works Β· the thesis
Every AI-agent config claims "safe" and "cheap." compass is the one that hands you the number β and lets a skeptic reproduce it in 30 seconds. Everyone has the same models; the edge is configuration you can trust. Five claims, five commands:
π‘ Guardrails with a score. Catastrophic commands and secret writes are blocked before they run β and the policy is eval-gated in CI, not asserted.
compass bench # β guardrail 100% precision/recall (61-case bench corpus; a separate 147-case bypass corpus gates CI), router 96.9%
# then ask the agent to `rm -rf /` or write a .env β denied; `rm -rf ./build` β allowedπ§ͺ Red-team resistance, measured. Prompt-injection (direct/indirect/paste), agent-config poisoning, local safety-override, malware & insecure-code β scored against a labeled corpus that gates CI, obfuscation-resistant (--attack), with optional escalation to a managed guardrails backend. A poisoned repo or web page can't quietly turn your agent against you β and you can measure how well that holds.
compass redteam # β injection corpus 100% P/R (99 cases) + 100% obfuscation-robust, then scans THIS repo's config/MCP/settings
compass redteam --external # β score the detectors against a public corpus we DIDN'T write (honest: 90% precision, and we tell you why recall is what it is)Most tools show you 100% on their own test set. We show that too β and the number against someone else's corpus, because a floor you can only hit on your own cases isn't a floor.
πΈ A budget ceiling that actually stops it. Usage trackers report spend; compass enforces it β the session is halted before the next tool call once your dollar cap is reached. An agent can't quietly run up a $40 bill while you're away.
export COMPASS_MAX_USD=5 # this session hard-stops at $5 β blocked, not warned
compass spend --max-usd 5 # the same ceiling on the ledger, for scheduled / fleet runsπ Cost routing that's measured. Cheap work goes to cheap models β ~62% cheaper than all-Opus at 96.9% routing accuracy on the 44-case routing evalset, with the pricing table and token assumptions stated in the output. Run the number, don't take it.
compass route "redesign the auth model" # β opus
compass route "fix a typo" # β haiku
compass bench # β routed vs all-Opus: ~62% cheaper (assumptions printed)π Supply chain you can verify. Releases carry keyless SLSA provenance β a tampered or look-alike download is rejected β and the repo publishes an OpenSSF Scorecard. And before you trust someone else's plugin, scan it.
compass verify # resolves the latest release β β provenance verified
compass audit-plugin ./their-marketplace # injection Β· tool-poisoning Β· unpinned MCP Β· fetch-and-execute hooks β before you installNo service, no telemetry, no --dangerously-skip-permissions; git pull to update. The work it can't safely own, it hands back β you keep the merge.
The day-to-day feel β guardrails, the cost-aware status line, the loop, and the crew, in ~25 seconds:
How the loop works β review Β· security Β· tests Β· cross-audit run in parallel; Blocking findings get auto-fixed and re-reviewed (round-capped) until green, then it stops at you:
Run it locally in 30s with ~/compass/sdlc/orchestrate.sh "<task>" (no tokens), or wire the GitHub loop for every PR. β how it works Β· reproduce it
And the everyday status line quietly keeps score, so you watch it earn its keep:
Opus 4.8 Β· myrepo Β· main* Β· 45k ctx Β· $1.23 Β· π§ π‘1 π§Ή2 π‘1 π~$1.65
session spend, then today's compass activity: π‘ footguns blocked Β· π§Ή files formatted Β· π‘ policy nudges Β· π~$ estimated saved vs all-Opus. Nothing leaves your machine.
Autonomy here isn't one big magic button β it's the same closed loop applied at five scales. Each runs until a gate says "done," then stops at a human. That's the whole trick: iteration under a gate beats a single confident guess.
| Loop | What it drives | Where it stops | |
|---|---|---|---|
| π | The task loop | generate β test β critique β fix β repeat β one change driven to green | when tests + review pass |
| π | The review loop | review β auto-fix the Blocking findings β re-review, round-capped (Γ3) | hands off to a human if still red |
| π©Ί | The CI-fix loop | any check suite goes red β failure log + auto-fix on the PR; main goes red β one free rerun, then a ci-fix/* PR |
round cap β a human; never merges |
| π°οΈ | The fleet loop | the whole pipeline, scheduled across every repo you own, overnight, test-gated | a PR per repo, approve from your phone |
| π₯ | The workflow loops | parallel agents that fan out, fact-check each other, and converge | one synthesized answer |
The newest turn of the crank β pr-shepherd: every open PR taken end-to-end β diagnose the red check from its log, classify it, fix + verify the mechanical ones, and stop at a merge gate that's enforced server-side (required checks + ruleset, not the agent's honor). Run it on demand (/pr-shepherd), on an interval (/loop 15m /pr-shepherd), or unattended: compass schedule add pr-shepherd --twice-daily.
A loop that runs while you sleep is five moves β discovery β handoff β verification β persistence β scheduling β and compass ships a primitive for each. It also guards the four costs a loop runs up silently (verification debt, comprehension rot, cognitive surrender, token blowout): an independent evaluator that assumes broken and runs it, compass digest to keep you understanding what merged, the permanent human gate, and per-day + live budget caps. β the five moves & four guards Β· the thesis
Every loop ends the same way β you merge. That gate never moves.
Pick the door that fits β all reversible, version-pinnable, no curl | sh. You need an AI assistant (Claude Code; Codex/Gemini optional) + git. No API keys for the manual, guardrails, crew, and CLI; the autonomous PR loop and fleet need model auth when you opt in.
πΊ Homebrew β managed & versioned
brew install dshakes/tap/compass # latest release Β· --HEAD to track main
compass quickstart # previews, asks, then wires it into ~/.claudeπ¦ Git clone β own & edit your config (recommended)
git clone https://github.com/dshakes/compass ~/compass && cd ~/compass
git checkout "$(git describe --tags --abbrev=0)" # optional: pin to the latest release
./quickstart.sh # previews every change, asks first, fully reversibleπ§© Claude Code plugin β no terminal (ideal for a team)
/plugin marketplace add dshakes/compass
/plugin install compass@compass
π οΈ By hand: make dry-run (preview) β make install β make doctor. β Team rollout
π Put your other repos on it β one command each (or a list):
compass enable --schedule owner/repo ~/code/another-repo # config + PR gates + secrets-from-env
# + required-checks ruleset + auto-merge
# + twice-daily pr-shepherd (--dry-run to preview)What install actually does: replaces your global
~/.claudeconfig (settings,CLAUDE.md, agents, skills, hooksβ¦) with symlinks into the repo β sogit pull/brew upgradeupdates everything. Anything it replaces is backed up first to~/.claude/backups/;--copycopies instead of linking;make uninstallremoves only what it added. Personal overrides (your model, plugins, UI prefs) live inclaude/settings.local.jsonβ gitignored, deep-merged at install, so your prefs never fight the shipped defaults.
| Agent | Native install (no terminal) | or own the files |
|---|---|---|
| Claude Code | /plugin marketplace add dshakes/compass β /plugin install compass@compass |
make install |
| Codex | codex plugin marketplace add dshakes/compass β /plugin install |
make install (~/.codex/AGENTS.md + config.toml) |
| Gemini CLI | gemini extensions install https://github.com/dshakes/compass |
./install.sh --gemini (~/.gemini/GEMINI.md) |
| Cursor Β· Copilot Β· OpenCode Β· Windsurf | read the repo's AGENTS.md (AGENTS.md standard) |
clone + make install |
CLAUDE.md Β· AGENTS.md Β· GEMINI.md are one file (symlinks), and the plugin/extension manifests are generated from one source and CI-checked (scripts/check-vendor.sh) β a git pull updates every agent at once and a manifest can't drift. The manifests are structure-validated in CI; the live gemini extensions install / codex plugin marketplace add paths are verified manually (those CLIs aren't in the runner).
Enforcement, not just the manual. Claude Code gets the full hook layer (guardrails, budget gate, scans). For everything else β Codex, Gemini, Cursor, any SDK β the budget cap travels via compass gate, a localhost proxy you point ANTHROPIC_BASE_URL/OPENAI_BASE_URL at, so the hard dollar ceiling holds for any agent, not only the one with hooks. β 02-cost
compass doctor # validate the install β expect "0 error"
compass status # is compass active here, and what's loaded?Then open your agent as usual. Feel it in a minute: ask for a dangerous command (blocked), run /review on your diff, or compass route "<task>" to see the tier it picks. No tokens, no signup.
Everything below is on after one install or a single opt-in β the autonomous loops sit on top. Each row links to the detail.
| Capability | One line | Deep dive | |
|---|---|---|---|
| π | Autonomous SDLC | the review β security β tests β cross-audit β auto-fix β re-review loop; you merge | 09-sdlc |
| π©Ί | CI auto-fix | no CI failure goes unhandled: red PR checks feed the fix loop; red main gets one free rerun, then a ci-fix/* PR |
09-sdlc |
| π | Loop engineering | the five moves wired up: morning-triage discovery Β· pr-shepherd takes every open PR to the merge gate (on demand, /loop 15m /pr-shepherd, or compass schedule add pr-shepherd --twice-daily unattended) Β· an acting/skeptic evaluator Β· compass digest Β· per-day budget cap |
20-loops |
| π°οΈ | The fleet | the loop, scheduled across all your repos through a test gate; approve from your phone | 14-fleet |
| π₯ | The crew + workflows | cost-tiered expert subagents Β· slash-commands Β· dynamic workflows that fact-check each other | agents roster Β· 12 Β· 13 |
| π‘ | Guardrails & scanning | a hook layer that blocks disasters, catches secrets (write-hook + compass scan), auto-formats, keeps a JSONL audit log |
16-hardening |
| π§ͺ | Red-team hardening | eval-gated defense vs prompt-injection, config poisoning, safety-override, malware & insecure code | 17-red-team |
| π§ | Cost-tier router | a standalone, reusable module β keyword heuristic β optional classifier β judge cascade; eval-gated | router/ |
| π§° | The compass CLI | onboard Β· impact Β· drift Β· scan Β· redteam Β· audit-plugin Β· gate Β· sandbox Β· verify Β· audit-log Β· spend Β· dashboard |
11-using |
| π¦ | Cross-agent enforcement | compass gate β a localhost proxy that hard-caps spend for Codex/Gemini/any SDK, not just Claude Code |
02-cost |
| π | Plugin-security scanner | compass audit-plugin β vet a third-party plugin/marketplace (injection Β· tool-poisoning Β· unpinned MCP Β· fetch-exec) before you install it |
17-red-team |
| π | MCP + LSP | curated, version-pinned MCP servers + opt-in language-server intelligence | 04 Β· 06 |
| πͺͺ | Every agent, one source | Claude Code Β· Codex Β· Gemini β plus Cursor/Windsurf/Copilot via the AGENTS.md standard |
12-every-agent |
| πΈ | Live budget ceiling | a hard cap that halts the session before the next tool call (COMPASS_MAX_USD), plus a per-day cap for unattended loops |
02-cost |
Built to be trusted before it's run β and honest about its limits.
- You own the irreversible. Agents prepare; humans push, merge, deploy. Required checks + code-owner approval enforce it.
- Readable & reversible. No
curl | sh; the installer backs up what it replaces andmake uninstallremoves only what it added. Pin a tag, notmain. - Guardrails reduce footguns; they are not a security boundary. Keep least-privilege credentials and review your diffs. For untrusted code,
compass sandboxis a real boundary. Red-team hardening is defense-in-depth, not immunity β the cardinal rule (external content is data, not instructions) and the human gate are what actually hold. - What talks to the network. compass phones home to nothing. The pinned MCP servers reach the endpoints you'd expect (library docs, URLs you request); hooks are short, commented shell scripts in
claude/hooks/β disable any in your settings.
Status: beta. The core β manual, hooks, subagents, commands, MCP, plugin β is stable, dogfooded daily, and eval-gated in CI (guardrails + red-team scored on labeled corpora; run
compass benchyourself). The SDLC pipeline is newer: statically validated in CI, exercised via a smoke-test you run on your own repo. Managed-guardrail adapters are contract-tested, with live cloud-backend calls unverified in CI (need your creds). Dynamic workflows are a research preview. The human merge/deploy gate is permanent, by design. β full details
Start here β Using compass β install, the pieces in plain language, the daily workflow. The thesis β Loop engineering β why iteration-under-a-gate beats a one-shot guess. In practice β The five moves β each move of a self-running loop, mapped to the primitive that builds it. Fundamentals β The layers β prompt/context/harness/loop/graph, dated and evidence-graded, with a rubric for the next one. Fundamentals β Context β the context window as a budget you spend, not a container you fill. Fundamentals β Harness β everything around the model that isn't the model, and the evidence it moves outcomes more than the model does. Fundamentals β The gate β a loop without a gate is just an agent talking to itself; generator vs. evaluator, and what makes a gate real vs. asserted. Fundamentals β Verification β the ladder of what counts as proof, from "the model said so" to a human watching it run. Fundamentals β Orchestration β when fan-out earns its cost, the Cognition/Anthropic disagreement, and graph engineering graded honestly. Fundamentals β Ablation β make every config rule defend itself with a number, or admit your corpus never tested it. Fundamentals β Glossary β every term from this series, alphabetized and graded, so you can look one up mid-sentence.
Philosophy Β· Architecture Β· Cost & models Β· Customize Β· MCP Β· Plugin & team rollout Β· LSP Β· Practices Β· Defaults Β· SDLC Β· Roadmap Β· Every agent Β· Workflows Β· Fleet Β· Competitive audit Β· Hardening Β· Red-team Β· Benchmark Β· Provenance Β· Loops Β· Run any framework Β· The layers Β· Context Β· Harness Β· The gate Β· Verification Β· Orchestration Β· Ablation Β· Glossary Β· Agents roster Β· Router module Β· ADRs
MIT Β· built to be shared Β· contributions welcome


