Cursor ? How to leverage this small little shIDE
During the past few months, I have been trying to apply AI and LLMs into my day-to-day SWE life, but somehow something feel off, I still need to paste code into the browser, Copilot, ... in order to get the responses. That changed until I found out about Cursor.
Here's my really short 2 cents about the IDE:
It's bascially traditional IDE have a baby with LLMs and pop up a deus ex-machina-type of IDE. Though that's on paper things look really shiny and stuff, but there are some drawbacks, frustrations, tips & trick that I will post in here during my 2 months experiencing this IDE.
Cons:
Welp that's for all the cons that I can think of, at least what I have experienced so far. Then with that in mind, how do we move forward? Rather introducing the cons part, I will just dump here what I did to improve my developing experience instead.
Costs
AI tools notoriously famous for subscriptions plans, and now you have a bazzilions of tool that you need to pay in order to get your hands on these nice features
But as a SWE and some CTF (WebSec) knowledge and some testing here are some tricks
-> You add your free API Key of Google's AI Studio Tier 1 into your cursor which give you access for: 2.5o pro & flash. And you can basically vibe codings for days without the worry of that 500 requests / months.
Dump response & lost of context
You can actually fix this by doing 2 simple steps:
Beside that, you can adjust the User's Prompt and Project Prompt, in order in every prompt you send to the Agent, the Agent will fully follow that context.
With User Prompt, here are some tips you can apply when trying to forge a prompts or ask GPT to forge a prompt: defines what is your code styles, princples you're using, conventions, what is your approachs to coding (for me it's first understand the context & the codebase regarding the problems, design a bit, then implement), some tiny details that tailor to you.
Then ask GPT / create the User Prompt yourself, here is the GPT-created version:
Project's Prompt, it's dedicated to your project. Assume that you're using microservices, meaning that each repo has its own querks & details, you can add it there also. Cool thing is that you can add this to your Git repo as well, so that other team members can test & refine, and finally you have yourself a really nice Project's promp that working for that Project only.
Here's my frontend app Project's Prompt:
With that it is increase the odds that the Agent will pick up the context way faster & don't lose focus. But you still need a detailed prompt whenever you ask the Agent something.
In Project's prompt, you can also add limitations, commands you don't want the AI to run like running yarn instead of npm, aliases, no rm -rf, ...
Focused prompts & context.
In developing features, if you project is well designed where all the components follow SRP to the core, meaning that you only need the context of a selective files to actually develop the features, in order to do it in Cursor use the @ annotation within the chat prompt:
And before you actually do coding, add the related files to the chat windows, so that the Agent is more focused, ultimately more precise responses. The general conventions & other stuff you can defined in User's & Project Prompt, don't use it here.
In order to do that, you have to break down your task accordingly, and load these files in, example in the Login feature for examples:
Here're the breaked down requirements:
Then the order you should, or i least i would do is:
More steps? Indeed, but this way you broke it down to tiny steps, so that at each steps if you want to add more juices to it (eg: UI improvments, animations, ...) you can seperate the concerns and most of my case, the Agent doesn't get confuse. And write precisely what I need.
No native programming language features
This is indeed a thing that I have not figure out yet, beside ask the AI to write you some sh scripts, or a Makefile so that you can automate this within Cursor, to be honest I don't have an solution for this yet. Since for Java Application, Intellij is so powerful in that matter. And I'm not a fan of adding extension so if i find something nice, I will share it here.
Reminders.
Here are some reminders regarding the AI Agent and all this new shiny stuff. Use it to enhance yourself, not dumbfoundedly ask the AI to do everything without understanding anything.
Imho, the AI is here to support you & speed up the learning rates / speed regarding SWE, especially in some of the topics where documentations are not clear / wonky and offloading a lot of reduntdant & tedious tasks.
Compliances & data security, make sure you don't accidentally put an .env in the Agent, or any files that contains sensitive information, you won't know whether those black hat hackers can ultilize it or not, and follow yours company compliances regarding this topic. I think most of the company already picked up on this topic.
Finally, use AI responsibly, with a good mindset in mind and a shit ton of tools you can basically do anything. Disclaimer! Don't use AI over 180 minutes / day it will dumb down your brain.
Finally here is my recommendations model you can use:
OSCP | Dvuln | President Deakin Information Security Club | Sydney, Australia
2moHahahaha you just have to spread the vibe code spirit don’t you 😂