Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

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…

oimiragieoот oimiragieo★ 48 звёзд на GitHub

Об этом скилле

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:

  1. measure raw versus compressed token usage
  2. compress large text or adapted JSON payloads
  3. preserve query-relevant evidence instead of doing naive summarization
  4. check whether compressed output still contains enough evidence to answer safely
  5. 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:

  1. profile first
  2. run query_guided when there is a specific question
  3. run evidence_aware when correctness matters and you need a sufficiency check
  4. if evidence is weak, reduce compression aggressiveness or increase retrieval breadth
  5. 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 yet
  • query_guided: best default for QA, review, or targeted extraction tasks
  • evidence_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:

  1. original size versus compressed size
  2. estimated token savings or compression ratio
  3. whether the output is query-targeted or generic
  4. whether evidence looked sufficient
  5. 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 flows
  • references/prompt-caching.md: stable-prefix ordering, cache telemetry, and cache-safe prompt structure
  • references/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

  1. compression-trigger.cjs detects context pressure → writes `compressio
Полный SKILL.md на GitHub

Установить context-compressor в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Write
Bash

Вложенные файлы

commands/context-compressor.mdevals/evals.jsonhooks/post-execute.cjshooks/pre-execute.cjsreferences/evaluation.mdreferences/prompt-caching.mdreferences/research-requirements.mdreferences/skill-creator-reference/LICENSE.txtreferences/skill-creator-reference/SKILL.mdreferences/skill-creator-reference/agents/analyzer.mdreferences/skill-creator-reference/agents/comparator.mdreferences/skill-creator-reference/agents/grader.mdreferences/skill-creator-reference/assets/eval_review.htmlreferences/skill-creator-reference/commands/skill-creator-reference.mdreferences/skill-creator-reference/eval-viewer/generate_review.pyreferences/skill-creator-reference/eval-viewer/viewer.htmlreferences/skill-creator-reference/hooks/post-execute.cjsreferences/skill-creator-reference/hooks/pre-execute.cjsreferences/skill-creator-reference/references/research-requirements.mdreferences/skill-creator-reference/references/schemas.mdreferences/skill-creator-reference/rules/skill-creator-reference.mdreferences/skill-creator-reference/schemas/input.schema.jsonreferences/skill-creator-reference/schemas/output.schema.jsonreferences/skill-creator-reference/scripts/__init__.pyreferences/skill-creator-reference/scripts/aggregate_benchmark.pyreferences/skill-creator-reference/scripts/generate_report.pyreferences/skill-creator-reference/scripts/improve_description.pyreferences/skill-creator-reference/scripts/main.cjsreferences/skill-creator-reference/scripts/package_skill.pyreferences/skill-creator-reference/scripts/quick_validate.pyreferences/skill-creator-reference/scripts/run_eval.pyreferences/skill-creator-reference/scripts/run_loop.pyreferences/skill-creator-reference/scripts/utils.pyreferences/skill-creator-reference/templates/implementation-template.mdreferences/workflow-guide.mdrules/context-compressor.mdschemas/input.schema.jsonschemas/output.schema.jsonscripts/_compression_engine.pyscripts/_external_adapters.py

FAQ

Что делает скилл 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.

Как установить скилл context-compressor?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл context-compressor запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить context-compressor с