grepai-chunking
Configure code chunking in GrepAI. Use this skill to optimize how code is split for embedding.
By yoanbernabeu · 631 installs
npx skills add yoanbernabeu/grepai-skills --skill grepai-chunking
Source repository · Upstream listing
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.
Size Effect
256 More precise, less context
512 Balanced (default)
1024 More context, less precise
Overlap
Tokens shared between adjacent chunks. Preserves context at boundaries.
Overlap Effect
0 No overlap, may lose context at boundaries
50 Standard overlap (default)
100 More context, larger index
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:
Size Overlap Chunks per 10K tokens Index Impact
512 0 ~20 Smallest
512 50 ~22 Standard
512 100 ~24 +10%
256 50 ~44 +100%
Impact on Search Quality
Too Small Chunks (size: 128)
Just Right (size: 512)
Too Large Chunks (size: 2048)
Experimentation
Testing Different Settings
1. Try smaller chunks for more precise results:
2. Re index:
3. Test with searches:
4. 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:
1. Empty lines (function/class boundaries)
2. Closing braces
3. Statement ends
This means actual chunk sizes may vary slightly from the target.
Best Practices
1. Start with defaults: 512/50 works well for most codebases
2. Adjust based on code style: Verbose = larger, concise = smaller
3. Test with real queries: See what your searches return
4. Re index after changes: Must regenerate embeddings
5. 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: