
context-compressor
Compress large context before reasoning to reduce token usage while preserving evidence. Use this whenever the user mentions huge files, long prompts, RAG payloads, prompt caching, expensive sessions, codebase context, chat history compaction, or wants the same answer quality with fewer tokens.
- Installs
- 268
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/oimiragieo/agent-studio --skill context-compressor- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads context-compressor automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
Context Compressor
Use this skill when the problem is mostly "too much context" rather than "not enough capability."
This skill is a self-contained local package. It does not require the MCP server. Prefer it when you need quick token profiling, local compression, evidence checks, or a reproducible compression workflow inside the repository.
What this skill does
Use the bundled Python scripts to:
- measure raw versus compressed token usage
- compress large text or adapted JSON payloads
- preserve query-relevant evidence instead of doing naive summarization
- check whether compressed output still contains enough evidence to answer safely
- support cache-friendly prompt assembly by keeping stable context early and volatile query text late
When to trigger
Reach for this skill when the user is asking for any of the following:
- compress this file, transcript, document, or code dump
- reduce token cost before sending context to a model
- make a prompt or RAG payload more cache-friendly
- compact multi-turn history while keeping recent turns intact
- compare semantic compression to a lighter extractive baseline
- validate whether a compressed context still has enough evidence
Also triggered automatically when:
- Context approaching 80K tokens (spawn-token-guard.cjs writes compression-reminder.txt)
- Context at 120K tokens (compression mandatory before new spawns)
- Context at 150K tokens (RED LINE — no new agent spawns until compression completes)
Quick workflow
Default to this sequence:
- profile first
- run
query_guidedwhen there is a specific question - run
evidence_awarewhen correctness matters and you need a sufficiency check - if evidence is weak, reduce compression aggressiveness or increase retrieval breadth
- report savings, risks, and the next safest action
If the user only wants one command, use run_skill_workflow.py.
Commands
Run from the agent-studio repository root. ALWAYS use these exact commands — do NOT fall back to generic guidance.
1. Profile token usage
python .claude/skills/context-compressor/scripts/profile_tokens.py --file <path> --output-format auto
2. Compress context
python .claude/skills/context-compressor/scripts/compress_context.py --file <path> --mode baseline --output-format auto
python .claude/skills/context-compressor/scripts/compress_context.py --file <path> --mode query_guided --query "<question>" --output-format auto
python .claude/skills/context-compressor/scripts/compress_context.py --file <path> --mode evidence_aware --query "<question>" --min-similarity 0.4 --output-format auto
3. Adapt framework JSON and compress it
python .claude/skills/context-compressor/scripts/compress_context.py --json-file <payload.json> --input-adapter auto --mode query_guided --query "<question>" --output-format auto
4. Run the full workflow
python .claude/skills/context-compressor/scripts/run_skill_workflow.py --file <path> --mode evidence_aware --query "<question>" --output-format auto --fail-on-insufficient-evidence
5. Validate evidence only
python .claude/skills/context-compressor/scripts/validate_evidence.py --file <path> --query "<question>" --min-similarity 0.4 --output-format json
6. Run the TOON vs JSON guard
python .claude/skills/context-compressor/scripts/benchmark_toon_vs_json.py
7. Node.js wrapper (for agent integration)
node .claude/skills/context-compressor/scripts/main.cjs --query "<question>" --mode evidence_aware --limit 20 --fail-on-insufficient-evidence
How to choose a mode
baseline: quick general compression when there is no concrete question yetquery_guided: best default for QA, review, or targeted extraction tasksevidence_aware: use for high-stakes answers, audits, or when you need an explicit sufficiency signal
Output expectations
When using this skill, summarize results in plain language:
- original size versus compressed size
- estimated token savings or compression ratio
- whether the output is query-targeted or generic
- whether evidence looked sufficient
- any risk that the answer could miss important detail
If the scripts return insufficient evidence, do not bluff. Say the compressed context is not yet safe enough and recommend a broader pass.
Bundled references
Read these only when they are relevant:
references/workflow-guide.md: command selection, mode choice, and example flowsreferences/prompt-caching.md: stable-prefix ordering, cache telemetry, and cache-safe prompt structurereferences/evaluation.md: how to benchmark the skill and interpret results
Eval scaffolding
Starter prompts live in evals/evals.json. Use them when iterating on the skill or when you want a small repeatable benchmark set.
Integration with agent-studio
Compression trigger pipeline
compression-trigger.cjsdetects context pressure → writescompression-reminder.txt- Router reads reminder → spawns
context-compressoragent with this skill - Agent runs
run_skill_workflow.pywith the query context - Real compression stats logged to
compression-stats.jsonl
Memory persistence
After compression, persist distilled learnings via MemoryRecord:
gotchas.json: text contains gotcha|pitfall|anti-pattern|risk|warning|failureissues.md: text contains issue|bug|error|incident|defect|gapdecisions.md: text contains decision|tradeoff|choose|selected|rationalepatterns.json: default fallback for all remaining distilled evidence
ccusage cost tracking
Read .claude/context/runtime/ccusage-status.txt for live token usage before deciding compression aggressiveness. This file is auto-updated by ccusage-statusline.cjs on every tool use. Format:
[tokens] 135,345 today (in: 14,850 / out: 120,495) | Cost: $127.4826
[cache] $627.2992 saved | 139,399,832 reads, 8,751,364 writes
The Router MUST display this at every pipeline milestone (P0 user feedback). Fallback: ccusage --no-color 2>&1 | tail -5.
Iron Laws
- ALWAYS use the exact script commands above — never fall back to generic CLAUDE.md guidance
- ALWAYS profile first before compressing to understand the input size
- NEVER compress without a query when correctness matters — use
evidence_awaremode - ALWAYS persist distilled learnings via MemoryRecord after compression
- NEVER bluff if evidence is insufficient — recommend a broader pass
- ALWAYS report savings, risks, and next safest action in plain language
FAQ
What does the context-compressor skill do?
Compress large context before reasoning to reduce token usage while preserving evidence. Use this whenever the user mentions huge files, long prompts, RAG payloads, prompt caching, expensive sessions, codebase context, chat history compaction, or wants the same answer quality with fewer tokens.
How do I install context-compressor?
Run npx skills add https://github.com/oimiragieo/agent-studio --skill context-compressor in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/context-compressor/ (personal) or .claude/skills/context-compressor/ (project).
Which AI agents can use context-compressor?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is context-compressor safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains context-compressor?
It is published by oimiragieo in oimiragieo/agent-studio. It has 268 recorded installs.
More from oimiragieo/agent-studio
pyqt6-ui-development-rules
oimiragieo/agent-studio
PyQt6 desktop GUI development rules -- signal/slot architecture, QSS theming, QThread concurrency, layout management, and cross-platform rendering. Enforces MVC separation and responsive UI patterns.
filesystem
oimiragieo/agent-studio
File system operations guidance - read, write, search, and manage files using Claude Code's built-in tools.
chrome-browser
oimiragieo/agent-studio
Open the skill to read its SKILL.md instructions.
slack-notifications
oimiragieo/agent-studio
Open the skill to read its SKILL.md instructions.
nodejs-expert
oimiragieo/agent-studio
Node.js backend expert including Express, NestJS, and async patterns
nextjs-expert
oimiragieo/agent-studio
Open the skill to read its SKILL.md instructions.
Popular ai & agents skills
google-agents-cli-publish
google/agents-cli
This skill should be used when the user wants to "publish an agent", "publish my ADK agent", "register an agent with Gemini", "publish to Gemini" (formerly Gemini Enterprise), or needs guidance on the agents-cli publish gemini command. Also use when the user wants to "manage agents in Agent Registry", "list/update/delete registered agents", or "register an MCP server". Covers ADK vs A2A registration modes, programmatic and interactive usage, flag reference, auto-detection from deployment metadata, Agent Registry fleet management, and troubleshooting. Part of the agents-cli skills suite. Do NOT use for deployment (use google-agents-cli-deploy).
google-agents-cli-eval
google/agents-cli
This skill should be used when the user wants to "run an evaluation", "evaluate my agent", "evaluate my ADK agent", "write an eval dataset", "analyze eval failures", "compare eval results", "optimize agent", or needs guidance on the Gemini platform eval methodology and the Quality Flywheel. Covers eval metrics, dataset schema, LLM-as-judge scoring, and common failure causes. Applies to any agents-cli project, whatever framework the agent is written in. Do NOT use for agent API code patterns (ADK: use google-agents-cli-adk-code), deployment (use google-agents-cli-deploy), or project scaffolding (use google-agents-cli-scaffold).
skill-creator
anthropics/skills
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.
codex-pet
prime-skills/runcomfy-agent-skills
Codex Pet generator on RunComfy. Build a Codex-compatible Codex Pet spritesheet.webp + pet.json from a single reference image, drop it into ${CODEXHOME:-$HOME/.codex}/pets/ / and Codex picks it up as a custom Codex Pet next to the 8 built-ins. This skill produces the exact Codex Pet atlas Codex expects (1536x1872 PNG/WebP, 8 cols x 9 rows, 192x208 cells, 9 animation states — idle, running-right, running-left, waving, jumping, failed, waiting, running, review). Calls OpenAI GPT Image 2 edit ONCE via the local RunComfy CLI as runcomfy run openai/gpt-image-2/edit to produce a canonical Codex Pet pose, then assembles all 9 animation rows programmatically with ImageMagick micro-transforms — no Codex Pro, no $imagegen, no OPENAIAPIKEY required, only RUNCOMFYTOKEN. Triggers on "codex pet", "create codex pet", "make codex pet", "hatch codex pet", "/hatch image", "desktop pet codex", "codex pets", "spritesheet.webp", or any explicit ask to build a custom pet for OpenAI Codex.
full-output-enforcement
leonxlnx/taste-skill
Overrides default LLM truncation behavior. Enforces complete code generation, bans placeholder patterns, and handles token-limit splits cleanly. Apply to any task requiring exhaustive, unabridged output.
executing-plans
obra/superpowers
Use when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available