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.
npx agentmods add rules/yvgude/lean-ctx/compression-safetygit clone --depth 1 https://github.com/yvgude/lean-ctxWhat 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 | $0.00399 | $0.00399 |
| Opus 5 | $0.00199 | $0.00199 |
| Sonnet 5 | $0.00080 | $0.00080 |
| Haiku 4.5 | $0.00040 | $0.00040 |
Grade A, and why
compression-safety 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 2d 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.
What it actually says
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:
LEAN_CTX_DISABLED=1 git restore --source=HEAD -- <file>
File restoration commands
Always use LEAN_CTX_DISABLED=1 when restoring files from git:
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:
LEAN_CTX_DISABLED=1 git restore --source=HEAD -- <file>- Use
LEAN_CTX_DISABLED=1 sed -i '' 's/old/new/g' <file>for the edit - 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 showoutput to a file withoutLEAN_CTX_DISABLED=1 - Trust
wc -loutput that's significantly lower than expected - Commit files containing
[lean-ctx: omittedor--- lean-ctx:text
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.
- 2d ago First seen · 48 lines · 399 tokens per session scan A bdd0c6cff805
compression-safety is a cursor rule published in the GitHub repository yvgude/lean-ctx (3,696 stars, last pushed today), licensed Apache-2.0. It adds 399 tokens to every session, about $0.0020 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-08-30.
Other cursor rules, from other repositories
greedy-token
Greedy token — MCP greedy-token before Grep/Shell.
cursor
You are working on the checkout service. Preserve transaction integrity and auditability.
beanstalk-deploy
Robust deployment patterns for Elastic Beanstalk with GitHub Actions, Pulumi, and edge case handling.
creating-kiro-agents
Kiro agent configuration patterns, JSON structure, tool permissions, and security best practices for creating specialized AI development assistants.
archcore-files
Enforce MCP-only operations when working with .archcore/ files.
frontend-architecture
Vite + React SPA architecture - directory layout, providers, bundle splitting. Tailwind styling in tailwind.mdc.