lean-ctx: Cursor rule for Windsurf

.windsurfrules

windsurfrules is a cursor rule for Windsurf from yvgude/lean-ctx. It costs 280 tokens per session, scanned A, original, Apache-2.0.

A set of mandatory instructions that makes a coding agent use lean-ctx tools to read files, search code, run commands, and list folders instead of its built-in tools.

In plain words
What is it for?
Controlling how an agent inspects a codebase and runs development commands while reducing unnecessary context use.
Why use it?
It prevents the agent from working from incomplete context or using unapproved tools. It also defines a fallback command when the MCP server is unavailable.

Cursor rule for Windsurf

Written for Windsurf: a Windsurf rule.

This is yvgude/lean-ctx's own configuration. It tells Windsurf how to work on lean-ctx itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything lean-ctx configures →

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,931 stars · on GitHub · leanctx.com

Reuse

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.

Copy the file
curl -O https://raw.githubusercontent.com/yvgude/lean-ctx/main/.windsurfrules
Clone the repo
git clone --depth 1 https://github.com/yvgude/lean-ctx

Made for: Windsurf.

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 windsurfrules

README.md
[![agentmods](https://agentmods.dev/badge/rules/yvgude/lean-ctx/windsurfrules/github.svg)](https://agentmods.dev/rules/yvgude/lean-ctx/windsurfrules)
Your own site
<a href="https://agentmods.dev/rules/yvgude/lean-ctx/windsurfrules"><img src="https://agentmods.dev/badge/rules/yvgude/lean-ctx/windsurfrules/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 windsurfrules

Your own site · 80×15
<a href="https://agentmods.dev/rules/yvgude/lean-ctx/windsurfrules"><img src="https://agentmods.dev/badge/rules/yvgude/lean-ctx/windsurfrules.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 280 This file is loaded in full into every session.
When invoked 280 The same file — it is already loaded in full.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00280 $0.00280
Opus 5.5 $0.00112 $0.00112
Sonnet 5.5 $0.00056 $0.00056
Haiku 4.5 $0.00028 $0.00028

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

Security

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 7d ago.

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.

.windsurfrules · 21 lines

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.

Fallback only if MCP is unavailable: prefix with lean-ctx -c:

  • lean-ctx -c git status
  • lean-ctx -c cargo test
  • lean-ctx -c npm install

Write, StrReplace, Delete have no lean-ctx equivalent — use them normally.

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 · -1 lines · -17 tokens per session 709353b0e432
  2. 2mo ago First seen · 22 lines · 297 tokens per session scan A 79f7c66acaed

Subscribe to this mod's changes

windsurfrules is a cursor rule published in the GitHub repository yvgude/lean-ctx (3,931 stars, last pushed yesterday), licensed Apache-2.0. It adds 280 tokens to every session, about $0.0011 per session on Opus 5.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.

Related

windsurfrules compared with cursor rules from other repositories

windsurfrules next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
windsurfrulesyvgude/lean-ctxCursor rule3.9kyesterdayApache-2.0A280Windsurf
cdvazank1/cdvCursor rule43mo agoMITA407Cursor
frontend-csstomasz-tomczyk/critCursor rule1.3k2d agoMITA0Cursor
roslyn-mcp-overviewVuDZ/RoslynMcpServerCursor rule8yesterdayMITA3,629Cursor
roslyn-mcp-pitfallsVuDZ/RoslynMcpServerCursor rule8yesterdayMITA3,053Cursor
roslyn-mcp-docs-agentsVuDZ/RoslynMcpServerCursor rule8yesterdayMITA707Cursor
roslyn-mcp-version-bumpVuDZ/RoslynMcpServerCursor rule8yesterdayMITA524Cursor