Teaching Cursor Agent Tricks
David Gasquez
January 8, 2025
I've been using Cursor during the last few months for both coding and note-taking. They recently introduced a feature that makes their Composer model able to use an agent. That means it can write code and run shell commands iteratively.
That is amazing but I've found it lacking. For example, it doesn't know how to search the web or use tools like uv (it always tries to go with pip).
To solve that, I've teached to use some CLI tools that allows the agent to do more interesting things using the .cursorrules file.
Tools
Use uvx to run any Python package without installing it first (e.g: uvx yt-dlp).
Use npx to run any Node.js package without installing it first (e.g: npx npm-check-updates -u).
Use ddgs to search the web (e.g: ddgs "uv docs").
Parse any URL as Markdown with markitdown (e.g: markitdown https://docs.astral.sh/uv/guides/scripts/).
Understand how to write and run PEP 723 compatible Python scripts.
Rules
To teach Cursor about the tools, I have this generic .cursorrules file that is always active.
For Python projects though, I add a new .cursorrules file in the project folder with some extra rules for Python.
Conclusion
Thanks to these instructions, I've found Cursor Agent to be a much more useful tool. I've seen it do web searches to check documentation, use uvx to run one off CLI Python commands and even follow random links in with markitdown to learn more about a topic.
---
Example
Say for example, you tell cursor to Write a script that generates a PNG plot of Tokio temperature for the last 10 days. This is how the process looks like.
Initially, it writes a small script, tries to run it and realizes it's not working.
Then, it realizes it needs to install some dependencies. It adds the missing dependencies and tries again.
And it works! This is the plot it generates.
The final script, if you're curious, is this:
Discussion in the ATmosphere