Skip to content
Source on GitHub (opens in a new tab)

An administrator can set limits for every zelk on a machine: the permission modes allowed, a required sandbox, how far commands may reach on the network, rules for every session, and more. The user’s settings, a project’s settings, flags and the terminal UI can’t widen them.

System File Drop-ins
Linux, WSL /etc/zelk/policy.json /etc/zelk/policy.d/*.json
macOS /Library/Application Support/zelk/policy.json /Library/Application Support/zelk/policy.d/*.json
Windows %ProgramData%\zelk\policy.json (usually C:\ProgramData\zelk) %ProgramData%\zelk\policy.d\*.json

On Windows zelk finds ProgramData from the machine’s own settings, not from the ProgramData or SystemDrive environment variables, which a user can change.

The paths are fixed: no flag or variable moves them, since either would let a user skip the policy. zelk reads policy.json first, then each drop-in in name order (10-network.json, 20-rules.json), so separate tools can manage separate concerns. Lists from all the files are combined; a value a later file sets replaces an earlier one. zelk reads the policy once, when it starts.

The files must be owned by root, and writable by no one else, as must the folders holding them; a folder above them must not let anyone else move them away. On Windows, “root” is the administrators: see Setting it up on Windows. A policy a user could edit isn’t a policy, so zelk refuses to start and says why. It also refuses to start when a file isn’t valid JSON, holds a value it can’t use ("sandbox": "maybe", a malformed rule), is larger than 1 MiB or can’t be read; the error names the file. A missing file means no policy. A key zelk doesn’t know, such as one from a newer zelk or a misspelling, is skipped with a warning naming the file and the key.

On Windows, a folder a standard user makes in ProgramData is theirs, and ProgramData lets every user create files in it, so the folder has to be made by an administrator and then locked down. zelk accepts the folder, and each policy file in it, only when:

  • SYSTEM, the Administrators group or TrustedInstaller owns it;
  • no one else is granted the right to write, add files, delete, change its permissions or take ownership, by an entry on it or one inherited from ProgramData;
  • no one else may remove or rename it, or a folder above it; and
  • it and the folders above it are ordinary folders, not links or junctions.

From a PowerShell opened with Run as administrator:

$dir = Join-Path ([Environment]::GetFolderPath('CommonApplicationData')) 'zelk'
New-Item -ItemType Directory -Path $dir -Force | Out-Null
icacls $dir /inheritance:r
icacls $dir /grant:r '*S-1-5-18:(OI)(CI)F' '*S-1-5-32-544:(OI)(CI)F' '*S-1-5-32-545:(OI)(CI)RX'

Then create policy.json (and policy.d) in that folder, and set the owner of everything in it. Save the JSON as UTF-8 without a byte-order mark, which WriteAllText does and Windows PowerShell’s Set-Content -Encoding utf8 doesn’t:

[IO.File]::WriteAllText((Join-Path $dir 'policy.json'), '{ "modes": ["plan", "default"], "hooks": false }')
icacls $dir /setowner '*S-1-5-32-544' /T
icacls $dir

The last command should list only NT AUTHORITY\SYSTEM and BUILTIN\Administrators with full control and BUILTIN\Users with read and execute (RX). Users need to read the policy; they must not write it. Check that zelk reads it with zelk policy.

If zelk refuses to start, the message names what it found: the owner’s account, or the account, the rights and whether they were inherited. Folders with no policy in them, and no folder at all, mean no policy. Windows has no sandbox in zelk, so a policy that requires one (sandbox, or network narrower than full) stops zelk from running commands there; use WSL2 for that.

{
"modes": ["plan", "default", "accept-edits"],
"sandbox": "required",
"network": "allowlist",
"network_allow": ["github.com", "*.npmjs.org"],
"deny": ["Bash(curl *)", "Read(**/.env)"],
"human": ["Bash(git push *)"],
"protect": ["infra/**"],
"rules_only": false,
"hooks": false,
"client_terminal": false,
"credential_store": "keychain"
}
Key Effect
modes The only permission modes zelk may start in or switch to, by any means: -mode, the TUI’s saved start mode, Shift+Tab, a plan’s approval, an editor over ACP, and subagents. Leaving out bypass and auto is the usual use.
sandbox "required": commands require bwrap (Linux), seatbelt (macOS) or MXC (Windows). "optional" lifts a requirement an earlier file set.
network The widest network commands may reach: "off", "allowlist" or "full". Anything narrower than "full" also requires a sandbox, since only a sandbox holds commands to it. A managed allowlist requires bwrap’s enforced network boundary. On macOS and Windows, "allowlist" limits network mode to "off".
network_allow The hosts a user’s allowlist may name. zelk’s own web tools and HTTP MCP servers keep to the same list.
deny, ask, human, protect, allow Rules and protected paths added to every session. They combine with everyone else’s and the strongest match wins, so a policy deny can’t be undone by any allow, and a policy human rule always asks a person.
rules_only true: only the policy’s allow rules count. The user’s, the project’s and the flags’ allow rules are dropped, and skills pre-approve nothing; their deny, ask and human rules still apply. Allow rules a person grants in a session still count.
hooks false: the user’s hooks.json and the project’s .zelk/hooks.json don’t run. A hook can answer an approval, so a policy with human rules usually turns hooks off too.
client_terminal false: zelk acp -client-terminal is overridden, since it runs commands in the editor’s terminal, outside zelk’s sandbox.
credential_store "keychain": credentials must be kept in the system keychain. A credential still in a file is refused until zelk credentials move -to keychain moves it. "any" lifts a requirement an earlier file set. See Credentials.

A key left out limits nothing, and an empty policy changes nothing.

The policy always wins. A setting the user never chose is moved inside the policy without comment; one they did choose is overridden with a warning naming both values and the policy file. For example, -sandbox none under a policy that requires a sandbox runs with bwrap, seatbelt or MXC, and says:

-sandbox none overridden: the policy at /etc/zelk/policy.json requires a sandbox; commands run under bwrap

A -mode the policy doesn’t allow becomes the first mode it allows, with the same kind of warning, so a script that passed -mode bypass may find commands refused that no one is there to approve. Warnings appear as a notice in the terminal UI, on standard error from zelk exec and zelk -p, and in zelk acp’s log.

In the terminal UI, Settings… shows a value the policy sets with “· policy” and won’t change it, choices the policy rules out aren’t offered, and Shift+Tab cycles only through the allowed modes. A session resumed under a policy takes the policy’s modes and rules, whenever it started.

zelk policy # the files read, the limits in force and the keys skipped
zelk policy -json # the same, as JSON

With no policy:

No managed policy. zelk reads one from /etc/zelk (policy.json, then policy.d/*.json).

On Windows the folder is C:\ProgramData\zelk (or wherever the system keeps ProgramData).

Support staff should ask for this output first.