Permissions and rules
Rules decide what the agent may do without asking you. They are a list in a file: each rule matches a kind of tool call and says allow, deny, ask, or nudge. The first rule that matches wins. A fifth kind, a hint, decides nothing and only adds text to whatever rule wins below it.
What happens without any rules
Xi ships with defaults that cover the usual cases. Out of the box:
- Reading, searching and listing inside the project runs freely.
- Writing inside the project runs freely. Writing outside it, or into
.env,.git/,node_modules/or a mail or key directory, asks. - Read-only commands (
ls,cat,git,grep, …) run freely. Every other command asks the first time; "always" allows it for the rest of the chat. - A command whose program is not installed fails at once with an error naming it, with no dialog.
- Destructive commands (
rm -rf,git push,kill, …) ask every time. - Dumping the environment (
env,printenv,/proc/<pid>/environ), reading a credential file (.env,~/.aws/credentials, …) or printing a secret (pass,gh auth token, …) asks every time, with a warning that the output goes to your LLM provider. Reading one variable is free. - Tools from an MCP server ask until you trust the server.
- Starting a sub-agent asks.
Some things are never allowed, whatever your rules say: sudo, remote shells and copies (ssh, scp, rsync), reading SSH private keys, and writing to ~/.config/xi/rules.edn. Changing a project's .xi/rules.edn or config.edn always asks, even when it is a symlink into a dotfiles checkout the agent may otherwise edit. This is the hardened tier; only the person starting Xi can turn it off, with a command-line flag, and the agent cannot.
The dialog
When a call asks, both clients show the same dialog: what the tool wants to do, and for an edit, the diff it would make.
| Key | Answer |
|---|---|
y | Allow this call |
n | Deny it |
a | Allow it, and stop asking for the same thing in this chat |
r | For writes: allow writes anywhere in that repository |
d | For edits: open the whole diff |
/allow, /deny, Alt+a and Alt+d answer it from the keyboard. An answer of a or r adds a rule that lives with the chat; /rules shows it.
To tell the agent why you said no, deny with a reason. In the web client, click the ⋯ next to Deny: the message box becomes a reason field, and Enter denies the call (Esc goes back without answering). In either client, /deny <reason> does the same. The agent gets your reason in the tool result, so it can change course instead of retrying.
Yolo mode
Yolo mode stops most dialogs for the current chat: a call that would ask runs instead. It has two levels:
| Command | Level | Still asks |
|---|---|---|
/yolo | Sane | Writes into .env, .git/ or key directories; secret leaks (environment dumps, credential files, secret CLIs); git push, mkfs, dd; deleting a directory outside the project; persistence (below); server restarts. Removing a system directory (/, the home directory, /usr, /etc, /nix, …) is denied. |
/yolo relentless | Relentless | Server restarts (bb serve:restart, serve:stop); persistence: writes to ~/.ssh and ~/.profile, systemd user units and autostart entries (Linux), LaunchAgents (macOS), and crontab, systemctl --user enable, launchctl load, ssh -R. Your shell's rc files too once you add its bundle. |
/yolo again, or /yolo off, turns it off; /yolo sane switches back from relentless. It works while the agent is busy, and raising the level allows the open asks it would have skipped. The terminal prompt shows 🔥 (sane) or 🔥🔥 (relentless), the web chat header a Yolo or Relentless chip (click it to turn yolo off). The level is saved with the chat: it stays across turns, chat switches and server restarts. New chats start off, or at the level you made the default (Chat settings).
It skips confirmations only: rule asks, the clj tool's own prompts (programs, paths outside the project, directory deletions) and sub-agent starts. A rule that denies or nudges still does, and the hardened tier still asks for its own dialogs (writes into .git/hooks or .git/config) at both levels.
To keep one of your own asks in sane mode, give its action :guard :sane; :guard :always keeps it in relentless mode too:
{:match {:tool :sh :cli "terraform" :command #"\bapply\b"}
:action {:type :ask :guard :always}}An agent profile with :yolo false has no yolo mode: /yolo refuses and the web client shows no flame.
A :guard :always ask can't be shadowed. An allow above it asks in its place, an ask above it takes its guard, and only a deny or nudge above it wins. For example, bb serve:restart always asks, even with a changed bb.edn or a rule that allows every bb task. A :guard :sane ask passes its guard to asks above it that match the same call.
Writing your own rules
Put rules in ~/.config/xi/rules.edn. They apply to every project.
;; ~/.config/xi/rules.edn
{:type :xi/rules
:version 1
:rules
[;; reads anywhere under ~/code never ask
{:match {:tool #{:read :grep :find :ls} :path #"^~/code(?:/|$)"}
:action {:type :allow}}
;; steer away from shell scripts
{:match {:tool #{:write :edit} :path #"\.sh$"}
:action {:type :nudge :message "Write Babashka scripts, not shell scripts."}}
;; deleting under /tmp never asks (every path the command names must
;; be under /tmp — the glob is tested against each one)
{:match {:tool :sh :cli "rm" :path "/tmp/**"}
:action {:type :allow}}
;; every bb task of this project but deploy, with any arguments
{:match {:tool :task :task {"bb" ["*" "!deploy"]}}
:action {:type :allow}}
;; always confirm a push
{:match {:tool :sh :cli "git" :command #"\bgit push\b"}
:action {:type :ask :message "Push to the remote?"}}]}A rule has a :match and an :action. Every key in :match must hold for the rule to apply; a key you leave out is no constraint.
Matching
| Key | Matches | Value |
|---|---|---|
:tool | The kind of call | :read :write :edit :grep :find :ls :sh :task :clj :net :mcp :other, or a set of them. :task is the run_task tool and a (sh …) running a project task |
:path | The file a call targets, or every file a (sh …) command names | A regex (#"…", partial match) or a glob string ("src/**/*.cljs", full match; **/ is zero or more directories). Tested against the path as given, resolved, and with $HOME shown as ~. For a command, each non-flag argument must match |
:cli | The program a command runs | A string, a set, or a regex |
:read-only | Whether a (sh …) call's arguments are read-only for its program (find without -exec, git without push or -c, …) | true or false; see the reference |
:task | The project task a command runs (bb test, npm run build) | A map of runner to task patterns, like {"bb" ["*" "!deploy"]}; see the reference |
:command | The command line | A regex or a substring |
:repo | The git repository | The end of its path, like "code/my-app" |
:dir | The working directory | A path prefix |
:extension | Calls made by an extension | Its id as a string |
:host | The host an extension requests, or every host a read-only (sh "curl" …) requests | A string, set or regex |
:mcp-server / :mcp-tool | An MCP server and its tool | Strings or globs |
:tool-name | One particular tool by name | A string, set or regex |
:user | Who the call acts for | A user id (string, set or regex), or a map matched against their config.edn profile, like {:meta {:team "ops"}} |
Actions
:type | Does |
|---|---|
:allow | Runs the call. No later rule is consulted. |
:deny | Blocks it; the agent sees :message. |
:ask | Shows the dialog. :message replaces the default text. |
:nudge | Blocks it, but tells the agent :message as a hint rather than an error. |
:hint | Decides nothing. Its :message is added under the message of the rule that wins below it, so a note of yours rides on a built-in deny or ask. |
:message can use {cli} for the program and {command} for the command line. Hints are how you teach the agent what to do instead on your machine without rewriting the built-in rule. If python3 is not installed, the default rule already denies it with an error; a hint adds the alternative:
{:match {:tool :sh :command #"-m\s+http\.server"}
:action {:type :hint
:message "No python3 here. Serve a directory with babashka:
(process/start \"bb -m babashka.http-server --port 8000 --dir public\")"}}Order and precedence
Rules are tried in this order, and the first match wins:
- The hardened tier (built in, cannot be overridden)
<project>/.xi/rules.edn~/.config/xi/rules.edn- Rules added during a chat (
aandranswers,/clj allow) - The built-in defaults
Your files sit above the in-chat grants on purpose: a rule you wrote down beats an "always" clicked in a hurry. The project's file beats the global one.
Within a file, order matters too. Put the specific rule before the general one.
Rules for some users
On a shared server, :user scopes a rule to the people it is for. A call acts for whoever sent the chat's latest prompt (see Users). Name them by id, or by what config.edn says about them under :users:
;; config.edn
:users {"alice" {:name "Alice" :meta {:team "guests"}}
"bob" {:meta {:roles ["admin"]}}}
;; rules.edn
[;; alice may not run commands at all
{:match {:user "alice" :tool #{:bash :sh :clj :task}}
:action {:type :deny :message "Commands are off for this account."}}
;; every guest is asked before any write
{:match {:user {:meta {:team "guests"}} :tool #{:write :edit}}
:action {:type :ask}}
;; admins push without asking
{:match {:user {:meta {:roles "admin"}} :tool :sh :command #"\bgit push\b"}
:action {:type :allow}}]A user with no matching rule falls through to the rest of the list, as usual. An id nobody declared has an empty :meta. The profile is read when a rule needs it, so an edit to config.edn applies on the next call. If config.edn is invalid, a :meta rule that restricts applies to everyone and one that allows applies to no one, until you fix it.
A user is whoever their device says it is, unless you pin the device to a user with xi clients user (see Users). Do that for every device before you rely on a rule that restricts someone. Tutorial: users and roles sets up roles end to end, including an extension that grants its own.
Rules for one project
A repository can carry its own rules in .xi/rules.edn at its root, with the same shape. They apply when the chat runs inside that repository and win over the global file.
The agent may write this file, but every change asks, yes or no only. No rule or Yolo mode skips the question, and with no client attached to answer it the write is denied.
/rules save (also in the Ctrl/Cmd+K palette) moves the rules you granted in the current chat into that file.
Changing the defaults
A :defaults key replaces the built-in set with the bundles you list. Leave one out to switch it off:
{:type :xi/rules
:version 1
:rules []
:defaults [:xi.rules.defaults/env
:xi.rules.defaults/write-gates
:xi.rules.defaults/bash-guards
:xi.rules.defaults/mcp-confirm
:xi.rules.defaults/clj-sh]}/rules shows the full default list with its bundle names.
Some bundles aren't in the default list because they only fit some systems, like the one guarding your shell's rc files. Name them in :rules to turn them on:
:rules [:xi.rules.defaults/persistence-zsh]The list: Opt-in bundles.
Reference
Every match field, action option, and default bundle: Rules reference.