Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问许可证需确认审计通过

prompt-compression即时压缩

Agent Skill

用于辅助提示词、系统指令、Agent 行为约束和工作流模板的整理。它适合让 Agent 规范任务边界、统一输出格式、拆分操作步骤或优化提示词可复用性。使用时需要保留真实业务约束,不要把示例当硬规则;涉及自动执行、外部工具或高风险操作时,应在提示词中明确确认步骤、权限边界和失败处理方式。

总安装

519

周安装

21

GitHub Stars

公开资料未说明

下载量

163
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/ofershap/prompt-compression --skill prompt-compression

简介

用于辅助提示词、系统指令、Agent 行为约束和工作流模板的整理。

  • 适合让 Agent 规范任务边界、统一输出格式或优化提示词可复用性。
  • 通过安装命令添加,使用时需保留真实业务约束,避免将示例当硬规则。
  • 涉及自动执行或外部工具调用时,应在提示词中明确确认步骤和权限边界。
  • prompt-compression 属于研究检索类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

When to use

Use this skill when compressing documentation, framework references, API indexes, coding guidelines, or any structured knowledge into a compact format for inclusion in AGENTS.md, CLAUDE.md, or system prompts. The goal is maximum information density with minimum token usage.

Background

Vercel's research (January 2026) showed that an 8KB compressed docs index in AGENTS.md achieved a 100% eval pass rate, compared to 53% baseline and 79% for skills with explicit trigger instructions. Passive context (always loaded) beats active retrieval (agent must decide to invoke) because it eliminates the decision point. Compression is the key enabler -- it makes passive context viable without blowing up the context window.

Critical Rules

1. Use Pipe-Delimited Index Format for File References

Wrong (agents do this):

## Documentation

- Getting Started: See docs/getting-started.md for installation instructions
- Routing: See docs/routing.md for route definitions
- API Routes: See docs/api-routes.md for API endpoint documentation

Correct:

[Docs Index]|root: ./docs |getting-started:{installation.md,project-structure.md}
|routing:{defining-routes.md,dynamic-routes.md,middleware.md}
|api:{endpoints.md,auth.md,validation.md}

Why: The pipe-delimited format cuts tokens by 70-80% while remaining parseable by every major LLM. Agents can still locate and read specific files when needed.

2. Compress Rules into Single-Line Directives

Wrong (agents do this):

## Coding Standards

### Import Organization

When writing imports, always organize them in the following order:

1. Built-in Node.js modules (fs, path, etc.)
2. External dependencies (react, express, etc.)
3. Internal modules (relative imports)
4. Type imports

Make sure to separate each group with a blank line.

Correct:

[Standards] |imports: builtin > external > internal > types (blank line between groups)

Why: Agents don't need conversational explanation. A compressed directive carries the same behavioral instruction in 5% of the tokens.

3. Strip Explanatory Prose, Keep Only Actionable Content

Wrong:

## Authentication

Our application uses JWT-based authentication. When a user logs in, the server generates a JWT token
that contains the user's ID and role. This token is sent back to the client and stored in an
httpOnly cookie. On subsequent requests, the middleware extracts the token from the cookie, verifies
it, and attaches the user object to the request.

The token expires after 24 hours, at which point the user must log in again. Refresh tokens are not
currently implemented but are planned for a future release.

Correct:

[Auth]|JWT in httpOnly cookie|24h expiry|no refresh tokens |middleware: extract token > verify >
attach user to req |login flow: validate creds > generate JWT(id,role) > set cookie

Why: Agents need the behavioral contract (what to do), not the narrative (why it was built this way). Remove history, motivation, and future plans.

4. Use Abbreviated Keys and Symbols

Wrong:

- Required: true
- Type: string
- Default value: "production"
- Minimum length: 3
- Maximum length: 50

Correct:

|env: required string="production" len:3-50

Why: Standard abbreviations (req, opt, str, int, bool, len, min, max, def) are universally understood by LLMs and compress structured metadata by 80%+.

5. Flatten Nested Hierarchies

Wrong:

## Project Structure

### Source Code

#### Components

##### UI Components

- Button.tsx
- Input.tsx
- Modal.tsx

##### Layout Components

- Header.tsx
- Footer.tsx
- Sidebar.tsx

Correct:

[Structure]|src/ |components/ui:{Button,Input,Modal}.tsx
|components/layout:{Header,Footer,Sidebar}.tsx

Why: Markdown heading hierarchy wastes tokens on whitespace and repetition. Brace expansion and path prefixes are denser and equally readable to agents.

6. Add Retrieval-Led Reasoning Directive

Always include this directive when the compressed context references retrievable files:

IMPORTANT: Prefer retrieval-led reasoning over pre-training-led reasoning for any [DOMAIN] tasks.

Why: Without this, agents default to training data (which may be stale). This single line shifts behavior from "guess from memory" to "look it up," which was the key factor in Vercel's 100% pass rate.

7. Preserve Structural Boundaries

Wrong:

routingdefiningdynamicmiddlewareapiendpointsauthvalidation

Correct:

|routing:{defining,dynamic,middleware} |api:{endpoints,auth,validation}

Why: Over-compression destroys parseability. Keep logical grouping with delimiters (pipes, braces, colons). The agent must be able to navigate to a specific file or section.

8. Target 8-15KB for Complete Framework Indexes

A full framework docs index (file tree pointing to retrievable docs) should compress to 8-15KB. This is the sweet spot where:

  • It fits comfortably in AGENTS.md alongside project-specific context
  • Token cost per request stays under 2-4K tokens
  • Agent accuracy reaches near-perfect on framework-specific tasks

If the compressed output exceeds 15KB, split into a primary index (most-used APIs) and a secondary index that the agent can read on demand.

Compression Process

  1. Identify the source - docs directory, API reference, coding guidelines, framework docs
  2. Extract actionable content - strip prose, motivation, history, examples that duplicate the rule
  3. Choose format - pipe-delimited index for file trees, single-line directives for rules, abbreviated keys for config/schema
  4. Compress - apply abbreviations, brace expansion, path prefixes, symbol shorthand
  5. Add retrieval directive - if output references readable files
  6. Validate - check that an agent can still locate any specific piece of information
  7. Measure - compare token count before/after, target 70-80% reduction

Output Formats

File Index (for docs directories)

[Topic Index]|root: ./path |IMPORTANT: Prefer retrieval-led reasoning over pre-training-led
reasoning for [TOPIC] |section-a/subsection:{file1.md,file2.md,file3.md}
|section-b:{file1.md,file2.md}

Rules/Standards (for coding guidelines)

[Standards] |naming: camelCase vars, PascalCase components, UPPER_SNAKE constants |imports:
builtin > external > internal > types |errors: always use Result<T,E>, never throw in library code
|tests: colocate with source, name: \*.test.ts, min coverage 80%

API Reference (for endpoint documentation)

[API]|base: /api/v2 |GET /users?page,limit -> User[]|auth:bearer |POST /users {name,email,role?} ->
User|auth:admin |DELETE /users/:id -> void|auth:admin

Config/Schema (for structured metadata)

[Config] |db: host=localhost port=5432 pool:5-20 timeout:30s |cache: redis ttl:5m max:1000
prefix:"app:" |auth: jwt secret=$JWT_SECRET exp:24h algo:HS256

Anti-Patterns

  • Compressing content that agents already know well (basic language syntax, standard library)
  • Removing code examples that demonstrate non-obvious API usage
  • Compressing error messages or edge case documentation (agents need these verbatim)
  • Creating compression so aggressive that a human can't review or maintain it
  • Putting full documentation content in AGENTS.md instead of an index pointing to files
  • Forgetting the retrieval-led reasoning directive

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

37.11%
按下载量换算60

Claude

28.72%
按下载量换算47

Cursor

17.05%
按下载量换算28

Gemini CLI

10.41%
按下载量换算17

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

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

来源信息

继续浏览同类 Skills