How to Roll Out Claude Code in a Company Without Losing Control

To roll out Claude Code safely, treat it like any other admin tool that lands on developer laptops: set the defaults centrally with managed settings, lock MCP servers to an allowlist, turn on the Bash sandbox where the operating system supports it, and use hooks for the checks permission rules can’t express. The model is rarely the problem. The problem is 300 laptops, each with its own idea of what Claude Code may do.
We run Claude Code every day against our own fleet of containerised apps, behind an authenticated gateway. Almost every mistake we made early on was a default nobody had decided on, not something the model did. If you don’t know yet who runs which agent, start with finding the AI agents your staff already run.
What changes when Claude Code goes from one developer to a company
For one developer, Claude Code is a personal tool. They pick the permission mode, approve commands as they come up, and connect whatever MCP servers look useful. That works because the person taking the risk is the person making the decision.
In a company, that same setup means hundreds of private decisions nobody reviews. Two facts from the official documentation matter here. First, the starting point is not read-only: according to the security docs, “Auto mode is the built-in starting permission mode for interactive terminal and VS Code sessions.” Manual mode, where Claude Code “starts with read-only permissions” and asks before editing files or running commands, is a choice you have to make.
Second, and this is the good news: “Permission rules are enforced by Claude Code, not by the model.” A rule you set is not a polite request in a prompt that a clever injection can talk its way around. The client enforces it. That is what makes central policy worth the effort, and why prompt injection cannot be patched inside the model alone.
Most security teams start the conversation with prompt injection. In practice the bigger exposure is quieter: MCP servers nobody approved and shell commands that run without a second look.
Step 1: Ship managed settings
Claude Code reads settings from several places. From highest to lowest priority: managed settings, the command line, project-local settings, shared project settings, and the user’s own settings. The settings documentation is explicit: “Nothing in your own settings files or --settings overrides a managed key.“
So the first job is to deploy a managed settings file through the tools you already use for endpoint configuration:
- macOS:
/Library/Application Support/ClaudeCode/managed-settings.json, or an MDM configuration profile with the domaincom.anthropic.claudecode - Linux and WSL:
/etc/claude-code/managed-settings.json - Windows:
C:\Program Files\ClaudeCode\managed-settings.json, or the registry valueSettingsunderHKLM\SOFTWARE\Policies\ClaudeCode
Then decide whether developers may add their own permission rules on top. Setting allowManagedPermissionRulesOnly to true makes Claude Code ignore permission rules from user, project and local files and from --allowedTools. That is strict. For the pilot phase we would leave it off and watch what people add; for the org-wide rollout, turn it on.
Step 2: Decide the permission baseline
Rules come in three kinds: allow, ask and deny. The order matters more than the wording. “Rules are evaluated in order: deny, then ask, then allow.” A deny always wins, no matter how specific an allow rule looks.
A sensible baseline:
- Reads stay frictionless. File reads and search inside the project don’t need approval by default, and that is fine.
- Shell commands ask. Bash execution asks for approval, except a built-in set of read-only commands. Keep it that way for most teams.
- Secrets get deny rules. SSH keys, cloud credentials and
.envfiles should be unreadable for Claude Code, whatever mode a developer picks.
One trap catches almost everyone. A deny rule such as Bash(curl *) looks like it blocks curl. It doesn’t, reliably: the permissions documentation notes that a Bash rule “doesn’t match the same program by path or inside sh -c“. Treat command patterns as guidance, not a boundary. The same lesson shows up in guardrails for coding agents with shell access. If a tool must be gone, deny the bare tool name: “A bare tool name like Bash removes the tool from Claude’s context entirely.“
Step 3: Lock down MCP servers
This is the step most rollouts skip, and the one we would do first. The documentation says it plainly: “By default, anyone running Claude Code can connect any MCP server they choose.” Each MCP server is code with access to whatever its tools expose, and the MCP docs warn that “Servers that fetch external content can expose you to prompt injection risk.”
You have two levers:
managed-mcp.json(same directories as the managed settings file). When it exists, “Claude Code loads only these MCP servers.” Users can’t add their own. This is the cleanest option if you can curate the list.- An allowlist in managed settings: set
allowedMcpServerstogether withallowManagedMcpServersOnly: trueto make the list authoritative, and usedeniedMcpServersfor servers that must never load, managed ones included.
Match servers by URL or by command, not by name. The docs are blunt: “A serverName entry, in either list, is not a security control.“ Anyone can call a server ”github“, which is exactly the trick behind the skill marketplace supply-chain attack.
Project-level servers defined in a repository’s .mcp.json still prompt for approval in interactive sessions. That helps, but a prompt that pops up for every new repo trains people to click yes. A central list is better.
Step 4: Turn on the sandbox where it runs
The Bash sandbox is an operating-system boundary around the shell commands Claude Code runs. It is useful, and it is easy to overestimate. Know its limits before you rely on it:
- It is off by default. You have to turn it on.
- It runs on macOS, Linux and WSL2. “On native Windows, Claude Code runs commands unsandboxed.” Windows shops need WSL2 for this layer.
- It limits writes, not reads. Writes are restricted to the working directory, a per-user temp directory and directories you add. Reads cover “most of the machine, including credential files such as
~/.sshand~/.aws/credentials.“ The sandbox does not protect secrets; your deny rules from step 2 do. - Network goes through a proxy that checks each host against your allowed domains, and that list starts empty.
- It fails open. If the sandbox can’t start, Claude Code runs commands without it, unless you set
sandbox.failIfUnavailabletotrue. In a managed rollout, set it. - It covers shell commands only. File tools, MCP servers and hooks run outside it.
Step 5: Use hooks for what rules can’t express
Hooks are commands or endpoints that run at fixed points in Claude Code’s lifecycle. The one that matters for control is PreToolUse, which runs before a tool call and can block it. Use it for checks that depend on context: a command touching a production hostname, a write to a path that only exists in some repos, a ticket number missing from the session.
Two rules from the hooks documentation keep you out of trouble. “The hook can deny the call, but staying silent doesn’t approve it.” And for hard yes/no decisions, use permissions: the docs recommend “the permission system rather than a hook to enforce a hard allow or deny.” If you don’t want developers adding hooks that change behaviour, allowManagedHooksOnly in managed settings restricts which hooks run.
Prompt injection: what is and isn’t solved
Anthropic doesn’t oversell this. The security documentation describes the protections (the permission system, web-fetching commands like curl and wget not being auto-approved by default, and Manual mode asking before running a command it can’t fully analyse) and then states: “no system is completely immune to all attacks.”
That is the right frame. You won’t stop every injected instruction in a README or a web page. You can make sure that when one gets through, it hits a deny rule, an empty network allowlist and an MCP list it can’t extend.
A four-week rollout plan
- Week 1, pilot: one team, Manual mode, no managed restrictions yet. Collect which commands and MCP servers people actually need.
- Week 2, managed settings: deploy
managed-settings.jsonto the pilot with deny rules for secrets and the sandbox set to fail closed. - Week 3, MCP: replace “connect anything” with
managed-mcp.jsonor an authoritative allowlist built from week 1. - Week 4, org-wide: push the same files to everyone through MDM or your endpoint tooling, and turn on
allowManagedPermissionRulesOnly.
An example managed settings file for the end of week 4 (adapt paths and servers to your environment and check the current schema in the settings documentation before deploying):
{
"allowManagedPermissionRulesOnly": true,
"permissions": {
"deny": ["Read(~/.ssh/**)", "Read(~/.aws/credentials)", "Read(./.env)"]
},
"sandbox": {
"enabled": true,
"failIfUnavailable": true
},
"allowManagedMcpServersOnly": true,
"allowedMcpServers": [
{ "serverUrl": "https://mcp.internal.example.com/*" }
]
}Checklist
- Managed settings deployed through MDM or endpoint tooling on every OS you support
- Deny rules for SSH keys, cloud credentials and
.envfiles - MCP servers limited to a central list, matched by URL or command, not by name
- Sandbox on,
failIfUnavailableset, WSL2 for Windows developers PreToolUsehooks for context checks,allowManagedHooksOnlyon- Permission rules locked with
allowManagedPermissionRulesOnlyafter the pilot
Related reading
- AI agent session token theft
- Securing AI agents as non-human identities
- How to find the AI agents your staff already run
Sources: Claude Code documentation on security, permissions, settings, managed settings, managed MCP, MCP, sandboxing and hooks.