lake-meter

Registre officiel Outils de développement

Per-step model recommendations and cost estimates for coding-agent plans.

Installation

Ajoutez ceci à la configuration MCP de votre client (Claude Desktop : claude_desktop_config.json ; Cursor : .cursor/mcp.json ; VS Code et les autres utilisent la même forme « mcpServers »).

NPM package lake-meter
Claude Code
claude mcp add lake-meter -- npx -y lake-meter@0.1.2 mcp
Configuration JSON (Claude Desktop, Cursor, VS Code)
{
    "mcpServers": {
        "lake-meter": {
            "command": "npx",
            "args": [
                "-y",
                "lake-meter@0.1.2",
                "mcp"
            ]
        }
    }
}

Documentation

Tirée du README du projet sur GitHub, actualisée chaque semaine. Les liens ouvrent GitHub.

Sommaire
  1. lake-meter
  2. What you see
  3. Commands
  4. Measured vs estimated (read this)
  5. How it works
  6. Limits (honest list)
  7. Privacy
  8. Verification
  9. Demo (from a clone, no account needed)
  10. Teams
  11. License

lake-meter

A model for every step, and a hard stop for every run. For Claude Code.

Claude Code is great until a run loops, fans out into subagents, or quietly eats your 5‑hour window on a step a cheaper model could have done. lake-meter adds two things using only Claude Code's own extension points (hooks, statusline, skills, MCP):

  1. Model per step. When Claude writes a plan in plan mode, lake-meter rates each step's complexity, recommends the cheapest model that should handle it (Haiku / Sonnet / Opus), and estimates tokens and dollars per step and in total, next to the cost of running everything on Opus. The table appears inside Claude Code's own "Ready to code?" plan dialog.
  2. A per-run cap that stops and asks. Set $5 (or a token budget, or a % of your 5‑hour window). When a run reaches it, the next tool call becomes a permission prompt: Yes continues with +50% headroom, No stops Claude right there. In unattended modes it ends the turn instead.
  3. An end-of-run receipt. Measured tokens and list-price dollars for the run, split by model and subagents, compared with the plan's estimate.

Local only. No account, no server, no telemetry.

npx lake-meter init

That's the whole install. Restart Claude Code (or open /hooks) and work as usual.


What you see

In plan mode, at the top of the plan dialog:

Ready to code?
Here is Claude's plan:
▎ Lake Meter estimate: $3.53–$13.0 with a model per step, vs $3.96–$14.5 all on Opus 5.5. Table at the end.

and at the end of the plan:

┌─────┬─────────────────────────────────────┬────────────┬─────────────────────┬───────────┬─────────────┐
│ #   │ Step                                │ Complexity │ Recommended model   │ Tokens    │ Est. cost   │
├─────┼─────────────────────────────────────┼────────────┼─────────────────────┼───────────┼─────────────┤
│ 1   │ Add retry settings to config        │ 1/5        │ Haiku 5.5 (haiku)   │ 40k–161k  │ <$0.01      │
│ 2   │ Design an idempotent delivery queue │ 5/5        │ Opus 5.5 (opus)     │ 1.5M–6.2M │ $2.10–$8.22 │
│ 3   │ Implement the retry worker          │ 4/5        │ Opus 5.5 (opus)     │ 720k–2.6M │ $1.01–$3.38 │
│ 4   │ Expose delivery status in the API   │ 3/5        │ Sonnet 5.5 (sonnet) │ 284k–1.0M │ $0.21–$0.71 │
│ 5   │ Tests for failure paths             │ 3/5        │ Sonnet 5.5 (sonnet) │ 284k–1.0M │ $0.21–$0.71 │
│ 6   │ Update the changelog                │ 1/5        │ Haiku 5.5 (haiku)   │ 40k–161k  │ <$0.01      │
└─────┴─────────────────────────────────────┴────────────┴─────────────────────┴───────────┴─────────────┘
Total: $3.53–$13.0 vs $3.96–$14.5 with everything on Opus 5.5 (about 10% less).

When the cap is reached, before the next tool call:

│ Hook PreToolUse:Bash requires confirmation for this command:
│ Lake Meter: this run has used about $2.15 (cap $2.00). Approve to continue with +$1.00 headroom.
│ Deny to stop here. Or run /meter cap <usd> to set a new cap. [settings]
 Do you want to proceed?
 ❯ 1. Yes
   2. No

When the run ends:

Stop says: Lake Meter · run $3.44 · 524k tok (313k cache reads, 155k out) · Opus 5.5 $3.44 · cap $7.00
           Since plan approved: $3.25 measured vs $3.53–$13.0 estimated

All the time, in the statusline: ◒ Lake · run $0.65 / $5.00 · session $4.54 · 5h 42%

(These are copied from a real Claude Code 2.1.322 session; see Verification.)

Commands

npx lake-meter@latest initinstall hooks, statusline, /meter skill and two subagents (installed by default; skip with --no-agents) into ~/.claude
npx lake-meter@latest init --projectinstall hooks into this repo's .claude/settings.local.json (also writes .claude/skills and .claude/agents with machine-specific paths: don't commit them)
npx lake-meter@latest init --cap 10 --no-agents --statuslineset the cap, skip the subagents, replace an existing statusline
/meter, /meter cap 10, /meter cap off, /meter reportinside Claude Code (uses one short model turn to display)
npx lake-meter@latest cap 10 · npx lake-meter@latest status · npx lake-meter@latest reportsame, from any terminal, no model turn (or npm i -g lake-meter and drop npx)
npx lake-meter@latest plan plan.md [--why] [--openai] [--json] (flags after the file)plan breakdown for any markdown plan
npx lake-meter@latest mcpMCP server with estimate_plan and meter_status (works in Cursor too)
npx lake-meter@latest uninstallremove everything init added (your settings are restored; a backup of the original is kept as settings.json.lake-meter.bak)
Config

~/.lake-meter/config.json (per-project override: .lake-meter.json in the repo root):

{
  "capUsd": 5,
  "capTokens": null,
  "capFiveHourPct": null,
  "sessionCapUsd": null,
  "onCap": "ask",
  "extendPct": 50,
  "warnPct": 80,
  "provider": "anthropic",
  "annotatePlans": true
}
KeyMeaning
capUsdper run, API list-price equivalent. null = off
capTokensper run, all tokens incl. cache reads
capFiveHourPcte.g. 80: stop when your 5-hour subscription window passes 80% (needs the statusline)
sessionCapUsdacross the whole session
onCap"ask" = permission prompt; "stop" = end the turn
extendPctheadroom granted when you press Yes
warnPctone heads-up (to you and to Claude) at this % of the cap
provider"anthropic" or "openai" for plan recommendations
annotatePlansadd the table to plan files in plan mode

Simplest: npx lake-meter@latest cap 10 writes this file for you.

A run is everything from one prompt you submit until Claude stops.

Cursor and other MCP clients

Add to ~/.cursor/mcp.json (or any MCP client's config):

{ "mcpServers": { "lake-meter": { "command": "npx", "args": ["-y", "lake-meter@latest", "mcp"] } } }

Then ask the agent to "estimate this plan with lake-meter". In Cursor you get the per-step model and cost breakdown. The cap and the receipt are Claude Code only, because Cursor doesn't expose per-run token usage to extensions.

Measured vs estimated (read this)

HowAccuracy
Tokens per runMeasured. Read from Claude Code's session transcript (message.usage on each response, de-duplicated by message id) plus subagent transcripts in <session>/subagents/.Exact as reported by the API, up to transcript write lag (see limits).
Dollars per runComputed from measured tokens × list prices in src/prices.json, per request, including cache writes (5m/1h), cache reads and Haiku's long-context tier.Matches Claude Code's own total_cost_usd in our tests. It's an API-equivalent figure: on Pro/Max you don't pay it per token; it tells you how heavy a run was. Your invoice can differ (discounts, batch, regions).
5-hour window %Reported by Claude Code to the statusline (rate_limits.five_hour.used_percentage, Pro/Max only).As accurate as Claude Code's own number.
Plan breakdownEstimate. Keyword and size heuristics rate each step 1–5; token budgets per complexity live in prices.json (assumptions). Run npx lake-meter@latest plan plan.md --why to see every reason.Rough. Ranges are wide on purpose. Tune the budgets from your own npx lake-meter@latest report history.
Model recommendationOpinion, encoded as complexity → tier (1–2 Haiku, 3 Sonnet, 4–5 Opus). Frontier models are never recommended by default.A starting point, not a guarantee of quality.

Prices last verified 2026‑11‑12 from Anthropic pricing and OpenAI pricing. To update, edit src/prices.json, or drop an override at ~/.lake-meter/prices.json with the same shape.

How it works

init copies a pinned runtime to ~/.lake-meter/runtime (so hooks run in ~50 ms with plain node, no npx per call) and adds to your Claude Code settings:

Extension pointWhat lake-meter does
UserPromptSubmit hookmarks the start of a run
PreToolUse hook (*)reads new transcript bytes, prices them, and returns permissionDecision: "ask" when the cap is reached (or continue: false in bypassPermissions / dontAsk / onCap: "stop"). On ExitPlanMode it records the plan estimate and gives Claude a one-line note about cheaper subagents
PostToolUse hook (*)if the tool we asked about ran, you pressed Yes, so headroom is added. When Claude writes a plan file in plan mode, appends the per-step table to it
Stop hookprints the receipt (systemMessage, never blocks) and appends one line to ~/.lake-meter/runs.jsonl
statusLineshows the meter and stores Claude Code's own session cost and rate-limit % for the window cap. Only installed if you don't already have a statusline
~/.claude/skills/meterthe /meter command
~/.claude/agents/lake-light.md, lake-standard.mdsubagents pinned to haiku and sonnet (installed by default; skip with --no-agents), so the per-step advice is actionable. Claude only uses them if it decides to

Limits (honest list)

  • The cap is checked before each tool call. A single long model response can overshoot it, and the final text answer of a turn isn't gated. Expect a run to end slightly above the cap.
  • Transcript lag. Claude Code writes transcripts asynchronously, so the newest response may land a moment late. Spend can lag by about one response.
  • Pressing No interrupts the turn. Claude Code doesn't run Stop hooks on interrupts, so there's no receipt for that turn; npx lake-meter@latest status still has the numbers.
  • "Run" = one submitted prompt. Background subagent reports and /loop iterations also fire UserPromptSubmit and start a new run; use sessionCapUsd to bound the whole session.
  • Dollar figures are list-price equivalents, not your bill. On subscriptions use capTokens or capFiveHourPct if dollars feel abstract.
  • Plan breakdown is heuristic and English-keyword based. Unknown models count tokens but not dollars (and the receipt says so).
  • /meter costs one short model turn because skills run through the model; the CLI commands don't.
  • Claude Code only for caps and receipts. Cursor, Codex and others get the MCP plan estimate.

Privacy

Step titles are stored locally in ~/.lake-meter, along with config and a run log of token and dollar totals. Nothing leaves the machine. No prompts or code are stored. lake-meter makes no network requests, and there's no telemetry. Debugging: touch ~/.lake-meter/debug logs raw hook inputs locally to ~/.lake-meter/debug.jsonl; delete the file to stop.

Verification

  • npm test: 48 tests (pricing math, transcript parsing and de-duplication, plan splitting and scoring, every hook path, install/uninstall round-trip, MCP over stdio, a simulated session through the real CLI).
  • test/real-claude.test.js runs the real Claude Code binary (2.1.322 at time of writing) against a local mock of the Messages API (scripts/mock-anthropic.js, no account needed). It checks that the hooks fire, the cap produces a permission decision, bypassPermissions stops the turn, and that lake-meter's measured run cost equals Claude Code's own total_cost_usd. Skipped when no Claude Code binary is installed.
  • The screens in What you see were captured from an interactive Claude Code session driven against the same mock.

Demo (from a clone, no account needed)

npm run demo        # simulated session: plan breakdown → cap prompt → receipt

Teams

Works with lake-gate: a teammate approves the plan before the expensive run. Shared caps and a dashboard of runs by repo and model are in early access. Request a team pilot.

License

MIT © Lake

Questions fréquentes

Qu'est-ce que lake-meter ?

Per-step model recommendations and cost estimates for coding-agent plans.

Comment installer lake-meter ?

Il s'exécute sur votre machine. Dans Claude Code : claude mcp add lake-meter -- npx -y lake-meter@0.1.2 mcp. Pour les autres clients, collez la configuration JSON de cette page dans leurs réglages MCP.

Faut-il une clé API pour lake-meter ?

Son entrée au registre n'indique aucune clé ni secret obligatoire. Certaines fonctions peuvent tout de même demander un compte auprès du service auquel il se connecte.

lake-meter est-il open source ?

Oui. Son code est sur GitHub sous licence MIT.

Qui maintient lake-meter ?

Il est publié par getlake. AI.tn le référence sans le maintenir ni le recommander.

Issu du registre MCP officiel. Être listé n'est pas une recommandation : vérifiez le code et les permissions d'un serveur avant de lui donner accès à vos données.