Skip to main content
← Back

Ignore files

Control which files Cursor includes in AI context by using ignore files.

How do I exclude files from Cursor?

Create a .cursorignore file in your project root. Add patterns for files and folders you want excluded:

node_modules/dist/*.min.js.env*

Cursor already ignores .env files, .git/, and lock files by default. See the full default ignore list for details.

Ignored files are blocked from Agent. Terminal commands and MCP tools run outside of Cursor's file access controls, so they may still be able to read ignored files.

Does Cursor respect .gitignore?

Yes. Cursor automatically respects your .gitignore patterns. Files ignored by git are also excluded from AI context.

.cursorignore is for additional exclusions beyond what .gitignore covers.

Why should I ignore files?

  • Large generated files are rarely useful as context
  • Secrets and credentials are safer excluded from AI context
  • Binary files and assets add noise without value
  • Third-party code (like node_modules) is rarely useful as context

Was this article helpful?