Safe runs instantly
Every part is read-only or a known-safe local write: git status, rg, jq, test runners, formatters, terraform plan, installs, writes to temp dirs.
agent-policy auto-approves the shell commands that are actually safe, blocks the ones that never should run, and hands everything else back to you. One policy for every agent you use.
$ agent-policy check 'git status && git diff | head -50'
ALLOW all 3 part(s) read-only or permitted
$ agent-policy check 'sed -i "s/foo/bar/" src/app.ts'
DENY edit files with your Edit/Write tools, not the shell
$ agent-policy check 'git commit -m "fix" -m "Co-Authored-By: Bot"'
DENY no Co-Authored-By trailers in commits/PRs
$ agent-policy check 'rm -rf build'
DEFER rm outside temp dirs → your harness asks you▍ The problem
Your agent asks permission to run git log | head. Then cat package.json. Then
ls src. By the fortieth prompt you are clicking "Yes" without reading, which is exactly when
the one command that matters slips through. Turning prompts off entirely is worse.
And every tool solves it differently: Claude Code, Codex, Cursor and opencode each have their own allowlist format, none of them understand a pipe, and none of them share a policy.
How it works
Every part is read-only or a known-safe local write: git status, rg, jq, test runners, formatters, terraform plan, installs, writes to temp dirs.
AI attribution trailers, secrets caught by gitleaks before a commit, and shell-based file edits that bypass your editor. The agent is told why and how to retry.
Unknown or risky commands go to your harness's normal prompt, untouched. git push, kubectl, cloud writes: you stay in the loop.
Why it's different
Prefix allowlists see "git" and stop. agent-policy parses chains, pipes, loops, $(…), bash -c and heredocs, and judges every part. git diff | head sails through; git diff | sh does not.
When a command would trip a prompt for no good reason (a cd X && chain, a path in a shell variable), the agent gets a concrete rewrite and retries on its own. Never the same hint twice.
No AI co-author trailers. No secrets committed: gitleaks runs before every git commit. No sed -i edits that dodge your editor, diff view and formatters.
agent-policy check '<cmd>' prints the verdict and the reason for each part. No black box, no guessing why something prompted.
A git-ignored .agent-policy.json per repo, inherited by every worktree. Folder scopes for whole client trees. Lists append; denies always win.
Session retros queue candidate rules. Nothing lands until you accept it, and destructive, publishing or credential-touching entries are auto-gated so they can never be accepted.
One policy, six harnesses
| Harness | Shell policy | After edits | Shared AGENTS.md |
|---|---|---|---|
| Claude Code | Allow + deny + rewrite hints | Post-edit checks | ✓ |
| Codex | Allow + deny | — | ✓ |
| Cursor | Allow + deny | Formatting | ✓ |
| opencode | Deny + auto-answer | Post-edit checks | ✓ |
| Pi | Deny | Post-edit checks | ✓ |
| Gemini CLI | Shared instructions | — | ✓ |
Plus portable commands every agent can call (verify, wait-for, smoke, tf-check) and git hooks that protect humans too.
Configure in JSON, not in six UIs
Drop a git-ignored .agent-policy.json in a repo. Lists append to the global policy, denies
always win, and every worktree inherits it, so parallel agents get the same rules.
Not sure what a command will do? Ask: agent-policy check '<cmd>'.
// .agent-policy.json
{
"allow_prefixes": ["make test", "docker compose up"],
"deny_prefixes": ["terraform apply"],
"write_allow_globs": ["coverage/**"],
"guards": {
"block_shell_edits": true,
"gitleaks_on_commit": true
}
} Install
git clone https://github.com/brian-childress/agent-kit ~/.agent-kit && ~/.agent-kit/install.sh install.sh --dry-run shows every hook and link first.agent-policy test runs the built-in self-test suite.No. It sits in front of it. Anything agent-policy does not positively recognize as safe is deferred to your harness's normal prompt, unchanged.
Python 3 and a POSIX shell on macOS or Linux. Standard library only: no pip install, no daemon, no network calls, no telemetry. gitleaks and lefthook are optional.
Yes. install.sh --dry-run prints every link and hook it would add. It never overwrites a file you own, and --uninstall removes only what it added.
rm, pushes, deploys, cloud writes and anything unrecognized are deferred to you. The policy only ever auto-approves read-only commands and a short list of safe local writes.
Yes. MIT licensed. Fork it, change the defaults, ship it to your team.
Free and open source under the MIT license.