Tips for using Cursor
Here are a list of tricks I've learned for using Cursor:
- Running multiple copilots in parallel can cause edit wars, especially if they edit the same file or try to fix the same failing test. I isolate each agent to its own branch using git worktrees, which is a neat git feature that creates separate directories for each branch.
- Cursor seems to keep a global cache for library docs. Iβve seen it use ancient docs versions (from 2024) when adding new URLs, especially for less popular libraries. I periodically click "Reindex" in the settings to ensure docs are current, and to also help other Cursor users. Before I got into this habit, the Ray and Anyscale docs were sometimes months stale.
- This one is a bit funny, but sometimes models can get demoralized if they think you are upset. I see this especially with Gemini and Claude. you can see them panicking in their reasoning traces. I've even seen Clause spontaneously hallucinate that you're furious with it when many tests break. when the agents start panicking, they start ignoring directions and write overly cautious code littered with too many try/except blocks. to prevent this, I glaze the model at each turn ("great work! let's try ...") to keep up morale.
- If the copilot misinterprets your request, donβt try to rescue and clarify in follow-up instructions. Scroll to the original request, add constraints, and try again. Cursor will ask if you want to revert and rewind the code state, undoing the bad edits. This avoids degraded performance from distracting context.
- Similarly, when a session runs too long, or if the agent is struggling, it's better to start a fresh session. I ask the copilot to write a comprehensive hand-off for the next on-call, something like "write a comprehensive hand-off report for the next on-call. Summarize the objective, work done so far, things that failed, your hypotheses, and recommended next steps." Amusingly, it often ends the hand-off saying things like "feel free to ping me on Slack if you run into any issues", lol.
- Instead of a single rules.yaml, you can split your rules into multiple rule sets and tell Cursor when to add each rule set to the context. this is useful to not pollute the context with irrelevant rules. For example, I use different rules for .md vs .py files, and have test-specific rules that are only applied to files in the tests/ directory.
- Whitelist safe commands so that you don't need to explicitly approve every command: uv run pytest, uvx pre-commit, git diff, sed, awk, find, head, cat, touch, grep