What a cloud VM changes
The VM is disposable, but a cloud session pushes to your real remote, sogit push --force lands on a branch your teammates pull, and git reset --hard loses the session’s uncommitted work. An environment set up for infrastructure work can also use a working cloud identity to run terraform destroy or aws s3 rm, which the official rulebooks block. A deny layer committed to the repository applies in every session that clones it.
Claude Code cloud and self-hosted sessions
Claude Code on the web reads settings, including hooks, from files committed to the repository. Two pieces make a cloud session enforce your policy.1
Commit the project policy
Commit
.cc-safety-net/policy.json and any project rulebooks under .cc-safety-net/rules/. The session clones them with the repository. This is the same configuration team setup commits for developer machines.A cloud session starts with no user policy file of its own, so the built-in defaults apply wherever the project file is silent. Set the session’s preset in the project file instead of relying on whatever preset a member has locally.2
Get the hook into the session
There are two ways, depending on whether the environment has a setup script.An environment setup script, or the image behind a self-hosted environment, runs the ordinary install:A target flag makes the install non-interactive, so it needs no terminal to confirm in and runs headless.Without a setup script, commit the hook entry itself as
.claude/settings.json:hook --coding-cli is the canonical hook entrypoint, the same one the installed plugin invokes. It costs an npx spawn on every tool call, so prefer the setup script when the environment has one.npx -y cc-safety-net@latest explain "git reset --hard" shows the verdict your configuration gives without running the command.
Amp Orb threads
Amp needs no per-container step.npx -y cc-safety-net@latest install --amp publishes the plugin to your Amp account, so it also covers threads that run remotely, including Orbs. The plugin carries a snapshot of your user policy for machines with no policy file. Re-run the install after you edit your user policy. See Amp Code policy snapshot.
Devcontainers and container images
For a container you build yourself, run the install at build time. This Dockerfile works:gitandca-certificatesmust be present. The Claude Code install adds a plugin marketplace, which clones over HTTPS. Slim base images ship with neither.- Install the agent CLI first. The installer drives the agent’s own plugin commands, so a build that installs CC Safety Net before the agent fails.
postCreateCommand:
process.env.CI guard from team setup. Here the agent runs in the container, so it needs the install.
What stays human-approved
You can automate installing protection but not relaxing it, in a cloud VM or on a laptop. An agent can draft a policy proposal but cannot runpolicy apply. See Agents cannot run policy apply.
Related pages
- Team setup covers the committed project policy and rulebooks in full.
- Policy documents the merge between user and project scope.
- Official rulebooks are the AWS, Terraform, gcloud, and Azure denials worth committing where cloud credentials are live.
- Installation has the per-agent install details for every supported CLI.