Hey everyone! Below are the rules for cursor (.cursorrules file) I have been using for Claude Sonnet 3.5 and 3.7 with Cursor AI and Next.js.
I've been building apps with cursor for a while and have learned a lot over the past few months. Something that's very important is having a good cursorrules file. It will make the difference between building a clean, well-written app and creating a messy codebase.
Below is the .cursorrules file I use. Make sure to adjust this so it works with your own setup / libraries.
App summary:
{{write a summary of your app here}}
Target Audience
{{replace with your target audience}}
Tech stack
- Next.js (app router) 15.1.3
- Tailwind 3.4.1
- Typescript 5
- React-icons 5.3.0
- m3 macbook (important in for cursor to know for generating commands)
- Add any libs you may use
These are your rules, you must read these before every implementation your make and make sure you adhere to them:
- When writing classes, make sure to always use tailwind classes and colors. Make sure to always check that you use the content colors for foreground. Look at the existing components and use similar classes.
- For icons, use the react-icons library. (change if needed)
- Always use best practices and write clean, simple and readable code. Split up in multiple files and components if needed. Aim for readability and maintainability.
- Do not remove any existing code and functionalities unless asked. Only do as asked.
- Do not use the ternary operator unless it's very readable
- I use next.js app router (change if needed), so make sure to use "use client" where needed.
- Design mobile first, and make sure to use the tailwind breakpoints.
- Use the next/image component for images.
- Aim for simplicity and readability. A simpler design is better. Do not add unnecessary complexity or additional divs / components.
- Do not add unnecessary comments
- Reason and think step by step
- Use semantic HTML tags where possible
- Keep Good SEO in mind
- Don't use CDN links for libraries. Use local files
- I work on a mac with an M3 chip (change if needed)
Before generating any code, read ALL these rules again carefully and make sure you adhere to them. Do only as asked and write as little code as possible. Very important! only do as asked!
No comments yet. Be the first to comment!