Token导航 LogoToken导航TokenDH.com
AI 工具需要联网github未标认证来源可访问clear审计通过

context-compression上下文压缩

Agent Skill

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

总安装

594

周安装

25

GitHub Stars

160

下载量

208
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/yonatangross/orchestkit --skill context-compression

简介

用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合项目协作管理。

  • 围绕仓库状态、代码变更或协作事项进行信息整理,支持多宿主环境使用。
  • 通过 npx skills add 命令从 GitHub 仓库安装,需结合原始 README 确认具体用法。
  • 安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写操作。
  • context-compression 属于AI 工具类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Context Compression

Reduce context size while preserving information critical to task completion.

Overview

Context compression is essential for long-running agent sessions. The goal is NOT maximum compression—it's preserving enough information to complete tasks without re-fetching.

Key Metric: Tokens-per-task (total tokens to complete a task), NOT tokens-per-request.

When to Use

  • Long-running conversations approaching context limits
  • Multi-step agent workflows with accumulating history
  • Sessions with large tool outputs
  • Memory management in persistent agents

Strategy Quick Reference

StrategyCompressionInterpretableVerifiableBest For
Anchored Iterative60-80%YesYesLong sessions
Opaque95-99%NoNoStorage-critical
Regenerative Full70-85%YesPartialSimple tasks
Sliding Window50-70%YesYesReal-time chat

Recommended: Anchored Iterative Summarization with probe-based evaluation.


Anchored Summarization (RECOMMENDED)

Maintains structured, persistent summaries with forced sections:

## Session Intent
[What we're trying to accomplish - NEVER lose this]

## Files Modified
- path/to/file.ts: Added function X, modified class Y

## Decisions Made
- Decision 1: Chose X over Y because [rationale]

## Current State
[Where we are in the task - progress indicator]

## Blockers / Open Questions
- Question 1: Awaiting user input on...

## Next Steps
1. Complete X
2. Test Y

Why it works:

  • Structure FORCES preservation of critical categories
  • Each section must be explicitly populated (can't silently drop info)
  • Incremental merge (new compressions extend, don't replace)

Implementation

from dataclasses import dataclass, field
from typing import Optional

@dataclass
class AnchoredSummary:
    """Structured summary with forced sections."""

    session_intent: str
    files_modified: dict[str, list[str]] = field(default_factory=dict)
    decisions_made: list[dict] = field(default_factory=list)
    current_state: str = ""
    blockers: list[str] = field(default_factory=list)
    next_steps: list[str] = field(default_factory=list)
    compression_count: int = 0

    def merge(self, new_content: "AnchoredSummary") -> "AnchoredSummary":
        """Incrementally merge new summary into existing."""
        return AnchoredSummary(
            session_intent=new_content.session_intent or self.session_intent,
            files_modified={**self.files_modified, **new_content.files_modified},
            decisions_made=self.decisions_made + new_content.decisions_made,
            current_state=new_content.current_state,
            blockers=new_content.blockers,
            next_steps=new_content.next_steps,
            compression_count=self.compression_count + 1,
        )

    def to_markdown(self) -> str:
        """Render as markdown for context injection."""
        sections = [
            f"## Session Intent\n{self.session_intent}",
            f"## Files Modified\n" + "\n".join(
                f"- `{path}`: {', '.join(changes)}"
                for path, changes in self.files_modified.items()
            ),
            f"## Decisions Made\n" + "\n".join(
                f"- **{d['decision']}**: {d['rationale']}"
                for d in self.decisions_made
            ),
            f"## Current State\n{self.current_state}",
        ]
        if self.blockers:
            sections.append(f"## Blockers\n" + "\n".join(f"- {b}" for b in self.blockers))
        sections.append(f"## Next Steps\n" + "\n".join(
            f"{i+1}. {step}" for i, step in enumerate(self.next_steps)
        ))
        return "\n\n".join(sections)

Compression Triggers

ThresholdAction
70% capacityTrigger compression
50% capacityTarget after compression
10 messages minimumRequired before compressing
Last 5 messagesAlways preserve uncompressed

CC 2.1.7: Effective Context Window

Calculate against effective context (after system overhead):

TriggerStatic (CC 2.1.6)Effective (CC 2.1.7)
Warning60% of static60% of effective
Compress70% of static70% of effective
Critical90% of static90% of effective

Best Practices

DO

  • Use anchored summarization with forced sections
  • Preserve recent messages uncompressed (context continuity)
  • Test compression with probes, not similarity metrics
  • Merge incrementally (don't regenerate from scratch)
  • Track compression count and quality scores

DON'T

  • Compress system prompts (keep at START)
  • Use opaque compression for critical workflows
  • Compress below the point of task completion
  • Trigger compression opportunistically (use fixed thresholds)
  • Optimize for compression ratio over task success

Target Metrics

MetricTargetRed Flag
Probe pass rate>90%<70%
Compression ratio60-80%>95% (too aggressive)
Task completionSame as uncompressedDegraded
Latency overhead<2s>5s

References

For detailed implementation and patterns, see:

  • Compression Strategies: Detailed comparison of all strategies (anchored, opaque, regenerative, sliding window), implementation patterns, and decision flowcharts
  • Priority Management: Compression triggers, CC 2.1.7 effective context, probe-based evaluation, OrchestKit integration

Bundled Resources

  • assets/anchored-summary-template.md - Template for structured compression summaries with forced sections
  • assets/compression-probes-template.md - Probe templates for validating compression quality
  • references/compression-strategies.md - Detailed strategy comparisons
  • references/priority-management.md - Compression triggers and evaluation

Related Skills

  • context-engineering - Attention mechanics and positioning
  • memory-systems - Persistent storage patterns
  • multi-agent-orchestration - Context isolation across agents
  • observability-monitoring - Tracking compression metrics

Version: 1.0.0 (January) Key Principle: Optimize for tokens-per-task, not tokens-per-request Recommended Strategy: Anchored Iterative Summarization with probe-based evaluation


Capability Details

anchored-summarization

Keywords: compress, summarize history, context too long, anchored summary Solves:

  • Reduce context size while preserving critical information
  • Implement structured compression with required sections
  • Maintain session intent and decisions through compression

compression-triggers

Keywords: token limit, running out of context, when to compress Solves:

  • Determine when to trigger compression (70% utilization)
  • Set compression targets (50% utilization)
  • Preserve last 5 messages uncompressed

probe-evaluation

Keywords: evaluate compression, test compression, probe Solves:

  • Validate compression quality with functional probes
  • Test information preservation after compression
  • Achieve >90% probe pass rate

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

补充不同宿主或平台的使用分布数据

能力 5

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

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

平台分布

windsurf

31.15%
按下载量换算65

Gemini CLI

21.42%
按下载量换算45

Antigravity

19.8%
按下载量换算41

Claude Code

11.61%
按下载量换算24

trae

7.12%
按下载量换算15

OpenCode

3.74%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills