Stop Wasting LLM Tokens! I Built a Rust CLI to Prune JS/TS Codebases by 80% ๐Ÿฆ€๐Ÿš€ A developer built urai-ecma, a multi-threaded Rust CLI that uses SWC to parse JavaScript and TypeScript into ASTs and semantically prune codebases before feeding them to LLMs. The tool reportedly compresses a 209,757-token codebase to roughly 36,000 tokens, an 82.7% reduction, addressing attention degradation, KV-cache prefill lag, and rate-limit throttling in agentic coding workflows. โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ THE "INFINITE CONTEXT" TRAP โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ 1. Attention Degradation โ”‚ Lost-in-the-Middle: critical interfaces get โ”‚ โ”‚ โ”‚ buried under repetitive DOM noise and loops. โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ 2. KV-Cache Prefill Lag โ”‚ Time-to-First-Token TTFT scales with promptโ”‚ โ”‚ โ”‚ size; 150k+ raw tokens stall your agent. โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ 3. The "Tailwind Tax" โ”‚ Paying frontier API rates to ingest 80-char โ”‚ โ”‚ โ”‚ strings like "flex items-center justify-..." โ”‚ โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค โ”‚ 4. Rate-Limit Throttling โ”‚ Bloated prompts quickly exhaust TPM Tokens โ”‚ โ”‚ โ”‚ Per Minute quotas in CI/CD pipelines. โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ Have you ever dumped an entire React or Next.js repository into Claude 3.5 Sonnet, GPT-4o, or a local Ollama model to ask: "How does authentication state flow through my UI, and what endpoints handle it?" If you inspect the prompt you sent, over 70% of the tokens are dead weight : className="flex flex-col items-center justify-between p-8 bg-white dark:bg-zinc-950 rounded-2xl shadow-xl..." . While building an agentic Chrome extension powered by local LLMs, my context window collapsed: 209,757 tokens per scan . Responses took forever, local inference crawled, and the model routinely hallucinated core functions because key architectural interfaces were buried under syntactic noise. I built urai-ecma https://sanjaiyan-dev.github.io/urai-ecma : a multi-threaded CLI tool written in Rust that uses SWC Speedy Web Compiler to parse JavaScript and TypeScript into Abstract Syntax Trees AST . Instead of blindly concatenating files together like a text scraper, it acts as a semantic compiler for prompt engineeringโ€”compressing that same 209k token codebase down to 36k tokens an 82.7% reduction in milliseconds . Here is how it works, how it is architected under the hood, real benchmarks, and the engineering trade-offs you should know before using it. In classical Tamil literary heritage, monumental masterworks like the Thirukkuแน›aแธท เฎคเฎฟเฎฐเฏเฎ•เฏเฎ•เฏเฎฑเฎณเฏ and Tolkฤppiyam เฎคเฏŠเฎฒเฏเฎ•เฎพเฎชเฏเฎชเฎฟเฎฏเฎฎเฏ contained dense, multi-layered philosophical thought. To make these works practical without destroying their architectural depth, classical scholars practiced เฎ‰เฎฐเฏˆ เฎŽเฎดเฏเฎคเฏเฎคเฎฒเฏ Urai Ezhuthudhal . Master commentators Uraiyฤsiriyars like Parimelazhagar and Ilampuranar did not just copy or mechanically summarize texts. They performed structural distillation : Modern enterprise JavaScript and TypeScript codebases are the epic literatures of software engineering. When asking an LLM to reason about your code, it doesn't need raw syntactic exhaustionโ€”it needs the structural anatomy, API contracts, state flows, and component signatures. urai-ecma acts as a modern Uraiyฤsiriyar for your codebase. Tools like repomix , gitingest , and code2prompt are file dumpers. They walk your directory, wrap raw text in XML/Markdown fences, and pass every single line of styling directly into your model's context. urai-ecma is an AST-aware compiler engine . Rather than treating code as raw strings, it parses your source into concrete syntax trees using ByteDance/Vercelโ€™s swc ecma engine and applies deterministic, semantic transformations: โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ URAI COMPILER PIPELINE โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ Enterprise Monorepo .ts, .tsx, .js, .mjs, .json โ”‚ โ–ผ ignore::WalkBuilder Rust Honor .gitignore, prune node modules & dist โ”‚ โ–ผ Rayon Parallel Work-Stealing Multi-threaded AST parsing across all CPU cores โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ–ผ โ–ผ swc ecma parser swc ecma parser Worker Thread A Worker Thread B โ”‚ โ”‚ โ”œโ”€โ–บ RouteVisitor โ”œโ”€โ–บ RouteVisitor โ”‚ Next.js/Express/NestJS โ”‚ Next.js/Express/NestJS โ”‚ โ”‚ โ”œโ”€โ–บ ReactComponentAnalyzer โ”œโ”€โ–บ ReactComponentAnalyzer โ”‚ Props, State, Hooks, JSX โ”‚ Props, State, Hooks, JSX โ”‚ โ”‚ โ”œโ”€โ–บ ReactJsxPruner โ”œโ”€โ–บ ReactJsxPruner โ”‚ Tailwind static class strip โ”‚ Tailwind static class strip โ”‚ โ”‚ โ””โ”€โ–บ FunctionSummarizerVisitor โ””โ”€โ–บ FunctionSummarizerVisitor Preserve structural stubs Preserve structural stubs โ”‚ โ–ผ Foyer Hybrid Cache Disk + RAM Sha512 256 + Zstd compression โ”‚ โ–ผ swc ecma codegen + Tiktoken Engine Emits high-density Markdown prompt + BPE o200k report is structural stub stmt Traditional minification forces a bad compromise: either include full function bodies wasting thousands of tokens on loops and math or strip functions down to empty signatures which deletes hooks, event listeners, and JSX layouts . urai-ecma solves this through Structural Stubbing . It inspects AST statements and retains only nodes critical to architectural comprehension: // Only statements defining component anatomy are preserved: fn is structural stub stmt stmt: &Stmt - bool { match stmt { Stmt::Decl Decl::Fn = true, // Nested helper declarations Stmt::Decl Decl::Var var decl = var decl.decls.iter .any |decl| { if let Some init = &decl.init { matches init, Expr::Arrow | Expr::Fn } else { false } } , Stmt::Expr expr stmt = { if let Expr::Call call expr = & expr stmt.expr && let Callee::Expr callee expr = &call expr.callee && let Expr::Ident ident = & callee expr { let name = ident.sym.as ref ; // Preserves React Hooks, lifecycle timers, and global listeners: return name.starts with "use" || name == "setTimeout" || name == "setInterval" || name.contains "addEventListener" || name.contains "requestIdleCallback" ; } false } Stmt::Return ret stmt = { // Preserves JSX layout hierarchies: if let Some arg = &ret stmt.arg { matches & arg, Expr::JSXElement | Expr::JSXFragment | Expr::Paren } else { false } } = false, // Computational loops, arithmetic, & validations are pruned } } useEffect = { ... }, dep remains intact, signaling side-effects to the LLM. Modern utility CSS accounts for massive token bloat. urai-ecma provides 4 modes remove , remove aggr , summarize , preserve : className={clsx "btn", isActive && "btn-active" } or ternary conditions, / UI: Frosted glass card with dark mode / . Summarizing every single function with an LLM is slow. urai-ecma uses a two-tier resolution strategy : @description , @param , @return already exist. It even includes a proximity-scan fallback within a 300-byte span to associate detached comments. This takes gemma4 , llama3.2 . foyer crate 64MB direct RAM buffer + 128MB Zstd-compressed disk storage with Sha512 256 keys . Look at what happens to a bloated React component when passed through urai-ecma : js const ErrorUI = { headerDescTxt = "The real-time telemetry pipeline requires runtime binding. Ensure this window resides in a Chrome extension popup configured with permission parameters.", copyTextCommand = 'OLLAMA ORIGINS=" " ollama serve', copyTagTxt = "MV3", copyHeaderTxt = "Manifest Interface Schema", copiedButtonTxt = "Copied Configuration", copyButtonTxt = "Copy Permission Manifest", } = { const copyState, setCopyState = useState false ; const handleCopyManifest = = { navigator.clipboard.writeText copyTextCommand ; setCopyState true ; setTimeout = setCopyState false , 2000 ; }; const copyButtonTxtNode = copyState ? copiedButtonTxt : copyButtonTxt; return