Is Claude Code safe? Yes for everyday work in a repository you can roll back, on four conditions: its permission checks stay on, it cannot read your secrets, production keys stay out of the session, and someone reviews what it writes. Claude Code can read files, run shell commands and reach the network, so the settings decide the risk.

Is Claude Code safe? The verdict, and the four conditions behind it

Claude Code is safe for repository work when four things hold: the permission checks stay on, no secrets are readable in its folder or git history, production credentials stay out of the session, and a person reviews and tests what it writes. Each is a setting or a habit you can check.

ConditionWhy it mattersThe setting or habit that meets it
The permission checks stay onbypassPermissions skips permission prompts, including for writes to protected paths such as .git and .claudeManual mode (config value default) for sensitive work, and permissions.disableBypassPermissionsMode set to "disable"
No readable secrets in the folder or its git historyFile reads inside the working directory need no approval, and file contents sit in the model’s contextRead deny rules such as Read(./.env), secrets kept outside the folder, and a scan of the full history
Production credentials stay out of the sessionIn auto mode, reading .env and sending credentials to their matching API is allowed by defaultA session started from a shell with no production URL or live key in its environment
A person reviews and something tests the changeAnthropic’s docs leave reviewing proposed code and commands for safety to youThe diff read before it merges, and a CI check that fails on a forbidden change

That verdict covers Claude Code safety on your machine. Whether the app it writes is safe to ship is a second question, answered further down in the section on the code it writes, because a permission setting never sees what the code does to your users. Instructions you give the agent are a third layer, and the guardrails that make an agent’s rules stick sort the ones that bind from the ones that only ask.

Whether Claude Code is secure depends less on the product than on those four rows. Anthropic’s Claude Code security docs put the last safety check on the person at the keyboard: “You’re responsible for reviewing proposed code and commands for safety before approval.” With the rows in place, Claude Code is safe to use; on a laptop that also holds production keys, the third row is the one to fix first.

What Claude Code can reach by default

Claude Code reads files in the folder where it starts without asking, and in Manual mode it asks before most actions that edit files, run shell commands or reach the network. Reading needs no approval, so anything readable in that folder can reach the model.

Which prompts you actually see depends on the permission mode. Since Claude Code’s late-September 2026 releases, auto mode is the built-in starting permission mode for interactive terminal and VS Code sessions on every plan; on earlier versions it was the starting mode only on Pro, Max, and Team plans. In auto mode a second model, the classifier, reviews actions instead of you, and its default allow list includes installing dependencies declared in your lock files or manifests and reading .env to send credentials to their matching API.

Manual mode is still there under the config value default, and Anthropic’s own table of common setups pairs it with sensitive work and unfamiliar code. In Manual mode, Claude Code runs a built-in set of read-only commands such as ls, cat and git status without asking, and asks before file edits, other shell commands and most web fetches. What people call Claude Code safe mode is this one. The Claude Code unsafe mode, in the same loose sense, is bypassPermissions, which turns the prompts off almost entirely and belongs only in a container or VM.

Approvals stick in two different ways. Choosing “Yes, and don’t ask again” on a shell command saves a rule to .claude/settings.local.json at the root of the git repository, and that rule applies to future sessions anywhere in the repository; a file-edit approval is never written there and lasts until the session ends. Every mode trades some prompts for something else, so what each permission mode replaces the prompt with is worth knowing before you change the default for a team.

Paths need one more look once you start writing rules, because a prefix in a permission rule does not always mean what it means in a shell. Claude Code’s permissions docs read the prefixes like this:

Prefix in a ruleWhere it pointsHow to read it
//The filesystem rootRead(//Users/alice/secrets/**) is a true absolute path
~/Your home directoryRead(~/Documents/*.pdf) reaches files in your home folder
/The folder tied to the settings file that holds the ruleIn user settings, Read(/secrets/**) blocks ~/.claude/secrets/**, not a folder in your project
./ or no prefixThe current directoryRead(./.env) blocks the .env file where you started

Permission rules: what they enforce and what they do not

Permission rules are enforced by Claude Code itself, not by the model; instructions in a prompt or a CLAUDE.md file only shape what Claude tries to do. Rules come as allow, ask and deny, and Claude Code evaluates them as deny, then ask, then allow, so a narrow allow rule can never reopen a call that a broad deny rule closed.

They live in four places. User settings at ~/.claude/settings.json apply to you in every project, .claude/settings.json reaches everyone in the project once committed, .claude/settings.local.json is yours for one project, and managed settings from an organization override everything you set, apart from a few security-sensitive exceptions. The reference for every key is the page on Claude Code settings.

A deny rule has gaps that Anthropic names. Read and Edit deny rules cover Claude’s own file tools, the file commands Claude Code recognizes in Bash such as cat, head and sed, and redirection targets; they don’t cover a command that reads files without naming them, such as a recursive grep run from the folder that holds the file, or a Python or Node script that opens files itself. A .claudeignore file has no effect at all. For a block that holds against every process, the sandbox is the tool.

What sandboxing blocks, and how to turn it on

The Claude Code sandbox is a boundary the operating system enforces around the shell commands Claude runs: writes stay in the working directory and a temp directory, and network traffic passes a proxy that checks each host against an allowed list. It is off until you turn it on.

Turning it on takes one command, /sandbox, or sandbox.enabled set to true in a settings file. macOS uses the built-in Seatbelt framework, Linux and WSL2 need bubblewrap and socat, and on native Windows commands run unsandboxed. If a dependency is missing, Claude Code runs commands without the sandbox unless sandbox.failIfUnavailable is true.

Two defaults matter for secrets. Sandboxed reads stay open to most of the machine, including ~/.ssh and ~/.aws/credentials, until you add filesystem.denyRead entries, and commands inherit Claude Code’s environment, secrets included. The sandbox also wraps shell commands only: Claude’s file tools, MCP servers and hooks run outside it.

A session in bypass mode needs a container, a VM or the sandbox runtime around it, by Anthropic’s own setup table, and for untrusted content the security page recommends running scripts and tool calls in a virtual machine and suggests dev containers for extra isolation. Claude Code’s sandboxing docs list each setting and what it changes.

How safe is your data with Claude Code: training, retention and what leaves your machine

Code and prompts leave your machine whenever Claude Code sends them to the model, and what happens next depends on the account. Consumer and commercial accounts have different training and retention terms, and zero data retention is available only on eligible commercial setups, never on consumer plans.

Claude Code runs locally, but to reach the model it sends all user prompts and model outputs over the network, encrypted in transit with TLS 1.2 or later. The model’s context holds more than what you type: file contents and command outputs sit in it too, so a file the agent reads goes out with the conversation.

Account typeUsed for trainingRetention on Anthropic’s sideZero data retention available
Free, Pro and Max (consumer)Yes while the model-improvement setting is on, Claude Code use included5 years with the setting on, 30 days with it offNo: consumer plans are outside the products it applies to
TeamNot under commercial terms, unless the customer chooses to provide data for model improvement30 days standardNot among the products it applies to
EnterpriseSame terms as Team30 days standardFor qualified accounts using Claude Code on Claude for Enterprise, enabled per organization after an eligibility check
API (Commercial organization key)Same terms as Team30 days standardFor eligible APIs and for products on a Commercial organization API key, Claude Code accessed through the API included, subject to Anthropic’s approval

Turning off training on a consumer account is a different thing from zero retention. With the setting off, the data-usage page still lists a 30-day retention period, while zero data retention means Anthropic “does not store their inputs or outputs except where needed to comply with law or combat misuse or harm”, and no consumer setting gets you that.

Retention also splits by where the data sits. Local resumable transcripts, feedback uploads, and alternate model providers create separate retention boundaries: transcripts stay in plaintext under ~/.claude/projects/ for 30 days by default, cleanupPeriodDays changes that, and a transcript shared with /feedback, /bug or /share is kept for 5 years. On a consumer account, a deleted conversation leaves the chat history immediately and is deleted from back-end storage within 30 days. Anthropic’s page on how Claude Code uses your data covers the provider-by-provider detail.

Health data needs one more line. Anthropic’s business associate agreement page says: “Some services, like Claude Code, are only covered under the BAA when ZDR is enabled, which means those services can’t use Covered Models under the BAA.” That is Anthropic’s wording, not legal advice, and whether it fits your case is a question for your lawyer.

Claude Code risks that survive the permission prompts

Claude Code risks that no permission prompt removes come in six kinds: readable secrets, secrets in git history, approval fatigue, untrusted text from MCP servers and web pages, malicious packages that drive installed AI tools, and production credentials in the session.

RiskHow it happensThe controlThe check
Readable secrets in the folderFile reads in the working directory need no approval, so a .env the agent opens enters its contextRead deny rules, and secrets kept outside the folderA read of .env requested in a session is refused
Secrets in git historyA secret deleted from the latest commit stays in the earlier onesA scan of the full history, then rotation of every exposed keyA clean history scan, kept with its date
Approval fatigue”Yes, and don’t ask again” saves a rule that applies to future sessions anywhere in the repositoryRead the command and path before approving, and prune saved rules/permissions shows only rules you recognize
MCP servers and fetched pagesPrompt injection: malicious text written to override the agent’s instructions; Anthropic does not security-audit or manage any MCP serverServers you wrote or from providers you trust, and a VM for untrusted external servicesEvery server a session loads is accounted for, not only those in .mcp.json
Malicious packagesAn install script runs with your access and can call any tool installed on the machineUnfamiliar dependencies installed in a container or VMDependency changes in a pull request are read before anyone installs them
Production credentials in the sessionSandboxed commands inherit Claude Code’s environment, secrets includedProduction values kept out of the shell that starts Claude Codeenv in that shell shows neither

The dangers of Claude Code on this list share one trait: none needs the agent to misbehave, only to read or run what is already within reach. MCP servers deserve a review one by one, starting with what each MCP server can reach, because reviewing .mcp.json doesn’t show every server a session can load.

Claude Code remote control security risks are narrower than the name suggests. Remote Control lets claude.ai/code or the Claude mobile app drive a session that keeps running on your machine; the local process makes outbound HTTPS requests only, never opens inbound ports and uses short-lived credentials each scoped to one purpose, and on Team and Enterprise an Owner must switch it on first.

When malware borrowed the AI coding tools on a developer’s laptop

On August 27, 2025, the Nx maintainers published a critical GitHub security advisory, GHSA-cxm3-wv7p-598c: malicious versions of the nx build package and some of its plugins had been published to npm, containing code that scans the file system, collects credentials and posts them to GitHub as a repository under the user’s account. The maintainers’ postmortem adds the part that matters here: the post-install script also attempted to use local AI tools, like Claude and Gemini, and the malicious packages were active for 4 hours before they were removed from the registry.

Some of the people affected had no workspace that used Nx. The advisory names transitive dependencies, AI agents, editors and editor extensions among the ways a package gets installed, and versions 18.6.30 to 18.65.1 of the Nx Console extension for VS Code installed the latest nx, so opening the editor was enough to trigger the malicious script.

The lesson we take is about reach. An AI tool installed on a machine can be called by any code that runs there, so the settings that limit the tool, such as permissions.disableBypassPermissionsMode in managed settings, also limit what malware can make it do. Installing unfamiliar dependencies inside a container or VM keeps both the package and the agent away from your home folder.

Secrets in the folder and in git history

Secrets were a recurring finding in our audits: 6 of the 21 third-party apps we audited shipped a real secret, and a secret deleted from a file stays readable in the earlier commits that held it.

Those 21 are third-party apps from our June and July 2026 audits, picked for review rather than drawn at random, so the count shows what can ship, not how often it ships across AI-built apps. In the same audits, three apps had a real secret permanently in git history: a webhook signing secret, a live AI-provider key, and a Stripe test key with its webhook secret.

Deleting the file leaves the old commits holding the old value. The fix is a scan of the whole history, then rotation of every key it finds, and a tool that can scan the whole git history for secrets is where that starts. If a key has already reached a public repository or a log, the first hour after a key leaks comes before any cleanup. Both are parts of secrets management for a small team, which keeps the next key out of the folder in the first place.

The code Claude Code writes: what the tool cannot vouch for

Code from Claude Code is only as safe as the review behind it: 11 of the 21 third-party apps in our audits had unauthenticated endpoints doing privileged work, and no permission setting would have caught one.

The same June and July 2026 audits of 21 apps apply here, with the same limit: a chosen set of third-party apps, not a random draw, and not a Claude Code measurement either, since the findings describe what each app shipped whatever wrote it.

Permission modes govern what the tool does to your machine; they say nothing about what the code does to your users. That is our reading of the split, and the audits show why it matters: 10 of the 21 apps trusted the client, so the server accepted whatever the browser asserted. A permission prompt never asks whether an endpoint checks who is calling. A review of the diff and a test with a second account catch that, and no setting stands in for them.

Claude Code security review: what /security-review checks and what it skips

Claude Code’s security review is the /security-review command, which checks the diff between your branch and origin’s default branch for risks like injection, auth issues and data exposure, plus a GitHub Action that brings the same analysis to pull requests. It is a useful second look, not an audit, and its README lists what it skips.

To run a security review from Claude Code, the repository needs an origin remote, since the command compares your branch with origin’s default branch. Anthropic publishes the Action in its claude-code-security-review repository on GitHub, and the README states the limits plainly: the Action “is not hardened against prompt injection attacks and should only be used to review trusted PRs”, and its filter excludes denial-of-service issues, rate-limiting concerns, memory and CPU exhaustion, generic input validation without proven impact, and open redirects. A Claude security scan of that kind can therefore pass a pull request that leaves a login route with no rate limit.

A separate product carries the name Claude Code Security. Anthropic announced it on February 20, 2026 as a limited research preview for Enterprise and Team customers, built into Claude Code on the web, scanning codebases and suggesting patches for human review.

A Claude Code security audit of your own app is a different job. As we read it, a model reviewing a model’s diff is one more check, not a sign-off: it sees the change, not how your app decides who may read which row. The wider job is what an early-stage security review covers.

How to use Claude Code safely: the setup, step by step

Eight steps cover using Claude safely on a real codebase, and each has a check that fails if the step is missing: a clean folder, a clean history, prompts on, deny rules, the sandbox, no production keys, commits and CI.

These are the Claude Code security best practices we would put in place before a first session on a repository with real users, each written as an action and a check. Steps 3 to 5 follow Anthropic’s permissions, settings and sandboxing docs; the others are our own advice. The Claude Code safety net is ordinary version control: a commit before each session means any change the agent makes to tracked files can be undone with git, which is step 7.

  1. 01 Start Claude Code in a project folder that holds no .env files, keys or customer exports. Check: a file search in that folder for .env, *.pem and *.key names returns nothing.
  2. 02 Scan the whole git history for secrets before the first session and rotate anything the scan finds. Check: the clean scan result is saved with its date.
  3. 03 On a repository with live users, start in Manual mode with claude --permission-mode default and read the command and path in every prompt. Check: the rules /permissions lists are ones you recognize, with no bare Bash entry.
  4. 04 Add Read deny rules for secret paths, such as Read(./.env) and Read(./.env.*), to .claude/settings.json. Check: ask Claude to read .env and see the call refused.
  5. 05 Turn on the sandbox with /sandbox on macOS, Linux or WSL2. Check: ask Claude to run touch ~/sandbox-probe; it fails with Operation not permitted on macOS, or Read-only file system on Linux and WSL2.
  6. 06 Start the session from a shell with no production database URL or live API key in its environment. Check: env in that shell shows neither.
  7. 07 Work on a branch and commit before every agent session. Check: git log shows a commit before each session.
  8. 08 Put the project's rules in CLAUDE.md and let CI enforce the ones that matter. Check: a pull request with a forbidden change fails CI.

Step 8 needs both halves. Instructions in CLAUDE.md shape what Claude tries to do, but they don’t change what Claude Code allows, so only the CI check enforces a rule, and it stops a merge only where branch protection makes it a required status check.

In the Production Hardening Sprint, deliverable 10.8 is verified this way: we review the guidance and demonstrate CI catching a representative forbidden regression.

Where the sprint does this

If the app Claude Code built is about to take its first customers and nobody has checked the history, the rules or the code, the decision is whether to do that work yourself or have it done. The Production Hardening Sprint scans Git history for committed secrets and rotates every exposed credential found, and provides CLAUDE.md, AGENTS.md, Cursor rules or equivalents describing conventions and protected patterns, with CI checks for enforceable rules. If you would rather have it done, start with a free audit: a video call where we weigh up with you which of those risks matter before launch. The work itself is our Production Hardening Sprint, which follows the published scope.

Common questions about using Claude Code at work and at home

Is it safe to install Claude code on your computer?

Yes, from Anthropic’s own installer or one of the package managers its setup docs list, such as Homebrew, WinGet or npm. Each release publishes a manifest.json of SHA256 checksums signed with an Anthropic GPG key, so the binary can be verified, and the docs warn against sudo npm install -g. The risk starts once it runs, so install it, then start it in a clean project folder in Manual mode.

Is it safe to use the Claude code at work?

Yes for most code, on a commercial plan your company controls and within its policy. Claude for Teams adds admin tools, SSO and server-managed settings, Claude for Enterprise adds domain capture, role-based permissions and the compliance API, and managed settings sit above anything a developer sets. Check the employer’s policy first, keep production credentials out of the session, and ask for zero data retention where a contract requires it, on a commercial setup that is eligible for it.

How private is Claude AI?

Claude chat on a consumer account is as private as its model-improvement setting: with it off, Anthropic will not use your previous or new chats for future model training, and with it on, your data may be kept in de-identified form for up to 5 years in training pipelines. A chat you delete is gone from your history at once and from back-end storage within 30 days, and Incognito chats are not used to improve Claude.

Can I trust the Claude code?

Yes, to the extent that you can check its controls: trust those, not the tool’s intentions. A session with its permission checks on, no secrets or production keys within reach and a person reading the diff is one you can verify, because each of those conditions has a setting or a habit behind it.