Exploiting Cursor to write better code
Table of contents
I have been using the Cursor IDE for some time already and I really like its documentation indexing feature. Recently, I discovered a better way to leverage Cursor’s tools to make better references to official documentation and write better code.
The local docs advantage
Here’s what I’ve been doing: Instead of relying on URL-indexed documentation, I download official docs directly to my machine. Take Caddy, for example. I grabbed their docs from GitHub (see src/docs/markdown
), keeping just the markdown files in a local subfolder called docs
. Now when I’m tweaking my Caddy config, the documentation sits right next to my work.
This setup is surprisingly powerful. When I use Cursor’s chat with CMD + Enter, it scans my entire codebase – which now includes my Caddy config plus the official docs. The LLM gives me better, more accurate suggestions because it’s working with authoritative sources.
Learning new tools
This approach isn’t just for tools you’re already using. When learning new technologies, I now start by searching for official docs or handbooks for the tool or library I want to learn. Then I try to find where I can download it in a plain text format like Markdown and save all useful documentation to a local subfolder.
When I have any doubt or question, I can ask in the Cursor chat and add @docs
to reference the subfolder. I know the answers will more likely be based on the official documentation. I can also see which files Cursor is using, so I can open them directly in the editor to double-check.
Building a knowledge base
But here’s where it gets interesting: You can build a single folder that becomes your knowledge hub. Drop in:
- Official documentation
- Useful forum posts
- Code snippets
- Design patterns
When you use this folder as context in Cursor (or any LLM assistant), you’re essentially creating a curated knowledge base. Your LLM helper now draws answers from sources you trust, not just whatever it finds online.
Is it perfect? No. But I’ve found it works better than relying on indexed URLs. Plus, there’s something satisfying about having all your reference material in one place, ready to use offline, and ready to quickly add to the Cursor chat.