A utility script that automatically generates and updates .rooignore files to prevent LLM context overflow while preserving your custom content.
- Identifying files that exceed your specified token threshold
- Adding minimal patterns for binary file types that wouldn't be useful to the LLM
- Preserving existing content and custom patterns in your
.rooignorefile
This ensures Roo-Code's LLM can operate efficiently without context overflow issues, while respecting your specific project needs.
Generally you want to put this file in the project root and run it. If you are using bash you can use wget
wget https://raw.githubusercontent.com/Michaelzag/RooCode-Tips-Tricks/main/roo-ignore/generate-rooignore.jsthen:
node generate-rooignore.js node generate-rooignore.js --threshold=30000if it doensm't work you might need to chmod +x
node generate-rooignore.js [directory] [--threshold=NUMBER][directory]- The directory to analyze (defaults to current directory)--threshold=NUMBER- Set custom token threshold (default: 45000)--help- Show help information
# Generate for current directory with default threshold (45k tokens)
node generate-rooignore.js
# Set a custom threshold
node generate-rooignore.js --threshold=30000
# Generate for a specific directory
node generate-rooignore.js ./my-project
# Display help information
node generate-rooignore.js --helpThe script uses a simple estimation method:
- Approximately 4 characters ≈ 1 token
- Binary files are auto-detected and handled appropriately
- Skips only essential directories like
.git,venv,node_modulesduring scanning. There should be no readon the llm should be accessing these folders anyhow. - Uses insights from .gitignore to identify additional directories to skip
- Only skips directories when scanning, not in the final ignore patterns
- Only adds large files that exceed your token threshold
- Includes minimal binary file patterns that are definitely not useful to an LLM
The script is designed to preserve your custom modifications:
- Only updates the large files section of existing .rooignore files
- Maintains your custom patterns and structure
- Adds new large files when detected
- Scans files in the target directory (skipping specific directories for efficiency)
- Estimates token count for each file
- Identifies files exceeding the specified threshold
- Intelligently updates or creates a .rooignore file
- Run periodically after adding new large files to projects
- Set an appropriate threshold based on your LLM's context window (45k is a good default)
- Review the .rooignore file after generation to ensure it meets your needs
- Consider adding custom patterns for your specific project needs
- Review generated files to ensure they don't block important project files
This script is provided as-is for use with Roo-Code.