ai-engineering
v4.0.0
Published
Guardrails for the AI coding agents you already run
Readme
Turn any repo into a governed workspace. The agent can't edit its own rules, and every refusal it gets is saved as a file you can read.
Bun 1.4.4+ · macOS · Linux · Windows · Apache-2.0 · Runs on your machine and calls no model · 7 of 10 agent hosts enforced and verified on 2026-11-23
Guards · Receipts · Skills · Fail closed · Your repo · Measured · Known limits · Under the hood · Release · Answers · Get it · Build with us
- The agent proposes a tool call: a command, an edit or a read.
- The host sends the call to
ai-eng chain, which runs the guards in a fixed order. The first refusal wins. - The verdict is allow (a recognised test command is rewritten to show only failures), annotate (the call goes ahead with a review note) or deny (the call is refused, with the reason).
- On allow or annotate the tool runs. On deny it never runs, and the agent is told why and what to do instead.
- A guard that crashes or cannot decide ends in a refusal.
- Every verdict writes one JSON file to
.ai-engineering/receipts/.
Seven protection guards read each governed tool call and answer before the tool runs. The cards split what stops the agent from what only tells it. The hosts where a refusal stands are in Where the agent still can.
Each guard runs only for the tools it governs, in this order, and the first refusal wins:
| Order | Guard | Refuses |
|---|---|---|
| 1 | self-protect | writes to anything that governs the agent: .ai-engineering/ (except the milestone files a session owns), the agent settings, the git hooks, the installed skills |
| 2 | no-verify | anything that skips the git hooks: --no-verify, git commit -n, HUSKY=0, deleting the hooks folder, repointing core.hooksPath. And every comment that silences a linter or a type checker: ESLint, TypeScript, Ruff and Flake8, Bandit, clang-tidy |
| 3 | no-stash | creating a stash, which takes work off its branch; list, show, apply, pop and branch still work |
| 4 | policy | commands outside the allowed scope (see configuration) |
| 5 | injection | reading a file, or acting on a fetched page, whose text carries instructions to the model. The text is data, never an order |
| 6 | loop | the same call repeated, or the same failure retried with small changes |
| 7 | checkpoint | phase and gate writes that break the active workflow checkpoint. It is the workflow gate, not a protection guard |
| 8 | lease | a write in a folder another session wrote in during the last 15 minutes. The second session goes to a worktree; ai-eng work release frees the folder |
| 9 | wrap | nothing. It rewrites a recognized test command to ai-eng wrap test --base64 <encoded command>, which prints only the failures and a summary |
spoken-secret checks each prompt you submit, on agents with a prompt hook. It refuses a prompt that seems to contain a credential, and it never prints the value it found.
- You give
ai-orchestratora feature, in your own words. You approve the idea: that is the first stop. - It splits the work into numbered checkpoints, smallest first.
- It builds one checkpoint at a time and gates each before the next. A checkpoint that fails a gate does not move on.
- You review the app: that is the second stop.
- On your approval, it ships as a pull request or a local merge.
| Group | Skill | What it does |
|---|---|---|
| Shape the idea | ai-brainstorm | Questions a fuzzy idea until it fits in plain words, then asks for approval |
| | ai-research | Answers from outside the repository with numbered sources, or marks a claim [unsourced] |
| | ai-architect | Advises on approach, stack, cost and prior art before the build starts |
| | ai-read-docs | Reads the current docs before you depend on external or versioned behavior |
| Build it | ai-orchestrator | Builds a feature end to end in gated checkpoints |
| | ai-test-planner | Plans and writes tests from the bottom layer up |
| | ai-prototype | Builds a clickable single-file HTML prototype of a screen or flow |
| | ai-design-md-planner | Writes a DESIGN.md design system and lints it with the official CLI |
| Understand the code | ai-explore | Answers "where does this live", with file:line evidence |
| | ai-codegraph | Maps call chains, blast radius and cross-file links |
| | ai-debug | Names the root cause at file:line and writes the failing check before the fix |
| | ai-note | Saves a hard-won finding as committed Markdown, stamped so staleness shows |
| Check the work | ai-verify | Checks finished work at the right depth and returns a verdict with evidence |
| | ai-adversarial-loop | Debates a critic and a fixer, round after round, until the code is clean |
| | ai-security | Runs a six-phase security audit; the finder never verifies its own findings |
| | ai-stress-test | Finds the load that breaks the system |
| | ai-audit-code | Finds the simplest solution that works: least code, fewest dependencies |
| | ai-audit-design | Finds and fixes visual defects in a rendered page, by measurement |
| | ai-review-ui | Screenshots the live UI and its prototype, then compares them |
| Ship and write it up | ai-pr | Runs the pull request: cut, push, open, watch CI, merge. Your words decide how far it goes |
| | ai-write | Writes a README, wiki page or API doc, verified against the tree |
| | ai-audit-docs | Checks the docs against the repository: dead links, false claims, stale versions |
| | ai-visual-recap | Turns a diff into an interactive recap: diagrams, file map, annotated diff |
| | ai-issue-report | Drafts a bug report locally, with sensitive fields removed; sends nothing without your yes |
| Keep the repo in order | ai-triage | Ranks one GitHub or Azure DevOps backlog in a read-only report |
| | ai-refresh-project | Aligns AGENTS.md, the docs, the governance files and the branches with the tree |
| | ai-writing-behavior | Writes BEHAVIOR.md specs for agent conduct that can be judged |
None of this is required to get the refusals above. The triggers that send a change to a skill are in docs/skills.md.
The exceptions are real. The Copilot adapter (CLI and VS Code) fails open on a timeout and when ai-eng is not on PATH, and Codex fails open on a hook error. Both are in Where the agent still can, next to the dated host matrix.
- Versioned files.
AGENTS.md,DECISIONS.md,.ai-engineering/config.tomland the git hooks sit in your repository, plus~/.ai-engineering/on your machine. - Self-protected.
self-protectis the first guard in the order. The agent cannot write to the files that govern it; a person changes them in a reviewed diff. - Local only. 0 hosted services, 0 model calls. No prompt and no source leaves the machine.
- One optional network read. Commands you type ask the npm registry for a newer version at most every 24 hours. Set
AI_ENG_NO_UPDATE_NOTICES=1and it never does. Offline, the check stays silent.
Want the figure for your repo? ai-eng doctor counts refusals per 1,000 real tool calls from your own receipts, and warns above 50 or on any call you mark as a false alarm. We publish the method and the test corpus. We do not publish anyone's receipts, our own included.
- Guard chain, before the tool runs: it alone stops an attempt to skip a check, because a hook cannot see the flag that skips it.
- Git hooks, at commit and push: they alone read the staged diff for a secret, and they run for a person as well as an agent.
- CI workflows, on the server after the push: they alone stop a push that skipped the local hooks, because a laptop cannot switch them off.
- External review: it alone catches a test that was deleted or weakened. ai-eng does not read test content, so every layer above passes it.
- Merge: a person decides whether the change ships. A release reaches npm only from a signed tag that a person approved.
- Enforced and verified, 7:
claude-code,cursor,copilot-cli,copilot-vscode,opencode,piandoh-my-pi. A denial blocks the call, tested on the measuring machine. The two Copilot hosts fail open on a timeout or whenai-engis not onPATH. - Enforced but unverified, 1:
codex. It is wired to deny, but the CLI was not installed on the measuring machine. It fails open on a hook error. - Advisory, 2:
zedandagy.zedhas no hook API; theagyhook file is a template that nothing installs. They offer skills and advice, never a refusal. - The source of every count is
docs/surface-capability-matrix.md, measured 2026-11-23 on macOS arm64.
The guards stop an agent's mistakes. They are not a sandbox.
The Copilot adapter (CLI and VS Code) shares one hook runner and one hook file set for both hosts. Its preToolUse command hook fails closed on a crash or non-zero exit, but fails open when ai-eng is not on PATH (the template exits 0 on purpose, so a machine without it is not locked out) and on a timeout. The prompt hook is advisory on Copilot: userPromptSubmitted command output is ignored.
The Antigravity CLI (agy) is declared and advisory, and it cannot be enabled: ai-eng init --surface agy and ai-eng config --add agy are refused, because no hook of ours judges an agy call yet. Only a hand-edited [surfaces] enabled = ["agy"] followed by ai-eng update writes its hook file (~/.gemini/config/hooks.json), and that file fails soft rather than risk a lockout, because agy denies on any non-zero exit. What is measured, what is unverified (the Windows form has never been run) and what would make the surface enforceable are in the capability matrix.
Command guards read the visible command text. They do not sandbox opaque programs or scripts prepared in earlier calls: a script written in one call and run in a later call does whatever it contains.
For untrusted code, use OS-level isolation: a container, a VM or an OS sandbox.
Some limits are not on the host list at all. ai-eng does not read test content, so an agent that deletes a failing test or weakens an assertion still gets a green build. Figure 3 shows which layer is meant to catch that.
- A command arrives as text, for example
git commit -n -m fix. - One reader,
src/guards/shell.ts, parses it the way the shell will: quotes, escapes, substitutions and heredocs. - The result is a typed command model: segments, their words, and which text is code and which is data.
- Six guards read that model as predicates:
no-verifyasks whether a hook is skipped,no-stashwhether a stash is created,policywhether the call is inside the scope,self-protectwhether a rule is edited,leasewhether another session is writing there, andinjectionwhether the text carries orders for the model. - The check on the reader is
tests/shell-guard-contract.spec.ts. It pins what every guard reads, so a reader that splits or decodes one character differently from the shell fails.
- Policy is code, not a prompt. The model reads
AGENTS.mdand can choose otherwise. The guards run on every call and cannot be talked out of it. - One definition set for every host. The same guard judges the same call whichever host sent it.
src/surfaces/surfaces.jsonrecords what each host supports. - Answers in the host's own format. The chain reads the host's payload on stdin and replies in the same dialect.
- Built with Bun and TypeScript, with 2 runtime dependencies (
@clack/prompts,fast-wrap-ansi).
The two hosts that never call the command: Zed has no hook API, and the agy hook file is a template nothing installs.
- A signed annotated tag, from an allowed key, on exactly the dispatched commit.
- Every row of NOTICE.md marked
verified. - A person approves the run (
environment: release). - A CycloneDX SBOM, and build-provenance attestations verified before publish.
npm publish --provenance(SLSA v1).
The rules are in scripts/release-policy.ts and .github/workflows/release.yml. Check a release yourself:
npm audit signatures
gh attestation verify ai-eng-darwin-arm64 --repo arcasilesgroup/ai-engineering # a binary from the GitHub releaseYes, and we list how. It is not a sandbox: command checks read the visible command, so a script written in one call and run in a later call does whatever it contains. Copilot lets a call through on a timeout, and Codex on a hook error. On Zed and Antigravity it can only advise. What it does close are the common forms of skipping a hook (-n, HUSKY=0, a new core.hooksPath) and every edit to its own rules. For untrusted code, use a container or a VM.
For one guard, yes. The loop guard reads .ai-engineering/overrides.toml: add an entry there with a reason and an end date and the repeated call goes through. The agent cannot write to that file, and ai-eng doctor shows every active entry with its time left. When the date passes, the loop guard is on again. Every other guard has no override today: the way out is to run the call another way, or to ask a person to change the rule in a reviewed diff. To remove everything, run ai-eng uninstall; it keeps your own files.
You should, and ai-eng writes one for you. But the model reads AGENTS.md and can choose otherwise, which is how most hook-skipping commits happen. A rule that must never break belongs in code that runs on every call. AGENTS.md keeps the judgement calls, and the checks handle the rules that never change.
No money: it is Apache-2.0. On our Mac it adds under 3 ms to a tool call at the 95th percentile (bun run bench). It also costs context. Your agent loads about 3,000 tokens of skill descriptions and about 1,200 for the AGENTS.md template, by a bytes-divided-by-four estimate (bun run tokens). Those tokens are the real price, so they are measured.
Once a day at most, and you can stop it. Commands you type ask the npm registry whether a newer version exists, at most every 24 hours. Set AI_ENG_NO_UPDATE_NOTICES=1 and it never does. It sends no telemetry and calls no model. Your prompts and your source never leave the machine.
Measured on 2026-11-23, it enforces and has verified Claude Code, Cursor, Copilot CLI, Copilot in VS Code, opencode, pi and oh-my-pi. It enforces Codex, but we have not verified Codex on our machine yet. On Zed and Antigravity it is advisory only. The capability matrix has the details and the date. ai-eng doctor tells you which of your agents are enforced.
When it refuses something harmless, it tells you which check fired and why. Only the loop guard takes a dated override; for any other guard, run the call another way or ask a person to change the rule in a reviewed diff. ai-eng doctor warns if refusals climb above 50 per 1,000 calls. Every false alarm we have fixed is kept in a test, paired with the attack it looks like. When it misses something, report it: on an enforced host, a way past a check that our list does not already name is a security bug.
Install Bun (>= 1.4.4) once. On macOS and Linux: curl -fsSL https://bun.sh/install | bash. Then the CLI, then govern a repository:
bun add -g ai-engineering@latest # or: npm install -g ai-engineering@latest
ai-eng init
ai-eng doctorai-eng init asks which agents to govern, installs the skills on your machine, and writes the contract into the repository you are in. Run it again at any time; it converges. Hooks do not run in an untrusted folder, so trust the folder in your agent once. That is the one step ai-eng cannot do for you.
- 01 · Write the contract —
ai-eng init --surface claude-code --yesinmy-app(ai-eng3.3.1):- Installs editable contract files
AGENTS.mdandDECISIONS.md, plus.ai-engineering/config.toml,.github/workflows/ai-eng-check.yml, marker-managed hooks in.git/hooks/, and.ai-engineering/ai-eng.lock(6 assets). - Reminds you to trust the workspace in your editor, prints
Nothing committed., and ends withNext: ai-eng doctor.
- Installs editable contract files
- 02 · Verify the chain —
ai-eng doctorinmy-app:- Passes 16 checks (
16 OK · 0 WARN · 0 FAIL), includingAGENTS.md(47 rules · 89 lines),canon(107/107 verified · 0 drift),git floor(.git/hooks/ · gitleaks), and the live chain test:git commit -nreturnsDENY · exit 2 · 8msfromno-verify([ai-eng] no-verify: git commit -n skips the git hooks, the floor every agent and every person in this repository commits through. Whatever the hooks would have said is what needs fixing. Run the command without it.). - Ends with
16 checks: 16 OK · 0 WARN · 0 FAILandChain verified.
- Passes 16 checks (
- 03 · Track your lanes —
ai-eng workinmy-app:- Shows
my-app · base main · 2 active · 1 parked:active feat/auth(0 d,checked out),active feat/search(0 d,no folder), andparked feat/billing(0 d,waiting on API key). - Reports
active lanes: 2/3(tidy · park · drop).
- Shows
- 04 · Change surfaces —
ai-eng config --add cursorinmy-app:- Installs
.cursor/hooks.jsonas a repo carrier, changes enabled surfaces to2 enabled: claude-code, cursor, writes thecursoradapter and skill mirror, verifies4 targets, and printsNext: ai-eng doctor.
- Installs
- The recording — the same four commands at human reading pace in the 56.7 s
quickstart.mp4behind the poster; it never autoplays, and click the poster to watch it with burned-in captions. It is its own run, so the numbers that move belong to that run: the live probe reportsDENY in 10ms, receipt latencyp50 7ms · p95 7ms, andactive lanes: 1/3with7 uncommitted.
More: install edge cases (from source, no administrator rights, Windows) · CLI · lanes · configuration · troubleshooting · skills (the triggers that send a change to a skill) · the commit rule on every route.
Read CONTRIBUTING.md and the Code of Conduct before you open a pull request. To work on ai-eng itself:
bun install
bun run build # compile the binary, skills, agents and templates inside
bun test # unit, adversarial, gate and architecture tests
bun run lint && bun run typecheck
bun scripts/readme-assets.ts # re-render the README's headings, buttons, cards, skills grid, hero and figuresThe video poster is rendered by bun scripts/readme-assets.ts; the walkthrough itself is recorded with VHS against the installed ai-eng CLI and edited with ffmpeg: run bash .github/assets/tapes/quickstart-video.sh (see .github/assets/tapes/quickstart.tape). Versions come from changesets; docs/history holds the early design record, which is history.
