leantoken
Code intelligence for agents: find the code that matters and keep your context window and tokens lean.
Install / Use
claude mcp add morluto -- npx -y github:morluto/leantokenIf the server publishes to npm under a different name, use that package instead — check the repo README.
MCP Server
Model Context Protocol server
Quality Score
Category
Development & EngineeringSupported Platforms
Our assessment of leantoken
leantoken scores 84/100 on our quality scale, 2887th of 4,591 Development & Engineering skills we index.
Its MCP Server is 17 KB long, well organised into 12 sections with 22 code examples: a thorough specification that gives an agent plenty to work with.
It has 43 GitHub stars, so there is little community track record yet; judge it on its content.
Maintenance, license and trust
- The repository was last updated 2 days ago, so leantoken is actively maintained.
- It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
- Its trust signals score 97/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.
leantoken compared with similar skills
All 4 of these similar skills score higher than leantoken; compare them before choosing.
| Skill | Score | Stars | Updated | Format |
|---|---|---|---|---|
| leantoken (this skill)by morluto | 84 | 43 | 2d ago | MCP Server |
| Agent-Reachby Panniantong | 100 | 94.8k | 1d ago | CLAUDE.md |
| headroomby headroomlabs-ai | 100 | 74.8k | today | CLAUDE.md |
| CowAgentby zhayujie | 100 | 47.3k | today | CLAUDE.md |
| ai-job-searchby MadsLorentzen | 100 | 45.4k | 1d ago | CLAUDE.md |
Frequently asked questions
- How do I install leantoken?
- Run
claude mcp add morluto -- npx -y github:morluto/leantoken. The install tabs above show the steps for each supported agent. - Which AI agents does leantoken work with?
- It is written for Claude Code and Claude Desktop, as a MCP Server file. Other agents that read the same format can often use it too.
- Is leantoken safe to use?
- It is Apache-2.0-licensed and scores 97/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
- Is leantoken still maintained?
- The repository was last updated 2 days ago, so leantoken is actively maintained.
Skill content
View source on GitHubCode intelligence for agents: find the code that matters and keep your context window and tokens lean.
Language: English · 简体中文 · 日本語 · 한국어
- MCP Registry name:
mcp-name: io.github.morluto/leantoken
Install · Why LeanToken · Tools · CLI · How it works · Docs
</div>Measured token savings: In a controlled 60-run study, LeanToken used 20.1% fewer model input tokens than the agent's built-in tools with limited repository exploration, and 37.6% fewer than those tools with broad exploration. See exactly how it was measured in the measurement methodology.
Quick start
Add LeanToken to Claude Code, Cursor, OpenCode, Codex, Gemini CLI, or Antigravity:
npx leantoken setup
<details>
<summary><strong>Setup behavior and safety</strong></summary>
Current releases stop setup before writing when npx resolves a stale
project-local or ancestor install, and point to
npx leantoken@latest setup. Older releases that predate this check can be
bootstrapped directly with that versioned command.
The interactive setup wizard preselects supported clients it detects; you can change that selection before continuing. It then shows the exact configuration paths and MCP launcher and asks for a separate final confirmation. Automation never treats detection as consent. An npx-based setup pins the exact LeanToken version that ran setup, so restarting a client cannot silently move to a newer release.
Global setup never stores the repository where setup happened. OpenCode gets a workspace-relative working directory; other supported clients launch LeanToken from the workspace cwd selected by the host. If a host instead starts it from the home directory or a filesystem root, LeanToken refuses to index that broad root by default.
</details>Restart or reload the configured clients, then verify the connection and first retrieval from a repository:
npx leantoken doctor
Try a broad task such as: Find the code related to request cancellation before
editing. LeanToken helps the agent start with leantoken.context, while its
normal tools remain available for edits, builds, and tests.
Inspect LeanToken's observed repository-local token accounting:
npx leantoken savings
<table>
<tr>
<td width="33%" valign="top">
<strong>Local by default</strong><br><br>
Source is indexed on your machine in a local database. LeanToken is a read-only
discovery and retrieval layer.
</td>
<td width="33%" valign="top">
<strong>Explicit token budgets</strong><br><br>
Every response has an explicit token limit, so large files cannot take over the
request.
</td>
<td width="33%" valign="top">
<strong>Built for agent workflows</strong><br><br>
Find files, search code, inspect structure, read exact ranges, trace history,
query JSON, and track token usage through focused tools.
</td>
</tr>
</table>
<details>
<summary><strong>Advanced setup and version management</strong></summary>
To skip the wizard, select clients explicitly or configure all supported clients:
npx leantoken setup --claude --codex --yes
npx leantoken setup --all --yes
For regular use, --private-runtime is the recommended launcher: it copies the
exact package-native executable into LeanToken's versioned application-data
directory so clients launch one verified process directly, without persistent
npm/Node wrappers. It remains opt-in so the zero-install path does not add an
application-data write. Preview its path and digest with --dry-run.
Automation never treats detection as consent: --yes requires explicit client
flags, --all, or --refresh for entries already managed by LeanToken. Preview
the same resolved plan without changing files:
npx leantoken setup --codex --cursor --dry-run
Setup adds the leantoken MCP entry plus a small owned discovery skill only in
the directories used by the selected hosts: Claude Code uses ~/.claude, while
Codex and the other supported hosts use ~/.agents. The skill advertises
routing metadata; it does not duplicate tool schemas, add rules, or install
shell hooks. Setup marks new MCP launchers as managed and refuses to replace a
same-name manual entry unless you review the dry-run and pass
--force-unmanaged. Remove the owned integration with:
npx leantoken remove
After private-runtime upgrades, inspect retained versions and preview a reference-safe cleanup before applying it:
npx leantoken runtime list
npx leantoken runtime prune --dry-run
npx leantoken runtime prune --yes
Refresh only existing LeanToken MCP entries after explicitly choosing a new version, or use an older version to roll back:
npx --yes leantoken@latest setup --refresh --yes
npx --yes leantoken@0.1.8 setup --refresh --yes --allow-outdated
</details>
Common agent workflows
LeanToken works best as a small evidence loop rather than a one-shot repository dump:
- Orient autonomous triage in one call. Start an uncertain broad task with
contextandplan_only: false, then use the materialized evidence directly. Make at most one focused follow-up only when coverage identifies a concrete missing implementation or regression-test owner. - Continue without resending source. Pass the prior
receipt_idon the next context call, or pass returned fragment hashes asknown_hashes. The response reports exact and overlapping omissions instead of silently charging the same evidence again. - Investigate an observed failure. Use the
investigationworkflow and provide only directly observedfailure_traces, paths, symbols, or test intent inworkflow_evidence. Follow with exactsearch,outline, orreadcalls for the owners the evidence identifies. - Review a change. Use the
reviewworkflow withbase_revisionset toBASE..HEADandstrict_changed_paths: true. Request ahandoffwhen another agent needs a compact manifest of selected hashes, changed paths, assumptions, and completed validations without copied source bodies.
This one-call contract is for autonomous repository triage, not a limit on
implementation agents. Human review and control-plane flows can still preview
expensive or high-risk retrieval with plan_only: true before materializing.
The repeated multi-agent context suite
found that an iterative LeanToken profile used 50.9% more total input than thin
native, while the frozen one-context-plus-optional-one-search profile saved
20.1% and had 15/20 path-set successes. Those results cover four pinned triage
tasks; they do not prove a universal implementation workflow.
Explicit focus constraints are contracts. When a request supplies
focus_paths, exact focus_symbols, and
minimum_fragments_per_focus_path, LeanToken generates candidates within the
documented per-file bounds and reports a coverage failure when distinct ranges
cannot satisfy the minimum. Explain-profile plans and materialized responses
also identify the bounded allocation boundary that generated, reserved,
selected, or suppressed each focus candidate without changing ranking.
Why LeanToken
Most agents start by searching widely and reading whole files. LeanToken narrows that work in stages:
| Typical repository exploration | With LeanToken | | --- | --- | | Scan broad directory listings | Find relevant paths in a compact tree | | Read whole files to find structure | See definitions and imports without loading the entire file | | Send the same code again after each turn | Avoid repeating unchanged evidence | | Let large files fill the request | Keep returned source within an exact source-token budget and report response overhead separately | | Guess which files matter | Rank likely relevant code for the task |
Your coding agent still handles editing, commands, tests, and conversation. LeanToken finds and returns the code those tasks need.
LeanToken does not create one giant prompt file. It answers focused searches and reads as the agent needs them.
Example
For a task like fix request cancellation during shutdown, an illustrative bounded result might look like this:
Budget: 1,200 source tokens
Selected evidence:
src/services/executor.rs lines 137-147, 251-259
src/services/reconciliation.rs lines 148-175, 257-272
The agent receives these ranges instead of both full files. If the budget is too small, the response also says what was left out. Paths, scores, receipts, JSON, and MCP transport wrappers are not part of this source-token budget; see token accounting for the measured boundaries.
Available tools
| Tool | Purpose |
| --- | --- |
| leantoken.context | Default materialized first call for autonomous broad triage; optional preview for human or control-plane review. |
| leantoken.search | Prefer over grep/rg for ranked search; exhaustive text/regex calls can explicitly record or reuse complete query coverage. |
| leantoken.files | Prefer over find/ls/glob for compact, ignore-aware path discovery. |
| leantoken.outline | Inspect definitions, signatures, imports, and ranges without whole-file reads. |
| leantoken.read | Prefer over cat/head/sed for one exact symbol or inclusive line range. |
| leantoken.history | Read, batch-diff, or trace parsed symbols across immutable Git revisions. |
| leantoken.json | Query, summarize, or compare bounded live JSON with paged keys and typed diagnostics. |
| leantoken.receipt_rebase | Explicitly carry only same-path, same-coordinate, same-hash evidence into a newer completed generation. |
| leantoken.savings | Report observed response accounting, hash suppression, failures, and explicit observation limits. |
Every index-backed retrieval tool, including receipt_rebase, accepts
consistency: "reconcile_working_tree" when completed edits must be reconciled
before the query. The default,
"indexed_generation", returns the latest completed index generation without
scanning or waiting for filesystem changes; it is not a Git revision boundary.
leantoken.history reads immutable Git objects and leantoken.json reads exact
live files, so neither accepts an index consistency mode. To constrain context
to immutable history, pass BASE..HEAD as leantoken.context.base_revision
with strict_changed_paths: true.
For autonomous broad triage, set plan_only: false and use the materialized
evidence directly. Reserve plan_only: true for human or control-plane review
before expensive or high-risk retrieval: it returns bounded ranked candidate
metadata without source fragments or receipt mutation. After approval, repeat
the same request with plan_only: false. Set response_profile: "compact" for
the smallest fail-loud response, keep the default "balanced" shape, or use
"explain" for bounded individual omissions, facets, and diff evidence. The
response reports the resolved choice as `e
Truncated for display — read the full file on GitHub.
Related Skills
Agent-Reach
94.8kGive your AI agent eyes to see the entire internet. Read & search Twitter, Reddit, YouTube, GitHub, Bilibili, XiaoHongShu — one CLI, zero API fees.
headroom
74.8kCompress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.
CowAgent
47.3kOpen-source personal AI assistant & Agent Harness. Plans tasks, runs tools and skills, self-evolves with memory and knowledge. Multi-agent, multi-model, multi-channel. Lightweight, extensible, one-line install.
ai-job-search
45.4kThe job search that runs on your machine. AI job application framework built on Claude Code: evaluate postings, tailor CVs, write cover letters, prep interviews. Fork it and own it.
Languages
Trust signals
From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.
