A coding agent that has to ask before every command is slow, and after the fortieth prompt you stop reading what you approve. An agent that never asks will, sooner or later, do something you didn’t want with full confidence. Most of the useful work happens between those two.
This post is the setup I use in between. The examples are for Claude Code, because that is what I can check against its documentation. Other agent tools have settings with the same purpose under other names.
The permission modes
Claude Code has six permission modes. Four matter for daily work:
| Mode | What runs without asking | What it means in practice |
|---|---|---|
default |
Reading files | You approve edits and commands one by one |
acceptEdits |
Reading and editing files | Edits go through. Most other commands still ask |
auto |
Everything, after a background check | Few prompts. The check can still block a step |
bypassPermissions |
Everything | No prompts and no check |
The last one is what the flag --dangerously-skip-permissions turns on. The documentation says what it is for: “Isolated containers and VMs only.” On a laptop that holds your SSH keys and your browser sessions, there is nothing between a wrong idea and its execution.
Why auto mode is the default I’d pick
In auto mode a second model looks at each action before it runs and compares it with what you asked for. It blocks, in the documentation’s words, “anything that escalates beyond your request, targets unrecognized infrastructure, or appears driven by hostile content Claude read”.
The first of those three is the one I notice in practice. Say you ask for a feature and a commit. The agent finishes, commits, and decides that pushing to GitHub would be a helpful next step. You said commit. Auto mode lets the commit through and stops the push.
It happened while this blog was being built. To check a quotation in a post, the agent tried to read my session logs from other projects. Nothing in my request had asked for that, and the check refused. I only learned about it because the agent told me it couldn’t verify the quote that way.
The list of what is blocked by default is long and reads like a collection of bad afternoons: force pushes, git reset --hard, production deploys, downloading a script and running it, printing a live credential into the conversation.
Since version 2.1.283, auto mode is the mode a new session in the terminal starts in. The same page carries a warning I’d repeat: “Auto mode reduces permission prompts but does not guarantee safety.” It is a second pair of eyes on each step. You still decide the direction.
Rules for the things it should never touch
Modes set the baseline. Rules on top of them name specific files and tools, and a deny rule holds in every mode, including the dangerous one.
The first rule I add in a project keeps the agent out of the file with the secrets. This is an example for a project’s .claude/settings.json:
{
"permissions": {
"deny": ["Read(./.env)", "Read(./.env.*)", "Read(./secrets/**)"]
}
}
A Read rule also blocks editing and writing the same path, and it covers the shell commands the tool can recognise, such as cat and head.
It has a limit that is easy to miss. The rule does not cover a script that opens the file itself. If the agent writes three lines of Python that read .env, the rule doesn’t see it. So I treat it as a seatbelt. The actual protection is that the .env on my development machine holds development keys, and the production ones never get there.
The same goes for tools the agent reaches through MCP servers, such as your issue tracker or your database. A deny rule can remove every tool of a server that writes. This example uses a made-up server name:
{
"permissions": {
"deny": [
"mcp__tracker__create_*",
"mcp__tracker__update_*",
"mcp__tracker__delete_*"
]
}
}
Where the service allows it, I also give the server a read-only token. Then the limit is enforced by the service and doesn’t depend on my settings file.
What the agent installs
Permissions cover what the agent does. They don’t cover what the packages it installs do, and an agent installs packages freely. Installing Astro alone brings in 52 other packages, each written by someone you’ve never heard of.
Attacks on this chain mostly work the same way: a popular package gets a malicious release, and it is caught and removed within hours or days. So the cheapest defence is to not install anything that new. Bun has a setting for it, in bunfig.toml:
[install]
minimumReleaseAge = 259200 # seconds, which is three days
With that line, a version published less than three days ago is skipped and an older one is installed. npm and pnpm have a setting with the same purpose.
The other half is the packages you already have. bun audit lists known vulnerabilities in what is installed. When I ran it on my personal site, which I hadn’t updated for a few weeks, it reported 22. I now ask the agent to update dependencies and run the audit as a regular chore.
Skills are instructions, so read them
A skill is a text file that tells the agent how to do a task, and you can install one written by a stranger with a single command. The agent then follows that text with your permissions. A skill can contain a line that says to send every secret in the project to some address, and nothing about installing it will look unusual.
Before I install a skill from someone I don’t know, I read it, or I have the agent read it and tell me what it does and what it sends where. Skills published by the company behind the tool they are for are a safer start.
The three habits behind the settings
Settings are half of it. The other half is how I work with the agent:
- I say how, and I say what not. “Analyse the orders table, read-only” gives the check in auto mode something to hold the agent to. “Look at the orders table” doesn’t.
- Irreversible steps are mine. For a migration on real data or a DNS change, the agent writes the commands and explains them, and I run them and look at the result.
- A correction I make twice becomes a rule. If I’ve told the agent the same thing two or three times, it goes into the instructions file it reads at the start of every session. I go through mine in A real CLAUDE.md, line by line.
None of this makes an agent safe to leave alone with production. It makes it safe enough to leave alone with a task for an hour.