context-compression
Skill4 starsChanged 8 months agoMITView on GitHub
When conversation context is getting long, when approaching token limits, when the user says "compress," "summarize context," "too long," "running out of context," "compact," or when you notice degraded performance due to context length. Implements a 3-layer compression pipeline (MicroCompact, AutoCompact, Full Compact).
16 other projects use a version of this.
Adopted by
Most recently taken up by
- SkotAlexsander/skillstheir own version, first seen Sep 16, 2026
- sharp-skills/skillstheir own version, first seen Sep 12, 2026
- docxology/templatetheir own version, first seen Aug 29, 2026
- dzhokhov/markdown-agent-vault-rutheir own version, first seen Aug 12, 2026
- Archive228/lab-skillstheir own version, first seen Aug 12, 2026
- muratcankoylan/Agent-Skills-for-Context-Engineeringtheir own version, first seen Aug 10, 2026
Used with
Projects with it also use bdi-mental-states, hosted-agents and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Downey6689Skillbdi-mental-states
Transforms external RDF context into BDI mental states. Invoke when modeling beliefs, desires, and intentions.
Also in 3 projects that use this
Downey6689Skillhosted-agents
Guidance for hosted/sandboxed agents. Invoke when running background agents in isolated VMs or multi-client setups.
Also in 3 projects that use this
Svenja-devSkillproject-development
Design and build LLM-powered projects from ideation through deployment. Use when starting new agent projects, choosing between LLM and traditional approaches, or structuring batch processing pipelines.
Also in 3 projects that use this
- +1 more from Downey6689
Other versions16 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 16
- muratcankoylan/Agent-Skills-for-Context-Engineering★ 18ksame name
- Fandry96/k3-agentic-skills★ 27same name
- docxology/template★ 20same name
- xfstudio/skills★ 9same name
- Archive228/lab-skills★ 8same name
- rohunvora/my-claude-skills★ 6same name
- yeaight7/agent-powerups★ 6same name
- r600a-code/context-compression-skills★ 4same name
- hmzainjamil/claude-ai-skills★ 3same name
- ai4brands-design/claude-skills★ 2same name
6 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository21 other files it gives its agents.
- docs/llms.txtllms.txt
- llms.txtllms.txt
- anti-distillationSkill
- autodreamSkill
- batch-modeSkill
- bughunterSkill
- codebase-insightSkill
- code-reviewSkill
- coordinator-modeSkill
- effort-estimateSkill
- frustration-awareSkill
- kairos-sessionSkill
- magic-docsSkill
- pr-autofixSkill
- prompt-speculationSkill
- security-reviewSkill
- session-reviewSkill
- stuck-recoverySkill
- thinkbackSkill
- ultraplanSkill
- undercover-modeSkill
The file
We split this skill into the rules it gives an agent
12 rules. 0 are common, 12 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 14 edited versions we read keep these.
12
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 19
Before a complex multi-step task that needs headroom
- Distinctive: line 24
Goal: Remove noise without losing any information.
- Distinctive: line 29
Remove failed attempts that were superseded by successful ones
- Distinctive: line 31
Remove conversational filler ("Let me think about this...", "Great question...")
- Distinctive: line 81
No code snippets — just file paths
- Distinctive: line 82
No exploration history — just conclusions
- Distinctive: line 89
When triggered, assess which layer is appropriate:
- Distinctive: line 101
After compression, present the compressed context to the user:
- Distinctive: line 120
Never compress away: user decisions, architectural choices, active task state, error patterns that haven't been resolved
- Distinctive: line 121
Always compress away: greetings, confirmations, exploration that led nowhere, superseded attempts
- Distinctive: line 122
When in doubt, keep it in Layer 1/2 and let the user decide
- Distinctive: line 123
After compression, re-read any critical files to refresh your understanding
“Common” is measured: kept by at least 6 in 10 of the 14 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Context Compression — 3-Layer Pipeline
You are a context compression engine. When conversations grow long, you systematically reduce context size while preserving all decision-critical information.
When To Trigger
- Conversation exceeds ~50 turns
- User mentions context is getting long or responses are degrading
- You notice you're losing track of earlier decisions
- User explicitly asks for compression
- Before a complex multi-step task that needs headroom
The Three Layers
Layer 1: MicroCompact (Light Touch)
Goal: Remove noise without losing any information.
Do this:
- Strip redundant confirmations ("Yes, that looks good", "Sure, I'll do that")
- Collapse repeated tool outputs into summaries ("Read 12 files — all TypeScript, avg 200 lines")
- Remove failed attempts that were superseded by successful ones
- Collapse verbose error messages into one-line summaries
- Remove conversational filler ("Let me think about this...", "Great question...")
Compression ratio: ~30-40% reduction Information loss: Zero
Layer 2: AutoCompact (Structural)
Goal: Restructure retained information for density.
Do this:
- Convert sequential discoveries into a structured summary:
## What We Know - The API uses Express with 14 endpoints - Auth is JWT-based, tokens expire in 24h - Database is Postgres via Drizzle ORM - Tests use Vitest, 73% coverage ## Decisions Made - Using server components by default - API routes return { data } or { error } - Commit style: conventional commits ## Current Task - Building the user dashboard - Blocked on: auth middleware refactor - Next step: implement session management - Group related file reads into summaries
- Merge multiple rounds of the same type of work into outcomes
- Replace code snippets with references ("see src/auth.ts:45-67")
Compression ratio: ~60-70% reduction Information loss: Minimal — details available via file re-reads
Layer 3: Full Compact (Aggressive)
Goal: Maximum compression. Only essential state survives.
Do this:
- Reduce to three sections only:
## State [What exists right now — files created/modified, current branch, build status] ## Intent [What the user wants to achieve — the goal, not the steps] ## Constraints [Critical decisions, patterns, rules that must be followed] - Everything else is discardable and can be re-derived from the codebase
- No code snippets — just file paths
- No exploration history — just conclusions
Compression ratio: ~85-90% reduction Information loss: Moderate — but all recoverable from codebase
How To Apply
When triggered, assess which layer is appropriate:
| Situation | Layer |
| "Getting long but still fine" | Layer 1 |
| "Losing context, need clarity" | Layer 2 |
| "About to hit limits, need maximum headroom" | Layer 3 |
| User says "compact" or "compress" | Layer 2 (default) |
| User says "hard compress" or "nuke context" | Layer 3 |
Output
After compression, present the compressed context to the user:
Context compressed (Layer [N]):
- Before: ~[X] turns, ~[Y]k tokens (estimated)
- After: ~[Z]k tokens (estimated)
- Preserved: [list key items kept]
- Dropped: [list what was removed]
Compressed context follows:
---
[compressed context block]
---
Does this capture everything important? Anything I should keep that I dropped?Rules
- Never compress away: user decisions, architectural choices, active task state, error patterns that haven't been resolved
- Always compress away: greetings, confirmations, exploration that led nowhere, superseded attempts
- When in doubt, keep it in Layer 1/2 and let the user decide
- After compression, re-read any critical files to refresh your understanding
- Flag if compression might lose something important: "I'm about to drop [X] — should I keep it?"
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

