12 Tips for Writing High-Quality Code with AI from Cursor's Design Lead

Discover 12 expert tips shared by Cursor's design lead on how to effectively use AI for writing high-quality code and improving programming efficiency.

Introduction

Recently, the design lead at Cursor shared a series of techniques for using AI to write high-quality code. These methods not only help developers better utilize AI tools but also significantly enhance programming efficiency.

Image 5

In the AI programming field, one of the most notable developments is ByteDance’s Trea supporting MCP. Having tried it, I can say the user experience is impressive. They have integrated popular MCPs, making it easy for users to add them.

However, I still choose not to use Trea.

Image 6

Although Trea allows free access to Claude 3.7, the version in Trea likely lacks intelligence. When I submitted modification requests for the same file in both systems, Cursor’s understanding was excellent, while Trea made confusing changes.

This highlights two points:

  1. Cursor has made many optimizations at the engineering level, which cannot simply be bought but require time and experience.
  2. To write good code with AI, the issue may not just lie with the AI and coding knowledge itself, but also with the unknown “insider” factors behind it.

Today, I came across Cursor’s lead sharing 12 insights on how to effectively use Cursor for smooth coding. Here’s a summary of those tips.

Image 7

Establish Clear Project Rules

Start by setting 5-10 clear project rules to help Cursor understand your structure and constraints. This step is crucial!

Key Point: Use the /generate rules command to let AI automatically generate rules for your existing codebase. It’s incredibly satisfying!

Be Precise with Prompts

Vague prompts = poor output. It’s that simple! Clearly specify the tech stack, behaviors, and constraints in your prompts, just like writing a mini specification document.

AI isn’t mind reading; if you don’t specify clearly, how will it know what you want?

File-Level Iteration is Key

Generating an entire project at once? Wake up! Focus on one file at a time—generate, test, review to keep work blocks small and concentrated. This way, if issues arise, they are easier to locate and fix.

Image 8

Test First, Code Later

Honestly, write tests first, lock them in, and then let Cursor generate code until all tests pass. This approach, combining test-driven development with AI, boosts efficiency significantly.

Never Forget Manual Review

No matter how powerful AI is, mistakes can happen. Always manually review outputs and fix any issues, then show Cursor the corrected code as an example. Skipping this step could lead to regret later.

Focus Cursor’s Attention

Use the @file, @folders, and @git commands to restrict Cursor’s attention to the correct parts of the codebase. It’s like telling a friend, “Look here, look here,” to avoid distractions.

Keep Design Documents in the .cursor/ Directory

Place design documents and checklists in the .cursor/ directory so that the agent fully understands what to do next. The more comprehensive the context, the higher the output quality—this is a fact!

If the Code is Wrong, Just Fix It!

If the code is incorrect, just write the correct version yourself. Humans learn faster from your edits than from explanations! Sometimes, it’s better to dive in and make changes rather than explaining for ages.

Utilize Chat History

Make good use of chat history to iterate on old prompts; there’s no need to start from scratch every time. This trick is incredibly useful and can save a lot of repetitive input time, boosting efficiency.

Model Selection Matters

Consciously choose models based on your needs: use Gemini for precision and Claude for breadth. Different models have different strengths, just like different tools are suited for different tasks.

Documentation is Crucial for New Tech Stacks

In new or unfamiliar tech stacks, directly paste documentation links and let Cursor explain all errors and fixes line by line. Don’t hesitate to let AI be your tech teacher, guiding you through problem-solving!

Large Projects Need Overnight Indexing

Allow large projects to index overnight and limit the context scope to maintain agile performance. It’s like preparing in advance so you can dive right in the next day, boosting efficiency!

Conclusion: Structure and Control are Key

Think of Cursor as a powerful junior developer—if you point the way, it can move forward quickly. But you must know the path first!

The core of effectively using Cursor is: clear guidance + strict review + continuous feedback. Master these, and your AI programming efficiency will definitely reach new heights!

Have you used Cursor? Do you have unique tips to share? Or have you encountered any pitfalls during use? Feel free to leave a comment and let’s explore more possibilities in AI programming together!

Was this helpful?

Likes and saves are stored in your browser on this device only (local storage) and are not uploaded to our servers.

Comments

Discussion is powered by Giscus (GitHub Discussions). Add repo, repoID, category, and categoryID under [params.comments.giscus] in hugo.toml using the values from the Giscus setup tool.