Skip to content

SOP-016: Ignore Files Configuration

Document Control

  • Version: 1.0
  • Last Updated: 2024
  • Category: Context & Rules

Purpose

Configure .cursorignore files to control which files Cursor can access for security and performance optimization.


Scope

This SOP covers configuring ignore files for:

  • Security (protecting sensitive files)
  • Performance (excluding large directories)
  • Global and project-level ignore patterns

Prerequisites

  • Cursor installed and running
  • Access to project root directory
  • Understanding of glob patterns

Procedure

Step 1: Understand What Gets Ignored

Cursor reads .cursorignore files to block access from:

FeatureAffected
Codebase indexingYes
Tab autocompleteYes
AgentYes
Inline EditYes
@ mentionsYes
Terminal/MCP toolsNo (cannot block)

Step 2: Create .cursorignore File

Create a .cursorignore file in your project root:

bash
# Create the file
touch .cursorignore

Step 3: Add Ignore Patterns

Use .gitignore syntax for patterns:

gitignore
# Specific files
config.json
secrets.yaml

# Directories
dist/
node_modules/
.git/

# File extensions
*.log
*.key
*.pem

# Nested directories
**/logs
**/temp

# Negation (include despite other rules)
!app/

Step 4: Configure Global Ignores

Set patterns that apply to ALL projects:

  1. Open Cursor Settings
  2. Navigate to Features > Editor
  3. Find Global Cursor Ignore List
  4. Add patterns that should always be ignored

Default global patterns include:

  • **/.env, **/.env.* (environment files)
  • **/credentials.json, **/secrets.json
  • **/*.key, **/*.pem, **/id_rsa (keys)

Step 5: Use Hierarchical Ignore (Optional)

Enable searching parent directories for .cursorignore:

  1. Open Cursor Settings
  2. Navigate to Features > Editor
  3. Enable Hierarchical Cursor Ignore

This is useful for monorepos where you want different rules per subdirectory.

Step 6: Limit Indexing Only

Use .cursorindexingignore to exclude from indexing but keep accessible:

gitignore
# These files won't be indexed but can still be referenced
large-data/
generated/

Common Patterns

Security-Focused

gitignore
# Environment and secrets
.env
.env.*
*.secret
secrets/
credentials/

# Keys and certificates
*.key
*.pem
*.p12
*.pfx
id_rsa*

# Database files
*.sqlite
*.db

Performance-Focused

gitignore
# Dependencies
node_modules/
vendor/
.venv/

# Build outputs
dist/
build/
out/
target/

# Large files
*.zip
*.tar.gz
*.mp4

Pattern Limitations

Negation in Nested Directories

Negation patterns don't work for files in excluded parent directories:

gitignore
# This won't work as expected:
public/*
!public/assets/style.css  # Won't be included

# Workaround - be more specific:
public/assets/*
!public/assets/style.css  # This works

Verification Checklist

  • [ ] .cursorignore created in project root
  • [ ] Sensitive files are excluded
  • [ ] Large directories are excluded for performance
  • [ ] Global ignores configured in settings
  • [ ] Patterns tested with git check-ignore -v [file]

Troubleshooting

IssueSolution
File still accessibleCheck pattern syntax, ensure file path matches
Pattern not workingTest with git check-ignore -v filename
Negation not workingCheck if parent directory is excluded
Performance still slowAdd more exclusions, check .cursorindexingignore

See Also

Built with VitePress | Powered by Claude AI