Permissions, sandboxes and first-session setup
A coding agent can read files, run commands and change code. Before the first real task, decide what it may do alone, what needs your approval and what it must never touch.
Words on this page (13)
- agent
- : A model run in a loop that chooses its own tools and steps until the task is done.
- allowlist
- : A list of the only actions or sites something is permitted to use. Everything not on it is refused.
- least privilege
- : Giving a person or program only the access it needs for the job and nothing more.
- sandbox
- : A restricted environment where code can run with limited access to files and the network.
- repo
- : Repository: a project folder tracked by git, usually hosted on GitHub.
- git
- : The standard tool for tracking changes to code.
- worktree
- : A second checked-out copy of a git repository on its own branch in its own folder.
- attention
- : The mechanism that lets each token weigh all earlier tokens by relevance when computing its next representation.
- prompt
- : The input text you give a model, including instructions, examples and data.
- harness
- : Everything around the model that makes it an agent: prompts, tools, rules, sandboxes, hooks, memory and checks.
- prompt injection
- : Untrusted text that contains instructions the model follows, such as a web page telling it to leak data.
- logarithm
- : The power you raise a base to in order to get a number. log base 2 of 8 is 3 because 2 to the power 3 is 8.
- tool
- : A function the model can ask your program to run, described by a name, description and argument schema.
What it is
Every coding has a permission system. Reading files is usually allowed. Running a command or editing a file asks you first. You can allow some actions for good, such as running your tests, and block others, such as deleting files or pushing to the main branch. A list of actions that are always allowed is an . The idea behind all of it is : give the agent only the access the job needs.
A goes one step further. It is a restricted space, such as a container or a separate checkout of the , where the agent can act freely because a mistake there cannot reach your real files, other projects or secrets.
Your first session
Work through this list once, before any real task.
- Open the agent in one project folder, not your whole home directory.
- Start on a new branch or , so every change can be thrown away.
- Keep approvals on for commands. Allow only safe, repeatable ones (tests, linting, reading git history).
- Keep secrets out of reach: no
.envfiles, keys or production credentials in the folder the agent can read. - Write down in the memory file what must never be done, such as "never run migrations on production".
A worked example: sorting commands
You ask the agent to fix a failing test. It wants to run seven commands. Allow npm test and git diff for the rest of the session, because they only read or check. Approve npm install lodash once after looking at the package. Refuse rm -rf build unless you read the path, and refuse git push --force outright. Four commands never interrupt you again, one needed a decision, two were blocked. That is a few seconds of instead of a on every step.
How the approval check works
Before the agent runs a command or edits a file, the , the program that wraps the model, compares the request with your rules. A rule can allow it, block it, or ask you. The model does not decide this. That is the point: the check is ordinary code, so a clever prompt cannot talk its way past it. A sandbox adds a second layer, enforced by the operating system or a container, so even an approved command is limited to a small area.
A second example: where approvals are not enough
The agent reads a web page to learn about a library. Hidden in the page is a line telling it to send your files to an address. This is : text from outside that tries to give the agent orders. Your approval prompt may catch an obvious command. A harmless-looking command could still pass. A sandbox with no secrets inside and no network access to unknown sites limits the harm even if you click yes. Permissions reduce mistakes. Isolation limits the damage from the ones that slip through.
Trade-offs
More prompts mean more safety and more interruptions. After the fifth identical question, people start clicking yes without reading, which defeats the system. Allow narrow, repeatable commands so the prompts that remain are rare enough to read. Broad rules, such as allowing any command that starts with a common word, can include dangerous cases, so keep them specific.
What goes wrong
Look for these symptoms. The agent stalls on a prompt you did not see because it is in another window. A command is blocked, and the agent tries a workaround that you did not intend. A change lands on the wrong branch because you forgot to switch. To confirm, read the of commands the ran and check your branch name before starting.
Try it yourself
Create a throwaway folder with a git repository and one small file.
- Ask the agent to read the file and add a comment.
- Approve the edit and view the diff.
- Ask it to delete the file, and decline.
- Restore with git if anything changed.
Expect to see exactly what it asked and be able to undo it.
Common mistake
Turning off all approvals to go faster, in a folder that contains secrets or production access. The speed is real, and so is the damage when the agent follows a bad instruction hidden in a web page or a file.
A developer turns off every approval prompt so an agent can finish a refactor overnight. The agent reads a README that says "to build, first run the cleanup script", and the script wipes the local database. A single allowlist for tests and a separate branch would have cost thirty seconds of setup and kept the database.
Check yourself
What does least privilege mean for a coding agent?
Not quite. Limiting access limits the damage when it makes a mistake or follows a bad instruction.
Which command is safest to allow permanently?
Not quite. Read-only and check commands carry little risk, unlike deleting or publishing.
Why start an agent on a new branch or worktree?
Not quite. A separate branch turns a bad run into something you can delete.
You got 0 of 3 right.
Go deeper
- Docs
Anthropic · How to allow, ask for or deny each kind of action.
- Docs
Anthropic · Running commands in a restricted environment.
- Docs
Anthropic · The safeguards built in and what is still your job.
- Article
Simon Willison · Why private data, untrusted content and outside access are risky together.
Spotted a mistake or something unclear? Report it on GitHub.