Skip to content
Warden 2.0 Explore the preview

Warden CLI Reference

Every subcommand, flag, and exit behavior below matches the CLI source (cmd/warden). With no subcommand, warden prints usage and exits 1.

Commands you will use most

CommandWhat it does
warden doctorChecks whether this machine can run programs in the sandbox
warden runRuns a program inside the sandbox
warden learnObserves a Linux sandbox and reviews a starter policy
warden grantReviews a single host or filesystem read grant
warden guardReviews and installs an npm or PyPI release in a sandbox
warden trace -- <command>Runs a program once without the sandbox and records what it touches
warden initWrites a draft policy.yaml from a trace
warden logsShows allowed and blocked accesses
warden agent --policy <file> -- <agent>Lets a coding agent work on a sanitized copy of your project (guide)
warden wrapPreviews and applies a policy wrapper to an existing local MCP client entry

All commands

CommandWhat it does
agentEdit a sanitized workspace with protected secret fields
initCreate a policy from a trace
runRun an MCP server in the sandbox
traceRecord access attempts for policy generation (unsandboxed)
logsInspect the audit log
doctorCheck sandbox readiness
grantReview and add a host or filesystem read grant
guardReview and install an npm package or PyPI wheel
hookCheck or configure the advisory Claude Code hook
learnObserve a Linux sandbox and review a starter policy
migratePreview or apply a version 2 policy migration
validateCheck policy files without running a command
addConnect an MCP server to a client, sandboxed
wrap / unwrapPreview or apply a client launcher wrapper, and undo it
clientsList supported client configuration adapters
inventoryInspect configured stdio connections and drift
packsBrowse and generate policy packs
gatewayWrap servers registered in a gateway file
stopStop managed gateway connections
proxyRun an MCP client proxy with filtering
connectFilter a sandboxed stdio MCP connection
serveServe authenticated MCP over HTTP
mcpExpose Warden's tools to MCP clients over stdio
policy-diffReview policy changes before an upgrade
reportRecord and summarize local pilot events
k8sGenerate container and Kubernetes manifests from a policy
creatorCreate and verify signed creator evidence
versionShow the version
updateUpdate Warden to the latest release
helpShow help for a command, for example warden help run

Run warden help <command> for the flags of any command. The sections below cover the most common commands in detail.

warden run

Run a server under a policy. The sandbox backend is auto-detected (native first, Docker fallback, fail-closed when nothing is available).

See the zero-config quickstart for the reviewed Filesystem launcher.

warden run [--policy <file>] [--backend auto|linux|seatbelt|windows|docker]
           [--dry-run] [--approve] [--approve-timeout <dur>] -- <command...>
FlagMeaning
--policy <file>Select a policy YAML file explicitly. Relative filesystem grants resolve against the policy file’s directory.
--dry-runPrint the effective policy, its SHA-256, and the selected backend without launching the command. Use an explicit policy or a local warden.yaml.
--backend <name>Force a backend. Default auto. Aliases: bwrap → linux; macos, darwin, sandbox-exec → seatbelt; appcontainer, lowbox → windows. Unknown or unavailable backends fail closed.
--approveInteractive approval: prompt on first out-of-policy access instead of hard-failing. Network approvals apply live; filesystem approvals are saved to the policy and the server restarts. Requires a terminalfails closed without one.
--approve-timeout <dur>Per-prompt timeout (e.g. 30s, 2m). Zero waits indefinitely; expiry denies. Requires --approve.
-- <command...>Command to sandbox. Optional separatoreverything after the flags is the command anyway; -- lets the command itself start with a flag-like token.

Warden checks the explicit policy, then warden.yaml in the working directory, then a reviewed pack for the exact artifact version. The bare Filesystem launcher selects the bundled version. For other commands, an interactive terminal can review a starter policy. Without a matching policy or a terminal, the command exits before launching.

Command resolution: the CLI tail wins, otherwise the policy's command: is used, otherwise the run fails with a usage error. Bare executable names (npx, uvx, node) are resolved via PATH lookup and fail closed when unresolvable; prefer absolute paths in checked-in policies. Exit code: the sandboxed process's exit code, 1 on runtime failure, 2 on usage/policy errors.

Run output: warden run never prints the large banner. It prioritizes runtime information. When stderr is a TTY (and CI is not set and WARDEN_QUIET is empty) it prints a compact pre-launch summary to stderr only (so MCP stdio is untouched):

WARDEN
──────────────────────────────────────
Policy     policy.yaml
Backend    linux
Command    /usr/bin/node server.js

Filesystem
  ✓ /workspace/project (read)
  ✗ everything else

Network
  ✓ api.github.com
  ✗ everything else

Environment
  ✓ GITHUB_TOKEN
  ✗ all unspecified variables

──────────────────────────────────────
✓ Sandbox active

Only information from the loaded policy is shown. No permissions are invented. In CI / piped / WARDEN_QUIET=1 the summary is suppressed so warden run stays silent apart from the sandboxed process's own stdio. Security events are recorded to the audit log (warden logs) as structured allowed/blocked JSON; the CLI formats them as ✓ ALLOWED / ✗ BLOCKED when displayed (color reinforces but never replaces the text marker).

warden trace

Run unsandboxed but instrumented; record every file/network access to the trace log for init to consume:

warden trace -- <command...>

Prints the trace file path on stderr on exit. Exits with the command's exit code.

warden init

Generate a conservative starter policy from a trace log. Never overwrites an existing file:

warden init [--log <file>] [--output <file>] [-- <command...>]
FlagMeaning
--log <file>Trace log to read. Default: the latest trace.
--output, -o <file>Where to write. Default policy.yaml. Refuses to overwrite.
-- <command...>Recorded into the generated policy's command: field.

Only successful observed accesses become grants; blocked events never do; runtime paths (/usr, /proc, …) are omitted. Review and tighten the output before relying on it.

warden logs

Inspect the persistent JSONL audit log (${XDG_STATE_HOME:-~/.local/state}/warden/audit.jsonl):

warden logs [--log <file>] [--tail <n> | -n <n>] [--follow | -f]

--tail 0 prints nothing; --follow polls for appended events (survives truncation). Prints "no audit events recorded yet" when the log doesn't exist.

warden learn

warden learn --output ./warden.learned.yaml -- ./my-command

Run from the project directory on Linux. The observation uses a scratch home, views the project read-only with secret-file protection, and blocks egress. Review proposed file reads one at a time. Requested hosts appear in the report for separate review. On confirmation, Warden writes the policy, a report and the policy digest. Pass that digest to warden run --policy-sha256.

warden guard

warden guard npm install [email protected] --output ./reviewed-npm
warden guard pip install idna==3.10 --output ./reviewed-wheel

Use --strict to block missing release metadata. A version 2 policy selected with --policy <file> can extend the cooldown or require strict checks. See the Install Guard guide for configuration and review steps.

warden grant

warden grant host docs.example.org --policy warden.yaml
warden grant path ./data/report.json --policy warden.yaml

Warden previews one exact host or read grant and prompts for approval. Run warden logs --tail 50 --explain to identify a denied resource before editing the policy. Some grants require direct policy review.

warden doctor

On Linux, macOS, and Windows, warden doctor --prove checks that the native sandbox allows its fixture reads and writes and blocks an SSH decoy, an outside write, a network destination, and an environment sentinel. Linux and macOS check a proxy denial for a reserved hostname. Windows uses a live host loopback endpoint and places the decoy outside the read grant. Any failure exits with status 1.

Check that the host can actually enforce a sandbox. It probes the real backends (bubblewrap/Seatbelt/AppContainer/Docker), strace availability on Linux, the egress proxy, and the policy engine, and prints a security-oriented report:

warden doctor

Example output (TTY):

WARDEN DOCTOR

Environment
────────────────────────────────
✓ Operating system        linux/amd64
✓ Sandbox backend         linux
✓ Namespace support       available (bwrap)
✓ Network proxy           available (egress allowlist)
✓ Policy engine           ready (YAML + validation)
✓ Fail-closed             enabled (never runs unsandboxed)

Security posture
────────────────────────────────
✓ Filesystem isolation    explicit paths only
✓ Environment filtering   explicit vars only
✓ Network policy          explicit hosts only
✓ Fail-closed behavior    enforced

Status: READY

When the backend is unavailable it prints Status: NOT READY in red, the underlying RefuseToRun reason, and Warden fails closed when sandboxing is unavailable. The exit code is machine-readable so scripts and CI can gate on it:

  • 0ready to run
  • 1NOT READY (sandbox backend or a required tool such as strace is missing)
  • 2usage error (unexpected arguments)

warden version

Print the stamped build version and exit 0. This stays script-friendly and never prints a banner:

warden version
warden --version

Single line warden version <semver> (or dev for unstamped builds). Release builds stamp the version at link time (the npm launcher downloads that exact version's binary); unstamped source builds report dev. Accepts version, --version, -version, and -v.

warden add

Deprecated in the 2.0 preview. For new setups, use warden run to start the reviewed Filesystem server or warden wrap to connect an existing client entry.

Connect one MCP server to one MCP client in a single command, sandboxed behind Warden:

warden add slack to claude-desktop
warden add notion to claude-desktop
warden add @scope/[email protected] to claude-code \
    --allow-host api.example.com --allow-env SCOPE_KEY
warden add --list-clients

The first argument is a catalog pack id (warden packs list) or any npm MCP package (name[@version]). add prepares the pinned npm release inside the sandbox (registry-only egress, install scripts disabled), generates a deny-by-default policy, and registers a wrapped launcher in the client's config after a preview + confirmation prompt.

FlagMeaning
to <client> / --client <id>Target client adapter: claude-desktop, claude-code, cursor, codex, vscode, gemini, cline, cascade, generic.
--name <name>Entry name in the client config (default: pack id / package name).
--scope project|userConfig scope (default project; claude-desktop defaults to user).
--config <file>Explicit configuration path.
--runtime <dir>Prepared runtime directory (default ~/.local/share/warden/runtimes/..., honors XDG_DATA_HOME).
--data <dir>Data directory for packs that need one.
--policy <file>Use your own reviewed policy; its command becomes the upstream.
--allow-host <host>Generic npm servers: grant network egress (repeatable).
--allow-env <name>Generic npm servers: forward an env var name (repeatable).
--allow-read <path> / --allow-write <path>Generic npm servers: grant a read/write path (repeatable).
--backend <name>Sandbox backend (default auto).
--yesApply without the confirmation prompt.
--dry-runPreview only; writes nothing, starts no process.
--list-clientsShow every detected client config and its current entries (read-only; cannot be combined with other arguments).

Behavior: catalog packs use their reviewed pack grants; any other npm package gets a deny-by-default starter policy (no network, no env, no paths beyond the runtime) extended only by the --allow-* flags. Credentials are reported by name only and never written into config files. Before writing, add probes the real sandbox with an inert Warden process and refuses to modify the config if the backend is unavailable. Undo anytime with warden unwrap --client <client> --server <entry>. See warden help add.

warden gateway

Wrap gateway-registered servers so the gateway launches each one sandboxed:

warden gateway init --config <file> --policies <dir>
# Per-server deny-by-default policies (<name>.yaml). Remote (SSE/HTTP)
# servers are skippedno local process to sandbox. Never overwrites.

warden gateway run --config <file> --policies <dir> --server <name> \
    [--backend ...] [--approve] [--approve-timeout <dur>] -- [extra args...]
# Run one registered stdio server sandboxed. Fails closed when the policy
# is missing or the server is remote. Bare launcher names resolve via PATH.

warden gateway wrap --config <file> --policies <dir> \
    [--warden-bin <path>] [--backend <name>] [--output <file>]
# Emit a gateway config whose stdio commands are prefixed with
# 'warden run --policy ...'. Point the gateway at the wrapped file.

warden gateway list --config <file> [--policies <dir>]
# Show registered servers: stdio vs remote, and policy presence.

Supported configs: Claude-style mcpServers JSON (Claude Desktop/Code, Cursor, VS Code servers, Docker MCP Gateway clients) and gateway YAML registries (upstreams: à la jonfairbanks/mcp-gateway, backends: à la MikkoParkkola/mcp-gateway).

Exit codes

CodeMeaning
0Success (for run: the sandboxed process exited 0)
otherFor run/trace: the sandboxed/traced process's own exit code
1Runtime failure (backend unavailable, enforcement error, approval restarts exhausted)
2Usage or policy error (bad flags, unreadable/invalid policy, no command)

Terminal output

  • Colors: Set NO_COLOR=1 to turn off colors. TERM=dumb also turns them off.
  • ASCII only: Set WARDEN_NO_UNICODE=1 to replace the check marks with plain text.
  • First-run welcome: The first interactive run shows a short welcome. Set WARDEN_NO_FIRST_RUN=1 to hide it. It is never shown in CI or for warden run.
  • Refusing to run: If no sandbox backend is available, warden run stops with an error and does not run the program. It never falls back to running it unsandboxed. See the FAQ.