localdex — Run a Codex-Style Coding Agent 100% Locally with LM Studio (and Cut Your AI Bill)
AI coding agents have quietly become part of our daily toolchain — and so have their bills. Every code review, every “summarize this folder”, every throwaway boilerplate request burns metered tokens on someone’s cloud. That’s fine for the hard problems. It’s a waste for the easy ones.
Meanwhile, the machine on our desk — an Apple-silicon MacBook with 48 GB of RAM — can comfortably run a 30-billion-parameter coding model for free. The tokens are already paid for; they’re called electricity.
So we connected the two: localdex, a fork of OpenAI’s Codex CLI that runs entirely against a local model served by LM Studio. No OpenAI account, no API key, no login, no per-token billing — and nothing, not a single prompt, leaves your machine. Plus a companion plugin that lets Claude Code delegate work to it.
Both are open source:
- CLI: github.com/DCSdevelop/codexforlocal
- Claude Code plugin: github.com/DCSdevelop/localcodex-plugin-cc
Why bother, when cloud models are smarter?
They are smarter — that’s not the argument. The argument is that a big share of what we ask AI agents to do every day doesn’t need frontier intelligence:
- “Summarize what this script does.”
- “Draft a docstring / commit message / config file.”
- “Give me a second opinion on this approach.”
- “Explain this 300-line file in three bullets.”
These tasks are token-heavy but mechanically simple. Routing them to a metered cloud model is like hiring a senior consultant to alphabetize your bookshelf. A local model handles them well — and every one of those tasks it absorbs is tokens your cloud subscription doesn’t spend, quota your rate limit doesn’t lose, and code that never crosses the network. That last part matters on client work: for some engagements, “the code never leaves the machine” isn’t a preference, it’s a requirement.
What localdex actually is
The nice surprise: recent Codex CLI already ships an lmstudio provider — pointed at http://localhost:1234/v1, no authentication required. Upstream just doesn’t make it the easy path. So our fork adds exactly one thing: install tooling that makes the local path the default. Zero Rust changes, which keeps the fork trivially in sync with upstream.
The install script builds the CLI, seeds a config that selects the LM Studio provider and your local model, and installs a localdex command with its own isolated config home (~/.localdex). That isolation means it coexists peacefully with an official codex install — different name, different config, different sessions.
git clone https://github.com/DCSdevelop/codexforlocal
cd codexforlocal
./scripts/install-localdex.sh --model qwen/qwen3-coder-30b # any model id from `lms ls`
localdex exec "reply with exactly OK" # smoke test
You’ll need a Rust toolchain to build, and LM Studio with its server running (lms server start), a coding model downloaded, and JIT model loading enabled. One version note: the CLI speaks the OpenAI Responses API (POST /v1/responses), so you need a recent LM Studio.
The Claude Code plugin: delegation, not replacement
The second repo is a fork of OpenAI’s Codex plugin for Claude Code, rewired to invoke localdex. Install it and Claude Code gets /localdex:review, /localdex:adversarial-review, and /localdex:rescue — code reviews and delegated tasks that run on your local model:
git clone https://github.com/DCSdevelop/localcodex-plugin-cc
# then, inside Claude Code:
# /plugin marketplace add /path/to/localcodex-plugin-cc
# /plugin install localdex@localcodex
# (restart, then run /localdex:setup)
/localdex:setup reports ready with no login step — the plugin recognizes that the LM Studio provider needs no OpenAI authentication.
The mental model we’ve landed on is delegation, not replacement. Claude (or you) stays the senior engineer; localdex is the free junior who handles the mechanical work. The plugin ships a when-to-delegate skill that encodes this triage so Claude applies it automatically: delegate self-contained, token-heavy-but-simple tasks; keep literal text searches (grep is faster than any LLM), tight feedback loops, and hard reasoning where they belong.
What it realistically saves — with numbers
On our M5 Pro / 48 GB machine running qwen/qwen3-coder-30b, we measured ~27 tokens/second of generation and ~1,400 tokens/second of prompt ingestion. Concretely: a pointed one-file summary round-trips in about 48 seconds. That’s the sweet spot — and every such task is a task your metered model never sees.
Where the local model does not pay off is just as important, and we learned it the expensive way: an unbudgeted “summarize both repos” exploration task once ran for half an hour before we killed it. A cloud model would have done it in two minutes. If a free task costs you 30 minutes of wall clock, it wasn’t free — so the skill now enforces a hard 5-minute budget: estimate before delegating (output tokens ÷ 27 tok/s, plus ~30 s of overhead per turn), cancel and fall back to the cloud model past the cap. Cost reduction only counts if it includes the cost of your time.
Three lessons that will save you an afternoon
1. Raise the context window — 8k makes the model drift. Codex sends a large system prompt with every thread. At LM Studio’s default 8,192-token context, our model literally lost the question mid-task and started hallucinating a different assignment. At 32k it’s rock solid: lms load qwen/qwen3-coder-30b --context-length 32768 --ttl 3600 -y (or set it permanently in LM Studio → My Models).
2. Set a TTL, or the model squats your RAM. A model loaded explicitly via the CLI gets no auto-unload by default — ours would have pinned ~17 GB forever. The --ttl 3600 flag unloads it after an hour idle.
3. Check the server before you delegate. If LM Studio is already generating for something else, your request queues behind it. A two-second lms ps before delegating tells you whether the model is loaded, idle, and holding the right context size.
The bottom line
localdex won’t replace your frontier model — it’s not supposed to. It’s the free, private lane next to the paid one: summaries, boilerplate, second opinions, reviews of privacy-sensitive code, and everything you’d rather not meter. The marginal cost of those tasks drops to zero, your quota stretches further, and your code stays home.
Both repos are Apache-2.0, built on OpenAI’s open-source Codex CLI and plugin. Clone them, point them at whatever model your hardware can carry, and let the junior do the busywork.
Questions or ideas? Reach us at apps@dataconsultingservices.net.