by morluto
Code intelligence for agents: find the code that matters and keep your context window and tokens lean.
# Add to your Claude Code skills
git clone https://github.com/morluto/leantokenGuides for using ai agents skills like leantoken.
See how leantoken compares with popular alternatives.
leantoken is an open-source ai agents skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by morluto. Code intelligence for agents: find the code that matters and keep your context window and tokens lean. It has 155 GitHub stars.
leantoken's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/morluto/leantoken" and add it to your Claude Code skills directory (see the Installation section above).
leantoken is primarily written in Rust. It is open-source under morluto on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other AI Agents skills you can browse and compare side by side. Open the AI Agents category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh leantoken against similar tools.
No comments yet. Be the first to share your thoughts!
Available after the catalog security scan passes.
⚠️ Third-Party Software Notice
This skill is third-party open-source software developed and hosted independently on GitHub. SkillsLLM is an informational directory and does not control or maintain the underlying repository.
Any security checks, ratings, or warnings displayed by SkillsLLM are automated and limited in scope. They do not constitute a security certification or guarantee that the software is safe, error-free, or free from malicious code, vulnerabilities, compromised dependencies, or prompt-injection risks.
Review the source code, permissions, dependencies, and configuration before installing or running any third-party skill. Use is at your own risk. To the maximum extent permitted by applicable law, SkillsLLM is not liable for losses arising from third-party software.
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
Code intelligence for agents: find the code that matters and keep your context window and tokens lean.
Language: English · 简体中文 · 日本語 · 한국어
mcp-name: io.github.morluto/leantokenInstall · Why LeanToken · Tools · CLI · How it works · Docs
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.
Add LeanToken to Claude Code, Cursor, OpenCode, Codex, Gemini CLI, or Antigravity:
npx leantoken setup
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.
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
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 an application-data directory named by
version and full BLAKE3 digest, so clients launch one verified process directly,
without persistent npm/Node wrappers. Different source builds of one version
can coexist. setup --refresh --private-runtime pins the current exact artifact;
other referenced artifacts stay usable. 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 artifacts 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
LeanToken works best as a small evidence loop rather than a one-shot repository dump:
context and plan_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.receipt_id on the
next context call, or pass returned fragment hashes as known_hashes. The
response reports exact and overlapping omissions instead of silently
charging the same evidence again.investigation workflow and
provide only directly observed failure_traces, paths, symbols, or test
intent in workflow_evidence. Follow with exact search, outline, or
read calls for the owners the evidence identifies.review workflow with base_revision set to
BASE..HEAD and strict_changed_paths: true. Request a handoff when
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.
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.
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.
| Tool | Purpose |
|---|---|
leantoken.context |
Default materialized first call for autonomous broad triage; optional preview for human or control-plane review. |