Topic 3 of 5 · 4 min read
Terminal agent permission modes
Goal: Choose a permission mode and command allow-list for a described task and spot an auto-approval that is dangerous.
A permission mode decides which agent actions run without asking you, and the right mode depends on how much damage a wrong action could do, not on how much you trust the model.
Check yourself · 1 of 3
Which setup is the safest default for daily work with a terminal agent?
Why it matters
An agent with shell access can delete files, rewrite git history, push code and call the network. Asking about every step is safe but slow, so people turn on auto-approval. The risk lies in what you approve in advance. A command that looks harmless can be dangerous once the agent chains it with another.
The common modes
Tool names differ, but most CLIs offer these levels:
- Ask every time. Reads may be free, but edits and commands need a yes. Safest, slowest.
- Allow-listed commands. You pre-approve exact commands, such as the test runner, and everything else still asks. This is the best default for daily work.
- Auto-accept edits. File edits go through without a prompt, shell commands still ask. Good when you will review the diff afterwards.
- Plan mode or read-only. The agent can read and propose a plan but not change anything. Good for unfamiliar code.
- Fully autonomous (often called "yolo" or "dangerously skip permissions"). Nothing asks. Use it only in a sandbox that holds no secrets and no access to anything you cannot lose, such as a throwaway container.
Writing an allow-list
Be narrow. Approve a command, not a family of commands.
{
"permissions": {
"allow": ["Bash(npm run test:*)", "Bash(git diff:*)", "Bash(git status)"],
"deny": ["Bash(rm:*)", "Bash(git push:*)", "Read(./.env)"]
}
}
Check your own tool's docs for the exact syntax. The pattern is the point: allow read-style and test commands, deny deletion, pushing and secret files.
Before and after
Before: allow
Bash(npm:*)because "it is just npm".
npm can run any script in package.json, including install scripts that download and execute code, or a deploy script.
After: allow
Bash(npm run test:*)andBash(npm run lint). Everything else asks.
What goes wrong
- Wildcards that are too wide.
Bash(git:*)includesgit push --forceandgit reset --hard. - Approval fatigue. After fifty prompts people press yes without reading. Narrow allow-lists reduce prompts so the remaining ones get real attention.
- Autonomous mode on a real machine. A wrong command or an instruction hidden in a file the agent reads (prompt injection) then runs with your credentials.
- Secrets in reach. Any file the agent can read, its output can leak into the model's context.
Examples
Too wide
{ "permissions": { "allow": ["Bash(git:*)"] } }
This allows git push --force origin main and git clean -fdx without a prompt. Replace it with Bash(git status), Bash(git diff:*) and Bash(git log:*).
Matching mode to task
Exploring a codebase you do not know: plan or read-only mode. Fixing a bug with a test: allow-list for the test command, edits asked or accepted. Running a large generated migration in a disposable container: autonomous may be fine, because the container is the safety boundary.
Key points
- Choose a permission mode by the damage a wrong action could do, not by how much you trust the model.
- A narrow allow-list for tests and read-only commands is a safe default for daily work.
- Wildcards such as a broad git or npm rule quietly allow destructive or remote-affecting commands.
- Fully autonomous mode belongs only in a throwaway sandbox with no secrets and no production access.
- Deny rules for deletion, pushing and secret files protect you even when you approve in a hurry.
Common mistakes
- Allowing a whole command family because it feels routine.
- Switching to fully autonomous mode on a laptop that holds SSH keys and cloud logins.
- Approving prompts without reading them once they become frequent.
- Forgetting that an agent can read secret files unless you deny them.
Check yourself · 2 of 3
Why is allowing the pattern Bash(git:*) risky?
Check yourself · 3 of 3
When is fully autonomous mode reasonable?
Practice items, not counted towards your mastery.
Start here
- How Claude Code works (opens in a new tab)DocsFree
A vendor's own description of the agent loop: gather context, take action, verify, repeat.
- Best practices for Claude Code (Claude Code docs) (opens in a new tab)DocsFree
Advice on giving the agent a way to verify its work, plus memory files and course correction.
- Configure permissions (Claude Code) (opens in a new tab)DocsFree
Allow, ask and deny rules and permission modes, with examples of command patterns.
More for this topic
- Security (Claude Code) (opens in a new tab)DocsFree
Prompt-injection risks, sandboxing and the safeguards around command execution.