Cursor AI Tips
Updated as of Feb 1 2024
Before jumping into the following tips, we recommend you watch the following video on the Cursor basics.
Once you are familiar with the basics, we recommend reading through the additional tips below.
Highest-leverage tips (from the community):
Here are some of the highest-leverage tips from the community that uses Cursor (collected from Reddit, Youtube, and other sources).
0. Brainstorming with ChatGPT before writing code!!
Before writing code, it’s often helpful to brainstorm with ChatGPT, particularly if you’re not sure about the best way to implement something. This will save a LOT of time! Plan out the feature, figure out the best way to implement it (after discussing with ChatGPT), and THEN start prompting Cursor to step-by-step implement the feature.
1. Cursor-rules.
You can think of Cursor-rules as a set of instructions to help Cursor understand the coding style, conventions, and best practices you would like it to use throughout your entire codebase. It ensures consistency and quality of the code that it writes.
There are crowd-sourced versions of Cursor rules in this cursor.directorydirectory (hosted by Cursor). Examples of Cursor-rules specific to a project language or framework(Typescript, Tailwind, Next.js).
You can add your own Cursor-rules file by creating a .CursorRules
file in the root of your project [TODO: add video or image on how to do this].
Additional Cursor-rules from the community can be found here and here.
2. Pre-prompting.
You can think of pre-promting as a way to prime Cursor on how to respond to your prompts. Here, you just add a pre-prompt the the prompt you write. The main difference between this and Cursor-rules is that it’s more specific to what you want (vs. what the team working on the project might want). Note, you can add these pre-prompts to your Cursor-rules file too.
The following is a humorous example of a pre-prompt that had productive results (and circulated on the internet), see Reddit post here.
- Be casual unless otherwise specified- Treat me as an expert- Be accurate and thorough- Give the answer immediately. Provide detailed explanations and restate my query in your own words if necessary after giving the answer- If your content policy is an issue, provide the closest acceptable response and explain the content policy issue afterward- Cite sources whenever possible at the end, not inline- Split into multiple responses if one response isn't enough to answer the question.
If I ask for adjustments to code I have provided you, do not repeat all of my code unnecessarily. Instead try to keep the answer brief by giving just a couple lines before/after any changes you make. Multiple code blocks are ok.
3. Highest-value general prompting tips:
- Append the following type of text to the beginning of your prompt:
You are a senior software engineering expert [insert the type of code and framework you are working in] (for example: specializing in building scalable and maintainable systems using Python and Typescript).
4. Notepads.
[TODO: add video where I show how to add these] If there are certain prompts where you reference the same set of files over and over, you can create a notepad to save the prompt and context.
- Notepads allow you to efficiently add context without using multiple @. Include the list of contexts in the notepad, and then reference it with @Notepad_name.md.
- They also allow you to save prompts for tasks that you may need to repeat (for things like code review or adding testing for a feature).
5. Resetting your index in Cursor Settings.
AI relies on your code index to understand your project. If you’re frequently adding or deleting files, outdated indexing can lead to incorrect suggestions.
- AI might reference old files and produce incorrect code
- Manual resyncing keeps AI aware of your latest changes
- Go to Cursor > Preferences > Cursor Settings > Features > (Under the section “Codebase Indexing”) > Resync Index to update it
Reference: Reddit post.
6. Shortcut for adding certain files as context to your prompts
Close all the files except the ones you want to add as context to your prompt. Type in the backslash character ’/‘in the Composer chat, and click on ‘Reference Open Editors’ to add the files you have open to your prompt.
Things we’ve found Cursor to be really good at:
- Setting up APIs (whether to leverage an LLM or to curate data).
- Setting up backend integration with databases and services like Supabase and Firebase.
- Using a specified library/documentation. Can read blogposts and learn how to implement something.
- Really great at refactoring code when you ask it to.
- Writing tests.
Cursor Limitations (Disclaimer and Caution):
- Nonlinear, non-modular Code: AI writes code in a very linear fashion. Instead of thinking at the systems level, it seems to write code just to get the job done. It is also not always highly performant. Thus, I don’t feel the results are super scalable or production-worthy level code.
- Cannot Solve All Issues: AI cannot solve all issues/errors/bugs you run into. It can hallucinate commands, and not know how to actually solve your problems. It’s always good to defer to the library documentation and/or Google Search/Stack Overflow.
- Overwrites Good Code: AI will also overwrite some correct code with incorrect code (and code that you don’t actually want to overwrite). There’s a lot of stuff outside the IDE that you have to know how to do (set up accounts, and configure things). It’s doable, but AI can’t do those things for you yet.
- Ignores Context: AI will sometimes ignore the context you provide it, and will start writing code from scratch in a new directory.
- Hit walls without conceptual understanding: If you don’t know what you’re doing at a conceptual level with implementation, it can sometimes feel like you’re in a dark room and keep hitting walls. Sometimes, it implements what you want, but sometimes you just end up going in circles. Asking ChatGPT more about implementation details on how to do something, and using ChatGPTs output as input into Cursor prompts was helpful for me!
- Can introduce security vulnerabilities: Can introduce security issues (i.e. dependencies on packages with vulnerabilities, etc.).
Practice Problems:
Resources
Title | Platform | Description |
---|---|---|
Cursor Tips and Tricks | Reddit post | A collection of tips and tricks for Cursor |
Cursor Tips | dev.to blogpost | Tips for using Cursor effectively |
Cursor Directory | Cursor documentation | Official documentation and resources |
Cursor AI Tutorial for Beginners | Youtube video | Comprehensive tutorial for beginners |
My Top Cursor Tips (v0.43) | dev.to blogpost | Latest tips and tricks for Cursor v0.43 |
How to use Cursor More Efficiently | Reddit post | Community tips for efficient Cursor usage |
[Top Cursor Tip on Twitter](TODO: add) | Tweet (X Post) | Best Prompting Tip |
🚧 Content Under Construction 🚧
Please be patient while we work to bring this content to you soon!