A managed policy lets an administrator set defaults, lock settings, and restrict capabilities (such as maximum permission mode, allowed providers, or remote access) for every user on a machine. The Zharf Code server enforces the policy for all connected clients (desktop, web, and mobile).
- Author a JSON policy (see Write a policy). Do not include secrets—all local users can read the policy.
- Validate it:
zharf-code policy check policy.json. - Deploy via MDM/GPO or a file to one supported location.
- Restart Zharf Code on the machine (policies load at startup only).
- Verify with
zharf-code policy show.
{
"schemaVersion": 1,
"organization": "Example Corp",
"supportUrl": "https://it.example.com/zharf-code",
"settings": {
"defaultRuntimeMode": { "value": "approval-required", "locked": false },
"enableAgentBrowserAccess": { "value": false, "locked": true }
},
"limits": {
"maxRuntimeMode": "auto-accept-edits",
"clients": ["desktop", "local-browser"],
"telemetry": false
}
}schemaVersion and organization are required. Locked controls display your organization name and optional supportUrl in Settings.
Use one source per machine (having both a native policy and a policy file prevents Zharf Code from starting):
| OS | Native policy | Policy file (admin-writable only) |
|---|---|---|
| macOS | Device configuration profile for ai.zharf.code |
/Library/Application Support/ZharfCode/policy.json |
| Windows | GPO template or Policy (REG_SZ) under HKLM\SOFTWARE\Policies\ZharfAI\ZharfCode |
C:\Program Files\ZharfCode\policy.json |
| Linux | — | /etc/zharf-code/policy.json |
- macOS profile: Generate
macos/zharf-code.mobileconfigwithzharf-code policy templates <dir> --policy policy.json(orplutil -convert xml1 -o ai.zharf.code.plist policy.json). Deploy as a single device profile (profiles cannot representnull; use a policy file if needed). - Windows GPO: Generate
windows/zharf-code.admxandwindows/en-US/zharf-code.admlwithzharf-code policy templates <dir>, import intoPolicyDefinitions/Intune under Computer Configuration → Administrative Templates → Zharf Code, set Organization, rungpupdate /target:computer /force, and restart Zharf Code. - Windows registry: Set
Policy(REG_SZ) to single-line JSON (do not mix with GPO template values).
Run zharf-code policy show as the user running Zharf Code to inspect the installed policy, fingerprint, and whether the running server has loaded it. After any policy change or removal, restart the desktop app or run zharf-code service restart. Removing a policy restores the user's own saved settings.
Note: Zharf Code refuses to start if a policy is unreadable, invalid, uses unknown keys from a newer version, or conflicts with another policy source. Always validate with
zharf-code policy checkand upgrade Zharf Code before deploying newer keys.
Run zharf-code policy settings to list every manageable path from settings.json and its default.
"locked": falsesets a default (users can override)."locked": trueenforces the value across Settings and project overrides.
Key constraints:
- Lock
worktreeCleanuptogether withstorageCleanupworktree rules. observability(OTLP endpoints) cannot be managed by policy.- Manage
idleCompaction(not legacycompactIdleThreads). - Lock
providerInstances.<id>as a whole, or pin per-driver fields underlimits.providers.instances.
{
"schemaVersion": 1,
"organization": "Example Corp",
"limits": {
"maxRuntimeMode": "auto-accept-edits",
"clients": ["desktop"],
"connect": false,
"webhookTasks": false,
"browserCookieImport": false,
"previewTunnel": false,
"worktreeLayoutCommands": false,
"telemetry": false,
"providers": {
"allowedDrivers": ["claudeAgent", "codex"],
"instances": {
"claudeAgent": {
"locked": true,
"environment": [{ "name": "CLAUDE_CODE_USE_BEDROCK", "value": "1" }]
}
}
},
"updates": { "mode": "auto", "feedUrl": "https://updates.example.com/t3code/" }
}
}maxRuntimeMode caps all threads (approval-required, auto-accept-edits, auto, or full-access). Threads above the cap cannot run until lowered.
When maxRuntimeMode is set, users cannot modify provider launch settings (binaryPath, launchArgs, config home, or env vars)—pin required values (including absolute binaryPaths so user PATH entries can't shadow them) in providers.instances. Leave acpRegistry out of allowedDrivers if you don't want users adding arbitrary ACP Registry agents.
clients allows any subset of desktop, local-browser, and remote (keep desktop on desktop machines).
- Omitting
remoterestricts the server to loopback, revokes paired devices, disables LAN/Tailscale Serve/Zharf Connect, and refuses startup if a Tailscale Serve route still forwards to Zharf Code (or if a legacy service has LAN enabled—runzharf-code up --no-lan). - Set
"connect": falseto disable Zharf Connect while allowing LAN/Tailscale remote access.
webhookTasks: false: Disables scheduled-task and workflow webhooks.browserCookieImport: false: Disables importing cookies from other browsers.previewTunnel: false: Disables remotelocalhosttunneling and port forwarding (streams tabs instead).worktreeLayoutCommands: false: Disablest3.jsonworktreeLayoutcreate/removecommands.telemetry: false: Disables product usage data and relay tracing for the server, desktop app, and server-opened browsers (does not controlcode.zharf.aior mobile).
providers.allowedDrivers: Whitelist of driver IDs (codex,claudeAgent,cursor,grok,opencode,antigravity,fx,kiro,pi,muse,acpRegistry).providers.instances: Sets or locks ("locked": true) fields across all instances of a driver (e.g., Bedrock/gateway env vars,binaryPath,launchArgs). Lockingcodex(or usingmaxRuntimeMode) disables ChatGPT-managed Codex; lockingopencodedisables externalserverUrl.
mode:"auto"or"off"(when updates are managed externally).feedUrl: Custom update mirror matching GitHub Release layout (latest*.ymland installers at root;t3-*archives andSHA256SUMSunderv<version>/).allowNightly: false: Disables the nightly channel.
- Provider CLIs: Restrict underlying CLIs with their own managed settings (e.g., Claude Code managed settings).
- WSL: Managed Windows desktop disables its WSL environment; a server started manually inside WSL reads
/etc/zharf-code/policy.jsonin that distro. - Local admins / port forwarding: Administrators can modify policies or Zharf Code binaries, and users can still port-forward loopback sockets with external tools. Use OS/MDM controls for binary integrity and network isolation.