Yesterday a quiet tool dropped in r/PromptEngineering, and it solves a problem most AI builders never bother to name. Developer u/Itchy-Cash4660 got tired of watching agent prompts balloon with conversational filler, duplicate notes, and messy transcripts. So they built “lcc,” a Local Context Compiler that cleans up prompts before they ever reach the model.
The pitch is simple. Over 70% of tokens in real-world prompts are pure bloat: rambling, repeated context, unformatted pastes, redundant code snippets. lcc strips that out deterministically. No model guesses what to cut, a fixed set of rules does the job the same way every time. It also checks whether a prompt is actually ready to run, or still missing details it needs. Then it formats whatever survives into caching-friendly templates built for Claude XML, Cursor, or plain Markdown.
Here’s the twist. Most “prompt cleaner” tools you’ve run into are just another LLM call wrapped around your LLM call. You wait two seconds, burn extra tokens, and pay for the privilege of shrinking your bill. lcc runs entirely local, makes zero API calls, and finishes in under 15 milliseconds. The top comment in the thread called that out first, and honestly, it’s the real headline here!
That distinction matters more than it sounds. If you’re running an agent loop that fires off dozens or hundreds of prompts a day, a two-second LLM-based cleanup step adds up fast. That’s real latency and real cost stacked on top of the tokens you were trying to save in the first place. A deterministic local pass costs a few milliseconds, and it never hallucinates a “cleanup” that quietly changes what your prompt actually says.
How the workflow looks in practice:
- 🧹 Drop your raw context in: a transcript, messy notes, a code dump.
- ⚡ lcc dedupes and cleans it deterministically, no model involved, in milliseconds.
- 🔍 It classifies the prompt: ready to execute, or missing key details first.
- It formats what’s left into a caching-contract template for Claude XML, Cursor, or Markdown.
- 🚀 You send the leaner prompt and start seeing higher cache hit rates.
That “classify before you run” step is easy to overlook, but it’s doing real work. Say your context is missing a target file path or a clear success condition. lcc flags that before you burn a full agent turn discovering it the hard way.
Getting started doesn’t take much either. It’s an open-source Python and TypeScript CLI, so you clone the repo and point it at a raw text file or a directory. Pipe the cleaned output straight into whatever agent or IDE you already use. No signup, no API key, no config wizard standing between you and a leaner prompt.
One commenter running a strict closed-world workflow put it to a real test. They load a 1MB JSON file as their entire prompt and let an agent grind on it until the build is right. After tightening that input, they reported a 98.5% cache hit rate and near-perfect stability across the run. That’s the actual payoff. Fewer wasted tokens per call adds up fast when you’re running agents all day, every day.
Pro tip: if you’re managing a swarm of subagents, point lcc at their outputs before folding them back into a parent prompt. Another commenter flagged this exact use case: trimming subagent output, tightening AGENTS.md files, cleaning up research-agent results. Anywhere text passes between agents in a pipeline, bloat creeps back in before the next step even gets to read it.
Second pro tip: treat lcc as a pipeline step, not a one-off cleanup you run by hand. Deterministic tools are boring in the best way possible. Same input, same output, every single time. Wire it into a script or a CI step without worrying about a model changing its mind on formatting mid-run.
Worth flagging before you install it: this is a young, single-developer project under an MIT license. Treat it like early tooling, not something battle-tested at scale yet. A few readers hit a formatting glitch on mobile and briefly assumed the repo was private. It isn’t; that was just a rendering issue on their end. If you want a baseline for comparison, weigh it against LLM-based prompt optimizers, but remember the entire pitch here is skipping that LLM step entirely. You trade some semantic understanding of your prompt for a whole lot of speed and zero added cost per run.
If you’re burning tokens on messy context every single day, go star the repo and run lcc before your next long agent session. 🌟
Frequently Asked Questions
Q: How is lcc different from other prompt cleaners?
Most prompt cleaners use an LLM to refine your context, adding 2+ seconds of latency and extra costs. lcc runs entirely local using deterministic algorithms, finishing in under 15ms with zero API calls. You get the same deduplication and formatting benefits without the wait or the bill.
Q: Can lcc handle near-duplicate or rephrased content?
lcc handles deterministic deduplication reliably for exact duplicates. For semantically similar text that’s been rephrased differently, fuzzy matching isn’t built in by default, but it’s worth checking the docs or opening a GitHub issue to see if that’s on the roadmap.
Q: What are some good use cases if I’m building agents?
Commenters mentioned several wins: cleaning up AGENTS.md files, trimming subagent outputs, pre-compacting research agent results, and reducing prompt context bloat. Think of it as a low-loss compression pass that runs before your prompts hit the LLM.
Q: Will lcc improve my prompt cache hit rates?
If your prompts have redundancy or inconsistent formatting, lcc’s deduplication can improve cache consistency. If you’re already running tightly structured prompts, improvements might be incremental since you’re already optimized.
I got tired of burning tokens on messy prompts, so I built an open-source local context compiler (lcc)
by u/Itchy-Cash4660 in PromptEngineering