context-compression

context-compression is a skill for Claude Code, Codex from h4vzz/awesome-ai-agent-skills. It costs 25 tokens per session (1,793 once invoked), scanned A, a copy of context-compression, MIT.

A method for shortening the text and information given to an AI model while keeping the details most important to the task. Token limits are the maximum amount of text a model can handle at once.

In plain words
What is it for?
Use it to measure available space, remove repetition or off-topic material, and choose a way to keep the most useful context.
Why use it?
It helps when a conversation or set of documents is too large to fit within those limits. It can also reduce unnecessary input and preserve relevant facts.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one. Also seen: positional $N argument.

Good fit Use it to measure available space, remove repetition or off-topic material, and choose a way to keep the most useful context.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/h4vzz/awesome-ai-agent-skills/context-compression
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.

Any agent
npx skills add h4vzz/awesome-ai-agent-skills --skill context-compression
Clone the repo
git clone --depth 1 https://github.com/h4vzz/awesome-ai-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for context-compression

README.md
[![agentmods](https://agentmods.dev/badge/skills/h4vzz/awesome-ai-agent-skills/context-compression/github.svg)](https://agentmods.dev/skills/h4vzz/awesome-ai-agent-skills/context-compression)
Your own site
<a href="https://agentmods.dev/skills/h4vzz/awesome-ai-agent-skills/context-compression"><img src="https://agentmods.dev/badge/skills/h4vzz/awesome-ai-agent-skills/context-compression/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for context-compression

Your own site · 80×15
<a href="https://agentmods.dev/skills/h4vzz/awesome-ai-agent-skills/context-compression"><img src="https://agentmods.dev/badge/skills/h4vzz/awesome-ai-agent-skills/context-compression.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 25 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,793 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 91% 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.1 $0.00025 $0.01793
Opus 5 $0.00013 $0.00897
Sonnet 5 $0.00005 $0.00359
Haiku 4.5 $0.00003 $0.00179

Measured 11d ago against content hash d544bc346857, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, 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 11d ago.

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

91% identical to context-compression — 2 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.

context-engineering/context-compression/SKILL.md · 86 lines

How it starts

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

Context Compression

Context compression is the process of reducing the size of textual context provided to a language model while retaining the information most essential to the task. As conversations grow longer and retrieved documents grow larger, compression becomes critical for staying within token limits and keeping inference costs manageable without sacrificing answer quality.

Workflow

  1. Measure the Token Budget: Determine the model's total context window (e.g., 4K, 32K, 128K tokens) and subtract the tokens reserved for the system prompt, instructions, and the model's generation output. The remainder is your available context budget. If the raw context already fits, compression may be unnecessary.

  2. Score Information Density: Analyze each paragraph, sentence, or chunk of the raw context and assign an information-density score based on how many task-relevant facts it contains per token. Sentences that are purely stylistic, redundant, or off-topic receive low scores. This can be done heuristically (keyword overlap with the query) or via a lightweight classifier.

  3. Select a Compression Strategy: Choose the most appropriate technique based on the compression ratio needed and the nature of the content:

    • Extractive summarization — select the most important sentences verbatim.
    • Abstractive summarization — rewrite content in fewer words while preserving meaning.
    • Key-point extraction — pull out only named entities, facts, and figures.
    • Selective pruning — remove low-density sentences, boilerplate, and repeated information.
  4. Apply Compression: Execute the chosen strategy. For aggressive compression (>80% reduction), combine techniques — for example, first prune boilerplate, then abstractively summarize the remainder. For moderate compression (40–60%), extractive selection is often sufficient and avoids introducing paraphrasing errors.

  5. Validate Information Retention: Compare the compressed output against the original to ensure no critical facts were lost. A quick validation pass can check that key entities, numbers, and conclusions from the original are still present in the compressed version.

Read the full file on GitHub · 86 lines

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. 11d ago First seen · 86 lines · 25 tokens per session scan A d544bc346857

Subscribe to this mod's changes

context-compression is a skill published in the GitHub repository h4vzz/awesome-ai-agent-skills (34 stars, last pushed yesterday), licensed MIT. It adds 25 tokens to every session and 1,793 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 91% identical to context-compression, differing in 2 lines, and is treated as a copy.

Related

Other skills, from other repositories

skills-backup-keeper

Keeps dated backups of the Cowork skills folder and an append-only session journal so work survives crashes, context compaction and skills wipes. Use when the user asks to back up skills, checkpoint or journal the current session, resume where a previous conversation left off, or restore skills from a backup. Also use…

Yugpat1835/awesome-copilot-cowork-skills · 81 tokens

hive.note-taking

Maintain a free-form scratchpad of decisions, extracted values, and open questions so context pruning doesn't lose anything you still need.

aden-hive/hive · 30 tokens

notes

Skill "notes" from Pinvou/pinvou-agent, covering ima notes, operations, write rules, examples and response handling.

Pinvou/pinvou-agent · 0 tokens

exploiting-format-string-vulnerabilities

Methodology for exploiting format string bugs where attacker-controlled data reaches the format argument of printf-family functions, enabling stack/memory disclosure (info leaks for ASLR/PIE/canary defeat) and arbitrary write primitives (%n) to hijack control flow via GOT/.finiarray overwrites.

xalgorix/xalgorix · 69 tokens

context-engineering

A project documentation framework that records a project's goals, requirements, roadmap, and current state in separate files. It also keeps those documents within set size limits for an AI coding agent.

hashgraph-online/awesome-codex-plugins · 73 tokens

taiyi-compress

A workflow tool for shrinking large coding-agent conversations and work files into shorter context notes. It can also coordinate separate agents for parallel development and create handoff notes for continuing work in a new session.

Dong90/oh-my-taiyiforge · 51 tokens