
Context Compression Strategies
Lets an agent compress long session history into summaries that keep files, decisions, and next steps
- Stars
- 18,282
- Licence
- MIT
- Files
- 4 files
What it does
When an AI agent works on a long task, its conversation history can outgrow its context window. This skill teaches the agent how to shrink that history without losing what matters: which files were changed, what decisions were made, and what comes next. It recommends structured summaries with fixed sections, merging new summaries into existing ones instead of rewriting everything, and judging compression by the total tokens needed to finish a task rather than tokens per request. It also includes a Python evaluator that generates probe questions to test whether a compressed summary still preserves key facts.
Great for
- Developers building or running long coding agent sessions that lose track of files they edited
- Teams designing handoff summaries between agents or sessions
- People building evaluation pipelines to compare summarization methods
Skip it if
- Simple short chats where compression is unnecessary; the guidance adds overhead without benefit
- Production quality checks relying on the bundled evaluator as-is, because its LLM judge calls are stubbed for demonstration and must be implemented before real use
- Long-term memory across separate sessions; the SKILL.md directs that to a different skill (memory-systems)
Try asking
- “Summarize this coding session so a new agent can continue, listing modified files and open decisions”
- “Our agent keeps forgetting which files it changed. Design a structured summary template for it”
- “Compare these two compression strategies on a sample conversation using the probe evaluator”
- “Set up a sliding window trigger for compressing our coding agent's history”
Install in 3 steps
- 1
Download the skill
The ZIP contains the 4 original files, the MIT licence and an attribution note.
context-compression.zip - 2
Add it to your agent
Claude Code (all projects)
mkdir -p ~/.claude/skills && unzip context-compression.zip -d ~/.claude/skills/Claude Code / Agent SDK (this project only)
mkdir -p .claude/skills && unzip context-compression.zip -d .claude/skills/Claude apps (web/desktop): Settings → Capabilities → Skills → Upload skill, and choose the ZIP.
- 3
Ask for the task
No special command needed — the agent reads the skill's description and loads it when your request matches. Try one of the prompts above.
Get better results
- Keep the artifact trail (file paths, function names, error messages) in a separate index or file-state tracker rather than relying only on the summarizer.
- Measure success by re-fetching frequency and total tokens per completed task, not by the smallest summary.
- Read scripts/compression_evaluator.py before running it, and replace the stubbed judge with your own model calls if you need real scores.
What's inside
- references/evaluation-framework.md
- scripts/compression_evaluator.py
- SKILL.md
- tests/test_compression_evaluator.py
Redistributed unmodified from muratcankoylan/Agent-Skills-for-Context-Engineering under the MIT licence. The assessment was drafted with AI from the skill's files on 2026-10-29. Skills can instruct your agent to run code — read SKILL.md and any scripts before installing.