Permissions in Claude Code
Understand how Claude Code decides what it may read, change, and run on your computer: the default approvals, the permission modes, allow and deny rules, where the settings live, and how to build a safe, comfortable policy for yourself or your team.
Claude Code is an assistant that works inside your software projects. It can read your files, edit your code, run commands in your terminal, and use outside tools. That is exactly what makes it useful, and it is also exactly why it needs rules. An assistant that can run commands on your machine is powerful. An assistant that can run any command without asking would be risky.
Permissions are the rules that sit between what Claude Code wants to do and what it is actually allowed to do. They answer simple but important questions. May it read this file? May it change that one? May it run this command, or must it ask first? May it never touch a particular folder at all? With good answers to these questions, you can let Claude Code work smoothly while keeping a firm hand on the things that matter.
This guide explains permissions from the very beginning. We cover why they exist, the layers of the system, the modes you can choose, how to write rules, where settings are stored, how sandboxing and hooks add protection, and how to design a sensible policy. Claude Code is updated often, and names of settings, commands, and options can change, so for the exact current wording, check the official documentation at docs.claude.com. This article focuses on the ideas that stay true as the details move.
1What Are Permissions, and Why Do They Exist?
Permissions are the safety rules that keep a powerful coding assistant inside boundaries you chose.
The plain-words definition
A permission is a yes-or-no decision about one action. Claude Code is about to read a file, edit a file, run a command, fetch a web page, or call an outside tool. For each action, the system asks: is this allowed automatically, does it need the user’s approval, or is it forbidden? The collection of all such decisions, together with the rules that produce them, is called the permission system.
Why a coding assistant needs them
Most programs do only what their buttons allow. A coding assistant is different, because it can combine small actions into big effects. Reading a file is harmless, but editing many files can break a project, and a single terminal command can delete a folder, install software, or send data across the internet. Permissions exist so that the small harmless actions can flow freely while the powerful ones get your attention.
Your files and machine
Stop accidental damage, such as deleting the wrong folder or overwriting important work.
Your secrets
Keep keys, tokens, and private files out of reach, so they cannot be read or leaked.
Your pace
Let you choose how much to approve by hand and how much to leave to Claude.
Your team’s standards
Let a team share one set of safe rules, so everyone works under the same boundaries.
Think of lending your car to a skilled driver. You might say: “Drive wherever you need in the city, ask me before a long trip, and never take it onto the highway at night.” Permissions are those instructions. They let a capable driver be useful without making you nervous every time the engine starts.
Permissions control what Claude Code is allowed to do. They are one layer of safety among several, alongside sandboxing, hooks, and your own review of its work.
2The Core Idea: Tools and Their Risk
Claude Code acts through tools, and permissions are attached to tools according to how risky they are.
What is a tool?
In Claude Code, everything Claude does in your environment happens through a tool. There is a tool for reading files, a tool for searching, a tool for editing, a tool for running terminal commands, a tool for fetching web pages, and others. When Claude wants to do something, it asks to use a tool with specific inputs. The permission system looks at that request and decides what to do.
A ladder of risk
Tools are not equally dangerous. A helpful way to see them is as a ladder, from harmless at the bottom to serious at the top.
flowchart TD
A["Request to use a tool"] --> B{"What kind of action?"}
B -- "Look only: read, search, list" --> C["Lowest risk: usually allowed without asking"]
B -- "Change files: edit, write" --> D["Medium risk: ask, or allow inside the project"]
B -- "Run commands" --> E["Higher risk: ask unless the command is known safe"]
B -- "Reach outside: web, network, outside tools" --> F["Highest variety: ask, or follow your rules"]
The ladder explains most of the default behavior. Looking at things is safe enough to allow freely. Changing files deserves a decision, because changes can be unwanted. Running commands is more serious because commands can do almost anything. Reaching outside the machine adds the risk of leaking data or pulling in untrusted content.
| Kind of action | Example | What can go wrong |
|---|---|---|
| Read | Open a source file | Little, unless the file holds secrets |
| Search | Find where a function is used | Little |
| Edit | Change a source file | Unwanted or broken changes |
| Run | Run the tests, or a build script | Anything the command can do |
| Fetch | Download a web page | Untrusted content, hidden instructions |
| Outside tools | Use a connected service | Changes in systems beyond your computer |
In a workshop, anyone can look at the blueprints, but you ask before using the saw, and the chemical store is locked. Permissions follow the same common sense: easy access to the harmless, a decision for the powerful, and a lock on the dangerous.
Permissions are about actions, not about trust in Claude’s intentions. Even a well-behaved assistant can make a mistake, or be misled by content it reads, so boundaries matter either way.
3The Default: Ask Before Acting
Out of the box, Claude Code is cautious. It reads freely and asks before it changes or runs things.
When you start Claude Code in its standard setup, it follows a careful default. Reading and searching within your project generally happen without interruption. When Claude wants to edit a file or run a command that is not already approved, it stops and shows you what it plans to do. You then choose whether to allow it. This is the safest everyday setting, and it teaches you how Claude works.
What an approval prompt tells you
An approval prompt is a small window of information. It names the tool, shows the specific input, such as the file to edit or the command to run, and offers choices. Typical choices are to allow this one time, to allow this kind of action from now on, or to refuse and tell Claude to try something else. Reading the prompt is the heart of the system, because it is the moment when you check what is really about to happen.
Claude proposes an action
It decides it needs to edit a file or run a command to move your task forward.
The system checks the rules
Deny rules are checked first, then ask rules, then allow rules, and the current mode.
You may be asked
If nothing allows or forbids the action, the prompt appears with the details.
You decide
You allow once, allow similar actions, or say no and redirect Claude.
The action runs or is refused
Claude continues with the result, or adapts its plan if it was refused.
Think of a new house-painter who asks, “May I move this table?” and “Shall I paint over this old patch?” before each non-obvious step. At first the questions are frequent. As you come to trust the painter, you say, “Go ahead and move the furniture, just ask me about color changes.” The default gives you the chance to build that trust step by step.
In your first sessions, read each prompt carefully. You will quickly learn which actions are routine and which deserve a pause, and that tells you what to automate.
Learning from the prompts
Treat your first week of approvals as a free lesson. Each prompt shows you what Claude considers necessary to do your task. Over time you will notice patterns: it often runs the tests, checks the version control status, and searches for names. These repeated, low-risk actions are natural candidates for allow rules. The unusual prompts, such as a command you do not recognize or a file outside the project, are the ones deserving a pause. The skill you are building is the ability to tell routine from surprising at a glance.
4Permission Modes
A mode is a quick setting that changes how much Claude Code does without asking.
Instead of editing rules for every situation, you can switch the overall mode of a session. Modes are like gears in a car: each suits a different road. The set of modes and their names can change between versions, so treat the table below as a guide to the idea and check the documentation for the current list.
| Mode (idea) | What Claude does without asking | Best for |
|---|---|---|
| Default, ask as needed | Reads and searches; asks before edits and commands | Learning, sensitive projects |
| Accept edits | Edits files in the project freely; still asks for most commands | Focused coding sessions you can review afterward |
| Plan only | Reads and thinks; makes a plan but changes nothing | Exploring a big change before committing to it |
| Bypass all checks | Everything without asking | Only isolated, disposable environments |
flowchart LR
A["Plan only: think, no changes"] --> B["Default: ask for edits and commands"]
B --> C["Accept edits: edits flow, commands asked"]
C --> D["Bypass all checks: no questions asked"]
Choosing a mode
Think about the stakes and the reversibility. If your work is under version control and you can inspect and undo changes easily, allowing edits to flow can be comfortable. If you are exploring an unfamiliar codebase, plan-only mode lets Claude study and propose without touching anything. If the project is sensitive, stay with the default and add rules. The last mode, which skips all checks, removes your safety net entirely. It is meant for isolated, throwaway environments such as a container that can be destroyed, never for your everyday machine with real credentials.
Driving modes work the same way. You use first gear on a steep, narrow lane and top gear on an empty highway. You would not stay in top gear down a mountain road. Choosing the mode for the road you are on is a sign of skill, not a lack of ambition.
Skipping all permission checks means a mistake or a hidden malicious instruction can run commands unchecked. Use it only where nothing valuable can be reached and the environment can be thrown away.
5Rules: Allow, Ask, and Deny
Rules are standing decisions that save you from answering the same prompt again and again.
Modes are broad. Rules are precise. A rule names a tool, and optionally a pattern describing exactly what it applies to, and states what to do: allow it, ask about it, or deny it. For example, you might allow running the project’s test command, ask before any command that installs software, and deny reading your secrets file.
Go ahead
The action runs without a prompt. Use it for safe, routine, repeated actions.
Check with me
The action always prompts, even if a broader rule might allow it. Use it for actions you want to see every time.
Never
The action is blocked, and Claude cannot do it even if asked. Use it for secrets and dangerous operations.
Which rule wins?
When more than one rule could apply, a simple order of strength decides. A deny rule beats an ask rule, and an ask rule beats an allow rule. This means a specific refusal always holds, even if another rule is generous. It is the same logic as a building where “staff only” on one door overrides a general welcome sign in the lobby.
| Situation | Result |
|---|---|
| Both a deny rule and an allow rule match | Denied |
| Both an ask rule and an allow rule match | Asked |
| Only an allow rule matches | Allowed |
| No rule matches | The current mode decides, usually by asking |
Patterns: narrowing a rule
A rule can be broad, such as “any file read”, or narrow, such as “reading files in one folder only”, or “running only commands that begin with a given word”. Patterns often use wildcards, which are symbols that stand for “anything here”. The art of writing rules is to be narrow enough to be safe and broad enough to be useful. A rule that allows only the exact test command is safe but may need a companion for a variant. A rule that allows any command beginning with a common word may allow far more than you intended.
Think of a school’s rules for pupils on a trip. “You may buy snacks” is allow. “Ask a teacher before leaving the group” is ask. “Never go near the water” is deny. If a pupil finds a loophole in the snack rule that leads to the water, the stronger rule about water still wins. Deny always has the last word.
Start with deny rules for what must never happen, then add allow rules one at a time for actions you approve repeatedly. This order builds safety first and convenience second.
Keeping rules readable
Rules are read by people as well as by the program. Keep the list short, group similar rules together, and prefer many clear rules over one clever pattern that nobody can decode. When a rule exists for a reason that is not obvious, write the reason in your team notes. A policy that a new teammate can understand in ten minutes is far more likely to be kept up to date, and far less likely to hide a gap.
6Where Settings Live: Scopes
The same rule can apply to just you, to one project, to your whole team, or to a whole company, depending on where it is stored.
Claude Code reads its settings from several places, called scopes. Each scope has a different reach. Understanding them tells you where to put a rule and which one wins when they differ.
| Scope | Who it affects | Shared? | Typical use |
|---|---|---|---|
| User settings | You, in every project | No, personal | Your own habits and general deny rules |
| Project settings | Everyone who uses this project | Yes, stored with the code | Team rules, such as allowing the test command |
| Local project settings | You, in this project only | No, kept out of version control | Personal tweaks for one project |
| Managed policy | Everyone in an organization | Yes, set by administrators | Company-wide rules that individuals cannot override |
flowchart TD
A["Managed policy: set by administrators, strongest"] --> B["Command-line options for this session"]
B --> C["Local project settings: personal, this project"]
C --> D["Shared project settings: team, this project"]
D --> E["User settings: personal, all projects"]
The picture shows a chain of authority. An organization’s managed policy sits at the top and cannot be overridden by an individual. Below it, options you give for one session take priority over stored files. Among stored files, those closer to the specific project win over your general ones. Because the exact order is a detail that could change, confirm it in the documentation before relying on it for something critical.
Which scope for which rule?
Shared project settings
Rules that everyone on the team should follow, kept with the code so new members get them automatically.
User and local settings
Your own preferences, which should not force themselves on teammates.
Managed policy
Non-negotiable rules, such as blocking access to certain files or tools across the whole organization.
A workplace has laws of the country, company policy, team rules, and your own habits at your desk. When they conflict, the law and company policy come first. A sensible person puts each rule at the right level: personal habits at the desk, team agreements on the team wall, and non-negotiables in the company handbook.
Shared project settings travel with the code. Keep passwords and keys out of them, and use deny rules to protect secret files instead.
7Managing Permissions Day to Day
You can adjust permissions as you work, instead of editing files by hand.
Claude Code gives you a way to view and change permissions from within a session. A dedicated command opens a screen listing your current allow, ask, and deny rules, and lets you add or remove them. There is also a quick way to cycle through modes during a session, so you can move from careful to fast and back again as the work changes. The exact commands and keys can change, so check the documentation or the in-product help for the current ones.
The “always allow” choice
When an approval prompt offers to allow an action from now on, it is creating an allow rule for you. This is convenient, and also the main way that permissions quietly grow. A rule made in a hurry on a Tuesday can still be there a year later, allowing something you have forgotten. Treat “always allow” as a real decision. Ask yourself whether you would be comfortable if this action ran every time, in any project covered by that rule.
A healthy review habit
List your rules
Open the permissions screen and read every allow rule slowly.
Remove the stale ones
Delete rules for projects or tools you no longer use.
Narrow the broad ones
Replace a wide rule with several specific ones where possible.
Add missing denies
Check that secrets and dangerous operations are blocked.
Think of the spare keys you hand out over the years: to a neighbor, a cleaner, a contractor. If you never check, you eventually do not know who has one. A yearly tidy-up, collecting the keys you no longer need, keeps your home secure. Reviewing allow rules is the same kind of tidy-up.
Each “always allow” is small, but together they can open far more than you meant. Review them regularly.
When the prompts become noise
If you are being asked dozens of questions in a session, something is out of balance. Either the rules are too tight for the work you do, or the work is too varied for a single setting. Do not respond by turning everything off. Instead, note which prompts are repeated and harmless, turn exactly those into narrow allow rules, and keep the rest. Fewer, more meaningful prompts mean you read each one, and reading each one is what makes the system safe.
8Working Directories and Boundaries
Claude Code normally works inside the folder where you started it, and that boundary is part of its safety.
When you start Claude Code in a project folder, that folder becomes its home base. File edits are generally limited to this working area and its subfolders. If Claude wants to go beyond, to a neighboring project, your home folder, or a system location, it usually needs your explicit permission. This keeps a task about one project from wandering into unrelated parts of your computer.
Adding more folders on purpose
Sometimes you genuinely need more than one folder, such as a shared library next to your main project. You can add extra directories to the session, which makes them part of the allowed area. Do this deliberately and only for the folders you need. Each added folder widens what Claude can read and change.
| Location | Typical treatment | Advice |
|---|---|---|
| The project folder | Home base; normal rules apply | Start Claude Code here, not higher up |
| Subfolders of the project | Included | Deny sensitive subfolders explicitly |
| A sibling project | Outside; needs permission or an added directory | Add only if the task requires it |
| Your home folder | Outside; may hold personal files and keys | Avoid starting sessions here |
| System folders | Outside; sensitive | Keep out of reach |
Start in the right place
A common mistake is to start Claude Code in a very high-level folder because it is convenient. That folder becomes the boundary, and everything below it is in reach, including old projects, downloads, and private files. Start as deep as the task allows. A smaller boundary is easier to reason about and safer if anything goes wrong.
A decorator hired to paint one room is given access to that room. If they also need the hallway, you open the hallway. You do not hand over keys to every room in the house on the first day. Working directories are the rooms you open for Claude Code.
If you find yourself adding many extra directories, consider whether the task is really several tasks, each of which could run in its own session.
9Protecting Secrets with Deny Rules
The most valuable use of deny rules is to keep sensitive files completely out of reach.
Every project has files that Claude does not need and should not see: environment files with passwords, private keys, token files, local configuration for services, and folders of customer data. Reading is usually allowed freely, which is why a deny rule on these files matters. If Claude cannot open them, their contents cannot end up in a conversation, a log, or a message to an outside service.
What to protect
Passwords and tokens
Environment files, credential stores, and any file holding keys for services.
Private keys and certificates
Files used to sign in, sign code, or prove identity.
Customer and personal data
Exports, backups, and test data that came from real people.
Machine and cloud settings
Cloud account files, shell history, and other personal configuration.
Reading is not the only risk
A good secret-protection policy denies reading and editing. It also pays attention to commands, because a command can read a file even when the file-reading tool is blocked. If shell access is allowed, a denied file might still be reachable by a command that prints it. So pair file-level denies with careful command rules, and with sandboxing, which we discuss later, for stronger protection.
| Protect against | Layer that helps |
|---|---|
| Claude reading a secrets file directly | Deny rules on file reading |
| A command that prints the secret | Command rules and sandboxing |
| Secrets committed to the repository | Ignore files, scanning, and review |
| Secrets sent to an outside service | Network limits and approvals |
| Secrets pasted into the chat by a person | Habits and training, since no rule can stop this |
Imagine a house-sitter who may roam freely but never enter the study with the safe. A lock on the study door is the deny rule. But if the study window is open, the lock alone is not enough. Several layers, a lock, a window latch, and an alarm, together make a secure home.
A single deny rule is good, but secrets deserve defense in depth. Combine rules, sandboxing, careful commands, and good habits.
Keep secrets out of the project in the first place
The strongest protection is not to have secrets lying in the project folder at all. Where possible, load credentials from a secure store at the moment they are needed, give them narrow rights, and rotate them on a schedule. Deny rules are a safety net, not a license to leave keys in plain files. If a secret has ever been exposed to a conversation or committed to a repository, treat it as compromised and replace it.
10Command Permissions: The Sharpest Tool
Running commands is the most flexible and most dangerous thing Claude Code can do, so it needs the most careful rules.
Why commands are special
A terminal command can do almost anything the user can do: read any file, change any setting, install software, contact the internet, or delete everything. Because of this breadth, it is not enough to say “allow commands” or “deny commands”. Rules need to be specific about which commands, and with what arguments.
Safe, careful, and dangerous commands
| Category | Examples (in words) | Typical policy |
|---|---|---|
| Read-only and informational | Listing files, showing the version control status, printing a file you may read | Often allowed |
| Project routines | Running the test suite, running the linter, building the project | Allow the exact commands |
| Changing state | Installing packages, committing changes, changing branches | Ask each time, or allow narrowly |
| Reaching outside | Downloading files, calling web services, pushing code to a shared server | Ask, with caution |
| Destructive or privileged | Deleting folders recursively, changing permissions broadly, running as administrator, changing system settings | Deny or always ask |
The trouble with wildcards and chains
Command rules often use a prefix match: allow any command that begins with a certain word. This is convenient, and it can be too generous. A rule that allows “anything starting with a common tool” may also allow variants with dangerous options. Commands can also be chained together on one line, so a harmless-looking first part can be followed by something harmful. Good systems look at the pieces of a chained command, but you should still write rules defensively and keep risky commands behind approval.
Allow exact, repeatable commands
The test, lint, and build commands your project uses every day.
Keep state-changing commands visible
Installing, committing, and pushing deserve a glance.
Allowing a whole program
Permitting every use of a powerful tool permits its worst uses too.
Trusting the first words only
What follows the prefix, including options and chained parts, matters as much.
Giving someone access to a toolbox is not the same as giving them permission to use every tool in every way. You might say, “use the screwdriver on the shelves”, not “use any tool on anything”. The precision of the instruction is what keeps the house standing.
Let Claude run a task once with prompts on, note the commands you approve repeatedly, and then turn exactly those into allow rules.
11Web and Network Permissions
Reaching out to the internet brings in outside content and opens a path for data to leave.
Claude Code can fetch web pages and search the web when allowed. These abilities are useful for reading documentation or checking an error message. But they also raise two worries. First, the content that comes back is not under your control and may contain text designed to mislead an AI. Second, a network connection is a way for information to leave your machine.
Controlling where Claude may go
Permissions for web access can be set per site or domain. A good starting policy allows a short list of trusted documentation sites and asks about anything else. Where company rules are strict, an administrator can restrict network access to an approved list. Commands that use the network, such as downloads or uploads, should be treated with the same care as web tools.
| Web action | Risk | Suggested policy |
|---|---|---|
| Read official documentation | Low | Allow trusted domains |
| Read arbitrary pages | Hidden instructions, misleading content | Ask, and treat content as information only |
| Download and run software | High | Ask, or deny |
| Upload or post data | Leaks | Ask each time |
| Call internal services | Changes in company systems | Follow organization policy |
Letting a trusted assistant read the encyclopedia in your library is one thing. Letting them accept a package from a stranger at the door, open it, and follow the note inside is another. Web permissions separate trusted reading from unknown content.
Claude is designed to treat web content as information, not commands. Still, limit what it can do after reading untrusted pages, especially sending data or running new software.
12Permissions for MCP and Outside Tools
Connected tools extend Claude Code’s reach, and each one needs its own permission decisions.
Claude Code can connect to outside tools through the Model Context Protocol, known as MCP. These might be an issue tracker, a database, a code host, or a monitoring service. Each connected tool offers its own set of abilities, and they are covered by the same permission ideas: allow, ask, and deny. A tool that reads information is lower risk than one that creates, changes, or deletes things in a real system.
Rules at several levels
Permissions can usually be set for a whole connected server or for individual tools within it. This lets you allow the harmless read tools and keep the write tools behind approval. For example, you might allow searching tickets freely while asking each time before a ticket is closed or a database record is changed.
| Kind of connected tool | Example ability | Suggested policy |
|---|---|---|
| Read-only lookups | Search issues, read documentation | Allow once you trust the server |
| Drafting or private notes | Create a draft | Allow with a glance |
| Changing shared records | Update a ticket, edit a page | Ask each time |
| Sending to other people | Post a message, send an email | Ask each time |
| Production systems | Change a live database or deploy | Deny, or require strong approval |
Choose servers carefully
An MCP server is software that acts on your behalf. Install only servers from sources you trust, review what they can do, and keep them updated. A shared project can list the servers the team uses, which is helpful, yet each person should understand what they are enabling. Remove connections you do not use.
Hiring a helper who can use the office phone, the post room, and the filing cabinet means deciding what each of those lets them do. They may look up numbers freely, but sending a letter in the company’s name is something you want to approve. Each connected tool is another door, and each door gets its own lock decision.
For a deeper look at how MCP works and how to use it safely, see the guide on MCP in Claude on this site, and the official documentation.
13Subagents, Headless Runs, and Automation
When nobody is there to answer a prompt, permissions must be settled in advance.
Helper agents
Claude Code can start helper agents, often called subagents, that handle part of a task separately. Helpers work under the permission rules of the session, and they may also have their own limits on which tools they can use. Giving a helper only the tools it needs, such as read and search for a reviewer, is a strong way to keep power low where it is not needed.
Running without a person present
Claude Code can also run in a non-interactive way, for example inside an automated pipeline, a scheduled job, or a script. There is no person to answer an approval prompt, so anything that would need approval will either be refused or will stop the run. This is why automated runs need their permissions decided ahead of time through rules and options, and why they should have very narrow rules.
Only the tools the job needs
A job that reviews code needs to read, not to edit or run arbitrary commands.
A disposable environment
Run automation in a container or a temporary machine with no real secrets.
Small credentials
Give automation keys that can do only what the job needs and nothing more.
Logs and results kept
Record what happened so a person can review it after the run.
A night security guard works while the manager sleeps, so the manager writes clear standing orders ahead of time: which doors to check, which to leave locked, whom to call. There is no one to ask at three in the morning. Unattended runs need standing orders written in the same spirit.
An unattended run that skips permission checks and holds powerful keys is the most dangerous setup. If checks are skipped at all, the environment must be disposable and the keys minimal.
Matching tools to the helper’s job
A good rule for helper agents is that their power should match their job. A reviewer needs to read and search, so it should not be able to edit or run commands. A test runner needs to run the test command, so it does not need web access. A documentation helper may need the web but not your source files. Writing each helper’s job description narrowly makes the whole system easier to reason about and far safer when something misbehaves.
14Hooks: Programmable Guards
Hooks let you attach your own checks to Claude Code’s actions, going beyond fixed rules.
Rules are good at simple decisions. But some policies need more thought: block any command that touches production, require a ticket number before a commit, or run a scanner before a file is saved. A hook is a small program you attach to a moment in Claude Code’s work, such as just before a tool runs or just after it finishes. The hook can inspect what is about to happen and approve it, block it, or add a message for Claude to read.
What hooks are good for
| Moment | Example use |
|---|---|
| Before a tool runs | Block dangerous commands, require extra checks, or check that a path is allowed |
| After a tool runs | Run a formatter, a test, or a scanner on the changed files |
| When a prompt is submitted | Add helpful context, or reject a request that breaks a policy |
| When a task ends | Run a final check, or send a notification |
Rules and hooks together
Think of rules as the simple signs on the door and hooks as the guard who can think. Rules are fast, predictable, and easy to read. Hooks can express policies that rules cannot, but they are code that you must write, test, and maintain, and they run with your permissions. A buggy hook can fail to protect you or can block valid work. Keep hooks small, test them on safe examples, and treat them like any other security-relevant software.
A building has signs that say “staff only”, and also a receptionist who checks badges and phones upstairs when something looks odd. The signs handle the usual case cheaply. The receptionist handles the unusual one with judgment. Hooks are the receptionist of your coding environment.
Begin with a hook that only logs what happens. Once you understand the pattern, add hooks that block specific risky actions.
15Sandboxing: A Wall Behind the Rules
Permissions decide what Claude Code may attempt. A sandbox limits what any command can actually reach.
The difference between a rule and a wall
A permission rule is a decision made by the program: it looks at a request and says yes or no. A sandbox is different. It is a restricted environment enforced by the operating system, in which the commands run. Inside it, a command simply cannot touch files outside allowed folders or connect to forbidden network locations, no matter how it is written. Rules are a guard at the door. A sandbox is the wall around the building.
flowchart TD
A["Claude proposes a command"] --> B{"Permission rules"}
B -- "Deny" --> C["Blocked"]
B -- "Ask" --> D["You decide"]
B -- "Allow" --> E["Command runs"]
D -- "Approve" --> E
D -- "Refuse" --> C
E --> F{"Sandbox boundary"}
F -- "Inside allowed folders and network" --> G["Works as normal"]
F -- "Outside the boundary" --> H["Stopped by the operating system"]
The diagram shows defense in depth. A request first meets the permission rules. If it passes, it runs, but inside a sandbox, so a mistake or a cleverly disguised command is still contained. Even an approved command cannot reach the folders or network addresses outside the boundary.
What a sandbox adds
Limited file reach
Commands can write only inside the project and approved folders.
Limited connections
Commands can reach only approved destinations, which makes leaking data much harder.
More comfortable approvals
Because the wall limits the damage, commands inside it can often run with fewer interruptions.
Protection against surprises
Even a command that nobody anticipated is held within the boundary.
A playground has a fence as well as a supervisor. The supervisor decides which games are allowed, but the fence stops a ball or a child from running into the road if someone is not looking. Rules are the supervisor, and the sandbox is the fence. Good safety uses both.
Sandbox features depend on your operating system and version. Check the documentation for what your setup supports, and use containers or virtual machines for stronger isolation when needed.
16Organization Policies and Managed Settings
Companies can set rules that individual developers cannot loosen.
In a company, the safety of a coding assistant is not only a personal matter. The organization has duties to protect customer data, source code, and its own systems. For this reason, administrators can deploy managed settings that sit above personal and project settings. These can set mandatory deny rules, restrict which tools and servers may be used, and limit which permission modes are allowed.
What organizations usually decide
| Decision | Typical reason |
|---|---|
| Block reading of secrets and sensitive folders | Prevent credentials and customer data from entering conversations |
| Forbid the mode that skips all checks | Keep a human in the loop on real machines |
| Approve a list of connected tools | Control what outside systems can be reached |
| Limit network destinations | Reduce the chance of data leaving |
| Require logging and review | Support audits and incident response |
| Standardize project rules | Give every team the same safe starting point |
Working well with policy
If you are a developer and a setting is locked, treat it as a boundary set for good reasons. Ask the platform or security team if you need something changed, and explain the task. Often there is an approved path, such as a sandboxed environment where more freedom is allowed. If you are an administrator, keep the policy small, clear, and explained. Rules that people understand are followed. Rules that look random are worked around.
Airports have security rules that no passenger can change, and they exist for everyone’s safety. A traveler who understands why the rules exist moves through calmly. A traveler who sees them as random may try to hide things in their bag. Clear reasons make policy easier to live with.
Test your managed settings on a pilot team first. A rule that blocks routine work will push people toward risky workarounds.
Communicating policy to developers
Policy works best when people understand it. Publish a short page that says what is blocked, what is allowed, and why. Give a clear route for requesting an exception, and answer requests quickly. Share stories of problems that the policy prevented, in general terms, so the rules feel purposeful and not arbitrary. When developers see policy as a partner, they bring concerns early, and the policy improves.
17Security Threats Permissions Help Prevent
Understanding the threats shows why each rule is worth having.
| Threat | What it means | Main defenses |
|---|---|---|
| Prompt injection | Text in a file, web page, or tool result tries to give Claude orders | Approvals for risky actions, limited tools, and treating content as information |
| Malicious repository | A project you open contains settings or scripts designed to run harmful commands | Trust prompts, careful review of unknown projects, and sandboxing |
| Data exfiltration | Secrets or code are sent to an outside place | Deny rules on secrets, network limits, and reviewing outbound actions |
| Over-broad allow rule | A convenience rule permits more than intended | Narrow patterns and regular review |
| Supply chain risk | An installed package or connected tool is compromised | Review installs, pin versions, and use trusted sources |
| Destructive mistakes | An honest error deletes or overwrites work | Version control, backups, and approval for destructive commands |
| Privilege escalation | A command gains rights beyond the user’s normal ones | Deny administrator commands and run with minimal rights |
The risky trio
Security specialists point to a dangerous combination: access to private data, exposure to untrusted content, and the ability to send things out. When all three are present in one session, a hidden instruction in an untrusted file could lead to private information being sent away. Permissions let you break the chain. You can deny access to private data, avoid fetching untrusted pages in sensitive sessions, or require approval for anything that sends data out.
Open unknown projects with care
When you open a project you did not write, such as one downloaded from the internet, remember that it may carry its own settings and scripts. Claude Code usually asks whether you trust a folder before applying its configuration. Read that question seriously. Review unfamiliar projects first, and for anything doubtful, work inside a disposable environment.
Before you run an unknown program that someone handed you on a memory stick, you check where it came from. You do not plug an unlabeled stick into your work laptop. Opening an untrusted project with a powerful assistant deserves the same caution.
Permissions reduce risk, but they do not remove it. Keep backups, use version control, and review what Claude changes before you rely on it.
18Monitoring, Logging, and Audit
Good permissions are visible permissions. You should be able to see what was allowed, what was refused, and what actually ran.
Without records, nobody can answer simple questions after an incident: what did Claude run, which files did it change, which approvals were given, and by whom? Records also reveal where permissions are too tight, causing constant prompts, or too loose, allowing risky actions without anyone noticing.
What to keep track of
What ran
A record of commands executed, with time and the project in which they ran.
What changed
File edits tracked through version control, so every change can be inspected and undone.
Approvals and denials
Which actions were allowed or refused, and which rule or person decided.
Rule changes
When rules were added or removed, so permission drift can be spotted.
Useful measures
| Measure | What it shows | Warning sign |
|---|---|---|
| Prompts per session | How much friction the rules cause | Very high numbers lead to approval fatigue |
| Share of actions auto-allowed | How much runs without a person | A sudden rise after a rule change |
| Denials triggered | How often protections are tested | Repeated denials for the same file may signal injection or confusion |
| Use of the no-checks mode | Risky sessions | Any use outside disposable environments |
| Age of allow rules | Staleness | Old rules nobody remembers |
Version control is the most important log of all. If Claude’s changes are always committed in small steps with clear messages, you can see exactly what happened and roll back any step. Teams can also use hooks to write their own audit logs of commands and approvals. Protect those logs, because commands and paths can themselves contain sensitive information.
A shop has a till roll and a security camera. The till roll lists what was sold, and the camera shows what happened if something goes missing. Neither slows the customers, and together they make problems solvable. Version history and logs play that role for a coding assistant.
Commit before a big Claude session and review the differences afterward. A clean starting point makes every change easy to see.
Reviewing after an incident
If something goes wrong, use your records to reconstruct the order of events. Which prompt appeared, who approved it, which rule allowed it, and what ran afterward? Then ask what single change would have prevented it: a deny rule, a narrower allow, a sandbox setting, or a hook. Make that change, and write a short note about it. Treat each incident as a free lesson that makes the next session safer.
19Designing Your Own Permission Policy
A good policy is a few clear decisions, matched to your risk, and reviewed regularly.
A step-by-step method
List what is valuable
Secrets, customer data, production systems, and unsaved work. These are what the policy protects.
Write the deny rules first
Block secret files, dangerous commands, and production access.
Choose a default mode
Pick the mode that matches how reversible your work is.
Allow the routine
Add narrow allow rules for the commands you approve every day.
Add a wall and guards
Use sandboxing and hooks for what rules alone cannot handle.
Test and review
Try the policy on a safe project, then review it every few months.
Starter policies by situation
| Situation | Mode | Rules | Extra protection |
|---|---|---|---|
| Learning on a personal project | Default, ask as needed | Few allows; deny secrets | Version control |
| Daily work on a trusted team project | Accept edits | Allow test, lint, and build commands; ask for installs and pushes | Sandbox, code review |
| Exploring an unfamiliar codebase | Plan only | Read and search only | Disposable copy of the project |
| Automation in a pipeline | Narrow, set in advance | Only the exact tools needed | Disposable environment, minimal credentials |
| Regulated or sensitive company work | Default, with managed policy | Strict denies; approved tools only | Logging, audit, and review |
Setting a household routine for a new babysitter, you start with the essentials: emergency numbers, rooms that are off-limits, and bedtime. Only then do you add the small conveniences, such as which snacks are fine. Safety first and comfort second makes a routine that works at midnight.
A policy of a dozen well-chosen rules is easier to understand, test, and maintain than one with hundreds of lines nobody reads.
20Best Practices and Anti-Patterns
A few habits produce safe and pleasant sessions, and a few mistakes cause most of the trouble.
What to do
Apply least privilege: give Claude Code only the access the task needs.
Why it helps
If anything goes wrong, whether by mistake or by a hidden instruction, the damage is limited to a small area.
What to do
Layer your defenses: deny rules, a sensible mode, a sandbox, version control, and review.
Why it helps
No single layer is perfect, but together they catch what any one would miss.
What to do
Share a project policy with the team through the project settings, and review it together.
Why it helps
Everyone starts from the same safe baseline, and new members are protected from day one.
Skipping all checks on a real machine
Turning off every permission check to avoid interruptions.
Why it hurts
A mistake or hidden instruction can run unchecked commands with your real access and credentials.
Do this instead
Use narrow allow rules and the accept-edits mode, and keep the no-checks mode for disposable environments only.
Clicking “always allow” without thinking
Building up broad allow rules from approval prompts.
Why it hurts
Rules accumulate, outlive their purpose, and permit more than you remember.
Do this instead
Approve once when unsure, create allow rules deliberately, and review them regularly.
Starting in a huge folder
Launching Claude Code from the home folder or a drive root.
Why it hurts
Everything beneath becomes reachable, including unrelated projects and private files.
Do this instead
Start in the project folder, and add extra directories only when needed.
Trusting any project you open
Accepting the trust prompt for an unknown repository without looking.
Why it hurts
A project can carry settings or scripts that act in your name.
Do this instead
Review unfamiliar projects first, and use a disposable environment for anything doubtful.
21Troubleshooting Permission Problems
Most surprises come from rules clashing, a wrong scope, or an unexpected mode.
| Problem | Likely cause | What to try |
|---|---|---|
| I keep being asked the same thing | No allow rule exists, or a more specific ask rule overrides it | Add a narrow allow rule, and check for ask rules |
| An action is blocked and I do not know why | A deny rule from another scope, or managed policy | List all rules, and check each scope |
| My allow rule is ignored | A deny or ask rule matches too, or the pattern does not match the command exactly | Check precedence, and test the pattern on the exact command |
| A teammate sees different behavior | Personal settings differ, or a local file overrides the shared one | Compare scopes, and keep shared rules in project settings |
| Automation fails on a permission | No person to approve it | Decide the permission in advance with narrow rules |
| Rules seem not to load | A mistake in the settings file, or the file is in the wrong place | Check the file’s format and location against the documentation |
| A command works in the terminal but not in Claude | Sandbox or network limits | Read the error, and adjust the sandbox settings deliberately |
A calm approach
Start by asking which scope each rule lives in, since the answer often explains a surprise. Then recall the order of strength: deny, then ask, then allow. Finally, test on a safe project with a very simple action. Change one thing at a time and write down what you changed, so you can undo it. If you are in a company environment, remember that managed policy may be the cause, and ask your administrator.
When a door will not open, you check the key, the lock, and whether someone has bolted it from inside. You do not start by taking the door off its hinges. Permission problems yield to the same patient order of checks.
Keep your permission settings in a tidy, commented form where the format allows it, and note why each rule exists. Future you will be grateful.
22Real-World Scenarios
Six examples show permissions chosen well.
A solo developer on a side project
A developer works alone on a small web app kept under version control. She uses the accept-edits mode so changes flow, allows the test and build commands, asks before installs, and denies reading the environment file. At the end of each session she reviews the differences and commits.
A team sharing a baseline
A team stores a short policy in the shared project settings: allow the lint and test commands, deny reading secret files, and ask before pushing. New teammates get the same safe defaults the moment they open the project. Personal tweaks stay in each person’s own files.
A new codebase to study
An engineer joins a company and needs to understand a large unfamiliar system. He uses the plan-only mode, so Claude reads and explains without changing anything. Once he understands the structure, he switches to a careful mode to make a small, reviewed change.
A review bot in the pipeline
A company runs Claude Code in its automation to review pull requests. The job can read the code and write comments, but cannot edit files, run arbitrary commands, or reach the network beyond the code host. It runs in a throwaway container with a minimal token, and logs are kept for audit.
An unknown repository from the internet
A developer wants to try a sample project found online. She opens it inside a disposable container, reads its configuration before trusting it, and keeps the plan-only mode at first. Nothing on her main machine is reachable, so any surprise stays inside the container.
A regulated company’s policy
A financial company deploys managed settings that deny access to customer data folders, forbid the no-checks mode, and allow only approved connected tools. Developers can still be productive, because the project rules allow the routine build and test commands. Security staff review logs weekly.
23Frequently Asked Questions
24Summary and Key Takeaways
Key Takeaways
- Permissions guard actions, not intentions. Claude Code works through tools, and each tool use is allowed, asked about, or denied according to risk, even when Claude means well.
- The default is careful. Reading is easy, while edits and commands need your approval unless a rule or mode allows them. Read each prompt, because it is the moment when you check what will happen.
- Modes are gears, rules are precision. Choose a mode to match how reversible your work is, and use narrow allow, ask, and deny rules for the details. Deny beats ask, and ask beats allow.
- Scope decides reach. User, project, local, and managed settings apply to different people. Put team rules in shared project settings and personal choices in personal ones.
- Protect secrets in layers. Deny rules on sensitive files, careful command rules, sandboxing, and good habits work together because no single layer is perfect.
- Add a wall and guards. A sandbox limits what any command can reach, and hooks add custom checks that rules cannot express. Never skip all checks outside a disposable environment.
- Start small, review often. Write deny rules first, add narrow allows for routine commands, keep work under version control, and review your rules regularly. For current names and options, see docs.claude.com.