lean-ctx

lean-ctx is a skill for Claude Code, Codex from yvgude/lean-ctx. It costs 55 tokens per session (1,037 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,879 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,037 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.01037
Opus 5.5 $0.00022 $0.00415
Sonnet 5.5 $0.00011 $0.00207
Haiku 4.5 $0.00006 $0.00104

Measured 12d ago against content hash 4bc69f7578cf, 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 12d ago.

The scan reads SKILL.md. This mod also ships 3 executable files (claude_mod/cockpit.d.ts, claude_mod/register.ts, skill_install.sh), 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 · 82 lines

How it starts

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

LeanCTX — Context Gateway for AI Systems

Control what your AI can see. LeanCTX Engine provides local context selection, supported access and content controls, and evidence of observed context operations for existing agents: Select → Control → Prove. 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 ctx_patch, or the host's native edit tool
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"

Do not read or search through ctx_shell (cat, sed -n, grep, rg): that bypasses the read cache and symbol index. Use ctx_read / ctx_search.

Read the full file on GitHub · 82 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. 12d ago Changed · +6 lines 4bc69f7578cf
  2. 13d ago Changed · +4 lines · +13 tokens per session de55dac0a4cc
  3. 1mo 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,879 stars, last pushed yesterday), licensed Apache-2.0. It adds 55 tokens to every session and 1,037 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

Other skills, from other repositories

data-sync

Sync and archive data from messaging platforms (WhatsApp, Discord, Slack, Twitter/X, Google) into Moltis memory as daily digest summaries. Orchestrates crawl tools and writes structured markdown to the memory system.

moltis-org/moltis · 46 tokens

karpathy-llm-wiki

Use when building or maintaining a personal LLM-powered knowledge base. Triggers: ingesting sources into a wiki, querying wiki knowledge, linting wiki quality, 'add to wiki', 'what do I know about', or any mention of 'LLM wiki' or 'Karpathy wiki'.

Astro-Han/karpathy-llm-wiki · 67 tokens

ax-rust-agent-context

Use when writing Rust code with axllm for deciding between context maps, trajectory context policy, offline optimization (ACE/GEPA), and memory recall for long-context agents.

ax-llm/ax · 43 tokens

memory-systems

Guides implementation of agent memory systems, compares production frameworks (Mem0, Zep/Graphiti, Letta, LangMem, Cognee), and designs persistence architectures for cross-session knowledge retention. Use when the user asks to "implement agent memory", "persist state across sessions", "build knowledge graph for…

LuizEduPP/Rememb · 115 tokens

experience-record

Record lessons learned and implementation experiences for future reuse. Use when a task reveals a durable pattern, important decision, or debugging lesson worth preserving.

LuizEduPP/Rememb · 31 tokens

ax-rust-agent-memory-skills

Use when writing Rust code with axllm for agent memory, recall callbacks, dynamic skill discovery, loaded-skill state, and used-skill tracking.

ax-llm/ax · 41 tokens