# Safety

Source: https://www.zerd.si/docs/safety

Every tool call goes through one tool registry, whether it comes from the main agent, a sub-agent or a parallel worker. The limits below are enforced in code at that point, so the model can't talk its way past them.

## Three layers

1. File tools resolve the path first. `..` and symlinks that lead out of the workspace are refused.
2. Shell commands are scanned before they run. Any that touch paths in your home, `/etc`, other users' folders or `..` escapes are refused. Git commands that destroy history are blocked.
3. The OS sandbox (macOS `sandbox-exec`, on by default). A command can't write outside the workspace, temp and package caches. It also can't read `~/.ssh`, `~/.aws`, `~/.gnupg`, keychains, or the workspace's own `.env`, however the command reaches them.

The OS sandbox is macOS only. Linux and Windows get the confined file tools and the shell path scan, not the kernel layer. See [Windows](/docs/windows) and [Limits](/docs/limits).

## The path of one tool call

```mermaid
flowchart LR
    C["Tool call"] --> R1["Tool-name and argument repair"]
    R1 --> R2["Schema validation"]
    R2 --> G1["Guard: protected paths,<br/>forbidden commands, repo rules"]
    G1 --> G2["Workspace confinement<br/>.. and symlinks resolved first"]
    G2 --> H["before_tool hooks<br/>can veto"]
    H --> AP{"Deny, allow or<br/>ask rules, approval mode"}
    AP -->|"you approve a diff"| X
    AP -->|refused| NO(["Refused: the model is told<br/>not to find another way"])
    X["Shell scan, then<br/>macOS sandbox-exec"] --> RUN(["Runs"])
```

## Other protections

- `.env*`, `*.pem`, `*.key` and SSH keys are protected by default.
- Permission rules use Claude Code's notation, for example `Bash(git diff:*)` and `Edit(src/**)`.
- `web_fetch` refuses localhost, private ranges and cloud metadata at every redirect hop.
- A cloned repo can't turn on code execution. Its `.zerd/config.toml` cannot enable `hooks`, `mcp_servers`, `verify_commands`, `approval` and similar until you trust that exact file. Editing the file revokes the trust.

## Approvals

An approval shows you a diff, and what you approve is exactly what gets written. For the approval modes, see [Everyday use](/docs/everyday-use).
