Does Anthropic train on the code you send through Claude Code, and how long is that data kept, on its servers and on your machine?
answer
- depends on the account type
- consumer privacy toggle decides training
- commercial terms: no training by default
- five years versus thirty days
- plaintext transcripts under ~/.claude/projects
basics
~20 sTraining and retention follow the account type: commercial accounts (Team, Enterprise, API) aren't trained on and are kept 30 days; consumer accounts are trained on only with the improvement setting on (5-year retention, else 30 days). Local transcripts persist 30 days.
solid answer
~40 sIt depends on who the account belongs to. On **commercial terms** — Team, Enterprise, the API and third-party platforms — Anthropic does not train generative models on code or prompts sent through Claude Code unless the customer opts in, for example through the Development Partner Program, and standard retention is 30 days. **Consumer** Free, Pro and Max accounts have a privacy setting: with model improvement allowed, data can be trained on and is retained for 5 years; with it off, retention is 30 days. Separately, Claude Code writes every session transcript in plaintext under `~/.claude/projects/` on your machine and deletes it after `cleanupPeriodDays`, 30 days by default. A `/feedback` report is its own case: the transcript it sends is kept for 5 years.
go deeper
Recall the split: commercial accounts are not trained on, consumer accounts depend on one privacy toggle, and transcripts also live on your own disk for 30 days.
Explain the retention numbers per account type, why /feedback is a separate 5-year path, and how cleanupPeriodDays and its minimum of 1 control the local copy.
Show you treat the plaintext transcripts as sensitive data: shorten retention, keep credentials out of reads, and know which commands send extra data upstream.
Frame the choice of account type as a data governance decision: consumer seats on company code carry a training toggle the organization does not control.
## Two policies, chosen by the account type Claude Code is a client: it sends your prompts, the files Claude reads and the model's outputs to the model provider over TLS. What happens to that data on Anthropic's side is not a Claude Code setting at all — it follows the **account type** the session is signed in with. Two families of terms apply. | Account type | Used for model training? | Server-side retention | | :- | :- | :- | | Consumer: Free, Pro, Max — model improvement **allowed** | Yes, new models may be trained on it | 5 years | | Consumer: Free, Pro, Max — model improvement **not allowed** | No | 30 days | | Commercial: Team, Enterprise, API | No, unless the customer opts in (for example the Development Partner Program) | 30 days standard | | Commercial with **zero data retention** (qualified Enterprise organizations) | No | Not stored after the response, apart from legal and misuse exceptions | Three details trip people up: - **Pro and Max are consumer plans.** A paid individual subscription is not commercial terms; the privacy toggle at claude.ai decides training, and it can be changed at any time. - **Third-party platforms count as commercial** for the training policy. Sessions routed through a cloud provider's endpoint are also governed by that provider's own data terms. - **Zero data retention is not a plan feature.** It is enabled per organization by Anthropic's account team for qualified Enterprise accounts; the standard Enterprise plan keeps the 30-day period. ## What else can leave your machine Some actions send more than a normal turn does, and they carry their own retention: - **`/feedback`** (and `/bug` and `/share`, which report through the same path) uploads a copy of the conversation, including code. Those transcripts are retained for **5 years**. `DISABLE_FEEDBACK_COMMAND=1` turns the command off. - **Session quality surveys** record only the rating. An optional follow-up can upload the transcript if you answer **Yes**; shared transcripts are kept up to 6 months and cannot be used to train models. - **Telemetry**: usage metrics never include your code, prompts or file paths, and error reports carry Claude Code's own stack traces with known secret and path patterns redacted; `DISABLE_TELEMETRY=1` and `DISABLE_ERROR_REPORTING=1` opt out. ## What stays on your machine The part developers forget is local. To make `/resume` work, Claude Code writes every session to `~/.claude/projects/<project>/<session>.jsonl`: every message, tool call and tool result. These files are **plaintext** — operating-system file permissions are the only protection — so a `.env` file Claude read or a token a command printed sits in that transcript. The retention knob is **`cleanupPeriodDays`**: - The default is **30** days and the minimum is **1**; a value of `0` fails validation rather than meaning "keep nothing". - The sweep runs in the background after a session starts and deletes silently, so an old session simply disappears from the `/resume` picker. - Transcripts of sessions started or last continued in the desktop app or Cowork are exempt by default and have their own limit. To avoid writing transcripts at all, set `CLAUDE_CODE_SKIP_PROMPT_HISTORY=1`, or pass `--no-session-persistence` with `claude -p`. ## Setting it once for an organization Because `cleanupPeriodDays` is an ordinary settings key, an administrator can put it in managed settings so a developer's own file can't lengthen it: 1. Decide the local retention your policy allows, for example 7 days. 2. Deliver `"cleanupPeriodDays": 7` through the organization's managed settings. 3. Pair it with permission rules that deny reads of credential files, so secrets are less likely to reach a transcript in the first place. ## Quick checks for a developer - **Which terms apply to me?** Look at how the session signs in: a personal Free, Pro or Max login is consumer terms, while a Team or Enterprise seat or an API key is commercial. - **Where is my history?** Under `~/.claude/projects/`, one folder per project and one `.jsonl` file per session, readable by anything that can read your home directory. - **What decides how long it stays?** The `cleanupPeriodDays` value in force on your machine; if your organization sets it in managed settings, your own value doesn't apply. - **Did my survey answer opt me into training?** No — survey ratings and shared transcripts don't change training preferences. ## Summary Training is decided by the account and, for consumers, by one privacy toggle; server retention is 30 days in most cases and 5 years only for consumers who allow model improvement or for anything sent through `/feedback`. Local retention is a separate clock you control with `cleanupPeriodDays`.
- A developer wants local transcripts deleted after a week. What do they set, and what would `0` do?Set `cleanupPeriodDays` to `7` in settings. The minimum is `1`; `0` fails validation instead of disabling storage. The sweep runs in the background after a session starts and deletes old sessions without a message. To write no transcript at all, use `CLAUDE_CODE_SKIP_PROMPT_HISTORY=1`, or `--no-session-persistence` on a `claude -p` run.
- Does running `/feedback` change what Anthropic keeps from a Claude Code session?Yes. `/feedback` sends a copy of the conversation, including code, and that transcript is retained for 5 years whatever the plan. `/bug` and `/share` use the same path. An organization can switch the command off with `DISABLE_FEEDBACK_COMMAND=1`, and it is disabled entirely under zero data retention.
- Anthropic trains on every Claude Code session, whatever the plan.
- A Pro or Max subscription is covered by commercial no-training terms.
- Local transcripts under ~/.claude are encrypted at rest.
- Setting cleanupPeriodDays to 0 stops Claude Code storing transcripts.
- Team and Enterprise data is kept indefinitely unless zero data retention is bought.