context-compression

context-compression is a skill for Claude Code from irfad7/claude-power-skills. It costs 70 tokens per session (983 once invoked), scanned A, original, MIT.

A method for shortening a long coding-agent conversation while keeping the decisions and details needed to continue the work. It removes repeated messages, noise, and outdated attempts in several levels of compression.

In plain words
What is it for?
Use it to compact long sessions, preserve important requirements and decisions, summarise tool results, and make room for a complex follow-up task.
Why use it?
It helps when the conversation is nearing its context limit or the agent is losing track of earlier decisions.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the claude-power-skills plugin — 20 skills shipped together

Good fit Use it to compact long sessions, preserve important requirements and decisions, summarise tool results, and make room for a complex follow-up task.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/irfad7/claude-power-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 irfad7/claude-power-skills --skill context-compression
Clone the repo
git clone --depth 1 https://github.com/irfad7/claude-power-skills

Made for: Claude Code.

Or install claude-power-skills, the plugin that ships this one along with the rest of its 20 skills.

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/irfad7/claude-power-skills/context-compression/github.svg)](https://agentmods.dev/skills/irfad7/claude-power-skills/context-compression)
Your own site
<a href="https://agentmods.dev/skills/irfad7/claude-power-skills/context-compression"><img src="https://agentmods.dev/badge/skills/irfad7/claude-power-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/irfad7/claude-power-skills/context-compression"><img src="https://agentmods.dev/badge/skills/irfad7/claude-power-skills/context-compression.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 70 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 983 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 original No closer match found 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.00070 $0.00983
Opus 5 $0.00035 $0.00491
Sonnet 5 $0.00014 $0.00197
Haiku 4.5 $0.00007 $0.00098

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

skills/context-compression/SKILL.md · 125 lines

How it starts

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

Context Compression — 3-Layer Pipeline

You are a context compression engine. When conversations grow long, you systematically reduce context size while preserving all decision-critical information.

When To Trigger

  • Conversation exceeds ~50 turns
  • User mentions context is getting long or responses are degrading
  • You notice you're losing track of earlier decisions
  • User explicitly asks for compression
  • Before a complex multi-step task that needs headroom

The Three Layers

Layer 1: MicroCompact (Light Touch)

Goal: Remove noise without losing any information.

Do this:

  • Strip redundant confirmations ("Yes, that looks good", "Sure, I'll do that")
  • Collapse repeated tool outputs into summaries ("Read 12 files — all TypeScript, avg 200 lines")
  • Remove failed attempts that were superseded by successful ones
  • Collapse verbose error messages into one-line summaries
  • Remove conversational filler ("Let me think about this...", "Great question...")

Compression ratio: ~30-40% reduction Information loss: Zero

Layer 2: AutoCompact (Structural)

Goal: Restructure retained information for density.

Do this:

  • Convert sequential discoveries into a structured summary:
    ## What We Know
    - The API uses Express with 14 endpoints
    - Auth is JWT-based, tokens expire in 24h
    - Database is Postgres via Drizzle ORM
    - Tests use Vitest, 73% coverage
    
    ## Decisions Made
    - Using server components by default
    - API routes return { data } or { error }
    - Commit style: conventional commits
    
    ## Current Task
    - Building the user dashboard
    - Blocked on: auth middleware refactor
    - Next step: implement session management
    
  • Group related file reads into summaries
  • Merge multiple rounds of the same type of work into outcomes
  • Replace code snippets with references ("see src/auth.ts:45-67")

Compression ratio: ~60-70% reduction Information loss: Minimal — details available via file re-reads

Layer 3: Full Compact (Aggressive)

Goal: Maximum compression. Only essential state survives.

Read the full file on GitHub · 125 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. 9d ago First seen · 125 lines · 70 tokens per session scan A bebacd2c8918

Subscribe to this mod's changes

context-compression is a skill published in the GitHub repository irfad7/claude-power-skills (4 stars, last pushed 1mo ago), licensed MIT. It adds 70 tokens to every session and 983 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.