Token导航 LogoToken导航

Agent Skill · 开发

context-compression(上下文压缩)

context-compression 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

context-compression 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 20,588。

总安装 218周安装 9GitHub Stars 67下载 71核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:context-compression(上下文压缩)
来源仓库:https://github.com/seb1n/awesome-ai-agent-skills
仓库路径:skills/context-compression
安装命令:
npx skills add https://github.com/seb1n/awesome-ai-agent-skills --skill context-compression
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/seb1n/awesome-ai-agent-skills --skill context-compression

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

context-compression 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息。适合围绕仓库状态、代码变更或协作事项进行整理和分析。通过 npx skills add 命令安装指定 GitHub 仓库中的技能模块。

安装前需确认权限范围、维护状态,以及是否触发联网或文件读写操作。适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

来源仓库内路径:skills/context-compression

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/seb1n/awesome-ai-agent-skills --skill context-…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

context-compression 怎么安装?

在终端执行 npx skills add https://github.com/seb1n/awesome-ai-agent-skills --skill context-compressio…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

context-compression 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

context-compression 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

context-compression 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

context-compression 用的人多吗?

公开数据是累计安装 218 次,近一周安装 9 次,下载 71 次,GitHub 67 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

context-compression 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
context-compression

上下文压缩 · 本页

21867只读未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

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.

  1. 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.
  2. 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.
  3. Assemble the Final Context: Insert the compressed text into the prompt in place of the raw context. Include a note to the model indicating the context has been summarized, so it can calibrate its confidence accordingly.

Techniques

  • Extractive Summarization: Selects the top-n most important sentences from the source text based on relevance scoring. Preserves exact wording, which is important when precision matters (legal, medical, code). Tools: TextRank, LexRank, or LLM-based extraction.
  • Abstractive Summarization: Generates a new, shorter version of the text that captures the same meaning. Produces more natural and concise output but risks introducing inaccuracies. Best used with a reliable LLM and a validation step.
  • Key-Point Extraction: Reduces text to a structured list of facts, entities, and data points. Extremely space-efficient (often 90%+ compression) but loses narrative flow and nuance.
  • Selective Pruning: Removes filler sentences, repeated explanations, greetings, and boilerplate while keeping substantive content intact. Low risk of information loss and easy to implement with rule-based heuristics.
  • Token Budget Management: Dynamically allocate token budgets across multiple context sources. For example, in a RAG pipeline with 5 retrieved chunks, allocate more tokens to higher-relevance chunks and aggressively compress lower-relevance ones.

Usage

Provide the raw context text and a target token budget. The skill returns a compressed version of the text that fits within the budget. Optionally specify the compression strategy (extractive, abstractive, key-points, or auto) and a list of must-retain keywords or entities.

Examples

Example 1: Compressing a Document for a Q&A Task

Input (excerpt, ~800 tokens):

The Acme Corporation was founded in 1987 by Jane Doe in Austin, Texas. It started as a small consulting firm specializing in environmental compliance. Over the years, the company expanded into waste management technology, receiving its first patent in 1994 for an automated sorting system. By 2005, Acme had grown to 500 employees across 12 offices nationwide. The company went public in 2010 with an IPO price of $18 per share. In 2018, Acme acquired GreenTech Solutions for $240 million, adding recycling automation to its portfolio. As of 2024, Acme reports annual revenue of $1.2 billion and employs 3,400 people. The CEO since 2020 is Michael Chen, who previously served as CTO. Acme's headquarters relocated to Denver, Colorado in 2021. The company's mission statement emphasizes sustainable industrial practices and carbon-neutral operations by 2030.

Compressed Output (key-point extraction, ~150 tokens):

- Acme Corporation: founded 1987 by Jane Doe, Austin TX; now HQ in Denver CO (relocated 2021) - Business: environmental compliance consulting → waste management tech → recycling automation - Key milestones: first patent 1994 (automated sorting), IPO 2010 ($18/share), acquired GreenTech Solutions 2018 ($240M) - Current: CEO Michael Chen (since 2020), 3,400 employees, $1.2B annual revenue - Goal: carbon-neutral operations by 2030

Example 2: Compressing Conversation History

Input (long-running chat, ~3,000 tokens across 18 messages):

User asks about setting up a Python virtual environment. Agent explains venv creation, pip usage, and requirements.txt. User then asks about Docker containerization. Agent explains Dockerfiles, docker-compose, and volume mounts. User encounters a port-binding error. Agent helps debug by checking for conflicting processes. User resolves the issue. User then asks about deploying to AWS ECS.

Compressed Output (abstractive summary, ~400 tokens):

Conversation summary: The user is setting up a Python application with Docker and deploying to AWS. Key context: 1. Python environment is configured with venv and requirements.txt (resolved). 2. Docker setup uses a Dockerfile and docker-compose with volume mounts (resolved). 3. A port-binding conflict on port 8080 was resolved by killing a conflicting process. 4. Current topic: User is now asking about deploying the Dockerized Python app to AWS ECS. They have a working Docker setup locally and need guidance on ECS task definitions, service configuration, and load balancing.

Best Practices

  • Compress progressively — apply light pruning first, measure the result, then apply heavier techniques only if you still exceed the budget. This minimizes unnecessary information loss.
  • Preserve numbers and names — quantitative data, proper nouns, dates, and code identifiers are disproportionately important and should be retained even in aggressive compression.
  • Tag compressed context — always indicate to the model that the context has been compressed so it can appropriately hedge when details might have been lost.
  • Prefer extractive methods for code — abstractive summarization can introduce subtle errors in code snippets. Use extractive selection or selective pruning for technical content.
  • Keep the most recent turns — when compressing conversation history, preserve the last 2–3 turns verbatim and summarize earlier turns. Recency is a strong signal for relevance.
  • Measure information loss — after compression, check that answers to key questions about the content remain correct. If a fact is lost that the task depends on, the compression was too aggressive.

Edge Cases

  • Context already within budget: Skip compression entirely — unnecessary compression always loses some information. Only compress when the raw context exceeds available tokens.
  • Highly technical or structured content: Tables, JSON, and code blocks compress poorly with abstractive methods. Use selective pruning or extract only the relevant rows/fields rather than summarizing.
  • Multiple languages in context: Compression models may perform unevenly across languages. Compress each language segment independently or use a multilingual summarization model.
  • Critical safety information: Never compress away safety warnings, legal disclaimers, or medical dosage information. Mark these as must-retain before applying any compression.
  • Near-budget context: If the context is only 10–15% over budget, simple pruning of whitespace, boilerplate headers, and duplicate sentences is safer than full summarization.

平台分布

Codex

34.77%
按下载量换算25

Claude

28.52%
按下载量换算20

Cursor

19.18%
按下载量换算14

Gemini CLI

9.72%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills