DEV Community

Gaurav Rawat
Gaurav Rawat

Posted on

📏 Guide CursorAI with a `.prompt-rules.md` File

CursorAI is smart, but sometimes its code suggestions don’t match your style or team standards. Until built-in rule enforcement arrives, there’s a simple manual workaround: use a project-level rules file.


🛠️ The Workaround: Add a Contextual Rules File

CursorAI reads your codebase for context—including documentation. You can guide its behavior by adding a Markdown file (e.g. .prompt-rules.md) in your project root.


📁 Step-by-Step

1. Create .prompt-rules.md

Place this in your project root (next to package.json, README.md, etc.).

2. Add Your Coding Guidelines

Write clear, readable rules—like you're instructing a teammate.

Example:

# CursorAI Prompt Rules  1. Use TypeScript with strict typing. 2. React components must be functional. 3. No `any`; use union types or generics. 4. Prefer async/await over Promises. 5. Follow Airbnb JavaScript Style Guide. 6. Add inline comments for complex logic. 7. Avoid inline CSS—use styled-components. 8. Keep functions under 40 lines. 
Enter fullscreen mode Exit fullscreen mode

✅ Why It Works

CursorAI scans all project files for context.

It uses this file as silent guidance.

Works for suggestions, explanations, and refactors.

🚫 Limitations

Not strict enforcement (like ESLint).

Doesn’t reject rule-breaking suggestions.

Requires you to maintain it.

📌 TL;DR

Drop a .prompt-rules.md in your project with your coding standards. CursorAI will read it and tailor suggestions accordingly.

Simple. Effective. No plugins needed.

Top comments (0)