All insights

Coding agents

Is Claude Code Safe? A Practical Risk and Privacy Guide

Claude Code’s safety depends on its permissions, execution environment, data terms, and your review process. Learn what to check—and why production API use is a separate decision.

Illustration for Is claude code safe

Is Claude Code safe?

Claude Code may be suitable for a coding workflow when its access is limited to what the task needs, you understand which actions can run, and you review consequential changes. It is not risk-free, and no single yes-or-no answer fits every setup. Security and privacy risks are separate from the possibility that generated code or advice is incorrect. Anthropic documents permission controls and security features, but those controls do not prove every workflow is safe. (Claude Code security documentation)

The practical decision depends on what code and secrets are in scope, what actions Claude Code can take, where it runs, and which data terms apply to your account. A personal project with limited access and reviewed changes is different from an unattended agent with production credentials and broad network access.

Your situation A sensible starting point
You are exploring a non-sensitive project Use a limited working directory, check the active permission mode, and inspect edits and commands.
The repository contains customer data, credentials, or proprietary code Confirm the data terms and retention settings for the account and organization you will use before submitting it. Remove secrets from the task context where practical.
You want unattended changes or access to production systems Treat this as a deployment-security decision. Use least privilege, isolation, and network restrictions appropriate to the job; test the setup before granting production access.
You are choosing between Claude Code and a production Claude API integration Evaluate them separately. API use has its own data terms and credential controls, and your application determines what tools or actions are available.

What Claude Code can do—and what to check first

Claude Code’s tools can let it read files, make edits, run shell commands, and interact with connected services. Which actions can proceed without asking depends on the permission mode and configuration. Anthropic documents Manual mode as asking before most edits and shell commands, while allowing a built-in set of read-only commands—such as ls, cat, and git status—without prompting. In Manual mode, file reads are allowed without approval within the working and additional directories. Your explicit allow/deny rules and organization settings also apply. Check the mode shown in your own session; do not assume every action will prompt. (permission modes, permission rules)

Before giving Claude Code access to an important repository, check:

  • Working directory and additional directories: Know which folders its file tools can read or change. The documented working-directory boundary for file tools does not, by itself, isolate shell commands. Treat Bash permissions and sandbox boundaries separately; do not assume a file-tool boundary prevents an approved command from reaching other files. (permissions documentation)
  • Shell permissions: Review which commands are allowed, require approval, or are denied. Permission rules determine whether an action is allowed; they are not the same as operating-system isolation. (permissions and sandboxing)
  • Sandbox and network boundaries: Anthropic’s built-in sandbox can restrict filesystem and network access for Bash, PowerShell, Monitor commands, and processes they start. It does not automatically cover every tool or integration. Check the active configuration and verify sandboxed execution using the documentation’s confirmation procedure before relying on it. (sandbox documentation)
  • Active settings: Check the permission-mode indicator or selector in your session, review the settings files and managed settings that apply, and use /sandbox to inspect or configure sandbox behavior. Settings and available controls can vary by session surface and organization policy. (settings documentation, sandbox documentation)
  • Integrations and credentials: Check enabled MCP servers, extensions, hooks, and other connected tools. Give them only the access the task needs, and avoid exposing credentials that could authorize actions beyond the task.
  • Changes before they leave your machine: Review the diff and commands that ran, then run appropriate tests and security checks. A permission prompt helps control actions; it does not establish that the resulting code is correct.

One risk worth taking seriously is prompt injection: malicious instructions can be embedded in files, webpages, or other content an agent processes. Anthropic’s deployment guidance identifies prompt injection and model error as sources of unintended actions and recommends defense in depth. A repository that looks trustworthy should not automatically receive broad permissions or powerful credentials. (secure deployment guidance)

What happens to your code and other data?

Some session context is sent to Anthropic’s processing service so Claude can respond. Anthropic’s Claude Code usage guidance says each model turn includes the conversation so far, project context such as CLAUDE.md and files Claude has read, and the new prompt. That does not establish that every file in a repository is uploaded automatically. But if you include a file, prompt, or command output in the context you ask Claude to analyze, treat it as data you are submitting. The cited usage guidance does not, by itself, establish how all local session files or caches are stored. (Claude Code usage guidance)

Training use and retention are different questions, and the applicable terms depend on how you authenticate and which plan or provider handles the session:

  • Free, Pro, Max, and Ultra consumer accounts: Anthropic says model-improvement use for Claude Code sessions depends on the consumer account’s setting. If you allow improvement, Anthropic may retain de-identified data in model-training pipelines for up to five years. Consumer conversations deleted from history are deleted from backend storage within 30 days; separate exceptions apply, including policy-violation investigations, legal requirements, and safety needs. Check the setting on the account you will actually use. (consumer training policy, consumer retention policy)
  • Team, Enterprise, and other commercial arrangements: Anthropic says commercial inputs and outputs are not used to train models by default; feedback or other voluntary sharing can be treated differently. Retention is not the same as training: commercial products that preserve conversations may retain them according to product and organization settings, and Enterprise offers configurable retention controls. For API-key or third-party-provider access, check the terms for that specific workspace and provider rather than assuming Claude Code’s consumer or Enterprise terms apply. (commercial training policy, commercial retention policy)
  • Zero Data Retention (ZDR): This is not a default Enterprise setting. Anthropic says Claude Code ZDR is available to qualified Claude for Enterprise accounts and must be enabled separately for the relevant organization. For the documented Claude Code inference coverage, prompts and model responses are processed in real time and not stored after the response is returned, except where needed to comply with law or combat misuse. Coverage is tied to requests routed to the ZDR-enabled organization and Anthropic’s direct platform; other providers have their own terms. Anthropic also documents exceptions for certain specially designated models, so confirm current model and feature coverage with your organization before relying on ZDR. (Claude Code ZDR terms, Covered Models retention policy)

For example, a developer using a personal Pro account for a private project should check the model-improvement setting and avoid placing secrets in the context. A company using Claude Code through an Enterprise organization should verify its own commercial terms, retention configuration, and any ZDR eligibility and routing requirements. Those arrangements are not interchangeable. If you cannot confirm the applicable terms for restricted material, do not submit it until your organization or provider confirms them.

Does Claude Code safety apply to a production model API?

No—not automatically. Claude Code is a coding workflow with agent tools and permission settings. A production Claude API integration is a separate context; the developer manages the application and any tools it gives the model. Evidence about Claude Code’s permissions does not establish API data terms or secure an API deployment. (Claude Platform documentation)

For a production API, separately verify:

  1. Which service processes the request. Direct Anthropic API use, Amazon Bedrock, Google Cloud, and Microsoft Foundry can have different data-processing and retention arrangements. (API data-retention documentation)
  2. What retention and training terms apply to the API features and models you use. Do not assume every endpoint, model, tool, or provider has identical coverage. (API data-retention documentation)
  3. How credentials and access are controlled. Keep API secrets out of client-side code and repositories. Choose an authentication method, scope access, and manage credentials according to your organization’s security practices. (API authentication documentation)
  4. What your application permits and verifies. Limit tools and data to what the feature needs, validate output before consequential actions, and require appropriate human review for sensitive operations.

Claude Code controls do not secure a separate API integration for you, and API terms do not establish what a coding-agent session can access. Treat them as separate reviews.

What Claude Code Security does—and does not prove

Anthropic’s February 20, 2026 announcement describes Claude Code Security, a particular vulnerability-scanning capability built into Claude Code on the web. Anthropic said the feature checks findings through multiple stages, assigns severity and confidence ratings, and presents findings and suggested patches for human review; it also said fixes are not applied without human approval. The announcement described a limited research preview for Enterprise and Team customers, with open-source maintainers invited to apply for expedited access. That announcement does not confirm current availability. (Anthropic’s announcement)

Anthropic says the feature aims to reason about code interactions and data flows, including complex issues such as business-logic flaws or broken access control. Those are descriptions of intended capability, not an independent benchmark or a guarantee that it will find every vulnerability. The announcement provides no measured accuracy or false-positive rate. Its human-approval statement applies to this scanning feature’s proposed fixes—not to every ordinary Claude Code action.

Bottom line: Claude Code can be a reasonable choice when its access is proportionate to the task, the applicable data terms fit the code you plan to use, and a person checks consequential actions and changes. For sensitive repositories, autonomous execution, or production API deployments, make permission, isolation, retention, and credential decisions explicit before rollout. A feature-specific safeguard is not a substitute for verifying your own setup.

Sources

Security — Claude Code Docs

Choose a permission mode — Claude Code Docs

Configure permissions — Claude Code Docs

Configure the sandboxed Bash tool — Claude Code Docs

Settings files and precedence — Claude Code Docs

Securely deploying AI agents — Claude Code Docs

Models, usage, and limits in Claude Code — Claude Help Center

Is my data used for model training? — Anthropic Privacy Center

How long do you store my data? — Anthropic Privacy Center

Is my data used for model training? — Anthropic Privacy Center

How long do you store my organization’s data? — Anthropic Privacy Center

Data usage — Claude Code Docs

Zero data retention — Claude Code Docs

Covered Models — Claude Help Center

Documentation — Claude Platform Docs

API and data retention — Claude Platform Docs

Authentication — Claude Platform Docs

Making frontier cybersecurity capabilities available to defenders — Anthropic

Contact us