8.3 Permissions and sandboxing¶
Agents act within bounds that the machine enforces, not only within bounds they are told: no session raises its own rights, the bot sessions run in a throwaway VM per repository, and what cannot be taken back is refused by the harness or a hook. The reason: an agent that gets a step wrong once must not be able to do damage that cannot be undone, and the owner's consent must be given in the session that acts (lessons-learned.md).
Contents: Rules · Committed deny rules · Where it is described
Rules¶
- No escalation on the host. The host user that runs Claude Code has no sudo; a step that
needs root is printed as the exact
sudocommand for the owner, who runs it as rule 2 says (SPEC.mdQ-5; rootCLAUDE.md(CLAUDE.md), "Rules the scripts follow"; chapter 2). - Root never runs a file the host user can change. An admin account runs the root steps from
the owner's own clone at the reviewed
main; the script refuses a folder the host user can write (#275, setup/linux-host.md). Root inside a sandbox's throwaway VM is allowed, for provisioning (#530). - One sandbox per repository. A repository's coordinator and its workers run in one Docker Sandbox, a microVM that mounts only the checkout and the shared worktree folder; the rest of the host, the token file included, is out of reach, and no token enters the VM (setup/linux-host.md, 8.1).
- The network is an allowlist. A sandbox reaches the hosts of sbx's
balancedprofile and of one list in the repository; a host goes in or out through a pull request with its reason, never by hand on a machine, and an allow rule added by hand anyway is reported as drift (setup/network-allowlist.md). - Standing consent is written down; the rest is the owner's. Using a coordinator is the owner's standing consent to the routine—taking up work, cleaning up, routine merges, plugin updates—and some steps need a yes each time (sdlc/parallel-work.md); scope, security, architecture, CI, secrets and anything irreversible outside the repository stay with the owner (sdlc/decisions.md).
- A worker cannot merge. The
workflowplugin'sguard-mergehook refuses a merge in every session recorded as a worker; a coordinator merges only throughcoordinator merge, which checks the merge rules and names the session in a comment, and the same hook refuses the coordinator's raw merge (#1024). The owner allows exactly that command, nevergh pr merge, which would hold for workers too (sdlc/parallel-work.md); the merge kinds are 8.5. - What cannot be taken back is denied. The repository commits deny rules
(below), and dcg, a
PreToolUsehookdev-env:dev-doctorinstalls on every machine, blocks the destructive shell commands a rule cannot express (plugins/dev-env/skills/dev-doctor/reference/dcg-guard.md).
Committed deny rules¶
.claude/settings.json carries a permissions.deny list for what cannot be taken back, by the
test of Anthropic's talk: if Claude gets it wrong once, can I take it back? A deny rule is checked
before the auto-mode classifier and holds in every permission mode, bypassPermissions included
(permission modes); no allow rule lifts it.
dcg (plugins/dev-env/skills/dev-doctor/reference/dcg-guard.md) and the
commit guard (git-flow plugin (plugins/git-flow/README.md)) stay as they are, for what a
pattern cannot express. The source is #765; the rules were checked by a recorded run in the pull
request of #767.
| Rules | Why |
|---|---|
git push --force, -f and +<refspec>, with the flag before or after the remote, also after git -C <path> |
Overwrites the remote branch; the lost commits may exist nowhere else. --force-with-lease is not matched by these rules; pr-watch push (push_slot.py) refuses it on its own |
git reset --hard, with the flag before or after the commit, also after git -C <path> |
Throws away uncommitted work, which git never recorded |
git clean, also after git -C <path> |
Deletes untracked files, which git never recorded. The dry run git clean -n is refused too |
Reading .env, *.env, .env.local, .env.*.local, .env.production, *.pem anywhere on the machine (//**/) |
A secret read into a session is in its transcript and cannot be taken back (setup/secrets.md). .env.example stays readable |
Reading ~/.ssh/id_rsa, id_dsa, id_ecdsa, id_ecdsa_sk, id_ed25519, id_ed25519_sk |
The private keys. The .pub files stay readable, which a plain id_* would deny too |
Reading ~/.config/claude-dev-doctor/** and ~/.config/ops-doctor/** |
The token file claude-remote.env, bws.token and the cache ops.env. dev-doctor, ops-doctor and the rotate scripts read them from their own processes, which a Read rule does not affect |
Which sessions read them.
| Session | Reads the rules |
|---|---|
| Claude Code in a checkout or worktree of the repository: owner's workstation, Linux host, Docker sandbox, desktop app, IDE | Yes: project settings are one of the default setting sources (settings). Observed with --setting-sources project |
| A cloud session | Yes: it clones the repository and loads its .claude/settings.json, as it loads the hooks there (Claude Code on the web). Not observed: no cloud session was started for the check |
The claude-review job in CI |
No: --setting-sources user keeps the checkout's settings out on purpose, and the job's own claude_args confine it (ci/claude-review.md) |
| A thread of a Claude Code Project | A cloud thread: no, not covered. It loads the repository's CLAUDE.md and .claude/rules/, not its .claude/settings.json (Projects, as noted in docs/plans/2026-10-24-mcp-server-scope.md). A Remote Control thread on our own machine and the Project's orchestrator conversation: not established |
Limits, from the permission rules and the recorded run:
- Rule shape. A pattern whose only wildcard is a trailing
*matches the bare command too (git push --force,git reset --hard). A pattern with a wildcard in the middle does not match a flag at the end:git push * --force *letgit push origin main --forcethrough. Each such rule therefore has a second form ending in the flag. A Read path**/.envis relative to the working directory and let a.envbeside the checkout through;//**/.envis absolute. - What a Bash rule does not see. A command inside
sh -c '…'(it went through in the run), a script, or a program's own subprocess, such aspush_slot.pycalling git from Python. Other options beforepush(git -c k=v push -f) and combined short flags (git push -uf) are not covered either, nor other ways to lose work: deleting a remote branch (--delete,:<branch>,--mirror),git checkout -- .,git restore .,git stash drop. dcg covers several of these where it is installed. A compound command is split:cd . && git push --force origin mainwas refused, and so was/usr/bin/git push --force origin main. - What a Read rule stops. The Read tool, and in the run also
cat .envin Bash. It does not stop a program that opens the file itself. A deny rule cannot carry an exception, so the list names the secret.envvariants rather than.env.*: other names such as.env.stagingstay readable. A private key under another name (~/.ssh/id_rsa_work) is not covered; braces and extglob (id_!(*.pub)) do not work in a Read path, so the default names are listed one by one.
Where it is described¶
| Topic | How-to |
|---|---|
| The root steps and why root never runs a file the host user can change | setup/linux-host.md |
| The sandboxes: layout, mounts, lifecycle | setup/linux-host.md, setup/owners-workstation.md |
| The sandboxes' network | setup/network-allowlist.md |
| What a coordinator does alone | sdlc/parallel-work.md, plugins/workflow/skills/coordinator/autonomy.md |
| What waits for the owner | sdlc/decisions.md |
| dcg | plugins/dev-env/skills/dev-doctor/reference/dcg-guard.md |