Does Claude Code train on your code?
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.
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.
What to actually do about it.
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.
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.
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.
Routes that remove the question.
Two directions when policy alone isn't enough — move to commercial terms, or stop sending the code anywhere.
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? +
Q · 02 How do I turn data sharing off? +
Q · 03 What is the Development Partner Program? +
Q · 04 Is anything stored on my own machine? +
~/.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.