A plugin for Claude Code and Cursor

Same tasks. Half the turns. Get Lean

Your coding agent wastes turns: wandering your repo, editing one file per call, pasting whole test logs. Every turn costs you time and budget. lean cuts them.

Run both inside Claude Code, then restart it.

/plugin marketplace add jkcailteux/lean-plugin
/plugin install lean@lean-marketplace
Add a timeout to every fetch(). One block is one turn.
Vanilla
29.5
lean
6
−80%turns
46s → 23swall time
$0.34 → $0.23per run

01Eight tasks, with and without

Cost per task
−18–28%
Turns
−43–47%
Wall time
−25–28%
Tasks still passing
40/40

Against vanilla Claude Code on Claude Opus 5.5: 8 tasks, two runs. Yours will vary; /lean:stats estimates it.

Biggest wins where Claude would otherwise explore or edit file by file.

Show as a table

Mean of 2 to 8 runs per task. Single tasks swing by chance, so read the pattern. On a one-shot grep lean costs about a cent more.

02Four small tools, no per-call hooks

One Node file, no dependencies. Hooks run once per session, never per tool call.

Tool 1

Repo map

About 2k tokens at session start: every file and its top-level symbols as name:line.

plugins/lean/scripts/ context-guard.mjs: lastTurn:22, guard:50 repo-map.mjs: repoMap:89 state.mjs: stateFor:10 bench/results/2026-11-01T18-10-07_base-vs-final/ (21 data files: 20 .json, 1 .md)

Exploring −50% turns; symbol lookups −47% to −60% cost.

Tool 2

BatchEdit

Many edits across many files in one call, no prior read.

BatchEdit({ edits: [ { path: "src/api/users.ts", old: "fetch(url)", new: "fetch(url, { signal })" }, { path: "src/api/orders.ts", … }, // one call instead of one per edit ]})

Edits −80% turns, −50% wall time, no failed calls.

Tool 3

MultiRead and RunCompact

Several files in one read. Test runs that return only the failures.

Removing them cost +10% and 4× the exploring turns.

Tool 4

Context guard

Back in a big session after the cache expired? lean says so once and suggests /compact.

lean: this session holds ~340k tokens of context and was idle 2.0h, so the prompt cache expired and this turn re-writes all of it at cache-write price. Run /compact after this reply so later turns carry a summary instead of all ~340k tokens.

Simulated: −36% to −42% when you compact on the warning.

03See where your tokens go

/lean:stats shows what your sessions cost, which tools fill your context, and what lean saved.

> /lean:stats
Last 24h · 1 session(s) in this project
Spent ≈ $18 at API list prices over 161 turns
median turn 5s

What lean saved (estimates)
lean:BatchEdit    10 round trips   $1.10   46s
lean:RunCompact   708 tokens       $0.01

04The leak isn't tool output. It's context.

Every turn re-reads the whole conversation, so long sessions are where the money goes.

autoCompactWindow 200k turns in one long session → context idle 1h+: cache expires, whole context re-written compact compact
Schematic, not measured data. Rising line: vanilla. Red sawtooth: with the guard and autoCompactWindow: 200000.
−50 to −60%

simulated spend over 8,158 real turns with the guard plus autoCompactWindow: 200000. Compact sooner.

05Install

Claude Code

Two commands, one restart.

1

Add the marketplace

/plugin marketplace add jkcailteux/lean-plugin
2

Install, then restart Claude Code

/plugin install lean@lean-marketplace
3

Optional: compact sooner in ~/.claude/settings.json

{ "autoCompactWindow": 200000 }

Cursor

Copy the plugin into Cursor's local plugins folder. No restart.

1

Clone the repo

git clone https://github.com/jkcailteux/lean-plugin
2

Copy the plugin into Cursor

rsync -a --exclude test lean-plugin/plugins/lean/ ~/.cursor/plugins/local/lean/
3

Turn on hooks in Cursor Settings

Turn on Include Third-Party Plugins, Skills, and Other Configs. The repo map needs it.

In Cursor, ask the agent what lean saved. Skipped round trips are a share of the model calls in Cursor's transcripts; the time saved is an estimate, since Cursor stores only each prompt's time, to the minute. In Claude Code, /lean:stats shows both: what lean saved there and in Cursor for the same project. The context guard is Claude Code only, and the Cursor port isn't benchmarked yet.

MIT licensed

Use it, fork it, ship it.

No telemetry

No network code.

Zero dependencies

No background process.