Token Optimization
Folder scoping
The single highest-leverage optimization.
The intuition
If src/auth/ is 5% of your project and that's all the AI needs, scoping to that folder cuts cost by 95%, far more than picking a lower level.
How to use it
From MCP
json
{ "level": 2, "folder": "src/auth" }From CLI
bash
larkx context --folder src/auth
larkx context --folder src/db --level 3Combine with levelsFolder + level multiplies. Level 1 on a 5% folder = 0.05 × 10% = 0.5% of original cost.
Folder matching rules
- Forward slashes only (
src/auth, notsrc\auth) - Path prefix match,
src/authmatchessrc/auth/login.tsbut notsrc/authentication/... - Trailing slash is optional
Typical workflow
- AI starts with
get_project_index level=1to see all files (~1K tokens) - AI identifies relevant subtree, calls again with
folder=src/auth level=2(~500 tokens) - AI uses
search_symbolorget_file_summaryfor specifics (~50 tokens each)
Total exploration cost: ~1.5K tokens vs ~50K+ for reading files directly.