# /context-compression: Compress long agent sessions without losing the file trail

Source: https://trendhub.net/skills/muratcankoylan-agent-skills-for-context-engineering/context-compression
Skill folder: https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/context-compression
Pack: Agent Skills for Context Engineering (https://trendhub.net/skills/muratcankoylan-agent-skills-for-context-engineering)
Works with: Claude Code (plugin marketplace), Cursor, Codex, Claude Code (single skill copy)

This skill teaches the agent to compress conversation history in a way that keeps work moving. It sets tokens per task, not per request, as the goal, compares three summarization approaches, and favours structured summaries with fixed sections for intent, files changed, decisions, state and next steps, merged incrementally and checked with probe questions.

## When to use it

- Coding sessions keep hitting the context limit and the agent loses track of which files it changed.
- You are designing the summarization or handoff step of an agent framework.
- You need a way to measure whether a compression method preserves what matters.

## How it works

1. **Pick an approach**: Chooses anchored iterative summaries for long file-heavy sessions, opaque compression for short cheap ones, or full regeneration when humans read the summary.
2. **Fix the sections**: Defines mandatory summary sections suited to the task, such as root cause for debugging or schemas for migrations.
3. **Merge, do not regenerate**: Summarizes only the newly truncated span and folds it into existing sections, deduplicating by file and decision.
4. **Choose triggers**: Uses a sliding window or a 70 to 80 percent utilization threshold, or task boundaries when sessions have clear phases.
5. **Probe the result**: Asks recall, artifact, continuation and decision questions after compression and scores six dimensions.

## What it steers the agent away from

- Compressing tool definitions or schemas, which breaks tool calls.
- Paraphrasing file paths, error codes and identifiers into vague prose.
- Losing the constraints set in the first turns of a session.

## What it can touch

Instructions only; it shapes how the agent writes summaries and evaluation probes.

## Pairs well with

- `/context-degradation`
- `/context-optimization`
- `/filesystem-context`

## Questions

### Why not just compress as much as possible?

Lost details force the agent to re-read and re-derive, so the total tokens for the task can rise even when each request shrinks.

### Are the compression ratios in the skill universal?

No. The skill presents them as figures from one benchmark source and says not to treat them as constants.
