lean-ctx

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

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.

agentmods
npx agentmods add skills/yvgude/lean-ctx/templates
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.

Per session 42 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 898 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 findings. Scan, not verified.
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 $0.00042 $0.00898
Opus 5 $0.00021 $0.00449
Sonnet 5 $0.00008 $0.00180
Haiku 4.5 $0.00004 $0.00090

Measured yesterday against content hash 31febfba9276, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 yesterday.

The scan reads SKILL.md. This mod also ships 1 executable file (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 · 72 lines

How it starts

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

lean-ctx — Local Context SDK for AI Agents

Setup

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

Tool Visibility Profiles

Profile Tools advertised
Lean (default, unpinned) ctx_read, ctx_shell, shell, ctx_search, ctx_glob, ctx_tree, ctx_session, ctx_compose, ctx_callgraph, ctx_patch*, ctx_call, ctx_expand
minimal ctx_read, ctx_shell, ctx_search, ctx_glob, ctx_tree; ctx_call is also advertised as the fallback invoker
standard Minimal + ctx_compose, ctx_explore, ctx_knowledge, ctx_session, ctx_callgraph, ctx_graph, ctx_delta, ctx_execute, ctx_expand, ctx_overview, ctx_url_read, ctx_patch; ctx_call is also advertised as the fallback invoker
power Full public tool registry

* Lean hides ctx_patch for clients with a reliable native editor. Disabled tools, role policy, and client compatibility can further narrow every profile.

Shell Hook (use instead of raw exec)

lean-ctx -c "git status"
lean-ctx -c "cargo test"
lean-ctx -c "npm install"
lean-ctx ls src/

ctx_read Modes

Mode When
anchored Files you will edit (full text + N:hh| anchors for ctx_patch)
full Verbatim cached read
map Context-only (deps + exports)
signatures API surface only
diff After edits (changed lines)
aggressive Large files, syntax-stripped; JSON arrays row-deduped (lossless)
entropy Shannon filtering
task Task-relevant lines
lines:N-M Specific range
auto System selects optimal

Re-reads may use the local cache. Set fresh=true to bypass it. Redundant JSON (arrays of like objects) is crushed losslessly into a compact _defaults + per-row form; if a slice was dropped, recover it with ctx_expand(id, json_path=… | search=…).

File Editing

Read the full file on GitHub · 72 lines

Files

What ships with it

6 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

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. yesterday 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,681 stars, last pushed yesterday), licensed Apache-2.0. It adds 42 tokens to every session and 898 once invoked, about $0.0002 per session on Opus 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

Agent Browser Automation

Fast Rust-based headless browser automation CLI with Node.js fallback for AI agents, featuring navigation, clicking, typing, snapshots, and structured commands optimized for agent workflows.

PramodDutta/qaskills · 37 tokens

codesynapse-cli

Use this skill to answer codebase architecture questions, trace dependencies, find callers/callees, calculate blast radius, and explore the code graph. ACTIVATE when the user asks "how does X work", "what handles Y", "where is Z defined", "explain the mechanism", "who calls", "blast radius", "shortest path", "trace…

sohilladhani/codesynapse · 182 tokens

feishu

Work with Feishu or Lark bots, docs, sheets, bitables, approval flows, and OpenAPI/MCP setup without hardcoding credentials.

Hmbown/CodeWhale · 33 tokens

interview

Ask one useful structured question at a time only when material product/implementation choices are genuinely missing; remember answers and produce a brief/spec. Discoverable facts should be investigated instead of asked.

Hmbown/CodeWhale · 40 tokens

migrate-better-result-3

Migrate a TypeScript codebase from better-result 2.x to 3.0. Use when upgrading better-result across the TaggedError syntax, removed Result serialization helpers, recovery inference, matching, or retry APIs.

dmmulroy/better-result · 52 tokens

browse-and-evaluate

Use when exploring the ai-agent-skills catalog to find, compare, and evaluate skills before installing. Always use --fields to limit output size and --dry-run before committing to an install.

MoizIbnYousaf/Ai-Agent-Skills · 43 tokens