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:
| Feature | Affected |
|---|---|
| Codebase indexing | Yes |
| Tab autocomplete | Yes |
| Agent | Yes |
| Inline Edit | Yes |
| @ mentions | Yes |
| Terminal/MCP tools | No (cannot block) |
Step 2: Create .cursorignore File
Create a .cursorignore file in your project root:
bash
# Create the file
touch .cursorignoreStep 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:
- Open Cursor Settings
- Navigate to Features > Editor
- Find Global Cursor Ignore List
- 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:
- Open Cursor Settings
- Navigate to Features > Editor
- 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
*.dbPerformance-Focused
gitignore
# Dependencies
node_modules/
vendor/
.venv/
# Build outputs
dist/
build/
out/
target/
# Large files
*.zip
*.tar.gz
*.mp4Pattern 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 worksVerification Checklist
- [ ]
.cursorignorecreated 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
| Issue | Solution |
|---|---|
| File still accessible | Check pattern syntax, ensure file path matches |
| Pattern not working | Test with git check-ignore -v filename |
| Negation not working | Check if parent directory is excluded |
| Performance still slow | Add more exclusions, check .cursorindexingignore |