Prompting Patterns That Actually Work – Cursor Edition

Soham ParateSoham Parate
7 min read

Ever stare at your AI coding assistant, wondering if you're truly making the most out of it? I certainly did with Cursor. My workflow felt smooth until mid-last month, when Cursor decided to charge 2x (instead of the usual 0.75x) for the Claude 4 thinking model and I quickly hit my limited 500 requests pool.

That's when two crucial realizations hit me:

  1. I don't need to use the thinking model for every request.

  2. Mindless prompting has to stop.

This pivotal moment forced me to rethink my approach and dive deep into effective prompting patterns. Today, I'm sharing the strategies that improved my workflow with Cursor, resulting in code that more precisely reflects my intent, is faster to develop, and uses resources more efficiently.

Note: My experiences and the effectiveness of these patterns are based on testing with Claude 4 Sonnet and its thinking model within Cursor.

1. Tree of Thought

Often, when faced with a coding problem, there isn't just one "right" way to solve it. Different approaches have different trade-offs in terms of performance, maintainability, complexity, or dependencies. Instead of asking Cursor for the solution and hoping it aligns with my unstated priorities, I now ask it to propose multiple viable approaches and analyze their pros and cons.

How it Works

Let's take an example: I need to implement a feature to send reminder emails to interviewers if they haven't filled in feedback for an interview taken more than 12 hours ago.

Rather than a simple request, the following prompt yields significantly better results by guiding Cursor through an analysis phase before it provides a solution:

💡
I need a feature to send reminder emails to interviewers for unsubmitted feedback after 12 hours. Propose 3 architectural approaches for this. Analyse it’s pros and cons (consider scheduling reliability, scalability, email templating, and failure handling) and choose an approach accordingly.

Alternatively, you can split this prompt into two parts. First, ask it to list the pros and cons of an approach. Then, in a second prompt, manually choose an approach.

This pattern empowers Cursor to act as a strategic advisor, presenting you with well-reasoned options and their trade-offs before diving into implementation. This shifts your interaction from simply requesting code to collaboratively designing the best solution for your specific needs, leading to more robust and thoughtful outcomes.

2. Red Teaming Prompting

I realized that directly asking an AI if something is "flawed" can sometimes lead to it taking the path of least resistance – essentially, confirming your confidence. It's like asking a child, "Did you break that vase?" when you know they did; they might just say no.

Instead, I've shifted to a more assertive and effective pattern: I assume the flaw exists and challenge Cursor to find it. This nudges the AI into a more critical, analytical mode, forcing it to actively search for problems rather than just passively validating your work.

How it Works

Let's look at a common scenario: I've written a Python function, and while it seems to work, I have a nagging feeling there might be an edge case or an inefficiency I missed.

Your old approach might have been to ask a vague, open-ended question like:

💡
Here's my Python function. Is there anything wrong with it or any potential issues?

This often leads to a generic "Your function appears syntactically correct" or "No obvious errors found at first glance." Such responses don't truly alleviate your concerns and often mean you'll discover the actual problem later.

Now, instead of asking if there's a flaw, you tell Cursor that one does exist, challenging it to uncover it. This immediately shifts Cursor's processing from "validate" to "investigate."

Your improved prompt would look like this:

💡
This Python function has a flaw related to [performance/edge cases/security/readability - pick one or be vague if unsure]. Find the flaw(s) and suggest improvements.

By framing the prompt this way, Cursor's response is significantly more analytical and helpful. It will actively search for specific problems, identify hidden edge cases, and suggest concrete improvements, sometimes even offering a refactored version of the code that addresses the identified flaw, along with an explanation of the changes.

3. The “Persona” Prompt

Instead of just asking Cursor to "write code," I tell it to "act as" a specific role.

It's like walking into a meeting and knowing exactly who you're talking to – you tailor your language and expectations accordingly. With Cursor, you define who it is, and it tailors its response.

How it Works

The core of this pattern is simple: preface your request with an instruction for Cursor to "act as," "assume the role of," or "you are" a particular expert.

When I just asked for a general refactor, the results were often basic, focusing on superficial changes or generic best practices:

💡
Refactor this Python code for better readability and performance.

When I give Cursor a specific persona, immediately setting the stage for the depth and type of analysis I expect:

💡
Act as a senior Python architect specializing in high-performance, maintainable systems. Review the following code and propose refactoring changes that improve its scalability, reduce technical debt, and ensure adherence to modern best practices. Focus on long-term impact.

By assigning a persona, Cursor's response is dramatically more insightful and aligned with expert-level thinking. For a "Senior Python Architect," it might suggest using design patterns, optimizing database queries, or proposing abstracting components.

4. The "Planner-Executor" Model

Instead of asking Cursor to do everything at once, you first ask it to act as a "Planner," generating a detailed, step-by-step plan. Then, you act as the "Executor," feeding those plan steps back to Cursor one by one, asking it to implement each part.

Tip: The executor part might not require the thinking model.

When I tried to tackle complex projects with a single prompt, the results were often incomplete, lacked integration, or missed crucial aspects:

💡
Create a simple Django API. It needs user registration and login (with password hashing), and CRUD operations for a 'Product' resource. Use PostgreSQL for the database.

Here's how I now tackle such complex tasks, breaking them down into a planning phase and an execution phase:

Phase 1: The "Planner" Prompt

💡
"I need to build a simple Django API with user authentication (registration, login with password hashing) and CRUD operations for a 'Product' resource. Use PostgreSQL for the database. Act as a senior backend architect. Outline a comprehensive, step-by-step development plan for this API. Break down each major step (e.g., Database Setup, Authentication Flow, Product CRUD) into smaller, actionable sub-steps. Include considerations for security (like password hashing) and basic error handling."

(Cursor would then provide a structured, numbered plan, perhaps like this: 1. Project Setup, 2. Database Setup, 3. Authentication Module, 4. Product Module, 5. Error Handling & Validation, 6. Testing. Each with further sub-steps and considerations.)

Phase 2: The "Executor" Prompts

Once I have the plan, I feed it back to Cursor step-by-step. For each step, I might give a new prompt, asking for the code or detailed instructions.

💡
Okay, let's start with 'Step 2: Database Setup' from our plan. Provide the code for setting up the database, defining the User model (with fields for username, email, hashed_password) and the Product model (with fields like name, description, price, and a foreign key to user). Include basic database initialization.

Pro-Tip: Don't Assume, Ask!

Add If you are unsure about anything, ask clarifying questions instead of assuming.

This ensures you get exactly what you need and prevents misunderstandings.

Conclusion

Mastering an AI coding assistant like Cursor isn't just about knowing what to ask, but how to ask it. As my journey with Cursor evolved, I realized that moving beyond "mindless prompting" and embracing strategic patterns like Tree of Thought, Assume the Flaw, Persona, and Planner-Executor has significantly elevated my productivity and the quality of code I produce.

References

https://www.promptingguide.ai/techniques/tot

https://learnprompting.org/docs/advanced/zero_shot/role_prompting

https://blog.langchain.com/planning-agents/

1
Subscribe to my newsletter

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

Written by

Soham Parate
Soham Parate