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’ll write.
You’re three lines into asking the agent to “debug why the prod database keeps timing out,” and you’ve already pasted the full DATABASE_URL — host, user, and password — into the chat. Or you find a community MCP server that promises one-click Postgres access, and you’re about to point it at your production database with your admin credentials. Both moves feel harmless in the moment. Both can leak the keys to your business.
AI assistants are safe on proprietary code if you configure them deliberately: turn on the right data-retention setting for your tool, never let a secret reach the model, and give every MCP server the least privilege it needs.
GRANT“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 can’t turn it off. Indexing still computes embeddings, but under Privacy Mode plaintext code isn’t retained server-side after the request.
For commercial usage — Team, Enterprise, and API — Anthropic does not train models on your code or prompts by default. Free/Pro/Max accounts may be used for training only if you opt in. Default retention is 30 days; zero data retention is available with appropriately configured API keys (transcripts aren’t retained server-side). If you’re on a personal plan for work, check the data-usage setting and prefer commercial terms for proprietary code.
Codex inherits ChatGPT Enterprise guarantees: no training on enterprise data, and zero data retention for the CLI and IDE, with residency/retention following your ChatGPT Enterprise policies. On personal ChatGPT plans, review your data controls (chat history / “improve the model” settings) before using Codex on a private repo.
The rule is unchanged from ordinary security hygiene, but the surface is wider: API keys, tokens, passwords, and DB 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 secret scanning into a pre-commit hook (e.g. gitleaks) so a leaked credential is caught before it’s ever committed or pasted.
Make the agent itself part of the check:
Treat every block the AI 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. Don’t just skim the diff — make a second pass with the model wearing a security hat, then verify the findings yourself.
This is the human-in-the-loop discipline that separates production work from demos — see Human in the Loop for the full review workflow.
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 (e.g. @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 automaticallyALTER 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.
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’ll 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, Codex’s --ask-for-approval) so risky actions require an explicit yes.
args — load them from the environment.UPDATE because the role you gave the MCP server could write. Fix: the read-only GRANT above; create a separate, deliberately-invoked write role only when you actually need mutations..env or key file got embedded because it wasn’t ignored. Fix: add it to .cursorignore (Cursor) and .gitignore; rotate any credential that was indexed.