You start a coding agent in a client’s repo, ask it to fix one failing test, and it opens .env to see how the database connects. From its side, that’s reasonable. From yours, a production password just became part of a prompt sent to someone else’s servers.
That’s the real question behind AI coding assistant privacy. It’s less “do they train on my code?” and more “what did the tool read, where did it go, and how long does it stay there?” I went through the current docs and terms for Claude Code, GitHub Copilot, Cursor, and OpenAI’s Codex to answer that, as they stand in November 2026.
Here’s where I come out, so you know where this is going. Cloud coding tools are fine for most work once you change a few defaults. The leaks that actually happen come from secrets sitting where an agent can read them, not from vendors quietly mining your repo. Local models fix a narrower problem than most people think.
What leaves your machine when a coding tool reads your repo
Most people picture the tool uploading the whole repository. Terminal agents don’t work that way. Claude Code and the Codex CLI run on your machine and open files one at a time as the task needs them. Every file they read becomes part of the conversation, and the conversation is what goes to the model. Anthropic’s Claude Code data usage docs say it plainly: Claude Code sends all user prompts and model outputs over the network, encrypted with TLS.
So your exposure isn’t the repo. It’s whatever the agent decided to open. In Claude Code’s default mode, reading files inside your project doesn’t even ask for approval, which is convenient right up until the file is .env.
The other tools differ in the details:
- GitHub Copilot sends your inputs, code snippets, and the context around them to generate suggestions and chat answers. GitHub groups all of that under “interaction data,” which matters for the training terms below.
- Cursor routes every request through its own backend, even when you plug in your own API key. Its data use page says that’s where the final prompt gets built. Cursor’s search index is built on your machine and isn’t uploaded, but any file the agent opens can still end up in the request.
- Cloud agents are a different category. Claude Code on the web and Codex cloud clone your repository into a VM the vendor runs. There, the whole repo leaves your machine by design.
What the data retention terms say right now
This is where the plan you pay for matters more than the tool you pick.
| Personal plans | Business and API plans | |
|---|---|---|
| Claude Code | You choose whether Anthropic trains on your data. Kept 5 years if training is on, 30 days if it’s off | No training. Kept 30 days, with zero data retention for qualified Enterprise accounts |
| GitHub Copilot | Free, Pro, and Pro+ interaction data used for training since April 24, 2026, unless you opt out | Business and Enterprise excluded from training |
| Cursor | Privacy Mode (any plan): no training, and zero-retention agreements with model providers. With it off, data may be used for training | Same Privacy Mode, enforced by an admin |
| Codex | Personal ChatGPT plans may be used for training unless you opt out | Business, Enterprise, Edu, and API not used for training by default |
A few details the table can’t hold:
- Claude Code also keeps session transcripts on your own disk, in plaintext under
~/.claude/projects/, for 30 days by default. Anything you send with/feedbackor/bug, code included, is kept for 5 years. - Copilot inside your editor discards the prompt once the suggestion comes back. Outside the editor (the CLI, github.com, mobile), GitHub keeps prompts and responses to preserve conversation history. The training change came with GitHub’s March 2026 terms update.
- Codex has two switches on personal plans. OpenAI’s training FAQ says turning off “Improve the model for everyone” covers Codex tasks, but a separate setting in Codex controls training on full environments, and the main toggle doesn’t touch it. Rating a response with thumbs up or down can also put that whole conversation into training, even after you opt out.
- Cursor doesn’t publish fixed retention periods. It says cached file contents are temporary and never permanently stored, and points to provider policies for the rest.
My read: on any of the four, a business plan or a two-minute settings change gets you terms I’d accept for client code. The personal-plan defaults are the weak spot, especially the opt-out models at GitHub and OpenAI, where doing nothing means your code can end up in training data.
Ignore files don’t keep secrets away from AI agents
This is the part most developers get wrong. .gitignore keeps a file out of git. It doesn’t keep it away from an AI agent, and none of the four tools treats its ignore mechanism as a hard wall.
Claude Code
.gitignore only hides files from the @ file picker. A .claudeignore file, which some tutorials still recommend, does nothing at all. The Claude Code permissions docs say to move those entries into Read deny rules instead. Even deny rules only cover Claude’s own file tools and shell commands it recognizes, like cat. A Python script the agent writes can still open .env by itself. The OS-level sandbox is what closes that gap.
Cursor
Cursor does the most out of the box. It skips everything in .gitignore and ignores .env* files by default. But its ignore-file docs call the protection best-effort, and they say the terminal and MCP tools the agent uses can’t block ignored files.
GitHub Copilot
Copilot’s version, content exclusion, only exists for organizations on Copilot Business or Enterprise. According to GitHub’s content exclusion docs, it isn’t supported in Copilot Chat’s Edit and Agent modes and doesn’t apply to symlinks. Your IDE can also pass along information from an excluded file indirectly, like type definitions.
Codex
Codex has no ignore file. You can deny reads with a glob in a permission profile, a feature OpenAI still labels beta.
Pro Tip: Test every block. Ask the agent to print your
.envand make sure it refuses. A rule with the wrong path pattern fails silently, and you won’t know until something leaks.
Secrets are where the real exposure is

GitGuardian’s State of Secrets Sprawl 2026 has the best data on this. In 2025, commits co-written with Claude Code leaked secrets at a 3.2% rate, against a 1.5% baseline across all public GitHub commits. The report also counted 24,008 unique secrets in MCP configuration files on public GitHub, and found internal repos about six times more likely than public ones to contain hardcoded secrets.
GitGuardian itself warns against reading that as a simple tool failure, and I agree. AI tools write and commit more code, faster, often for people who never learned where secrets belong.
That changes what privacy should mean in practice. A vendor holding a prompt for 30 days under a contract is a small risk. The same key sitting in a commit, a pushed MCP config, or a plaintext transcript on your laptop is a much bigger one. And if the agent read .env once, that key is in your local transcript no matter what the vendor keeps.
What fixes most of it:
- Keep production credentials off your dev machine. The agent can’t read what isn’t there.
- Load secrets at runtime from a secrets manager or your shell, not from a file inside the project.
- Run a secret scanner as a pre-commit hook, so a key gets caught before it reaches a remote.
- Keep API keys out of MCP configs. Reference environment variables instead.
AI coding assistant privacy settings worth changing
This is the checklist I’d run before pointing any of these tools at client code.
Claude Code
- On Pro or Max, check the model improvement setting in your claude.ai privacy settings.
- Add
Readdeny rules for secrets, and turn on the sandbox withdenyReadfor your credential folders. - Shorten how long local transcripts live with
cleanupPeriodDays. - Set
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1if you want to cut telemetry. Anthropic says its usage metrics never include code, prompts, or file paths anyway. - Don’t send
/feedbackfrom a client repo. Five years is a long time.
{
"permissions": {
"deny": ["Read(**/.env*)", "Read(**/*.pem)", "Read(~/.ssh/**)"]
},
"sandbox": {
"enabled": true,
"filesystem": { "denyRead": ["~/.ssh/**", "~/.aws/**"] }
},
"cleanupPeriodDays": 7
}
GitHub Copilot
- On Free, Pro, or Pro+, open your GitHub account’s Copilot settings and turn off “Allow GitHub to use my data for AI model training.”
- If a client needs files excluded, you need a Business or Enterprise seat. Individual plans don’t have content exclusion.
Cursor
- Turn on Privacy Mode. Any plan can use it.
- Add a
.cursorignorefor sensitive files that.gitignoredoesn’t already cover, and remember the agent’s terminal can still reach them.
Codex
- On a personal plan, turn off “Improve the model for everyone,” then check the environment training setting in Codex separately.
- Leave network access off, which is the default.
- Deny
.envreads with a permission profile in~/.codex/config.toml:
default_permissions = "locked-down"
[permissions.locked-down]
extends = “:workspace”
[permissions.locked-down.filesystem.”:workspace_roots”]
“**/*.env” = “deny”
When local models meaningfully reduce exposure

Running the model on your own hardware is the only way to make sure your code never reaches a vendor. But local only helps if the whole path is local, and that isn’t true for every tool.
Where it works:
- Claude Code can talk to Ollama through Ollama’s Anthropic-compatible API. You point
ANTHROPIC_BASE_URLathttp://localhost:11434, and Ollama’s own setup guide recommends a context window of 64k tokens or more. - Codex CLI has a built-in
--ossflag that talks to a local Ollama or LM Studio server, and it defaults togpt-oss:20b. - VS Code’s chat can use a local Ollama model with no GitHub sign-in at all.
Where it doesn’t:
- Cursor builds prompts on its backend even with your own key, so pointing it at a local model doesn’t keep your code off Cursor’s servers.
- Copilot’s inline suggestions can’t use a local model. The VS Code docs say semantic search, inline suggestions, and embedding-based features still need GitHub. Your chat goes local, but the ghost text doesn’t.
Even a fully local setup has leaks around the edges. MCP servers and web search tools send their queries out. Claude Code’s web fetch tool sends the hostname of every URL to Anthropic for a safety check unless you turn that off with skipWebFetchPreflight. A local model protects the prompt, not every tool around it.
So when is it worth it? I’d go local in three cases:
- A contract forbids third-party processing. If the NDA says client code can’t go to an outside processor, no retention promise fixes that.
- The repo holds regulated data, like health or financial records, and your compliance team hasn’t approved a vendor.
- The codebase can’t be cleaned of secrets, like an old project with credentials baked into its history.
For everything else, the trade isn’t worth it. Local coding models are a real step down in quality, which I covered in my post on where an Ollama coding setup falls short. That effort is better spent on a business plan and good secret hygiene.
Read the terms, change the defaults, move the secrets
Vendor promises alone shouldn’t earn your trust. What makes these tools safe is reading the terms, changing the defaults, and keeping secrets where no agent can reach them. Do that, and Claude Code, Copilot, Cursor, and Codex are all reasonable choices for most code. Skip it, and a local model won’t save you from a key you committed yourself.
FAQ
Does Claude Code upload my whole repository?
Not when it runs on your machine. It reads files as the task needs them, and only what it reads goes into the conversation. Cloud sessions are different, since they clone the repository into a remote VM.
Does opting out of training delete data that was already collected?
Opt-outs work going forward. OpenAI, for example, says it won’t train on new conversations after you opt out. Data you already sent follows each vendor’s normal retention schedule.
Is a business plan really different from a personal one?
Yes. All four tools exclude business-plan data from model training by default. That’s the biggest single difference in the terms.
Do I need a local model to work on client code?
Usually not. A business plan or the right opt-outs, plus secrets kept out of the project, covers most cases. Go local when a contract or regulation rules out third-party processing.


