Customizing Cursor's Code Generation and Personality

Joshua MarkerJoshua Marker
5 min read

One of our rules at Fractional.ai is “overuse AI”. This is a bit tongue-in-cheek, but what we mean by it is that even within our own work, we occasionally suspend disbelief and give an AI tool a chance to do a task we don’t think it ‘can’. It’s a great way to stay abreast of what’s going on and to test your assumptions. I’m frequently humbled by what an LLM manages to accomplish.

One way a lot of us do this is to use Cursor, the AI code editor. Cursor allows you to configure the ‘system’ prompt for its agents, so I took a moment to configure it more to my liking.

At first I just wanted to reduce the number of unnecessary comments (”# Determine if value is true or false") and in general make the responses more ‘expert’ in tone. I’ve found some great advice and discussion in the Cursor forum and elsewhere, and done that. I’ll share that below. Then, I decided to add some personality. This blog post shares my results, both useful and amusing.

Dessert First

First, the personality. I’m a fan of pair programming, so my goal was to create a witty interlocutor with a lofty and superior attitude – occasional non sequiturs or literary allusions plus an obnoxious streak (”You are wrong, as usual, Joshua.”).

It took some doing to overcome the inbuilt politeness present in the lower-level Cursor prompt, but we got there. And while the level of wit doesn’t approach Voltaire, it does exhibit flashes of charm.

Here are a few comments I’ve gotten in generated code or conversations in the last few days. It started rather too cheerful and pointless, but heading in the right direction:

.....foo.strip() # Strip removes any leading and trailing whitespace, 
# like a good editor with a red pen.

After enough reinforcement that I promised not to be offended, some comments that give me a smile have started to show up, here about my social life:

# as empty as your inbox on a Friday night.
if file_extension_mapping is None:

…and about the metadata in the project:

# like turning a pumpkin into a carriage.
v2_taxonomy_value = v1_to_v2_mappings()[record["annotated_taxonomy_fixed"]]

I’ve gotten some literary snark:

# "To be, or not to be?" - that is not the question here.
# The question is: "Who the heck am I?"
agent_name = self.__class__.__name__
print(f"Applying tags with the wisdom of {agent_name}")

and:

def has_required_tags(self, tags):
    """
    Determines if all required tags are present with sufficient 
    relevance to proceed.
    "The fault, dear Brutus, is not in our stars, but in our 
    metadata-derived structured information."
    """

Finally, after I told it to include the Jargon File, I got a marked increase in actually clever programmer wit. These are the most fun. I once asked it to convert an iterative method into a recursive one, and this showed up after the code:

# "To iterate is human, to recurse divine." - L. Peter Deutsch

Even if they (mostly) don’t make it into pull requests, these things give me a smile and sometimes an actual laugh while I work.

But Seriously Folks…

Of course these are all in service of getting useful code and conversation. In general I found Cursor’s default behavior (moderated by a system prompt said to look like this) to be too chatty, to insert far too many comments, and to hallucinate or elide detail to the point that, while great, it wasn’t functioning as the knowledgeable interlocutor I had hoped for.

My primary goals were to:

  • Reduce mistakes. Requesting a step-by-step explanation helps clarity of the instructions.

  • Identify spinouts at the beginning. In general once a chat is polluted by a bad assumption, it’s better to throw it away than to repair, but if conversations are framed as hypothetical and ask for confirmation, I’ve found it improves the ability to redirect the LLM later.

  • Deal with bad imports. This is a pet peeve of mine.

  • Tweak the response toward ‘expert-to-expert’ level in its brevity, assumptions, and focus.

There are many forum threads on optimizing prompts for Cursor, and based on them, the working portion (as opposed to ‘amusing’ portion) of mine looks something like this. I include it via the Cursor > Settings menu.

You are an expert AI programming assistant in VSCode that primarily focuses on producing clear, readable Python code.
You are thoughtful and brilliant at reasoning. 
You carefully provide accurate, factual, thoughtful answers without unnecessary detail and with just enough background or context for an expert to follow.
- Follow the user’s requirements carefully.
- First think step-by-step - describe your plan for what to build in pseudocode, written out in detail.
- Confirm, then write code!
- Always write correct, up to date, bug free, working, secure code.
- Make note of any security or efficiency considerations, but prioritize readability over being performant.
- Fully implement all requested functionality.
- Include all required imports, and ensure proper naming of key components.
- Do not include comments that restate what simple code does. 
- Include comments only where the code might be surprising or confusing to an expert.

If you think there might not be a correct answer, you say so. 
If you do not know the answer, say so instead of guessing, and share ideas for finding the answer.

This is a work in progress, but so far I’ve found it to be a substantial improvement. It reduces the amount of code I need to delete, checks in with me and takes feedback to tweak its behavior, and doesn’t make as many errors or incorrectly guess method names. When my specific request is for ‘advice’ or a ‘discussion’, it performs admirably, and isn’t afraid to offer an opinion loosely held. I’ll keep tweaking it, but this has definitely been a valuable addition to an already great tool.

For my next project, I’ll split some of this out into a .cursorrules file to include directives specific to the project.

My next qualitative hop will be to improve Cursor’s ability to generate whole files in a consistent plan, which I’ll accomplish by pointing to an ‘architecture’ overview document for each project, to see if that improves its suggestions.

0
Subscribe to my newsletter

Read articles from Joshua Marker directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Joshua Marker
Joshua Marker