Permissions in practice
Permissions explains how zelk decides each tool call. This page is about setting it up: which mode to use where, how to write rules and where to keep them, and how to confine commands.
Choose a mode
Section titled “Choose a mode”| Where | Starts in | Good for |
|---|---|---|
| The terminal UI | default, or mode in tui.json |
working alongside zelk: it asks before anything that changes state |
zelk -p |
bypass |
trusted one-off tasks in a directory you are willing to have changed |
zelk exec |
plan |
headless jobs that read and report; give -mode to let them change files |
zelk acp |
default |
editors, which show the approval prompts |
-mode plan|default|accept-edits|auto|dont-ask|bypass (or -plan) picks
another for any of them. In the terminal UI, Shift+Tab cycles default,
accept-edits, plan and auto, and the terminal UI never saves bypass
as a default.
dont-ask is useful for unattended runs that should only do what your
rules allow: whatever would ask is refused instead.
Write rules
Section titled “Write rules”A rule names a tool and, in parentheses, what it acts on:
zelk -p -allow 'Bash(go test *)' -deny 'Bash(rm *)' -mode dont-ask "run the tests"zelk -human 'Bash(git push *)' # always a person, even in auto modezelk -ask 'Edit(go.mod)' # ask even in accept-editszelk -allow 'WebFetch(domain:go.dev)' # a site and its subdomainsQuote rules for the shell: * and parentheses are shell syntax. In a Bash
rule, a trailing * also matches nothing, so Bash(npm test *) matches
npm test as well. Every command in a pipeline or && chain must be
allowed for the whole line to be. On Windows, PowerShell(Get-ChildItem *)
names the PowerShell tool in the same way; see
PowerShell commands. In
PowerShell, quote a rule in single quotes, as above.
Rules you want every time go in ~/.config/zelk/config.json, under the
same names as the flags:
{ "allow": ["Bash(go test *)", "Bash(go vet *)"], "deny": ["Bash(rm -rf *)"], "human": ["Bash(git push *)"], "protect": ["secrets/**"]}Flags, config.json and the project’s settings are used together; none
overrides another. The strongest matching rule decides: deny, then human,
then ask, then allow.
A project’s rules
Section titled “A project’s rules”A repository can carry rules for everyone who works in it, in
.zelk/settings.json, with the keys allow, ask, deny, human and
protect:
{"allow": ["Bash(make test)"], "deny": ["Bash(rm -rf *)"]}Its deny, ask and human rules and its protected paths apply at once: they only make zelk more careful. Its allow rules widen what zelk may do, so they apply only once you trust that exact file. The terminal UI asks at start, together with the project’s hooks; elsewhere, review and trust it with:
zelk project list # what the project's .zelk files bring, and whether each is trustedzelk project trust # trust them as they are now.zelk/settings.json (allow rules trusted: false, sha256 2615…) deny Bash(rm -rf *) allow Bash(make test)Changing the file asks again.
Protected paths
Section titled “Protected paths”Writes to .git/, agent settings (.zelk/, .claude/, .agents/,
.codex/), Git configuration, shell startup files and tool configuration
such as .vscode/ always go to a person, whatever the mode or rules, and
are refused where no one can be asked. Add your own with -protect or
protect: a pattern with a slash is relative to the workspace, one without
matches that name anywhere.
zelk -protect 'deploy/**' -protect '*.pem'Auto mode
Section titled “Auto mode”In auto, file edits in the workspace run (except edits to configuration,
build files, CI workflows and scripts, which are reviewed), and a reviewer
model decides what would otherwise ask you. Allow rules that would run any
code, such as Bash(python *), don’t apply in auto mode, so the reviewer
sees those commands. After three denials in a row, or ten of the last
fifty, the run stops for you.
Two flags shape the reviewer:
-trust TEXTnames something you count as your own, such as a repository, a bucket or an internal service, so that working with it isn’t judged as reaching outside. It authorizes no particular operation.-reviewer-effort low|medium|highsets how much it reasons per verdict.
Before relying on a model as reviewer, zelk checks it on a short built-in
set of actions, once per model; a model that fails isn’t relied on, and
what the rules leave open goes to you. -no-reviewer-check skips the check.
The auto-mode reviewer explains what it sees, what its
verdicts do and how well it has done when measured.
When the reviewer denies something
Section titled “When the reviewer denies something”A denial says why. In the terminal UI, Denied actions… lists what the
reviewer denied and asks it once more about one you choose. In exec,
resume with the denied action’s digest, read from its permission_decided
event in -json output:
zelk exec -mode auto -retry-denied DIGEST resume --last "try that exact action again"The retry asks the reviewer again under the current policy; it doesn’t force the action.
Confine commands
Section titled “Confine commands”Rules decide which commands run; a sandbox limits what a running command can do. For a run you leave alone, use one:
zelk exec -mode auto -sandbox bwrap "refactor pkg/foo" # Linux: bubblewrapzelk exec -mode auto -sandbox seatbelt "refactor pkg/foo" # macOSzelk -sandbox bwrap -network-allow github.com:443 -network-allow '*.golang.org'zelk -sandbox bwrap -sandbox-read-only ~/.local/binzelk -env GOPRIVATE -env NPM_CONFIG_REGISTRYOn Windows, run zelk sandbox setup, review and accept Microsoft’s MXC telemetry, then select -sandbox mxc. Unattended auto mode uses MXC when it is set up and available.
- Files. A sandboxed command writes inside the workspace and to the sandbox’s private temporary directory and explicit writable roots. bwrap
hides your home directory, but binds the toolchains it finds there
read-only (Go and its module cache, rustup and cargo, the
nodeon yourPATH);-sandbox-read-only PATHadds more, and credential files such as~/.sshstay hidden under them.-sandbox-read-onlyworks only with bwrap. MXC grants read-only what it finds of Go, Git for Windows, PowerShell, Node, Python and Rust (therg.exeexecutable alone), and gives Go, npm and cargo caches of its own to write in. - Network. Off under a sandbox unless
-network full, or-network-allow DOMAIN[:PORT]for an allowlist with bwrap or MXC. Without a port, only 80 and 443 are allowed. MXC allows Windows DNS queries outside the allowlist. - Environment. Commands get only a base set of variables (
PATH,HOME, user, locale, time zone,TMPDIR, XDG directories), sandbox or not. On Windows they also get the variables programs need to start (SystemRoot,PATHEXT,COMSPEC,TEMP,USERPROFILE,APPDATA,LOCALAPPDATAand the like), and-envnames match without regard to case.-env NAMEpasses another. API keys and tokens never reach a command unless you name them.
On Linux, -mode auto with no one to ask (-input deny) uses bwrap by
default; "sandbox": "none" in config.json, or -sandbox none, turns
that off. On Windows it uses MXC the same way when MXC is set up, and runs
commands unconfined, saying so, when it isn’t. Save a sandbox you always want
with "sandbox": "bwrap".
Where to go deeper
Section titled “Where to go deeper”- Settings, every key in
config.json - The permissions contract, every rule exactly
- The enforcement contract, what each sandbox guarantees