Last verified

Does Claude Code train on your code?

Depends.
Commercial: no · consumer: your setting

On commercial plans, no. Anthropic states it does not train generative models on code or prompts sent to Claude Code under commercial terms — Team, Enterprise, API and third-party platforms — unless the organisation opts into the Development Partner Program. On Free, Pro and Max it's your setting: leave data sharing on and your Claude Code sessions are used to improve future models, and retention stretches from 30 days to five years.

Team / Enterprise / API — no training under commercial terms Free / Pro / Max — trained on if the setting is on Retention 5 years with sharing on; 30 days with it off Switchable any time at claude.ai privacy settings Transcripts sit on your disk in plaintext for 30 days by default
§ 01 / SOURCE

Where this answer comes from.

Methodology →
PER VENDOR DOCS · AUG 01, 2026

Two policies, split by who's paying.

The consumer wording is explicit: for Free, Pro and Max accounts Anthropic gives you the choice, and "we will train new models using data from Free, Pro, and Max accounts when this setting is on (including when you use Claude Code from these accounts)". The parenthesis matters — Claude Code isn't carved out from the chat app's policy.

The commercial wording is the opposite default: Team, Enterprise, API, third-party platforms and Claude Gov "maintain existing policies: Anthropic does not train generative models using code or prompts sent to Claude Code under commercial terms", unless the customer opts in — for example through the Development Partner Program, which an organisation admin enables deliberately and which is first-party API only.

Retention follows the same split. Consumer accounts with sharing on: five years. Sharing off: 30 days. Commercial: 30 days standard, with zero data retention available to qualified Enterprise accounts on a per-organisation basis rather than as part of the standard plan.

One thing to know that isn't about Anthropic at all: session transcripts are cached locally in plaintext under ~/.claude/projects/ for 30 days by default, to allow resuming sessions. We confirmed the directory exists on our own machine — 50 project folders — checking only names and count, never contents. Adjust the window with cleanupPeriodDays.

Commercial plans: no trainingConsumer plans: opt-in settingRetention · sharing on: 5 yearsRetention · sharing off: 30 daysLocal transcripts: plaintext · 30 daysZDR: qualified Enterprise only
!
Per vendor docs — we did not run this test. The answer above rests on the source below, read on . Where we run a capability ourselves, this section carries the terminal transcript instead.
Source Anthropic docs — Data usage, training policy and retention https://code.claude.com/docs/en/data-usage
§ 02 / WHY

What to actually do about it.

2.1
Find out which side you're on

The split is by account type, not by tool. If you log in with a personal Pro or Max subscription, you're a consumer user even when the code belongs to your employer — which is the situation worth catching early. If you authenticate through a Team or Enterprise account, an API key under commercial terms, or a cloud provider, the no-training policy applies.

Consumer privacy settings live at claude.ai under data privacy controls and can be changed at any time.

2.2
Retention is the sharper edge

Most people focus on training and miss the retention consequence: leaving sharing on takes retention from 30 days to five years. If your concern is "how long does this exist somewhere", that difference is larger than the training question itself.

Commercial accounts sit at 30 days by default. Zero data retention exists but is not included in the standard Enterprise plan — it's enabled per organisation after an eligibility check, so assume you don't have it unless someone confirms you do.

2.3
Your own disk is part of the threat model

Independent of any policy, Claude Code writes session transcripts to ~/.claude/projects/ in plaintext and keeps them 30 days by default so sessions can be resumed. On a shared or backed-up machine that's a copy of everything you discussed, sitting locally.

Shorten the window with cleanupPeriodDays, or clear the directory. It's the cheapest privacy improvement available here and nothing about your plan changes it.

Frequently asked.

Quick follow-ups people search after this question.

Q · 01 Does Anthropic train on my code if I use Claude Code at work? +
It depends which account you log in with, not where you work. A personal Pro or Max login follows the consumer policy — trained on if the setting is on. A Team, Enterprise or commercial API account is covered by the no-training policy by default.
Q · 02 How do I turn data sharing off? +
Consumer privacy settings are at claude.ai under data privacy controls, and can be changed at any time. Turning sharing off also drops retention from five years to 30 days, which is the more consequential half.
Q · 03 What is the Development Partner Program? +
An explicit opt-in through which an organisation admin can provide materials for model training. It applies to Anthropic's first-party API only — not to Amazon Bedrock or Google Cloud's Agent Platform users.
Q · 04 Is anything stored on my own machine? +
Yes. Session transcripts are cached in plaintext under ~/.claude/projects/ for 30 days by default so sessions can be resumed. Shorten that with cleanupPeriodDays or clear the folder — no plan setting affects it.