I Built My Own Context Index Before Claude Code Had Skills and Memory
说明与用途
作者构建了树结构索引,以减少Claude Code中搜索所需的令牌数,并与RAG和内置技能进行了比较。
问题
Managing a growing set of project documents in Claude Code’s context window was inefficient; reading the entire collection for every task wasted tokens and time.
结果
The tree‑structured index dramatically reduced token usage per task, improved efficiency, and remained simple, deterministic, and portable across AI tools.
工作流
- 1. Create a flat index file listing each document with a short description and file path.
- 2. Organize the index into balanced folders (e.g., 10 top‑level folders, each with 10 subfolders, each containing ~10 entries).
- 3. When a task arrives, Claude Code scans only the relevant folder hierarchy to find the matching line.
- 4. Open the referenced file and load its full content only when needed.
- 5. Maintain the folder balance to keep search depth minimal.
- 6. Use the index for any document that is read, while keeping Skills and Memory separate for executable actions and personal preferences.
证据
The fix is something most people already do without thinking about it: folders. Nobody keeps a thousand files loose in one folder, they get split into subfolders...
At 1,000 lines, it stops being nothing. Reading the whole list at that size runs into the tens of thousands of tokens...
- 记录日期: 2026-09-05T18:45:00.117Z