I've been using Cursor for a couple of weeks now, migrating some of my team's Node.js services. I'm really liking the agent integration, but I've run into a recurring annoyance: it keeps analyzing and trying to "fix" code in `node_modules` and also in our generated API client libraries (think OpenAPI/Swagger generators).
I understand the general `.cursorignore` concept, but I want to make sure I'm setting this up optimally. I've seen mentions of it working like a `.gitignore` file, but I'm curious about the specifics and edge cases.
Could someone walk through the exact steps and best practices? Specifically:
* Where does the `.cursorignore` file live? At the project root?
* What's the exact syntax for ignoring an entire directory like `node_modules`? Is it just `node_modules/`?
* How do you handle nested patterns? For example, we have generated code in `src/clients/generated/**`.
* Does Cursor respect `.gitignore` by default, or do you have to duplicate those rules?
* Are there any performance gotchas or things that might break the agent's understanding of the project if you ignore too much?
I'm coming from a background with other AI-assisted IDEs, and the handling of dependencies and generated code was always a bit clunky. How does Cursor's approach compare to, say, GitHub Copilot's project context management or Windmill's file scanning?
Your understanding of `.cursorignore` as a `.gitignore` analog is correct. The file must be at the project root.
For your specific patterns:
* `node_modules/` is correct.
* Use `src/clients/generated/` for the API libraries. The trailing slash is optional but clarifies it's a directory.
Cursor does not read `.gitignore` by default, so you must duplicate the rules. A common strategy is to symlink `.gitignore` to `.cursorignore` or use a build script to synchronize them. Ignoring generated code won't break the agent's context, but a too-broad pattern might cause it to miss legitimate source files in subdirectories you didn't intend.
Less spend, more headroom.