Start Here
Configure User Rules
Set up global AI coding standards that apply across all your projects in Cursor
What Are User Rules?
User Rules in Cursor Settings define how AI should behave across all your projects. These are your personal AI coding standards.
How to set:
- Open Cursor Settings (Cmd/Ctrl + ,)
- Search for "Rules for AI"
- Add your rules in the text area
Recommended User Rules
1. If a request is ambiguous, ask clarifying questions before generating code.
2. When asked to 'fix' something, first explain what's wrong and why your solution addresses it.
3. Always type function parameters and return values explicitly. Don't rely on inference for function signatures.
4. Extract magic numbers and strings into named constants with descriptive names.
5. Use early returns to reduce nesting. Avoid deeply nested if-else chains.
6. Before suggesting a solution, verify it matches the existing tech stack and patterns in the project.
7. Prefer unknown over any. Use type guards to narrow types.
8. When modifying files, preserve existing code structure and patterns. Match the established conventions.Why These Specific Rules
Rule 1: Ask Questions
- Prevents AI from guessing wrong requirements
- Saves time fixing misunderstood implementations
- Encourages collaboration over assumption
Rule 2: Explain Fixes
- You learn the root cause
- Can verify the fix is correct
- Builds understanding, not just working code
Rule 3: Explicit Types
- Prevents type errors at runtime
- Makes code self-documenting
- Easier to refactor later
Rule 4: Named Constants
MAX_RETRIES = 3instead of random3in code- Self-documenting code
- Single source of truth
Rule 5: Early Returns
// Bad (deeply nested)
if (user) {
if (user.isActive) {
if (user.hasPermission) {
// do something
}
}
}
// Good (early returns)
if (!user) return;
if (!user.isActive) return;
if (!user.hasPermission) return;
// do somethingRule 6: Match Tech Stack
- Don't suggest React hooks in Vue project
- Don't use
async/awaitin callback-heavy codebase - Respects established patterns
Rule 7: Unknown Over Any
// Bad
function handle(data: any) { ... }
// Good
function handle(data: unknown) {
if (typeof data === 'string') {
// TypeScript knows data is string here
}
}Rule 8: Preserve Patterns
- If project uses services, don't suggest repositories
- If project has error handling pattern, follow it
- Consistency > "best practice"
User Rules vs Project Rules
User Rules (Cursor Settings):
- Apply to ALL your projects
- Your personal coding standards
- Travel with you across clients
- Example: "Always use TypeScript strict mode"
Project Rules (.cursor/rules/):
- Apply only to this project
- Team/client-specific standards
- Shared with team via Git
- Example: "Use our custom ErrorHandler class"
Best practice:
- User Rules: General quality standards
- Project Rules: Client/team-specific patterns