lean-ctx

lean-ctx is a skill for Claude Code, Codex from yvgude/lean-ctx. It costs 55 tokens per session (1,076 once invoked), scanned C, original, Apache-2.0.

A local context toolkit for AI coding agents. It helps an agent choose, inspect, reuse, and recover the files and command output it needs before generating an answer or making a change.

In plain words
What is it for?
Use it to read and search files, browse directories, run shell commands, inspect call relationships, manage sessions, compose context, and apply patches.
Why use it?
It gives agents structured ways to explore a codebase and manage the information they use, which can make work across files easier to inspect and repeat.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: mentions Claude Code.

Good fit Use it to read and search files, browse directories, run shell commands, inspect call relationships, manage sessions, compose context, and apply patches.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/yvgude/lean-ctx/templates
About the project

LeanCTX is a local Rust program that controls the repository context an AI coding agent receives, including selecting, compressing, remembering, and tracking information. Developers use it alongside coding agents to reduce repeated context and manage what those agents read and execute, while the catalogue entries provide related rules, skills, and instructions.

yvgude/lean-ctx · 3,967 stars · on GitHub · leanctx.com

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add yvgude/lean-ctx --skill templates
Clone the repo
git clone --depth 1 https://github.com/yvgude/lean-ctx

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for lean-ctx

README.md
[![agentmods](https://agentmods.dev/badge/skills/yvgude/lean-ctx/templates/github.svg)](https://agentmods.dev/skills/yvgude/lean-ctx/templates)
Your own site
<a href="https://agentmods.dev/skills/yvgude/lean-ctx/templates"><img src="https://agentmods.dev/badge/skills/yvgude/lean-ctx/templates/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for lean-ctx

Your own site · 80×15
<a href="https://agentmods.dev/skills/yvgude/lean-ctx/templates"><img src="https://agentmods.dev/badge/skills/yvgude/lean-ctx/templates.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,076 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector warn 7 Sept 2026
SkillSpector: 2 findings, up to high

These are SkillSpector’s own severities. On a checked sample its high-severity flags on skills were ~96% false positives — a documented command, a public API, a “never do X” rule — so we show them as a caution to read, not a verdict. Why →

  • high Tool Misuse · line 11
    Tool calls are chained to bypass individual safety checks or escalate capabilities beyond what any single tool call would allow.
    Fix: Limit tool chaining depth and validate the output of each tool before passing it to the next. Require explicit user approval for multi-step chains.
  • low Supply Chain · line 11
    Remote code is downloaded and executed. This bypasses code review and could introduce malicious code.
    Fix: Avoid downloading and executing remote scripts. Use trusted packages from PyPI/npm. If remote fetch is required, verify checksums and use HTTPS.
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00055 $0.01076
Opus 5.5 $0.00022 $0.00430
Sonnet 5.5 $0.00011 $0.00215
Haiku 4.5 $0.00006 $0.00108

Measured 7d ago against content hash 56d520ed54b4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

lean-ctx scanned grade C with 2 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 7d ago.

The scan reads SKILL.md. This mod also ships 4 executable files (claude_mod_jobs/register.ts, claude_mod/cockpit.d.ts, claude_mod/register.ts, …), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Downloads and executes remote codehighSupply chain

curl | sh runs whatever the server returns today, which is not necessarily what it returned when this was reviewed.

which lean-ctx || curl -fsSL https://raw.githubusercontent.com/yvgude/lean-ctx/main/skills/lean-ctx/scripts/install.sh | bash

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

which lean-ctx || curl -fsSL https://raw.githubusercontent.com/yvgude/lean-ctx/main/skills/lean-ctx/scripts/install.sh | bash
rust/src/templates/SKILL.md · 84 lines

How it starts

The opening of the file, as written. The whole thing — 84 lines — stays where its author put it; the contents beside it link to each section on GitHub.

LeanCTX — Context Gateway for AI agents

Less context. More intelligence. LeanCTX provides local context selection, supported access and content controls, and evidence of observed context operations for existing agents: Select → Control → Learn → Prove. Learn means local task and knowledge continuity, not model training. Recovery depends on source or archive availability and access permissions. LeanCTX | SDK is the separate integration surface for applications.

lean-ctx shapes context before it reaches you: cached reads, compressed shell output, focused search, recovery to exact source. Two rules beat every detail:

  1. Fewer round trips beat smaller outputs. One call that answers the question is cheaper than three small ones. Never add a call just to save a few hundred tokens.
  2. Never wait by polling. Do not loop sleep + status checks (see below).

Intent → tool

You want to… Call
Understand how something works (unknown location) ctx_compose(task) — ranked files + source in one call; use it FIRST instead of search→read→read
Find the exact definition of a symbol ctx_search(action="symbol", name=…)
Find code by meaning ctx_search(action="semantic", query=…)
Find a text/regex pattern ctx_search(pattern=…, path=…)
Who calls X / what calls X makes `ctx_callgraph(action="callers"
Read a file you will edit ctx_read(path, mode="anchored") → edit with the host's native edit tool, or ctx_call(name="ctx_patch", arguments={…})
Read a file only for context `ctx_read(path, mode="signatures"
Re-check a file after editing ctx_read(path, mode="diff")
Run a command (build, test, git, …) ctx_shell(command) — output is compressed
List files / directory shape ctx_glob(pattern) / ctx_tree(path, depth)
Remember across sessions `ctx_session(action="finding"

Read the full file on GitHub · 84 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 7d ago Changed 56d520ed54b4
  2. 26d ago Changed 238de3cbf947
  3. 1mo ago Changed · +1 lines d8387e920c3a
  4. 1mo ago Changed · +1 lines e0e832439ea0
  5. 1mo ago Changed · +6 lines 4bc69f7578cf
  6. 1mo ago Changed · +4 lines · +13 tokens per session de55dac0a4cc
  7. 3mo ago First seen · 72 lines · 42 tokens per session scan C 31febfba9276

Subscribe to this mod's changes

lean-ctx is a skill published in the GitHub repository yvgude/lean-ctx (3,967 stars, last pushed 3d ago), licensed Apache-2.0. It adds 55 tokens to every session and 1,076 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it C with 2 findings (downloads and executes remote code, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

lean-ctx compared with skills from other repositories

lean-ctx next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
lean-ctxyvgude/lean-ctxSkill4.0k3d agoApache-2.0C55Claude Code, Codex
knowledge-basePinvou/pinvou-agentSkill3.0ktodayMITA0Claude Code, Codex
notesPinvou/pinvou-agentSkill3.0ktodayMITA0Claude Code, Codex
data-syncmoltis-org/moltisSkill3.0k1mo agoMITA46Claude Code, Codex
semantic-contracts-installerLLM-Coding/Semantic-AnchorsSkill549todayApache-2.0A132Claude Code, Codex
karpathy-llm-wikiAstro-Han/karpathy-llm-wikiSkill2.8k4mo agoMITA67Claude Code, Codex
post-cortex-memoryjulymetodiev/post-cortexSkill23yesterdayMITA194Claude Code