Skip to content

Data Privacy and Enterprise Policies

Data privacy for AI-assisted development rests on a four-tier classification — public, internal, confidential, restricted — that says what may reach a model provider, enforced by each tool’s retention setting, pre-flight secret scanning, synthetic data instead of production copies, least-privilege MCP credentials, and environment isolation that keeps agents off production entirely.

A developer on your team pastes a database query result into their AI tool to debug a performance issue. The result contains customer email addresses, billing addresses, and partial card numbers, and the provider’s logs now hold PII from your production database. Three lines into another session, someone has pasted a full DATABASE_URL — host, user, and password — to ask why prod keeps timing out. A third person is about to point a community MCP server at production with admin credentials.

Every one of those moves feels harmless in the moment, and every one of them is the scenario that kills enterprise AI adoption before it starts. AI assistants are safe on proprietary code if you configure them deliberately: classify what can leave, turn on the right retention setting, never let a secret reach the model, and give every MCP server the least privilege it needs.

What you’ll walk away with from these privacy controls

Section titled “What you’ll walk away with from these privacy controls”
  • A four-tier data classification developers can apply without thinking, and the tool config that enforces it
  • What each vendor’s privacy setting actually guarantees — and the thing it explicitly does not
  • A secret-scanning prompt for every diff, plus a prompt that builds the pre-flight scanner your hooks call
  • An anonymization workflow that replaces production snapshots with synthetic data matching your schema
  • A least-privilege pattern for database MCP servers, with the exact GRANT
  • A security-review prompt that reads AI-generated code like a hostile pull request
  • Ready-to-use policies that satisfy legal, security, and engineering teams

Not all data carries the same risk when sent to AI tools. Classify it once, and every later decision — which files to ignore, which prompts to block, which database the agent may touch — follows from the tier.

TierDescriptionAI Tool PolicyExamples
PublicOpen-source code, public docsUnrestrictedOSS libraries, public APIs, documentation
InternalProprietary code, internal docsAllowed with privacy modeBusiness logic, internal tools, architecture docs
ConfidentialTrade secrets, unreleased featuresAllowed with strict controlsAlgorithms, competitive features, pricing logic
RestrictedPII, credentials, financial dataNever send to AI toolsCustomer data, API keys, payment info, health records

The Internal tier is doing quiet work in that table: it is allowed with privacy mode, which means the tier system only holds if you know what your tool’s privacy mode actually guarantees.

What each tool’s retention setting actually guarantees

Section titled “What each tool’s retention setting actually guarantees”

“Privacy Mode” is not universal — each vendor has its own control and its own guarantee. Know which one applies to you before you paste a single proprietary line.

Cursor has an explicit Privacy Mode toggle (Cursor Settings). With it on, your code is not stored by Cursor and not used for training — a zero-data-retention (ZDR) guarantee. Privacy Mode is on by default for Enterprise teams, and admins can enforce it team-wide so individuals cannot turn it off. Indexing still computes embeddings, but under Privacy Mode plaintext code is not retained server-side after the request.

Encoding the policy where the tool will read it

Section titled “Encoding the policy where the tool will read it”

A classification nobody can see is a classification nobody applies. Each tool has a file that gets loaded before the agent does anything, and a mechanism that enforces the hard edges rather than suggesting them.

Use .cursor/rules to state the data-handling policy:

.cursor/rules
DATA HANDLING POLICY:
Privacy Mode MUST be enabled at all times (Settings → Privacy).
NEVER include in prompts or context:
- Contents of .env, .env.*, or any secrets files
- Customer data, even for debugging (use anonymized samples)
- Production database query results
- API keys, tokens, certificates, or private keys
- Internal URLs that contain authentication tokens
ALWAYS use instead:
- .env.example with placeholder values
- Faker.js-generated test data that matches production schemas
- Redacted log entries: replace emails with user_XXX@example.com
- Mock credentials: sk_test_XXXXXXXXXXXX

Rules are guidance. The enforcement is .cursorignore, which keeps the files out of the index entirely:

.cursorignore
.env*
**/secrets/**
**/credentials/**
**/*.pem
**/*.key
config/production.*
database/seeds/production/**

The rule is unchanged from ordinary security hygiene, but the surface is wider: API keys, tokens, passwords, and database connection strings must never appear in a prompt. Reference process.env.DATABASE_URL, not the literal value. The most reliable enforcement is automation, not willpower — wire gitleaks into a pre-commit hook so a leaked credential is caught before it is ever committed or pasted.

Two prompts cover the two moments. The first is the per-diff check a human runs before committing; the second builds the scanner your UserPromptSubmit hook calls on every single interaction, which is why it has to be fast and pattern-driven rather than a model call.

When developers need production-like data for debugging, the answer is not a redacted export — it is synthetic data that matches the schema and the edge cases. Teach the agent to generate it from the shape of the table rather than its contents.

Anonymization only holds if production data is not sitting in the environment the agent can reach in the first place.

  1. Development environments never contain production data

    Use synthetic data generation or anonymized production snapshots. Never copy production databases to development.

  2. AI tools connect to development and staging only

    Database MCP servers, if used, connect only to development databases. Production database access requires separate tooling with full audit trails.

  3. CI/CD pipelines use service accounts

    AI-assisted CI workflows (headless Claude Code, Codex automation) use service accounts with minimal permissions, not developer credentials.

  4. Regular access reviews

    Monthly review of what data AI tools can access. Remove unnecessary access proactively.

The Model Context Protocol lets your agent connect to external tools — a database, GitHub, a browser. Every MCP server is executable software with whatever permissions you hand it, so an over-privileged or unvetted server is a real attack surface. Two rules cover most of the risk.

First, vet the server before you install it. Prefer official, scoped packages (for example @modelcontextprotocol/server-github, @modelcontextprotocol/server-postgres) over an unknown community fork. Have the agent summarize what a server actually does before you wire it up:

Second, connect it with least-privilege credentials. For a Postgres MCP server, never hand it your app or admin role. Create a read-only role scoped to exactly what the agent needs:

CREATE ROLE ai_readonly LOGIN PASSWORD 'rotate-me';
GRANT CONNECT ON DATABASE app TO ai_readonly;
GRANT USAGE ON SCHEMA public TO ai_readonly;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ai_readonly;
-- new tables inherit read-only access automatically
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO ai_readonly;

Then point the MCP server’s connection string at ai_readonly — identical config across Cursor, Claude Code, and Codex, since all three read the same mcpServers block. Now a hallucinated DROP TABLE is rejected by the database, not by hope. See Database MCP for full setup and MCP Security for the threat model.

Review AI-generated code like a hostile PR

Section titled “Review AI-generated code like a hostile PR”

Treat every block the agent writes as a pull request from a brand-new contributor: it may be functionally correct and still ship an injection bug or a missing authorization check. Do not skim the diff — make a second pass with the model wearing a security hat, then verify the findings yourself.

Read the diff, not the summary

Before approving a file edit, read the actual diff, not the agent’s one-line description of it. The summary is what the agent intended; the diff is what it will write.

Gate destructive commands

Never auto-approve terminal commands that delete, deploy, or mutate data. Run agents in a restricted mode (Cursor’s per-action approval, Claude Code’s permission prompts, or Codex with an explicit sandbox and approval_policy=on-request). In Codex, the sandbox enforces access boundaries while the approval policy separately controls escalation prompts.

This is the human-in-the-loop discipline that separates production work from demos — see Human in the Loop for the full review workflow.

If your organization processes data from EU residents, your AI tool usage must comply with GDPR:

  • Data Processing Agreement: ensure your AI tool vendor has a DPA in place
  • Legal Basis: document the legal basis for sending code (including any embedded data) to AI providers
  • Data Minimization: send only the minimum context needed for the task
  • Right to Erasure: confirm that your AI provider supports data deletion requests
  • Cross-Border Transfer: if using US-based AI providers, ensure adequate transfer mechanisms (for example Standard Contractual Clauses)

Make the policy something developers actually read

Section titled “Make the policy something developers actually read”

Privacy controls only work if developers understand and follow them. A short, memorable card beats a policy document nobody opens.

Then keep it honest with a quarterly review that verifies four things: tool configuration (privacy modes enabled, ignore files current), usage patterns (prompts containing suspicious patterns such as email addresses or key formats), vendor compliance (DPAs current, retention policies unchanged), and training freshness (new developers onboarded to the policy within their first week).

  • A developer accidentally sent PII to the AI tool. If your vendor has zero retention, the risk is limited. Document the incident, update your pre-flight scanning to catch that pattern, and use it as a training moment. Do not create a culture of fear — create a culture of process improvement.
  • You assumed Privacy Mode but someone was on a personal plan. A teammate logged into a personal Cursor or ChatGPT account on a work machine, bypassing the team’s ZDR enforcement. Enforce Privacy Mode at the team level and restrict logins to corporate accounts (Cursor’s Allowed Team IDs, ChatGPT Enterprise SSO).
  • A secret leaked through an MCP server’s logs. The model never saw the credential, but the server printed the full connection string to stderr on a connection error. Scope the server’s credentials with the read-only role above, and never put secrets in the MCP args — load them from the environment.
  • Over-privileged database credentials. The agent ran an exploratory UPDATE because the role you gave the MCP server could write. The read-only GRANT above is the fix; create a separate, deliberately-invoked write role only when you actually need mutations.
  • Sensitive files reached the index. A .env or key file got embedded because it was not ignored. Add it to .cursorignore and .gitignore, then rotate any credential that was indexed — an embedded secret is a leaked secret.
  • The privacy scanner has too many false positives. Tune the patterns. UUID strings that look like API keys, test email addresses in code comments, and localhost IP addresses should be allowlisted. A scanner with too many false positives gets disabled, which is worse than no scanner.
  • Legal wants to ban AI tools entirely because of privacy risk. Bring data: most enterprise plans have stronger privacy guarantees than several SaaS tools already in use. Prepare a comparison of AI tool data handling against Slack, Google Docs, and the rest of the stack that routinely holds company data.
  • “We cannot use AI tools for our healthcare or financial application.” You can — with appropriate controls. HIPAA-compliant and PCI DSS-compliant usage is possible with data isolation, anonymization workflows, and vendor agreements. The key is that no protected data ever reaches the provider.