Agent skill · research science · aiskillstore

context-compression

This skill should be used when long-running agent sessions need context compression, structured summarization, compaction, token-per-task optimization, or durable handoff summaries that preserve decisions, files, risks, and next actions.

Why this skill is useful

Provides domain-specific strategies for optimizing token usage and preserving critical information in long-running agent sessions.

What it needs

About 10k tokens when loaded. Last updated 2026-08-07. 405 stars on the source repository.

What this skill does

Context Compression Strategies When agent sessions generate millions of tokens of conversation history, compression becomes mandatory. The naive approach is aggressive compression to minimize tokens per request. The correct optimization target is tokens per task: total tokens consumed to complete a task, including re-fetching costs when compression loses critical information. When to Activate Activate this skill when: Agent sessions exceed context window limits Codebases exceed context windows (5M+ token systems) Designing conversation summarization strategies Debugging cases where agents "forget" what files they modified Building evaluation frameworks for compression quality Creating durable handoff summaries that preserve decisions, files, risks, and next actions Do not activate this skill for adjacent work owned by other skills: General token-efficiency tactics such as masking, prefix caching, or partitioning: context-optimization. Diagnosing why a long context is failing before choosing a mitigation: context-degradation. Writing raw outputs, logs, or plans to files without summarizing them: filesystem-context. Designing long-term semantic memory across sessions: memory-systems. Core Concepts Context compression trades token savings against information loss. Select from three production-ready approaches based on session characteristics: 1. Anchored Iterative Summarization: Implement this for long-running sessions where file tracking matters. Maintain structured, persistent summaries with explicit sections for session intent, file modifications, decisions, and next steps. When compression triggers, summarize only the newly-truncated span and merge with the existing summary rather than regenerating from scratch. This prevents drift that accumulates when summaries are regenerated wholesale — each regeneration risks losing details the model considers low-priority but the task requires. …

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills aiskillstore/context-compression--85f935

View the source on GitHub

Browse the @skills marketplace