How do I secure Claude Code across a company?
Updated
Short answer
To secure Claude Code across a company, push managed settings to every laptop with your MDM so developers can't override them. Pin the login, require the sandbox and set deny rules for secrets. Then add a pre-execution hook that checks each action against what the session is for. Make it fail closed, start it watch-only and send every decision to your SIEM.
What the risk is#
Claude Code runs with the developer's credentials. It reads repo files, web pages and tool output, then runs commands in the same step. Nothing separates "data to look at" from "instruction to follow".
On a laptop that holds SSH keys, cloud tokens and production access, you have to decide what the agent may do. Then you have to be able to prove what it actually did.
Permission prompts can't do that job. In Anthropic's write-up on auto mode, users accept 93% of permission prompts anyway. Plan as if every prompt gets approved.
Managed settings#
Managed settings take precedence over everything else. Per Anthropic's docs, nothing in your own settings files or --settings overrides a managed key. Push them with the MDM you already run.
Use them for:
- Permission
denyrules for.env, key files and cloud credential paths. - Managed permission rules only, so developers' own allow rules don't add to yours. Check the settings docs for the current key.
- A required sandbox, with unsandboxed retries blocked. See Claude Code and Codex sandbox.
- A pinned login, so personal accounts can't run on work laptops. See blocking personal accounts.
- A minimum version, because some fixes ship as plain changelog lines.
What managed settings don't stop: an allowed command used for the wrong purpose. Rules match the command text, and they don't know why it's running. Also check every surface your developers use (CLI, IDE, cloud sessions) to confirm the settings actually reach it.
Permission rules and the sandbox#
Deny rules handle the obvious cases well. A sandbox limits what the agent can reach on disk and on the network, and that's the best way to shrink blast radius.
Neither one knows why a command is running. curl to an approved host is fine during a build and a leak when it carries a secret. A sandbox also can't help when the action is allowed inside it, like a force-push with a token the agent legitimately holds. Our comparison of permission rules, hooks and sandboxing walks through each layer.
Hooks#
A PreToolUse hook runs before a tool call and can block it. The exit code matters. The docs say if your hook is meant to enforce a policy, use exit 2.
How the hook fails matters too. Per the docs, on most events when a hook fails or times out, Claude Code still carries out the action. So a policy hook pointed at the wrong path lets everything through. Configure it to block on failure, then test that it actually does.
A hook only gives you a place to run a check. The check you put in it decides what gets stopped. Valid uses and failure modes are in Claude Code hooks: valid enterprise uses.
A decision rule#
- If the action itself is the evidence (a private key read, a secret in a network call,
rm -rfat the root), a deterministic rule can decide alone. - If it's harmless in one task and harmful in another (deleting a test, editing CI config, adding a dependency), you need the session's intent.
- If it can't be undone (publish, push to a shared repo, deploy, email a customer), gate it every time. See irreversible actions to gate.
Checklist#
- Managed settings delivered by MDM, confirmed on a sample of machines.
- Deny rules for secrets, a required sandbox and managed-only permission rules.
- Any enforcement hook uses
exit 2and blocks when it fails. Test both. - Agent config and rules files read-only, with changes watched. See how agents persist past the session.
- A version floor, plus a way to see what's installed.
- Every decision recorded and exported to your SIEM.
- Watch-only for a week. Read the log, then enforce.
For the full review sequence, see security review before approving Claude Code and the rollout plan for 1,000 engineers.
Where Harden fits#
Harden Agentic Integrity Foundation (AIF) is a check that runs at the hook. It runs on the developer laptop, outside the agent, at the agent's pre-execution hook. No command, file edit or push runs until AIF has checked it against the session's intent.
Decisions are made locally in about 28 ms (P99 about 70 ms), and nothing leaves the machine. The enforcement path is deterministic, and a local model can only make a verdict stricter. If the check can't run, the action doesn't run.
AIF starts watch-only, ships through the MDM you already run and applies one policy across Claude Code, Codex, Cursor and other agents. It's a layer, not a perimeter, so it doesn't replace least privilege, scoped credentials or egress policy. See the Claude Code integration.
FAQ
Related questions
Can developers override managed settings in Claude Code?
Not the managed keys. Anthropic's docs say nothing in your own settings files or --settings overrides a managed key. Confirm on a sample of machines that the settings actually got there.
Is a Claude Code hook enough to enforce policy?
Only if it fails closed and runs a real check. The docs say policy hooks should use exit 2, and on most events a hook that fails or times out lets the action run. Set it to block on failure and test it.
Do permission rules and the sandbox make a hook-based check unnecessary?
No. Rules match command text and the sandbox limits reach, but neither knows why a command is running. An allowed curl or force-push can still be the wrong action for the task.
Where should we start?
Push managed settings by MDM, then run a hook-based check in watch-only mode for a week. Read what agents actually do before you enforce anything.