context-compression

A method for shortening long coding-agent sessions while keeping the important decisions, files, risks, and next steps. It focuses on reducing the total work needed to finish a task, not just the amount of text.

In plain words
What is it for?
Use it to design context-compression rules, create handoff summaries, and assess whether shortening a session loses important information.
Why use it?
Long sessions can exceed the agent’s memory limit or cause it to forget earlier work. Structured summaries reduce the need to reread information or repeat completed tasks.

Skill for Claude CodeCodex

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add skills/docxology/template/context-compression
Any agent
npx skills add docxology/template --skill context-compression
Clone the repo
git clone --depth 1 https://github.com/docxology/template

Made for: Claude Code, Codex.

Per session 47 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,438 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin 100% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00047 $0.03438
Opus 5 $0.00023 $0.01719
Sonnet 5 $0.00009 $0.00688
Haiku 4.5 $0.00005 $0.00344

Measured 2d ago against content hash c4111db0514e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

context-compression scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

The scan reads SKILL.md. This mod also ships 2 executable files (scripts/compression_evaluator.py, tests/test_compression_evaluator.py), listed below but not scanned — reading those needs a real analyzer, not pattern matching.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

100% identical to context-compression — 0 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

.agents/skills/context-compression/SKILL.md · 280 lines

How it starts

The opening of the file, as written. The whole thing — 280 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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. Structure forces preservation because dedicated sections act as checklists the summarizer must populate, catching silent information loss.

Read the full file on GitHub · 280 lines

Files

What ships with it

3 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 280 lines · 47 tokens per session scan A c4111db0514e

Subscribe to this mod's changes

context-compression is a skill published in the GitHub repository docxology/template (19 stars, last pushed 2d ago), licensed Apache-2.0. It adds 47 tokens to every session and 3,438 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. It is 100% identical to context-compression, differing in 0 lines, and is treated as a copy.

Related

Other skills, from other repositories

planning-with-files

Manus-style persistent file-based planning for AI coding agents: keeps taskplan.md, findings.md, and progress.md on disk so work survives context loss and /clear. Use when asked to plan out, break down, or organize a multi-step project, research task, or any work requiring 5+ tool calls. Supports automatic session…

mxyhi/ok-skills · 76 tokens

exa-search

Use Exa MCP for current web, code/docs, company, people, and page-fetch research. Prefer current hosted tool schemas and note deprecated tools.

mxyhi/ok-skills · 33 tokens

ontoly-software-graph

Use Ontoly's deterministic Software Graph and MCP capabilities for repository architecture, request tracing, dependency analysis, configuration lookup, and impact analysis before falling back to source search.

mxyhi/ok-skills · 40 tokens

product-decision-agent

中文产品决策 Agent。用于中国大陆互联网产品、运营、增长、商业化、数据、项目推进和组织协作场景:产品规划、需求分析、PRD、需求优先级、排期、版本规划、Roadmap、MVP、灰度、上线、迭代、增长停滞、拉新、投放、渠道、裂变、CAC、LTV、ROI、留存、转化、DAU/MAU、GMV、漏斗、社区运营、内容供给、创作者、用户运营、活动运营、私域、会员、定价、指标异常、数据口径、埋点、A/B…

mxyhi/ok-skills · 265 tokens

kimi-webbridge

Kimi WebBridge lets AI control the user's real browser — navigate, click, type, read, screenshot, and interact with any website using the user's actual login sessions. Use this skill whenever the user wants to interact with websites, automate browser tasks, scrape web content, or perform any action requiring a real…

mxyhi/ok-skills · 113 tokens

acupuncturist

Use when a task needs the judgment of a licensed acupuncturist — building a TCM pattern-differentiation-based treatment plan, choosing point combinations and needling technique for a presenting complaint, triaging a safety red flag (fainting, suspected pneumothorax, herb-drug interaction), or writing a SOAP note that…

wonsukchoi/domain-experts · 102 tokens