Back to articles
CTX: I built a LLM-free code context loader that uses 5.2% of tokens

CTX: I built a LLM-free code context loader that uses 5.2% of tokens

via Dev.to PythonJune7th

CTX: LLM-free Code Context Loader Every AI coding agent faces the same problem: what context to include in the prompt? Naive approach: dump the whole codebase → 100% of token budget gone. Smart approach: use BM25 search → misses dependency files, import chains, recent edits. I built CTX to solve this with a deterministic, zero-LLM approach. How It Works CTX classifies every query into one of 4 trigger types and routes it to the right retrieval strategy: from ctx import CTXRetriever retriever = CTXRetriever ( project_path = " . " ) result = retriever . retrieve ( " Where is AuthMiddleware defined? " ) # → Trigger: EXPLICIT_SYMBOL → symbol index lookup → returns 2 files Trigger types: EXPLICIT_SYMBOL → exact symbol lookup in structural index SEMANTIC_CONCEPT → BM25 hybrid blend TEMPORAL_HISTORY → git log + recently modified files IMPLICIT_CONTEXT → import graph traversal (finds what the target imports) Benchmark Results 87 queries, 29 docs: Metric CTX BM25 Dense TF-IDF R@3 0.862 0.667 0.

Continue reading on Dev.to Python

Opens in a new tab

Read Full Article
2 views

Related Articles