Cursor rules · yvgude/lean-ctx
1 Cursor rule file from yvgude/lean-ctx: compression-safety.
Template by yvgude
Install
Works with Cursor. Read the repository before you give any tool access to your data.
curl -fsSL https://raw.githubusercontent.com/yvgude/lean-ctx/main/.cursor/rules -o rules
Read it and adapt it to your project before use.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: code-generation
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
What's in it
Cursor project rules (.cursor/rules/*.mdc): instructions Cursor applies when it edits matching files.
- For
- Cursor
- File
.cursor/rules/compression-safety.mdc
First lines (shown under the repo's Apache-2.0 license)
# Compression Safety — Prevent lean-ctx Marker Corruption ## The problem lean-ctx shadow-mode hooks compress file reads. If an edit tool (StrReplace, Write) reads through the hook, it sees compressed content and writes markers like `[lean-ctx: omitted N lines]` back to disk. This silently destroys file content. ## Rules for ALL agents ### Never write compressed content to files The pre-commit hook blocks commits containing `[lean-ctx: omitted` markers. If your commit is blocked, the file was corrupted. Fix: ```bash LEAN_CTX_DISABLED=1 git restore --source=HEAD -- <file> ``` ### File restoration commands Always use `LEAN_CTX_DISABLED=1` when restoring files from git: ```bash LEAN_CTX_DISABLED=1 git restore --source=<commit> -- <file> LEAN_CTX_DISABLED=1 git checkout <commit> -- <file> ``` NEVER use `git show commit:file > file` — the shell redirect writes compressed output. ### When StrReplace produces unexpected results If a file shrinks after StrReplace or contains `[lean-ctx:` text: 1. `LEAN_CTX_DISABLED=1 git restore --source=HEAD -- <file>` 2. Use `LEAN_CTX_DISABLED=1 sed -i '' 's/old/new/g' <file>` for the edit 3. Verify: `wc -l` + `rg '[lean-ctx:' <file>` must show 0 ### Environment variable: `LEAN_CTX_DISABLED` Set `LEAN_CTX_DISABLED=1` to bypass ALL lean-ctx compression for a command. This is the escape hatch for any compression-related issue. ## NEVER do - Pipe `git show` output to a file without `LEAN_CTX_DISABLED=1` - Trust `wc -l` output that's significantly lower than expected - Commit files containing `[lean-ctx: omitted` or `--- lean-ctx:` text
Signals
- Stars
- 3,896
- Forks
- 356
- Open issues
- 9
- Last commit (this folder)
- Jul 28, 2026 (3 months ago)
- Last release
- Oct 11, 2026 (17 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- Apache-2.0
- Repository
- github.com/yvgude/lean-ctx
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from yvgude
- 0.847score
lean-ctx
yvgude
Use LeanCTX Context Gateway tools to select task-relevant code context, apply supported controls, reuse local knowledge and inspect recorded evidence.
SkillAFreshness: A★ 3.9KClaude Code +9 - 0.847score
lean-ctx-review
yvgude
Review how the lean-ctx ctx_* MCP tools performed in the current session and file upstream issues for confirmed problems.
SkillAFreshness: A★ 3.9KClaude Code +9 - 0.625score
AGENTS.md · yvgude/lean-ctx
yvgude
AGENTS.md from yvgude/lean-ctx: 250 lines covering Mandatory Routing Decision (Direct or Swarm), Integration Mode: Replace, Subagent Compatibility (Cursor /…
TemplateAFreshness: A★ 3.9KCodex +5
Cite this page
Cursor rules · yvgude/lean-ctx. Agent Mart. https://agentmart.dev/templates/yvgude-lean-ctx-cursor-rules (last updated 2026-10-24)