# lcc — Local Context Compiler
**Compact coding-agent context without summarizing it away.**
lcc cuts what the model does not need, keeps everything else byte for byte, and writes a receipt.
[](https://pypi.org/project/local-context-compiler/)
[](https://pypi.org/project/local-context-compiler/)
[](https://github.com/lucasmartins-ai/lcc/actions/workflows/ci.yml)
[](LICENSE)
[](https://github.com/lucasmartins-ai/lcc/stargazers)
## `/compact` vs lcc
Claude Code's `/compact` replaces your session with a summary written by a model. Summaries
drop the exact error, path or line the agent needs two turns later. lcc does the opposite: old
tool outputs leave the context but stay one `recall` away, and every user and assistant message
is kept as it was.
| One real Claude Code session (193 messages, 75 tool calls) | tokens | user and assistant messages | removed tool outputs |
| --- | ---: | --- | --- |
| before | 57,083 | 43, as written | — |
| `/compact` | one summary | rewritten into the summary | gone |
| **lcc** (`rules`, `stashed`) | **28,807 (−49.5%)** | **43 / 43 byte for byte** | 33, each one `recall` away |
Measured with `lcc measure-session` (PyPI 1.2.0, offline, exact `o200k_base` token count;
re-run 2026-10-23). On `main`, whose stash note now states lines and size, the same session
gives 28,983 (−49.2%). That session is one of the best cases. **Across all 299 of my long sessions** (100+ messages each,
36.3 M tokens) the median cut was **21.8%** (middle half 15% to 31%, best 65%), with 0 messages
lost (`python benchmarks/research/long_sessions.py`, 2026-10-23, `main`). These are all my sessions: [run it on yours](#send-us-your-numbers) and post the result.
In a pre-registered test on 172 real requests ([evidence](docs/EVIDENCE.md)), an agent answering
from the `stashed` context plus `recall` did as well as with the full context on file recall
(+0.006, 95% CI −0.023 to +0.034) with 36.6% fewer tokens. It called `recall` for 90% of the
questions about removed content. A `/compact`-style summary of the same sessions got 73% of exact values
right (our reimplementation of `/compact`, written by Opus); full and verbatim context got 98%.
## Install
```sh
pip install "local-context-compiler[tiktoken]" # the CLI is `lcc`
lcc measure-session "$(ls -t ~/.claude/projects/*/*.jsonl | head -1)" # your latest session
```
The second line reads your most recent Claude Code session, runs every mode offline and prints
counts only. Nothing is changed and nothing leaves the machine.
**Claude Code plugin** (replaces the `/compact` summary). Function hooks are early access, so
this needs **Claude Code 2.1.274+ and the flag below**:
```sh
export CLAUDE_CODE_ENABLE_FUNCTION_HOOKS=1
claude plugin marketplace add lucasmartins-ai/lcc
claude plugin install lcc@lcc --config provider=rules --config rulesMode=stashed
```
Allow `mcp__plugin_lcc_lcc__recall` so the agent can get removed outputs back. When a pass
fails or removes too little, the plugin hands over to the built-in summary and says so in a
toast. Details: [Claude Code guide](docs/CLAUDE_CODE.md).
**MCP** (Claude Code, Cursor, Claude Desktop, any stdio client):
```json
{"mcpServers": {"lcc": {"command": "lcc", "args": ["mcp"]}}}
```
Tools: `compact`, `compact_transcript`, `recall`, `inspect`, `prepare`, `explain`, `intake`
([MCP guide](docs/MCP.md)).
**CLI**, on a session file or any document:
```sh
lcc compact ~/.claude/projects/