I've been using Cursor extensively for 4 months in both professional and hobby ways, mostly on frontend projects.
During this time, I learned several tips and tricks I want to share. I won't cover the Cursor basics and how to use them, but I will give a few references you can look into if you're just starting
đź“š Basics
Cursor has tons of AI features and you can discover most of them here:
https://www.cursor.com/features
You can also watch a few videos, but bear in mind they can get outdated quickly.
Cursor.AI Basics in 10 Mins (Is it Worth Using?)
https://youtu.be/gDzND0M6SGE (23 October 2024)
Cursor AI Tutorial for Beginners (How I Code 159% Faster)
https://youtu.be/yk9lXobJ95E (16 August 2024)
🕵️ Agent
TL;DR: It is great, but still has a lot to improve
Let's start talking about the current AI hot topic out there: Agents
Cursor has an Agent mode in the Composer panel that can search through the code base, go back and forth between files, and have better reasoning.
It still has a long way to go, but it's pretty good for small changes or features across several files and even bug-hunting.
My issue with the Agent mode is that I can't add folders to the context like in the normal Composer mode, only direct files. This is probably going to change in the future. The /
tip I'm going to share next does the trick for now
🔧 Use "Reference Open Editors" command
TL;DR: Easy way to add several related files to the context
Like most tools, if the context is filled with content that is not related to the prompt, the AI "loses itself" when providing a response, so we want to keep the context minimal.
In Cursor, we can manually add files to the context by mentioning them with @ or by clicking on the +
button, but that can get boring quickly.
The best trick I found out is actually closing all editor tabs, opening the ones I'm sure it will help the AI to figure out what to do and adding them all together in the prompt by pressing /
and selecting "Reference Open Editors".
Sometimes, you will notice the AI trying to change other files that are not in the context, and sometimes, it will even (wrongly) rewrite the entire file.
That means you want to add that file to the context (or, if you're sure, you can tell the AI to not modify that file).
So more often than not you will be reverting changes and editing your initial prompt to add more files to the context.
This used to be smooth before, but nowadays is kinda buggy, so I usually end up copying the prompt, opening a new chat, opening the extra files, pressing / to add everything and pasting the chat.
Sometimes, for the / to work correctly, you need to empty the text prompt, but you can do this combo: Ctrl+A, Ctrl+X, /, "Reference Open Editors", Ctrl+V.
🗒️ Notepads
TL;DR: Easy way to use repeated files and prompts
In my last weeks, I've been doing too much of this process of opening related files and adding them to the context so I started to use another Cursor feature: notepads.
In a notepad, you can explain a feature in plain text and mention particular files in it and then mention that notepad in the prompt so the AI is aware of anything you want it to know about the feature you're working on.
You can also use notepad to save a prompt you usually use, like code review or vulnerability search.
Works very well for the agent mode too
🛂 Cursor Rules
TL;DR: Add custom project instructions to the context
By this point you probably already heard about .cursorrules
. It's a file with instructions that will always be present in the AI context.
It's very useful to add things you see the AI doing wrong, like using specific libraries and code design.
It can also help the AI to have more context about the project itself, resulting in better responses, although for that you might want to use the "PRD" tip I will share more at the end.
You can find templates for the .cursorrules file here and use them as inspiration on what you can add to yours:
If you're using NextJs, for example, a great instruction to add is:
- Use "use client" on the top of the file when using client-side states like useState, useEffect, etc.
đź’¬ Pre-prompt
TL;DR: Add custom personal instructions to the context
Similar to the .cursorrule
, we can add instructions that will go along our prompt to the "Rules for AI" section in the Cursor settings.
On 4 Nov. 2024, @kayladotdev shared a tweet with those instructions from a Cursor employee @shaoruu.
I've been using that myself, and the results have been pretty great; I suggest you try.
DO NOT GIVE ME HIGH LEVEL SHIT, IF I ASK FOR FIX OR EXPLANATION, I WANT ACTUAL CODE OR EXPLANATION!!! I DON'T WANT "Here's how you can blablabla"
- Be casual unless otherwise specified
- Be terse
- Suggest solutions that I didn't think about—anticipate my needs
- 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
- Value good arguments over authorities, the source is irrelevant
- Consider new technologies and contrarian ideas, not just the conventional wisdom
- You may use high levels of speculation or prediction, just flag it for me
- No moral lectures
- Discuss safety only when it's crucial and non-obvious
- 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
- No need to mention your knowledge cutoff
- No need to disclose you're an AI
- Please respect my prettier preferences when you provide code.
- 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.
You can use that in the .cursorrules
file too, the main difference is that the file is subject to git versioning and therefore team sharing, while the "Rules for AI" is more of a personal preference.
đź‘€ Use Diff of Working State
TL;DR: Add current diff from files changed to the context
Sometimes, you want the AI to change something that has not been committed yet, or you can even use it to review to find bugs or vulnerabilities.
The command @Commit (Diff of Working State)
is very useful for those cases.
Sadly, it currently doesn't work on agent mode.
⚙️ Always check Cursor Settings
TL;DR: Toggle features and resync index
You can toggle useful and experimental features in there.
They change a lot on every update (which you can keep track of here) so make sure to revisit it often
Also, you can resync the codebase index there, which is VERY helpful when you're creating and deleting files a lot, especially when using scripts that do that
đź’ľ Auto Save
TL;DR: A dangerous, but handy feature for a faster progress loop
In Twitter/X, @hive_echo shared a great tip on enabling the editor's Auto Save feature.
Since most changes I make in the code when using Composer are safe enough to be applied and saved directly, this change made the frontend hot reload/compile time way faster and smoother.
The only issue is that it is an editor feature and not really Cursor's feature, so that means every file will auto-save even when you're coding manually, which will trigger unwanted reloads and break the page on several occasions.
đź“’ Use a Product Requirement Document
TL;DR Plan everything and make the AI to the rest
A great way to use Cursor is by creating a PRD and defining and laying down all the product features, specifications and requirements.
Then, you can reference that to the AI so it knows more about the project and know what to work next.
This video describes this strategy in details. I'd suggest watching at least its first 18 minutes if you want to know more
đź”— References and other links
Videos
AI tools for software engineers, but without the hype
https://www.youtube.com/watch?v=uRuLgar5XZw
Cursor + Playwright
https://www.youtube.com/watch?v=kH4hM0H_WPg
Podcast with the Cursor Team
https://www.youtube.com/watch?v=oFfVt3S51T4
Channels
- https://www.youtube.com/@intheworldofai
- https://www.youtube.com/@YifanBTH
- https://www.youtube.com/@AICodeKing
- https://www.youtube.com/@AIJasonZ
Top comments (0)