LeanCTX for OpenAI Codex

Codex ships fast.
Make it ship lean.

LeanCTX reduces OpenAI Codex token usage by 60–90%: the MCP integration serves AST-aware compressed reads, ~13-token cached re-reads and 88–99% smaller command output. lean-ctx setup auto-detects Codex and writes the configuration. Agents keep their workflow; the context gets lean.

The problem

Where OpenAI Codex spends your tokens.

Parallel tasks multiply the bill

Codex runs many tasks against the same repository, and each one rereads the same files from scratch.

Cloud + local both pay per token

Whether tasks run in the cloud sandbox or locally, raw file dumps and verbose logs inflate every single run.

AGENTS.md can't fix volume

Instructions shape behavior, but they can't shrink a 4,200-token file. Volume needs a context layer, not a prompt.

The integration

How LeanCTX plugs into OpenAI Codex.

01

MCP server for Codex

lean-ctx setup registers the MCP server in Codex's configuration. Reads, searches and shell calls route through the compression engine.

02

AGENTS.md tool mapping

Setup adds the tool-preference block so Codex agents call ctx_read and ctx_shell by default.

03

One cache for every task

Parallel tasks share the same local session cache. The second task to touch a file pays ~13 tokens instead of the full read.

Setup

One command. Auto-detected.

# install LeanCTX
$ curl -fsSL https://leanctx.com/install.sh | sh
# auto-detect Codex and configure MCP + AGENTS.md
$ lean-ctx setup
# verify the wiring
$ lean-ctx doctor
# see the receipt
$ lean-ctx gain
What changes

Three moments you'll notice.

The second task is almost free

Task one explored the repo; task two hits the cache. Shared context across parallel runs is where the savings compound.

Logs that fit in a glance

Test and build output arrives as errors plus result. Codex's reasoning stays on the diff instead of the scrollback.

Numbers you can verify

lean-ctx benchmark report . reproduces the savings on your own repository, methodology included.

FAQ

OpenAI Codex + LeanCTX, answered.

How do I reduce OpenAI Codex token usage?

Install LeanCTX and run lean-ctx setup. Codex gets MCP tools serving compressed AST-aware reads (60–90% fewer tokens), ~13-token cached re-reads and compact shell output, across all tasks on the machine.

Does LeanCTX work with Codex CLI and the IDE extension?

Yes. Any Codex surface that loads the MCP configuration uses the same local server: CLI, IDE extension and locally executed tasks.

Is anything sent to additional servers?

No. LeanCTX runs entirely on your machine with zero telemetry. It sits between Codex and your filesystem. Nothing new leaves the machine.

Using this at work?

Team gives your whole org one shared, audited context plane, and the ledger proves the savings to finance. Local use stays free forever, enforced by CI.