GrepAI Chunking Configuration
This skill covers how GrepAI splits code files into chunks for embedding, and how to optimize chunking for your codebase.
When to Use This Skill
- Optimizing search accuracy
- Adjusting for code style (verbose vs. concise)
- Troubleshooting search results
- Understanding how indexing works
What is Chunking?
Chunking is the process of splitting source files into smaller segments for embedding:
Why Chunking Matters
Embedding models have optimal input sizes:
- Too large chunks: Less precise search results
- Too small chunks: Lost context, fragmented results
- Just right: Good balance of precision and context
Configuration
Basic Settings
Understanding Parameters
Chunk Size
The target number of tokens per chunk.
Overlap
Tokens shared between adjacent chunks. Preserves context at boundaries.
Visualization
With size=512 and overlap=50:
Recommended Settings by Language
Verbose Languages (Java, C#)
Concise Languages (Go, Python)
Very Concise (Rust, Zig)
Recommended Settings by Codebase
Small Functions (Microservices)
Large Classes (Monolith)
Mixed Codebase
How Tokens are Counted
GrepAI uses approximate token counting:
- ~4 characters = 1 token (for English text)
- Code varies based on identifiers and syntax
Example:
≈ 45 tokens
Impact on Index Size
Larger overlap = more chunks = larger index:
Impact on Search Quality
Too Small Chunks (size: 128)
Just Right (size: 512)
Too Large Chunks (size: 2048)
Experimentation
Testing Different Settings
- Try smaller chunks for more precise results:
- Re-index:
- Test with searches:
- Adjust and repeat until satisfied.
Comparing Results
Before changing settings, save a search result:
After changing settings and re-indexing:
Chunk Boundaries
GrepAI tries to split at logical boundaries:
- Empty lines (function/class boundaries)
- Closing braces
- Statement ends
This means actual chunk sizes may vary slightly from the target.
Best Practices
- Start with defaults: 512/50 works well for most codebases
- Adjust based on code style: Verbose = larger, concise = smaller
- Test with real queries: See what your searches return
- Re-index after changes: Must regenerate embeddings
- Consider overlap: Don't set to 0 unless index size is critical
Common Issues
❌ Problem: Search results are too fragmented ✅ Solution: Increase chunk size:
❌ Problem: Search results have too much irrelevant context ✅ Solution: Decrease chunk size:
❌ Problem: Results miss related code at function boundaries ✅ Solution: Increase overlap:
❌ Problem: Index is too large ✅ Solutions:
- Decrease overlap
- Increase chunk size
- Add more ignore patterns
Output Format
Chunking status:

