NewThe Mac app is out for Apple SiliconGet it →
Fenzi
blog, safety

Is Claude Code private?

Private from other people, not from the model provider. Claude Code sends your prompts, its replies, and the files and command output it reads to Anthropic, or to the cloud platform you route it through. Commercial accounts are not used for training and are kept 30 days; consumer plans are used for training only when that setting is on, and then kept five years.

By Boris Kwemo, , six-minute read

People who ask this usually mean one of two things: will my code train the next model, and will a secret in my project end up somewhere it should not? Anthropic's documentation answers the first in one table. The second depends on what the agent reads, what it sends, and what it writes to your own disk.

What Claude Code sends, and to whom

Claude Code runs on your machine. The model does not. Anthropic's Data usage page says what crosses the network: "This data includes all user prompts and model outputs," encrypted in transit with TLS 1.2 or later.

That is more than the words you type. When Claude reads a file or runs a command, the result goes back to the model in the next request, so the file contents and the command output travel too. If it opens your .env, the values are in the request.

Isolation also does not change what is sent to the model.Claude Code docs, Choose a sandbox environment

Where it goes depends on the provider you configure. By default that is the Anthropic API. If you route Claude Code through Amazon Bedrock, Google Cloud's Agent Platform or Microsoft Foundry, that platform's retention rules apply instead, and on Foundry deployments hosted on Azure, prompts and completions stay in Azure apart from usage metadata and content flagged by safety systems.

Who trains on it, and how long it is kept

The answer depends on the account you sign in with, not on the tool. The same Data usage page sets it out by plan.

AccountUsed to train models?Kept by Anthropic
Free, Pro, Max or Ultra, with the model improvement setting onYes5 years
Free, Pro, Max or Ultra, with the setting offNo30 days
Team and other business plans, and the APINo, unless your organization opts in to a program that shares data30 days
Zero data retention, for qualified organizationsNoNot stored after the response, except where law or misuse requires it

The consumer rows matter more than people expect. A personal Pro or Max login used at work follows the consumer rules, including for Claude Code, and the setting can be changed at any time in the account's privacy controls.

Zero data retention has edges of its own, listed on Anthropic's Zero data retention page. Anthropic turns it on per organization after checking eligibility.

A developer who signs in with a personal account, or with an API key from another organization, is not covered, which is why the page points to the forceLoginMethod and forceLoginOrgUUID managed settings. Data handled by MCP servers and other third-party integrations is not covered either, and a session flagged for a policy violation can be kept for up to two years.

What else leaves your machine

Besides the model requests, Claude Code sends a few smaller streams. Each has an environment variable that turns it off.

Usage metrics. Latency, reliability and usage patterns, which the page says never include your code, prompts or file paths. DISABLE_TELEMETRY=1 stops them.

Error reports. Stack traces from Claude Code itself, with known secret patterns, paths and email addresses redacted first. They are on only for Pro, Max and Ultra sign-ins that talk to the API directly. DISABLE_ERROR_REPORTING=1 stops them.

Feedback. /feedback, /bug and /share send a copy of the conversation, code included, and Anthropic keeps it five years. DISABLE_FEEDBACK_COMMAND=1 stops them.

Session surveys. A rating sends only the rating. Answering Yes to the follow-up after a session rating uploads the transcript and the raw session log as they are, with known key patterns redacted, for up to six months. CLAUDE_CODE_DISABLE_FEEDBACK_SURVEY=1 stops the surveys.

The web fetch check. Before WebFetch opens a URL, Claude Code sends the hostname, not the path, to api.anthropic.com to check it against a blocklist. It runs on every provider. skipWebFetchPreflight in settings turns it off.

On Bedrock, Agent Platform and Foundry, metrics, error reports and feedback are off by default. CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 turns off all of the optional streams at once, but not the web fetch check, which has its own setting.

What stays on your own disk

Anthropic's page on the .claude directory covers the copy on your machine. Every session is written to a transcript under ~/.claude/projects/, in plain text, with everything that passed through a tool: file contents, command output, pasted text. If a tool read a .env file, its values are in that transcript.

Transcripts are deleted after 30 days by default, set by cleanupPeriodDays. The file of prompts you typed, ~/.claude/history.jsonl, is kept until you delete it. claude purge removes the state Claude Code holds for one project, and --dry-run shows what it would remove first.

Plain text means file permissions are the only protection. Any program running as you can read those files, including the next agent you start.

"My code is private because it never leaves my laptop."

Revision 1: what the agent reads goes to the model provider, and a copy stays in plain text on the laptop.

The file that can end up in Git

When you answer "Yes, and don't ask again" to a shell command, Claude Code saves an allow rule in .claude/settings.local.json at the root of the repository, according to Anthropic's settings page. The rule names the command you approved. If that command had a password or a token typed into it, the file now holds it too.

Claude Code adds the file to your global Git excludes the first time it writes it, so on that machine it stays out of commits. A file you created by hand, or one that was already tracked, gets no such help. Check, and untrack it if needed:

git ls-files .claude/settings.local.json   # prints the path if Git tracks it
git rm --cached .claude/settings.local.json
echo '.claude/settings.local.json' >> .gitignore

Removing the file from the next commit does not remove it from history. If a secret in it was pushed, rotate the secret.

How to keep more of it to yourself

Start with the account: a commercial account for work, or the training setting off on a personal one, routed through your cloud platform if that is where your contract already lives. Then turn off what you do not need and shorten what stays on disk. Every environment variable above can sit in the env block of a settings file:

{
  "env": {
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  },
  "cleanupPeriodDays": 7,
  "permissions": {
    "deny": ["Read(./.env)", "Read(./.env.*)"]
  }
}

The deny rules come from Anthropic's own example, and our notes on keeping files away from Claude Code cover where such rules stop. The surer move is to keep secrets out of the folder: a value the agent never reads is in no request, no transcript and no settings file.

Privacy and safety are the same three questions seen from two sides: which files the agent reads, which hosts it can send to, and which keys it holds. Our post on whether Claude Code is safe covers what it can do on your machine, our list of AI agent security risks covers the wrong file and the wrong host, and the four rules of agentic AI security we hold to start with giving the agent only the directories the task needs.

A side note on how we do it

We build Fenzi, which runs Claude Code in an OpenShell sandbox on a copy of the project; with an API key, the agent holds a placeholder and the real key is added outside the sandbox, as the model keys sheet explains, so the key is in no transcript the agent writes. It does not change what the model receives: the files the agent reads, command output and your instructions still go to Anthropic, as they would without a sandbox. A container whose folder holds no secrets answers the same question.

So, is Claude Code private?

From other people, yes. From the model provider, no: what the agent reads is what it sends, and your account decides whether that is used for training and how long it is kept. Pick the account on purpose, keep secrets out of what the agent can read, and check what sits in ~/.claude and in your repository. Anthropic's Data usage page is the place to start.

One line to install.
One command to run.

curl -fsSL https://fenzi.dev/install.sh | sh

Then fenzi run claude. Ask it to open a pull request with the GitHub API, and watch the deny land.