# Permissions

> How zelk decides whether a tool call runs, asks a person or is refused.

Every tool call the model makes is decided before it runs: allowed, sent to
a person, or refused. The decision is recorded in the session's log with
the rule or step that made it, so you can always see why something ran.

For a workspace with a drive-absolute root such as `C:/repo`, file tools accept
both slash styles and report paths with forward slashes. They refuse ambiguous
Windows paths such as `C:file.txt`, UNC paths, alternate streams and reserved
device names. POSIX workspaces use POSIX paths.

## Modes

A session runs in one permission mode. A host always names it: there is no
default authority.

| Mode | What runs without asking |
|---|---|
| `plan` | reads only; anything else is refused. The agent explores and proposes a plan for approval |
| `default` | reads; anything else asks |
| `accept-edits` | reads, and file edits inside the workspace |
| `auto` | reads and workspace edits, though edits to build files, CI, scripts and configuration are reviewed; a reviewer model decides what would otherwise ask, and sends what it is unsure of to a person |
| `dont-ask` | reads; whatever would ask is refused |
| `bypass` | everything a rule doesn't deny, except protected paths |

In the terminal UI, Shift+Tab cycles `default`, `accept-edits`, `plan` and
`auto`. `zelk -p` runs in `bypass`, `zelk exec` in `plan` unless given
`-mode`. In Go, [`WithPermissionMode`](/reference/go/zelk/#withpermissionmode)
is required, and `zelk.New` fails without it.

## Rules

Rules name a tool and, optionally, what it acts on:

```text
Bash(npm test *)          a command, matched word by word
Edit(src/**)              a path in the workspace (Edit rules cover Write)
WebFetch(domain:go.dev)   a site and its subdomains
mcp__github__*            every tool from one MCP server
```

There are four kinds, and the strongest rule that matches decides,
wherever it came from: **deny** over **human** (always a person, even in
`auto`) over **ask** over **allow**. A deny rule wins in every mode.

Rules come from flags (`-allow`, `-ask`, `-deny`, `-human`), your
`~/.config/zelk/config.json` and a project's `.zelk/settings.json`. A
project's deny and ask rules apply at once, since they only make zelk more
careful; its allow rules apply only after you trust that file for that
workspace. Answering **Yes, always** to an approval adds an allow rule for
the rest of the session.

## Protected paths

Some writes are never allowed by a mode, a rule or a grant, because their
effect outlives the session: `.git/`, agent settings such as `.zelk/` and
`.claude/`, Git configuration, shell startup files, tool configuration such
as `.vscode/` or `.husky/`, and removing the workspace, `$HOME` or `/`. They
go to a person, and are refused where no one can be asked. `-protect` adds
your own. In `auto`, the reviewer decides some of these, such as tool
configuration; agent settings, `.git/` and shell startup files stay with a
person.

## The decision

Each call goes down these steps, in order. The first step with an answer
decides, and nothing below it is asked.

0. Hooks that gate tool calls run first; a hook’s deny is final.
1. A deny rule refuses.
2. Plan mode refuses anything that isn’t read-only.
3. A protected path, a human rule, or a hook’s ask goes to a person; in `auto` the reviewer may decide a protected path that isn’t human-only, such as tool configuration.
4. `bypass` allows.
5. An ask rule asks. Otherwise an allow rule, or the mode’s own grant, allows: reads in every mode, workspace edits in `accept-edits` and `auto`.
6. What is left asks a person, is reviewed in `auto`, and is refused in `dont-ask` or where no one can be asked.

The first step is your [hooks](/concepts/hooks/): code of your own that can
refuse, rewrite or ask about a call before any rule is read. A hook's deny
is final, and its allow counts as an allow rule, so it never overrides a
deny rule, plan mode or a protected path.

Reads count only inside the workspace: a command that reads `~/.aws` or a
path the shell computes isn't granted as a read.

## Shell commands

zelk parses each Bash command and matches rules against every simple
command in it, so `Bash(npm test *)` doesn't allow `npm test && rm -rf
build`. This matching is careful but not a security boundary: a shell
can always compute what a parser can't see.

### PowerShell commands

On Windows the agent also has a `PowerShell` tool, and rules for it take the
same form, `PowerShell(Get-ChildItem *)`. zelk reads a PowerShell command with
PowerShell's own parser, the one that will run it, and matches rules against
each command in a pipeline, statement or `&&` chain. Aliases count as the
cmdlets they stand for, so `ls`, `dir` and `gci` all match
`PowerShell(Get-ChildItem *)`. Cmdlet names match without regard to case. A few
read-only cmdlets, such as `Get-ChildItem`, `Get-Content` and
`Select-String`, run without asking when they read inside the workspace and
use audited parameters.

```sh
zelk -allow 'PowerShell(Get-ChildItem *)' -deny 'PowerShell(Remove-Item *)'
```

As with Bash, an allow rule needs every command to match. What the parser
can't read stays opaque and asks first: code built at run time (`iex`), `& $x`,
assignments, method calls, `Start-Process` and child PowerShell sessions. The
whole-tool rule `PowerShell` also covers opaque commands.

A hook matches a call by its tool name, so a hook for `Bash` doesn't see
PowerShell calls: to cover both, list both names. [The permissions
contract](/internals/permissions/) has the exact rules.

A [sandbox](/concepts/sandboxing/) limits what an allowed command can reach.
It provides a separate boundary around the running command; pair one with
unattended runs.

## Auto mode

In `auto`, a reviewer model judges each action that would otherwise ask
you, and sends what it can't judge to a person. It sees your messages and the
agent's tool calls, never the agent's own prose or the tools' output.
[The auto-mode reviewer](/concepts/reviewer/) says what it sees, what each
verdict does and how well it has done when measured.

Auto mode alone is not a safety boundary. To leave a run unattended, pair
it with a sandbox.

## Where to go deeper

The [permissions contract](/internals/permissions/) specifies every rule:
the read-only allowlist, how `cd` is followed, worktree sessions, approvals
and their digests, and the reviewer's circuit breaker.

See [the auto-mode reviewer](/concepts/reviewer/) for what the reviewer sees
and how well it works, [hooks](/concepts/hooks/) for the code that decides
first, and [sandboxing and enforcement](/concepts/sandboxing/) for launcher
profiles and network limits.
