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.
Borrowing it
Nothing to install: this file belongs to yvgude/lean-ctx. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/yvgude/lean-ctx/main/.windsurfrulesgit clone --depth 1 https://github.com/yvgude/lean-ctxWrote 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.
[](https://agentmods.dev/rules/yvgude/lean-ctx/windsurfrules)<a href="https://agentmods.dev/rules/yvgude/lean-ctx/windsurfrules"><img src="https://agentmods.dev/badge/rules/yvgude/lean-ctx/windsurfrules.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00297 | $0.00297 |
| Opus 5 | $0.00148 | $0.00148 |
| Sonnet 5 | $0.00059 | $0.00059 |
| Haiku 4.5 | $0.00030 | $0.00030 |
Grade A, and why
windsurfrules scanned grade A with 0 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 today.
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.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
What it actually says
lean-ctx — Token Optimization
MANDATORY: For every file read, code search, shell command, or directory listing you MUST call the matching lean-ctx ctx_* MCP tool — never a built-in/native tool, and never answer a code question from memory without first calling one. This is not optional. If you catch yourself about to use a built-in Read/Grep/Shell/ls, STOP and call the ctx_* equivalent instead.
lean-ctx is configured as an MCP server. Always use lean-ctx MCP tools instead of built-in tools:
- Read files →
ctx_read(path, mode)instead of built-in Read - Shell commands →
ctx_shell(command)instead of built-in Shell - Search code →
ctx_search(pattern, path)instead of built-in Grep - List directories →
ctx_tree(path, depth)instead of ls/find
ctx_read modes: auto, anchored (edit via ctx_patch), full, map, signatures, diff, task, reference, aggressive, entropy, lines:N-M.
Preferred workflow control: ctx_workflow (state + evidence + tool gating).
Fallback only if MCP is unavailable: prefix with lean-ctx -c:
lean-ctx -c git statuslean-ctx -c cargo testlean-ctx -c npm install
Write, StrReplace, Delete have no lean-ctx equivalent — use them normally.
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.
- today First seen · 22 lines · 297 tokens per session scan A 79f7c66acaed
windsurfrules is a cursor rule published in the GitHub repository yvgude/lean-ctx (3,728 stars, last pushed today), licensed Apache-2.0. It adds 297 tokens to every session, about $0.0015 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-07.
Other cursor rules, from other repositories
honcho_rules
Honcho persistent memory — capture every conversation, recall past context, and build a growing model of the user. Activates on every conversation.
nauro-adopt
Seeds Nauro's project store from an existing repo. Use after nauro adopt has run locally. On filesystem-capable surfaces, reads docs (README, manifests, ADRs, Memory-Bank) for rationale and inspects code, config, tests, lockfiles, and recent git history for evidence, then surfaces targeted probes that turn evidence…
nauro-context
Writes durable shared context into Nauro's project store so other agents (a later session or a parallel one) can discover and pull it, finds and reads context another agent left, or captures a resumable brief so your own next session in this environment picks up cleanly. Three modes. Author writes a shared brief for…
greedy-token
Greedy token — MCP greedy-token before Grep/Shell.
memforge-auto-recall
Rules that make an AI assistant automatically retrieve and save team memories during conversations.
compendium
Prefer the Compendium MCP gateway to shrink noisy/large context before pasting it into the conversation.