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 3
Combine 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, not src\auth)
  • Path prefix match, src/auth matches src/auth/login.ts but not src/authentication/...
  • Trailing slash is optional

Typical workflow

  1. AI starts with get_project_index level=1 to see all files (~1K tokens)
  2. AI identifies relevant subtree, calls again with folder=src/auth level=2 (~500 tokens)
  3. AI uses search_symbol or get_file_summary for specifics (~50 tokens each)

Total exploration cost: ~1.5K tokens vs ~50K+ for reading files directly.