Cursor Usage Tips and Common Pitfalls
I have been using Cursor for over a year while developing a system for converting PPT to digital training. Here are some tips and pitfalls I’ve encountered.
1. Write Rules Before Coding
Before you start coding, ensure you have a set of rules in place. This is especially crucial in Python, where the flexibility can lead to unstructured code. I learned this the hard way after writing a 2000-line main.py with mixed logic.
Now, I use rule files in the .cursor/rules/ directory to enforce structure, naming conventions, and documentation styles, significantly improving code readability.
Example Rules:
---
alwaysApply: true
---
You are a Python expert with 15 years of experience. Please strictly follow these coding standards:
### Coding Standards
1. Must have a layered structure (controller/service/utils)
2. Must use type annotations (typing)
3. Must include exception handling
4. Must have logging
5. Do not write everything in one file
6. Each function must have a docstring
7. Naming must be clear (no a, b, c)
8. Code must be extensible (avoid hardcoding)
9. Code must consider maintainability
10. System dependencies should be maintained in requirements.txt
11. Configuration should be in .env
12. System startup must use a virtual environment
13. Keep project structure clear, following modular principles
### Problem-Solving Approach
Read relevant code files thoroughly to understand their functionality and logic. Analyze the causes of errors and propose solutions. Interact with users multiple times to adjust solutions based on feedback. Always reference the official Python documentation to ensure best practices.
【Output Requirements】
1. Provide complete project structure
2. Display each file separately
3. Code must be runnable
2. Avoid Making Too Many Changes at Once
One of the biggest pitfalls with Cursor is its tendency to make excessive changes. If you only want to modify one function, it might inadvertently alter several other files incorrectly. My advice is to request one change at a time. Confirm that the change is correct before moving on to the next.
3. Utilize the Rules Directory
Cursor allows you to place rule files in the .cursor/rules/ directory in .mdc format. Many overlook this feature, but it can be very useful. You can write different rule files for various project types and tech stacks, which Cursor will reference automatically when processing files.
Clearly defined rules lead to significantly improved output quality. You can specify:
- Project structure requirements
- Code style guidelines
- Output format requirements
- Workflow agreements
4. Provide Sufficient Context
The quality of the context you provide directly affects Cursor’s output. If you give too little context, it will have to guess, leading to inaccuracies.
Useful Context:
- Project structure screenshots or descriptions
- Paths to relevant code files
- Complete error messages
- Your previous thoughts or attempts
Useless Context:
- Large blocks of code (it may truncate)
- Irrelevant historical conversations
- Vague requirement descriptions
Learning to provide effective context is crucial for maximizing Cursor’s utility.
5. Allow for Iteration
Many users expect perfect results from the first request. However, AI works iteratively. You should submit a request, review the output, and provide feedback for adjustments. This process is often faster than coding it yourself.
6. Avoid the “Death Spiral”
This is a common issue with AI assistants. If you let it modify one area and it introduces new problems, you may end up in a cycle of endless revisions, leading to a chaotic result. My strategy is to commit after completing a functional version. You don’t need to wait for perfection; just ensure the functionality is intact and commit with a clear message.
If things go awry, you can easily revert to a stable version using git reset. Cursor also supports “Continue and revert” modes, which work well in conjunction with commits.
Developing a habit of committing frequently can save you in critical moments.
7. Handling Agent Timeouts
Occasionally, the Cursor Agent mode may encounter timeout issues. Here are some effective strategies:
Solution 1: Break Down Problems Timeouts often occur due to overly large tasks. Break the problem into smaller parts and reduce the information load per request.
Solution 2: Test with Simpler Questions Start with a simple question like “Hello” to check if it responds. If it does, the connection is fine, and the previous task was too heavy. Try removing images and attachments, focusing on plain text.
Solution 3: Retry or Start a New Conversation Click “Try again” or start a new conversation. Sometimes, it’s just a transient network issue.
Solution 4: Restart Cursor This is the standard solution:
- Completely close Cursor.
- Rename the project folder (e.g., add a suffix like my-project-v2).
- Reopen Cursor.
It may sound odd, but it has proven effective.
8. Will I Lose Historical Conversations When Starting New Ones?
Cursor encourages breaking tasks into smaller conversations for smarter responses and token savings. You can reference past conversations by typing @p and selecting Past Chats.
9. Why Not Use Claude Code?
Some may wonder why I still use Cursor when Claude Code is available. Here are two genuine reasons:
First, Cursor makes frontend modifications very convenient. I can directly send a screenshot with annotations, and it understands my request better than written descriptions, reducing errors.
Second, I find Cursor accounts to be cost-effective and durable. In essence, it’s about value for money. Both tools have their strengths; the choice depends on your specific needs and available resources.
Conclusion
Cursor is not a silver bullet; using it effectively requires a few strategies:
- Write Rules first to make constraints cheaper than fixes.
- Do one thing at a time to reduce excessive associations.
- Utilize the Rules directory for different projects.
- Provide sufficient context to minimize inaccuracies.
- Accept iteration; multiple revisions are normal.
- Commit frequently to prevent death spirals and have rollback points.
- Don’t struggle with timeouts; break tasks down, retry, or restart.
- Don’t fear losing context when starting new conversations; use @p for references.
- Choose tools based on context; Cursor excels in frontend modifications and cost-effectiveness.
Tools are just tools; using them correctly can double your efficiency. Incorrect usage, however, can lead to pitfalls.
Comments
Discussion is powered by Giscus (GitHub Discussions). Add
repo,repoID,category, andcategoryIDunder[params.comments.giscus]inhugo.tomlusing the values from the Giscus setup tool.