context-compression
Skill by muratcankoylan
Guides long-running AI agent sessions through context compression, structured summaries and durable handoff notes. It is written for agents that outgrow their context window and must keep track of files, decisions, risks and next steps.
Install context-compression
Built from the published package, never by AI.
git clone --depth 1 https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering /tmp/Agent-Skills-for-Context-Engineering && mkdir -p ~/.claude/skills && cp -r /tmp/Agent-Skills-for-Context-Engineering/skills/context-compression ~/.claude/skills/context-compressionRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering /tmp/Agent-Skills-for-Context-Engineering && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/Agent-Skills-for-Context-Engineering/skills/context-compression ~/.gemini/antigravity-cli/skills/context-compressionAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Step-by-step: install context-compression in Antigravity CLI
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill describes how to compress the conversation history of long-running agent sessions when they exceed context window limits. It argues that the right target is tokens per task, not tokens per request, because lost file paths and decisions force the agent to re-read files and re-derive conclusions. It covers three approaches: anchored iterative summarization, opaque compression and regenerative full summaries.
It also provides structured summary templates with sections for session intent, files modified, decisions, current state and next steps. The skill recommends a separate artifact index, probe-based evaluation instead of metrics like ROUGE, and a three-phase workflow for large codebases. It is aimed at developers building or debugging coding and migration agents.
Written from the project's SKILL.md and checked against it.
What it can do
- Anchored iterative summarizationKeeps a persistent structured summary and merges only newly truncated content into it.
- Opaque compressionProduces highly compressed representations for short sessions where re-fetching is cheap.
- Regenerative full summaryRebuilds detailed structured summaries on each compression trigger for human review.
- Structured summary sectionsProvides templates for session intent, files modified, decisions, current state and next steps.
- Compression trigger strategiesCompares fixed threshold, sliding window, importance-based and task-boundary triggers.
- Probe-based evaluationUses recall, artifact, continuation and decision questions to test what survived compression.
- Six-dimension scoringScores accuracy, context awareness, artifact trail, completeness, continuity and instruction following.
- Three-phase compression workflowMoves a large codebase through research, planning and implementation phases within budget.
Try asking
- Summarize this session into intent, files modified, decisions and next steps.
- Set up anchored iterative summarization for my long coding session.
- Write probe questions to check whether my compressed summary kept the key files.
Good to know
- Opaque compression cannot be checked without probe-based evaluation.
- The benchmark figures in the source are specific to its tests, not universal.
- Compression that drops file paths or decisions can cause costly re-fetching.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: skills/context-compression/SKILL.md, skills/context-compression/scripts/compression_evaluator.py, skills/context-compression/tests/test_compression_evaluator.py. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md18 KB -
references/evaluation-framework.md8 KB -
scripts/compression_evaluator.py30 KB -
tests/test_compression_evaluator.py2 KB
Alternatives to context-compression
All alternatives →Aligns a Qwen Code feature with a Codex or Claude Code reference agent. It runs both under the same scenario, captures HTTP and terminal traces, and compares them until behavior matches.
Searches, views, creates, updates, and deletes the user's Google Contacts from an AI assistant. It is for people who want to manage their address book through conversation. A one-time Google connect is required before it returns data.
Guides an AI assistant on error handling choices. It covers when to use Result, Option, ? propagation, unwrap, expect and panic, plus anyhow and thiserror.
Caveman is an agent skill that makes an AI assistant reply in a terse style. It cuts filler and keeps technical facts, code, commands and errors exact. It is built for users who want shorter, cheaper replies.
docs-sync audits or updates English SDK documentation against the requested implementation scope. It is for maintainers who want docs to match main branch features, configuration options, and defaults.
Guides an AI assistant through setting up and running monorepos with pnpm workspaces, Turborepo and Nx. Aimed at developers who need faster builds, shared code and managed dependencies across multiple packages.
Compare with agent-reproduce-align, google_contacts or m06-error-handling
context-compression: common questions
When should I use anchored iterative summarization?
The source recommends it for sessions of 100 or more messages where file tracking matters, such as coding or debugging. It summarizes only newly truncated content and merges it into the existing summary.
What does tokens per task mean?
The source defines it as the total tokens consumed to complete a task, including re-fetching costs when compression loses critical information. It argues this is a better target than tokens per request.
Does this skill handle long-term memory across sessions?
No. The source says long-term semantic memory across sessions belongs to a separate memory-systems skill, and raw file outputs belong to filesystem-context.
How do I install context-compression?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is context-compression free?
The code is published under the MIT licence. The service it connects to may have its own pricing.
Is context-compression safe to use?
It scores 94 of 100. Grades: maintenance A, licence A, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to context-compression?
Similar skills: agent-reproduce-align, google_contacts, m06-error-handling, caveman.
