Template and guide for restructuring large documentation files into token-efficient directory structures. Reduces context bloat by 40-60% while maintaining accessibility.
A pattern for restructuring large documentation files into slim indexes with on-demand subdirectories, reducing always-included context by 40-60%.
Large documentation files (500+ lines, 5k+ tokens) that are always included in context:
Split monolithic docs into:
Before:
TOOLS.md (~11k tokens always included)
├── Section 1 (rarely needed)
├── Section 2 (rarely needed)
├── ... (15+ sections)
└── Section N (rarely needed)
After:
tools/
├── README.md (~4k tokens always included) # Slim index
├── topic1/README.md # Detailed docs (~1k tokens each)
├── topic2/README.md # Loaded on-demand
└── .../README.md # etc.
Good candidates for progressive disclosure:
Keep as single file when:
Count tokens and identify sections:
# Count lines and estimate tokens
wc -l LARGE_FILE.md
# Rough: 1 line ≈ 8 tokens
# Identify sections (look for ## headers)
grep "^## " LARGE_FILE.md | head -20
# Create topic directories
mkdir -p topic_dir/{topic1,topic2,topic3}
The index should contain:
Example slim index structure:
# Topic Name
Brief overview of what this covers and core concepts.
## Quick Reference
| Command | Description |
|---------|-------------|
| cmd1 | Most common operation |
| cmd2 | Second most common |
| cmd3 | Third most common |
## Detailed Documentation
For specific topics, see:
- **Topic 1** (topic1/README.md) - When you need X
- **Topic 2** (topic2/README.md) - When you need Y
- **Topic 3** (topic3/README.md) - When you need Z
## Principles
1. Core principle 1
2. Core principle 2
3. Core principle 3
Each topic README should:
Update gptme.toml (or equivalent) to include the slim index:
[context]
# Before: included entire large file
# files = ["LARGE_FILE.md"]
# After: include only slim index
files = ["topic_dir/README.md"]
Before:
TOOLS.md: 1380 lines, ~11k tokens, always includedAfter:
tools/README.md: 200 lines, ~1.5k tokens (slim index)tools/{shell,git,github,context,...}/README.md: ~150 lines eachResult: 44% reduction in always-included context