ALL POSTS
Software Engineering

He spent 400+ hours in Cursor, here’s what I learned

·

Introduction

This blog post distills over 400 hours of hands-on experience using Cursor, an AI-powered code editor, into a comprehensive guide. Whether you’re a seasoned developer or just getting started, this guide will empower you to leverage Cursor’s full potential, boost your productivity, and build robust applications. In this guide we’ll explore setting up Cursor, advanced prompting techniques, and best practices to streamline your workflow. Expect to spend about 30 minutes reading this to gain a foundational understanding that can save countless hours of coding time.

Who is This Guide For?

This guide is perfect for:

  • Developers of all skill levels who want to master AI-powered coding
  • Professionals looking to increase their coding productivity
  • Tech startup founders seeking efficient development practices
  • Anyone interested in the latest innovations in AI coding tools

Prerequisites

No specific technical background is required, but a basic familiarity with coding concepts will be helpful.

Setting Up Cursor: Laying the Foundation for Success

The Essential .cursorrules File

The cornerstone of effectively using Cursor is the .cursorrules file, which is where you define the rules and context for your project. Here’s how to set it up:

  1. Enable .cursorrules: In Cursor’s settings, ensure the option to “Use .cursorrules file” is enabled.
  2. Create the File: In the root of your project, create a file named .cursorrules.
  3. Set File Type: Click “Plain text” in the bottom-right corner and choose “Markdown.”

.cursorrules File Structure

Your .cursorrules should be structured as follows:

  • Project Overview: Include the project’s vision and goals.
  • AI Personality: Define how you want the AI to interact. E.g., “Teach me like a senior developer.”
  • Tech Stack: Specify front-end, back-end, database, and other technologies used in the project.
  • Processes: List repeatable instructions related to coding. For example, an error-fixing process.
  • Environment Variables: Mention the existence of environment variables, while keeping the actual values in your .env files.
  • File Structure: Copy the output of brew tree command to show the directory structure, also specify files to ignore (via .cursorignore)
  • GitHub Push Process: Detail how you want to push to GitHub (e.g., check current branch, switch to correct branch, push with clear commit message).
  • Core Instructions: Repeat the most important instructions, for emphasis.
  • Comments: Highlight the importance of writing comments.

The Power of Repo Prompt

Repo Prompt, a third-party tool (link in video description), allows you to load your entire codebase into a single prompt. This ensures comprehensive context for AI models, enabling more accurate and reliable responses. This is particularly valuable when using chat or pro mode within cursor.

Choosing the Right AI Models

Essential Models

  • New Anthropic 3.5 Sonnet: This is the essential model you should have enabled and use the majority of the time.
  • Gemini Models: Enable the best models from Gemini for diverse options.
  • GPT 4.0: Keep this model enabled as a backup if other models are acting up.
  • Reasoning Models (01 and 01 mini): Enable for specific reasoning tasks.

Model Selection Guidelines

  • Default Model: Primarily use the New Sonet Model.
  • Backup Options: Enable other models for diverse situations.
  • Terminal Model: Also select the model you want for when working in the terminal.
  • Command K: Also select the model you want to use when using command+k to modify code.

Advanced Prompting Techniques: Maximizing AI Efficiency

Essential Prompts for Effective Coding

  • “The fewer lines of code the better”: Encourages minimal and clean code implementation.
  • “Proceed like a senior developer/10x engineer”: Promotes high-quality code and best practices.
  • “Do not stop working until you’ve implemented this feature fully and completely”: Reduces model laziness and ensures complete tasks.
  • “Start by writing three reasoning paragraphs analyzing what the error might be. Do not jump to conclusions”: Crucial for tackling complex errors, preventing models from sticking to wrong initial thoughts.
  • “Answer in short”: Minimizes verbosity and saves time.
  • “Do not delete comments”: Preserves important context within the code.
  • “Summary of current state”: Captures the progress of long composers when switching to a new composer to avoid losing context.

Prompts for Complex Decision Making

  • Unbiased 50/50: Forces the AI to analyze and argue for both possible solutions before making a recommendation.
  • Properly Formatted Search Query: Formats web search queries to effectively use tools like Perplexity or ChatGPT.
  • Start reasoning with uncertainty: Forces the AI model to start reasoning with lots of uncertainty and then slowly gain confidence as it analyses the problem, this reduces bias.

Prompt Structure: A Template for Success

  1. Explain what you are doing: Provide a clear and concise description.
  2. Tag the relevant files: Ensure the AI has the necessary context.
  3. How to execute, what not to do: Include explicit instructions on implementation and constraints.
  4. Context dump: Incorporate documentation or other pertinent information.
  5. Repeat core instruction: Reinforce what you want the AI to do.
  6. Output format: Specify how you want the answer (e.g., short, detailed, with comments).

Specialized MD Files: Creating an Internal Documentation System

For each area of your project (database, UI, etc.), create specific markdown files (.md) with relevant documentation and tag them when needed. For instance, have a database_setup.md file with all details related to your database setup.

Optimizing Workflow with Voice and Comments

The Power of Voice: Whisper Flow

Utilize Whisper Flow, a free AI tool, to speak your prompts instead of typing. This dramatically increases input speed (200+ words per minute) compared to typing. This can be useful when wanting to dump a lot of information at once into cursor.

Comments: Future-Proofing Your Code

Comments are crucial not just for human understanding but also for AI. Add one line of comments for every 3-4 lines of code, explaining the purpose of functions, how they relate to the code base, or any non-obvious reasoning. In the future, AI will rely heavily on well-commented code for development so starting this habit now will be very beneficial.

Best Practices: Maintaining Code Quality and Efficiency

Avoiding Technical Debt

Always be learning and understanding the code the AI generates. Avoid blindly accepting code that you don’t comprehend. Ensure you grasp new concepts and only implement what you fully understand. Technical debt will only hinder your progress, so try to avoid it.

When to Use Claude vs. Cursor

  • Claude: Use for brainstorming, strategic planning, and project consulting. Keep it as a separate project to avoid context overload with code.
  • Cursor: Use for active code implementation. Use the agent mode for complex changes that require multiple files.

File Names and Structure

  • Include the name of each file (and the file structure) at the top of the file with comments, especially for complex projects. This ensures that when copying code into Claude, it will know the correct file.

When to Create a New Composer

Create a new composer when the current one starts exhibiting weird behaviors, like forgetting key information. This indicates context overload. Use the summary prompt to help transfer all the context.

When to Use Chat vs Composer

  • Chat: Use for quick questions.
  • Composer: Use for making complex changes (especially in agent mode).

The “Docs” Feature: An Alternative Approach

Instead of using Cursor’s built-in “docs” feature, create MD files for documentation and tag them as needed.

Web Searches with Perplexity

Whenever you encounter an error, create a properly formatted search query (use the prompt above) and use Perplexity to research it. Paste both results into cursor and then summarize the results. Always ask for a “tldr” summary of the results and always include a prompt to be careful of “red herrings”.

Advanced Settings and Configurations

System Prompts: General Coding Principles

In Cursor settings, customize rules for AI (not just project-specific rules in .cursorrules ). These are general rules that apply across all projects, such as “keep code fast, small and focused” or “include lots of comments”.

Avoiding Huge Refactors

Break large refactors into smaller, manageable steps. Use the “only include the truly necessary steps” to reduce optional (unnecessary) details that the AI adds.

Roadmap.md: Project Tracking

Create a roadmap file, roadmap.md, to keep track of what you are focused on, future plans, and notes about issues, or critical bugs, which ensures that the AI is always on the same page as you.

Understanding Limitations and Best Practices

Model Knowledge Cutoff

Be aware of each model’s knowledge cut-off date, ensuring that you do not reference documentation or tools that are newer than the knowledge cut-off date. Always cross-reference with original sources.

AI-Assisted Debugging

Let the AI guide you through the debugging process. Ask it how to use dev tools, what tests to run, and how to gather the necessary context to solve complex issues.

Minimum Viable Product (MVP)

When adding new features, always focus on the MVP first. Identify the core functionality and implement that before attempting to add any non-essential functionality. Always narrow down the scope of the changes. You should always question if the AI’s suggestions should be part of the MVP.

Human Oversight

Do not allow the AI to make big design decisions. Keep a human in charge of the vision and design.

Tool Usage

Use Cursor, Claude, and v0 for different aspects of your project. Always ensure that you understand what is happening under the hood and don’t just rely on what the AI has created. Develop an internal radar to identify where technical debt is accumulating.

Conclusion

This comprehensive guide should enable you to leverage the power of Cursor to its fullest extent. By integrating these best practices, prompting techniques, and configuration tips into your workflow, you can enhance your coding productivity, maintain code quality, and accelerate your development processes. The key to maximizing Cursor’s potential is to continuously learn, adapt, and always remain in control. With the rapidly evolving field of AI, the more effort you put in now to familiarize yourself with these best practices, the higher return in productivity you will experience in the long term.