BuiltSafely

Cursor: rules, ignore files and safe agent settings

Last reviewed October 2026 · Sources: Cursor docs: Rules, Ignore files, Agent terminal, Cursor security

Coding agents move fast and do what you ask. These settings make them safer by default.

1. Add a security rule the agent always follows

Cursor supports project rules (in .cursor/rules/) that are added to the agent's context. Add one for security:

---
description: Security defaults for this project
alwaysApply: true
---
- Never put API keys, tokens or passwords in source code or client-side files. Use environment variables loaded on the server.
- Every API route and server action must check the user is authenticated AND authorized for the specific record.
- Validate all user input on the server (types, length, allowed values).
- Use parameterized queries or the ORM; never build SQL with string concatenation.
- Don't disable security checks, RLS, or CORS restrictions to "make it work". Ask me first.
- When adding a dependency, prefer well-known packages and tell me the exact name.

2. Keep secrets out of the agent's reach

3. Decide what the agent may run without asking

Cursor's agent can run terminal commands. Review the auto-run settings in Cursor's agent/terminal docs: keep approval on for commands that delete files, deploy, push, or touch production databases, and use allow/deny lists where available.

4. Check privacy settings for your situation

Review Cursor's privacy mode and data-handling settings (see Cursor security) if you work with client code or sensitive data.

5. Review before you ship

Act as a security reviewer. List every route, server action and database query in this
repo. For each: who can call it, what it reads/writes, and whether input is validated
and the caller is authorized. Flag anything that exposes secrets to the browser.

Then fix and re-check. The agent can miss things, so verify the critical paths yourself.