applygate
Stop coding agents from running terraform destroy in production.

- What it does: before an AI coding agent runs a command, applygate checks it and answers allow, ask or block, with a reason the agent can act on. It covers Terraform, OpenTofu and Terragrunt, and the aws, gcloud, az, kubectl and helm CLIs.
- Who it is for: teams that let Claude Code, Codex or another coding agent work in infrastructure repositories.
- How: it runs on your machine as the agent's pre-tool-call hook. Fixed rules decide, with no model involved by default, and nothing leaves your machine.
- What it is not: a sandbox. It catches mistakes and most injected instructions, but an agent that is set on getting around it and holds credentials that can write can still do damage. What it does not protect against.
applygate is pre-1.0, for macOS and Linux.
Quick start
brew install Flurit/tap/applygate # other ways to install: docs/install.md
applygate scan # optional: look before you install a hook (below)
cd your-infra-repo
applygate init # .applygate.yaml for this repository, hooks for Claude Code and Codex, a user config if you have none
applygate check "terraform -chdir=envs/prod destroy"
- Look first.
applygate scan needs no hook and no config. It reads the sessions Claude Code and Codex already recorded on your machine and shows what your agents can reach and what applygate would have decided on the calls they made. Nothing is run, and nothing leaves your machine (docs/scan.md).
- Using Codex? Open it and run
/hooks once to trust the new hook. Until you do, Codex skips it without saying so. applygate doctor tells you whether it will run.
- Two config files.
.applygate.yaml lists the repository's environments; commit it so your team shares it. It can only add protection, and after every edit a person runs applygate trust, so an agent cannot quietly relabel production. Your own settings, such as observe or enforce, live in ~/.config/applygate/config.yaml.
- It starts in observe mode. It logs what it would block and blocks nothing. That includes an agent editing or removing applygate itself, so try it where that is acceptable.
- Then turn it on. After a few days,
applygate report shows what it would have stopped and applygate suggest proposes environments and tiers. Set mode: enforce in your user config and run applygate doctor.
What it decides
Every command is judged by the environment it targets. You map directories, workspaces, backends, AWS profiles, Kubernetes contexts, GCP projects and Azure subscriptions to a tier in .applygate.yaml (config): protected for production, standard or disposable. Anything applygate cannot place counts as protected.
| Command | Protected | Standard | Disposable |
|---|
Read-only: plan, show, validate, state list | allow | allow | allow |
Apply a saved plan: terraform apply tfplan | plan check | plan check | allow |
Apply without a saved plan: apply -auto-approve | block | ask | allow |
Destroy: destroy, apply -destroy, -replace, a plan that deletes or replaces | block | ask | allow |
| A plan that only replaces resources that hold no data, such as a launch template or a task definition | block | allow | allow |
State changes: state rm/mv/push, force-unlock, taint | block | ask | ask |
Cloud deletes: aws … delete-*, s3 rb, kubectl delete, helm uninstall | block | ask | ask |
| Turning applygate off: skip-permission flags, editing hooks or applygate's files | block | block | block |
Git commands that rewrite files in a repository holding agent hook files (such as .claude/settings.json): checkout BRANCH, pull, merge | ask | ask | ask |
Commands it cannot resolve: curl … | bash, eval "$(curl …)" | ask | ask | allow |
Anything else that is not a plain, known command: loops, bash -c, npx, unknown programs | ask | allow | allow |