Cursor AI Tips
as of Dec 15 2024
Things it’s really good at:
- Setting up APIs (whether to leverage an LLM or to curate data).
- Setting up backend integration with 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.
General tips:
- Version control your code (use Github). This way you can revert to a previous version when needed.
- Always check what it is performing (so you can quickly catch blatant/flagrant issues).
- Using your own LLM API keys (so you don’t max out the limit) and have to pay for additional tokens/requests. Up to you to figure out the financial trade-offs.
- It’s better to understand the libraries that Cursor is implicitly making for you (i.e. which UI components/frameworks/libraries/services).
- A lot of the error handling isn’t caught immediately. You might want to specify in prompts (to avoid trial and error with catching issues).
- Build your own set of CursorRules to improve the responses by the llm (see the .CursorRules file for more details).
- To reduce the amount of ways you iterate, it’s good to brainstorm your prompt and decompose the ask into multiple steps. Even better if you know how you want your code factored, so you can include that as well.
- If you want to learn as much as you can (if you don’t have an existing background in ). This will not only help you debug issues faster, but it will help you become a better developer.
- Sometimes Cursor is wrong—i.e. it will give you an outdated command. If you repeatedly run into an error, double check that the command is correct according to documentation online.
Leveraging LLMS (in parallel with Cursor):
- Sometimes it’s helpful to have Gemini or ChatGPT write a Cursor prompt for you (especially with respect to UI changes). Hard to describe aesthetic and overall theme so it’s easier to have some ad-hoc description, and put that into an LLM. Then, use the
- Making the PRD or any step-by-step decomposition of a complex task into an LLM can be helpful.
Some issues or limitations of Cursor:
- If you don’t specify you’d like modular code, it doesn’t write modular/factored code.
- Very difficult to undo a group of code changes.
- Overwrites code that was correct.
- Not good at integration with existing code (better when you start from a clean package).
- Sometimes it will write entirely new code that is distinct from your existing package, unless you make it clear exactly which file and package to integrate the new code with.
- itʼs best to work in one workspace so if you ask to create an app, it uses your pre-existing files and file structures. Cursor kept on messing up here.
- Not always the most performant/efficient code.
- Can introduce security issues (i.e. dependencies on packages with vulnerabilities, etc.).
- It does not initially make code super modular and/or readable. You want to make sure this is built into your CursorRules.
.CursorRules examples:
- Encourage modularity: “Always break complex functions into smaller, testable functions and ensure code is DRY.”
- Security guidance: “Use parameterized queries and sanitize all inputs when working with databases.”
- Performance criteria: “Avoid nested loops if possible; consider using built-in array methods or more efficient algorithms.”
- Code style standards: “Follow established naming conventions, and ensure functions do one thing well.”
- Testing requirements: “Include basic unit tests for new functions or logic blocks.”
When to use agent vs. composer vs. chat?
Cursor Agents:
https://www.youtube.com/watch?v=ctn3mvDo22E&ab_channel=Volo
autonomy and having AI
- find relevant files
- make changes to multiple files
- run commands in the terminal
Re-download and install Cursor to use Agents
- need to press the agent button.
- can use setting to make agent button sticky.
Biggest difference:
- composer vs. chat. compose makes all edits to file directly and deletes a lot of code.
Agent losses:
- Figure out the right scope that the agent could work on…
- Need to tag the right files for relevance.
- Agent flows take a while to run.
- Don’t keep going even when they should; getting work partially done (centralize a function example).
- Can execute terminal code; but doesn’t do this in the correct directories.
Agent wins:
- Iterate off lint setting; cursor agent will write code but then check that it’s correct based on lint and can fix those issues (imports and types); can only do one pass (recursively fix eventually).
- immediately applies code changes.
- Composer overriding a bunch of your code.
Axes to score Cursor agents on:
- autonomy
- reliability
- ease-of-use
Access Denied
You don't have permission to view this content.
Please sign in to access this content.