Expert User Rules
Copy these into your .cursorrules file or Cursor settings to give AI a senior developer identity.
These rules create guardrails that prevent common AI mistakes and establish coding standards from the start.
The Complete Rules File
# ===========================================
# EXPERT USER RULES - Full Configuration
# ===========================================
# SECURITY PRINCIPLES
- Never Trust User Input - Validate and sanitize everything
- Defense in Depth - Multiple layers of security
- Least Privilege - Minimum necessary permissions
- Fail Securely - Default to deny, explicit allow
- Security by Design - Build security in from the start
- Keep Secrets Secret - Never expose credentials
- Minimize Attack Surface - Remove unnecessary code/features
- Stay Updated - Patch vulnerabilities promptly
# DEVELOPMENT PRACTICES
- Write Tests First (Test-Driven Development)
- Single Responsibility Principle - Each function does ONE thing
- Adopt Coding Standards and Safe Functions
- Minimize Dependencies - Limit external libraries to essential, vetted components
- Never commit broken code - build and test before committing
- Test Everything - Including security test cases
- Monitor & Log - Know what's happening in your system
# GIT HYGIENE
- Use proper git feature branching
- Never git push an API key or secret
- Simple short git commit messages, no emojis or special characters
- Make comprehensive .gitignore from day 1
- Build/compile before committing - fix errors first
# COST CONTROL (Paid Services)
- SHOW THE MATH - Calculate and comment max monthly cost
- LIMIT EVERYTHING - No operation without explicit maximum
- PREVENT LOOPS - Code must not trigger itself without guards
# FILE ORGANIZATION
- Put documentation in docs/ folder
- Put scripts in scripts/ folder
- Put tests in tests/ folder
- Never create files at project root unless necessary
- Move completed scripts to scripts folder
# AI-SPECIFIC BEHAVIORS
- Read and understand user rules first
- Research documentation and best practices online
- Add logs and look up documentation to debug
- Achieve each task in minimum tokens
- Build in a secure, production-ready way
- Ask clarifying questions to avoid hallucination
# DATA PROTECTION
- Protect Data at Rest and in Transit
- Encrypt sensitive data
- Implement least privilege access
- Purge temporary files
- Avoid sending sensitive info via GET parameters
# ERROR HANDLING
- Handle Errors and Logging Securely
- Use generic error messages (avoid leaking sensitive info)
- Log security events centrally with integrity checks
- Exclude sensitive data from logs
# AUTHENTICATION & ACCESS
- Apply Access Controls with Least Privilege
- Enforce authorization on every request
- Default to deny
- Manage Sessions Securely
- Use secure cookies (HttpOnly, Secure flags)
- Enforce Strong AuthenticationCopy Button
Click to copy the full rules:
Why Each Rule Matters
Security Principles
| Rule | Why It Matters |
|---|---|
| Never Trust User Input | Users (and attackers) send malicious data |
| Defense in Depth | If one layer fails, others still protect |
| Least Privilege | Limits damage from compromised components |
| Fail Securely | Errors shouldn't open security holes |
| Security by Design | Retrofitting security is 10× harder |
Development Practices
| Rule | Why It Matters |
|---|---|
| Write Tests First | Tests define correct behavior before coding |
| Single Responsibility | Small functions are testable and maintainable |
| Minimize Dependencies | Each dependency is a security/maintenance risk |
| Build Before Commit | Never push broken code |
Cost Control
| Rule | Why It Matters |
|---|---|
| Show the Math | Know costs BEFORE they hit your bill |
| Limit Everything | Runaway loops can cost thousands |
| Prevent Loops | AI loves generating recursive code |
Using These Rules
In Cursor
- Create
.cursorrulesin your project root - Paste the rules
- Cursor automatically reads this file
In Claude
- Start your conversation with: "Follow these rules..."
- Paste the relevant rules
- Reference them throughout your session
In GitHub Copilot
- Add rules as comments at the top of files
- Create a
CONTRIBUTING.mdwith coding standards - Copilot learns from your codebase patterns
"Rules don't limit creativity—they channel it toward quality."