Skip to main content

Explainer

Does Your AI Coding Assistant Train on Your Code? What Actually Happens to What You Type

The difference between code sent for inference, code retained in logs, and code used to train future models, and what each major AI coding tool does by default.

Updated November 18, 2026 · Based on 16 sources · How we research

If you type your company's code into GitHub Copilot, Cursor, or Claude Code, three different things could happen to it: it could be sent to a server to generate a suggestion, it could sit in a log for 30 days, and it could be used to train a future model. Most developers hear any of those and assume all three. That is the mistake. Transmission is almost always happening with cloud tools. Retention is usually 30 days by default. Training on your code is only the default in a few specific cases, and even then it is a toggle, a plan tier, or a contract term away from being off. This guide maps what each major tool does by default, what each setting actually changes, and what GitHub's April 2026 policy change means if you ship on client code under NDA.

Three different things happen to the code you send

A cloud AI coding assistant handles your code in three stages, and they have very different privacy implications. Inference transmission is the request itself: your current file, selected context, maybe some indexed chunks, going over TLS to a server so the model can produce a response. Retention is what, if anything, the provider keeps in logs after the response comes back. Training is whether those retained logs are used to update the weights of future model versions. Treat them as three separate switches, because that is how every provider contract treats them.

Transmission is unavoidable with cloud frontier models. The server needs the code to generate a completion, and Anthropic, OpenAI, Google and the rest run their models on their own infrastructure, not yours. Claude Code's own docs say it plainly: Claude Code sends all user prompts and model outputs over the network, encrypted in transit via TLS 1.2+. If you need code that never leaves your machine, the question is not which plan to buy; it is whether to move to a locally hosted model.

Retention and training are where the meaningful choices live. Anthropic's standard commercial API retention is 30 days, Zero Data Retention is available on request to qualified accounts, and no training on customer code happens by default under the Commercial Terms (Anthropic API and data retention). OpenAI's enterprise API behaves the same way: API data excluded from training by default, up to 30-day retention for abuse monitoring, ZDR available by approval. These provider-level floors sit under whatever your coding assistant's own policy says, and the assistant's policy is the one you need to actually read.

What GitHub's April 24, 2026 shift actually changed

On March 25, 2026, GitHub announced that interaction data from Copilot Free, Pro, and Pro+ would be used to train AI models by default starting April 24, 2026, unless users opt out (GitHub Blog changelog). The announcement gave individual subscribers a 30-day window before the default flipped. Copilot Business and Copilot Enterprise are unaffected: training on customer code is still blocked under their Data Protection Agreement, as GitLab's governance writeup and Tessl's summary both spell out.

The nuance that catches organizations out is the gap between 'code at rest' and 'interaction data.' GitHub says it does not use code stored in private repositories at rest for training. But when a developer actively uses Copilot against that same code, the prompts, snippets, and surrounding context become interaction data, and on Free, Pro, or Pro+ that stream is now training material by default. If a contractor on a personal Copilot Pro account contributes to a client repo, the client's enterprise protections do not travel with the contractor's session (DEV Community walkthrough).

The opt-out lives at github.com/settings/copilot/features under the toggle labeled 'Allow GitHub to use my data for AI model training.' Set it to Disabled. The setting is per-account, so anyone juggling multiple GitHub accounts has to change it on each one. Data collected before the toggle flips is not retroactively removed from training sets, which is why anyone on an individual plan who waited past April 24 has some window of data in the pipeline. See our GitHub Copilot Pro and Copilot Pro+ entries for current plan and credit details.

What Cursor Privacy Mode actually does, and what it doesn't

Cursor's Privacy Mode is the clearest example of why reading the defaults matters. When enabled, Privacy Mode routes requests through model providers that Cursor has Zero Data Retention agreements with, so your code is used in memory to generate the response and then dropped; neither Cursor nor those model providers store it or use it for training (Cursor's enterprise privacy docs). File paths sent as context are obfuscated. For the codebase index, Cursor stores embeddings and obfuscated path metadata on its servers rather than the original code.

The catch is the default. On Business and Enterprise plans, Privacy Mode is on by default and admins can enforce it so members cannot turn it off. On Pro and Hobby, Privacy Mode is off by default, and your prompts, code snippets, and telemetry are collected until you enable it manually (Strac's breakdown). That gap between tiers matters: if a startup is on Pro to save on seat cost and nobody has flipped the toggle, code is being retained.

Privacy Mode does not mean 'private from the internet.' Requests still leave your device for inference, same as every cloud coding tool. What it means is that the data drops off the provider's side when the response is returned. Cursor Pro is rank 1 on our best AI coding assistants list and holds SOC 2 Type II, but SOC 2 reports describe how a provider operates its controls, not what their defaults are set to.

Does Claude Code keep my code private?

Anthropic splits Claude Code on a sharp commercial-versus-consumer line. On commercial plans, which include Team, Enterprise, the API, and third-party platforms like Amazon Bedrock and Google Cloud's Agent Platform, Anthropic does not train generative models on code or prompts sent to Claude Code, unless the customer opts in via the Development Partner Program. Standard retention is 30 days. Zero Data Retention is available on Claude for Enterprise, but it is not a self-serve toggle and not included in the standard Enterprise plan; the account team enables it per organization after confirming eligibility (Claude Code ZDR docs).

On consumer plans (Free, Pro, Max, Ultra) Anthropic's docs say it will train new models using data from these accounts when the setting is on, including when Claude Code is used from those accounts. If the setting is on, retention is five years. If off, retention is 30 days. The switch lives at claude.ai/settings/data-privacy-controls. This is a meaningful difference from Copilot's new posture: Anthropic makes the choice explicit on consumer tiers rather than defaulting training to on and asking you to opt out. Claude Code is rank 2 on our list and ships SOC 2 Type II and GDPR compliance on Enterprise, plus audit logs on Team.

There is a Claude Code wrinkle worth knowing: session transcripts are cached locally in plaintext under ~/.claude/projects/ for 30 days by default so you can resume sessions. Adjust the retention with the cleanupPeriodDays setting. That is a local-disk artifact, not a cloud retention issue, but anyone imaging a dev laptop should treat it the same way they treat shell history. The /feedback, /bug, and /share commands do upload transcripts to Anthropic and retain them for five years; opt out of the feedback command with DISABLE_FEEDBACK_COMMAND=1 or set CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC to kill the non-essential outbound traffic in one shot.

When you actually need code to stay inside the building

For regulated work (financial services, healthcare, government contracts, strict NDAs), the policy answer is only half the picture. The architecture answer is: route inference through infrastructure you control, or run the model locally. Three products in our rankings cover that space, and each takes a different route.

Sourcegraph Cody Enterprise supports self-hosted deployment, is model-agnostic across Claude, GPT-4o, Gemini, and self-hosted LLMs, and ships with a zero-retention and no-model-training guarantee (Sourcegraph's enterprise post). Context Filters let admins control which repositories Cody is allowed to send to third-party LLMs, so sensitive directories can stay off the cloud path entirely. Cody at the lower tier also supports BYOK with Ollama for fully local inference.

Google Gemini Code Assist Enterprise stores private-repo customization data in a Google Cloud managed project isolated to the customer's organization, and Google states that Code Assist Enterprise does not train the Gemini model on that private data (Google Cloud intro). VPC Service Controls draw a network perimeter around it if you are already a GCP shop. JetBrains Junie and Zed take the BYOK route: you point them at your own AWS Bedrock, Vertex AI, or Azure OpenAI endpoint, and the provider's retention and training terms apply directly to you rather than through a reseller.

If the requirement is that no code at all leaves the machine, none of the ranked SaaS tools qualify. Open-source editor plugins paired with a locally hosted model runner keep inference on a local workstation. Quality typically sits below cloud frontier models and setup is real work, but the privacy profile is unambiguous.

The other direction: public code bleeding into your suggestions

Training is the privacy question going out. There is also the licensing question coming in. Frontier models have been trained on GitHub-scale corpora, and a long suggestion that regurgitates a chunk of GPL or other copyleft code onto your proprietary branch is a legal problem regardless of what the provider did with your own code.

GitHub Copilot's duplicate detection filter compares inline suggestions and approximately 150 characters of surrounding code against the public-code index and either blocks the suggestion or surfaces the matching file's URL and license. Enterprise admins can enforce block mode across an organization; individuals can enable annotations with repo and license information (GitHub code referencing docs). The filter applies to code completions and not to Copilot Chat responses, and GitHub says matches to public code occur in fewer than one percent of inline suggestions. Sourcegraph Cody Enterprise ships open-source attribution guardrails that verify generated code is not a verbatim copy of public code. Cursor and Claude Code do not publish an equivalent public-code matching filter.

Is it safe to use AI coding assistants on client code under NDA?

The honest answer is: it depends on the tool, the plan, and the contract, and most NDAs written before 2023 do not explicitly address AI tools. Silence is not consent. Lawyers writing about this consistently point out that uploading code to an externally hosted AI platform can breach confidentiality clauses even when the AI provider never retains the code (tish.law on AI NDAs, technical.ly on AI coding legal risks).

Before using any cloud assistant on client code, work through this checklist. It takes five minutes and converts a vague worry into a defensible decision.

  • Does the client contract address generative AI tools? If written before 2023, assume not, and ask explicitly in writing.
  • Is the plan a commercial tier (Copilot Business/Enterprise, Cursor Business, Claude Team/Enterprise, Cody Enterprise, Gemini Enterprise), not an individual tier? Individual tiers either default to training-on or require manual opt-out.
  • Is training explicitly off? Open the setting and confirm; do not infer it from the tier name.
  • Is retention 30 days or Zero Data Retention? ZDR matters when you are worried about discoverable records in a future dispute.
  • Does the underlying model provider have its own retention agreement with the assistant vendor? Cursor documents this for its ZDR routes; confirm it for the vendor you are using.
  • Is there personal data in the code (GDPR), PHI (HIPAA), or cardholder data (PCI DSS)? If yes, the product setting alone is not enough; you need contractual coverage of processor terms and cross-border transfer.
  • Can you route through infrastructure you already own (Bedrock, Vertex, Azure OpenAI, self-hosted Cody)? If yes, do that.

What each tool does by default, side by side

Our head-to-head of Cursor Pro vs Claude Code vs Copilot Pro covers the feature differences. For privacy posture at a glance, this is what each ranked product does on its default tier without you touching a setting.

Tool and planTrains on your code by default?RetentionOpt-out or override
GitHub Copilot Free / Pro / Pro+ (post April 24, 2026)YesProvider standardToggle at github.com/settings/copilot/features
GitHub Copilot Business / EnterpriseNo, blocked by DPAContractualNot applicable, default is off
Cursor Pro / HobbyYes, unless Privacy Mode onProvider standardEnable Privacy Mode in settings
Cursor Business / EnterpriseNo, Privacy Mode on by defaultZDR via provider agreementsAdmin can enforce org-wide
Claude Code consumer (Free/Pro/Max/Ultra)Only if data-sharing setting on5 years on, 30 days offclaude.ai/settings/data-privacy-controls
Claude Code Team / Enterprise / APINo, per Commercial Terms30 days, ZDR on Enterprise by agreementContact Anthropic account team for ZDR
Sourcegraph Cody EnterpriseNo, zero-retention guaranteeSelf-hosted possibleContext Filters, self-host
Gemini Code Assist EnterpriseNo, customer data isolatedCustomer-controlled, purgeableVPC Service Controls

The short version

If you are on an individual Copilot plan after April 24, 2026, flip the training toggle off at github.com/settings/copilot/features now. If you are on Cursor Pro or Hobby, enable Privacy Mode in settings. If you are on a consumer Claude plan and use Claude Code from it, check claude.ai/settings/data-privacy-controls. For any serious work under NDA, move to a commercial tier (Copilot Business, Cursor Business, Claude Team or Enterprise, or Cody Enterprise) where training-off is contractual and the default. If you need code to stay on your network, Sourcegraph Cody Enterprise or a BYOK setup through Zed or Junie against your own cloud account is the right shape. If it has to stay on the machine, a locally hosted open-source code model is the only option, and you accept the quality tradeoff.

See Best AI Coding Assistant 2026

Questions people ask

Does GitHub Copilot train on my code?+

As of April 24, 2026, yes by default on Copilot Free, Pro, and Pro+. No on Copilot Business and Enterprise, which remain excluded by their Data Protection Agreement. Individual-plan users can opt out at github.com/settings/copilot/features under 'Allow GitHub to use my data for AI model training.' Data collected before you opt out is not retroactively removed from training sets.

Is my code sent to the cloud when I use an AI coding assistant?+

If the tool uses a cloud-hosted frontier model (Claude, GPT, Gemini), yes. The request has to reach the server for the model to generate a response. The question is not whether code is transmitted, but what the provider is allowed to do with it afterward: retain it in logs, use it to train future models, both, or neither.

What does Cursor privacy mode actually do?+

It routes your requests through model providers under Zero Data Retention agreements, so neither Cursor nor those model providers store your code or use it to train future models. File paths are obfuscated. Embeddings and obfuscated path metadata are stored on Cursor's servers, not the original code. On Business and Enterprise it is on by default and admin-enforceable; on Pro and Hobby it is off by default and you must enable it in settings.

Will my proprietary code end up in a public AI model?+

On commercial tiers of every major assistant, no. Training on customer code is off by default on Copilot Business/Enterprise, Cursor Business/Enterprise, Claude Code commercial, Cody Enterprise, and Gemini Code Assist Enterprise. On individual Copilot after April 2026 it is on by default until you opt out. On consumer Claude plans, it is on only if you leave the data-sharing setting enabled.

How do I stop my AI coding tool from using my code for training?+

Copilot Free/Pro/Pro+: set the dropdown to Disabled at github.com/settings/copilot/features. Cursor Pro/Hobby: enable Privacy Mode in settings. Claude consumer: toggle off at claude.ai/settings/data-privacy-controls. On commercial plans across Copilot, Cursor, Claude Code, Cody and Gemini Enterprise, training is already off by default.

Is it safe to use AI coding assistants on client projects under NDA?+

Only on a commercial tier with training confirmed off and retention short, and ideally after confirming the client contract permits generative-AI tools in writing. Many NDAs predate 2023 and do not address AI tools at all, which is not the same as permitting them. Personal data, PHI or cardholder data in the code pushes the requirement from product settings to contractual processor terms.

What is the difference between an AI using my code for suggestions and training on it?+

Suggestions use your code in memory to generate a response for you, then release it. Training uses retained copies to update the weights of a future model version, which then ships to every user. Suggestions are transient. Training is permanent. Two different switches in every major provider's contract.

Does Claude Code keep my code private?+

On commercial plans (Team, Enterprise, API, Bedrock, Google Cloud's Agent Platform), yes: no training on customer code by default per Anthropic's Commercial Terms, 30-day standard retention, Zero Data Retention available on Claude for Enterprise by account-team agreement. On consumer plans (Free, Pro, Max, Ultra), the training toggle is yours. If on, retention is five years; if off, 30 days. Session transcripts are also cached locally in plaintext under ~/.claude/projects/ for 30 days by default.

Sources

What this guide is based on. We research from published specifications, independent reviews and owner reports; we did not test these products ourselves.

  1. 1.Claude Code, Data usage, Anthropic
  2. 2.Claude Code, Zero data retention, Anthropic
  3. 3.API and data retention, Anthropic
  4. 4.Privacy and Data Governance, Cursor
  5. 5.Privacy and data, Cursor
  6. 6.Cursor Data Privacy: Is Your Code Trained On? (2026 Guide), Strac
  7. 7.Updates to our Privacy Statement and Terms of Service: how we use your data, GitHub Blog
  8. 8.GitHub Copilot's new policy for AI training is a governance wake-up call, GitLab
  9. 9.GitHub to use Copilot interaction data for training by default, Tessl
  10. 10.GitHub Copilot Is Now Training on Your Code: Here's Your 30-Day Window to Stop It, DEV Community
  11. 11.GitHub Copilot code referencing, GitHub
  12. 12.Cody is enterprise ready, Sourcegraph
  13. 13.Security considerations for enterprises adopting AI coding assistants, Sourcegraph
  14. 14.Introducing Gemini Code Assist Enterprise, Google Cloud
  15. 15.AI Non-Disclosure Agreements (NDAs) and Data Leakage, tish.law
  16. 16.AI coding agents: Legal risks startup founders should know, Technical.ly

Products mentioned

More on ai coding assistants