Code Memory Skill: Cutting AI Token Spend by 90% Without ChromaDB or PyTorch
The Bottleneck: Monolithic Files Burning AI Quotas
When AI coding assistants (Antigravity, Cursor, Claude Code, Windsurf, Aider) refactor code, their default behavior is reading entire files into context. In projects with 3,000–4,000 line components or giant controllers:
- Reading a single file costs 15,000 to 35,000 tokens per prompt.
- Developer AI quotas burn out within minutes of active session work.
- Long contexts degrade reasoning quality due to the Lost-in-the-Middle phenomenon.
The Solution: Pure Standard-Library BM25 Sparse Search
Instead of dragging in heavy 2GB external dependency chains (PyTorch, sentence-transformers, ChromaDB, Hugging Face, or paying for OpenAI embedding API calls), I implemented a zero-dependency search engine using only Python's standard library (re, math, json, pathlib).
It tokenizes camelCase, snake_case, and punctuation, indexing files into overlapping syntactic chunks with an offline BM25/TF-IDF sparse-vector algorithm. The AI queries the index and retrieves only the exact 20–30 lines it needs, dropping token consumption to ~500–1,500 tokens.
| const decoded = await jwt.verify(token, SECRET);
| if (Date.now() >= decoded.exp * 1000) throw new Error("Expired");
Verified Benchmarks from README
Skill Specifications
- Zero External Dependencies
- Multilingual & camelCase Parser
- Cross-Platform Console Encodings
- Drop-in single file integration
"Built an autonomous local code retrieval skill utilizing BM25 sparse vectoring in Python stdlib, cutting agent token consumption by 80–90% across 10,000+ line codebases."