← 返回 Skills 市场
c595390153-a11y

Context Compression Claude Code Custom

作者 c595390153-a11y · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
107
总下载
0
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install context-compression-claude-code-custom
功能描述
Use this skill whenever the conversation context is getting long, when a user asks to "compress", "summarize", or "clean up" the conversation, or when you de...
使用说明 (SKILL.md)

Origin: This skill was extracted from Claude Code's internal implementation and rules. Claude Code openly exposes its safety mechanisms (hooks, system prompts, skill definitions) in the ~/.claude/ directory. The tiered compression strategy, layer classification system, and memory file structure were reverse-engineered from Claude Code's PreCompact/PostCompact hooks and session memory handling, then adapted for OpenClaw's multi-channel environment.

Context Compression

Why Tiered Compression Is Needed

A one-size-fits-all approach to dropping context either leaves the agent without memory or burns through context too quickly. The core principle of tiered strategy is: different information has different lifecycles. A user's statement "I prefer concise responses" is worth remembering forever; but a resolved error message from three days ago has no value today.


Before Compression: Identify the Scenario

Before starting compression, determine which conversation scenario you're in, as retention strategies differ:

Scenario Characteristics Compression Tendency
Task-oriented Clear goal, step-driven Keep goal and incomplete steps, compress process details
Chat-oriented Open topics, no clear task Keep only user preference signals, discard aggressively
Research-oriented Gathering information, continuous accumulation Keep conclusions and sources, compress procedural discussions
Group-chat Multiple people, high noise Discard aggressively, keep only directly relevant content

Three-Layer Compression Strategy

Layer 1: Must Preserve (Keep Original)

These contents remain in original or near-original form after compression:

  • User's explicitly stated goals, requirements, deadlines
  • Incomplete tasks (in-progress, interrupted)
  • Confirmed important decisions ("We decided to go with Plan B")
  • User-expressed explicit preferences ("I don't like X", "Always use Y format going forward")
  • Key credentials or config (accounts, paths, special settings)

Layer 2: Compress to Summary (Extract and Keep)

Keep conclusions, discard process:

  • Completed tasks → One-sentence conclusion ("Completed X, result was Y")
  • Long explanations → Core point in 1-2 sentences
  • Tool call outputs → Keep only final results, discard intermediate steps
  • Repeated topics → Merge into one record

Layer 3: Discard Directly

  • Small talk, thanks, acknowledgment messages ("ok", "thanks", "got it")
  • Rejected or obsolete proposals
  • Multiple attempts at the same question (keep only the final effective one)
  • Pure transitional content ("let me think", "hold on")
  • Resolved error messages that won't be needed again

Compression Execution Steps

Step 1: Scan All Conversation Identify all Layer 1 content, make a checklist — this cannot be discarded.

Step 2: Process Layer 2 For each conversation segment, judge: Is there a conclusion worth keeping? If yes, distill into one sentence.

Step 3: Generate Compressed Summary In chronological order, combine Layer 1 content + Layer 2 extractions into a compact context summary, typically no more than 600 characters.

Step 4: Update Memory File Write high-persistence-value information (user preferences, long-term goals, important decisions) to the memory file. See memory-template.md for format.

Step 5: Inform the User Briefly explain what was compressed and what key information was preserved, so the user knows the context has been updated.


OpenClaw Multi-Channel Supplementary Rules

OpenClaw runs across multiple messaging platforms, pay extra attention:

Group chat scenarios: Other members' messages default to Layer 3 (discard) unless the user explicitly responds to or quotes that message.

Cross-day conversations: Judge by topic unit, not time unit. An unfinished task from yesterday belongs to Layer 1; a completed topic from yesterday drops one level today.

Channel switching: If the user asks similar questions on different channels (WhatsApp vs Telegram), it indicates genuine concern — promote priority to Layer 1.


Optional: Auto-Trigger (Hook Configuration)

If you use Claude Code or an agent that supports PreCompact hooks, you can configure auto-trigger. See setup-hook.md for details.

Without hook configuration, you can trigger manually: just tell the agent "compress my context" or "context is getting long, clean it up".

安全使用建议
This skill's compression strategy is plausible, but it contains red flags you should review before installing or enabling hooks: 1) It recommends storing 'key credentials or config' in a persistent memory file — do NOT store secrets unencrypted. Remove or redact any fields that would contain passwords, tokens, or private keys. 2) The setup examples show shell commands (cat, python3) and editing ~/.claude or OpenClaw hook configs; treat those as operations that can execute code and modify agent behavior. Only add hooks if you trust the exact command and understand what it runs. 3) If you want compression but not filesystem writes, modify the skill to return compressed summaries to the agent without writing to disk, or store memory in a secure, access-controlled store. 4) Inspect file permissions for any created memory files to ensure they are not world-readable. 5) If the author can provide an explicit statement that credentials will never be persisted (or that persisted secrets are encrypted and protected), and remove the example shell command or replace it with a safe API-based integration, the concerns would be reduced. If you are unsure, test in an isolated/non-production environment first.
功能分析
Type: OpenClaw Skill Name: context-compression-claude-code-custom Version: 1.0.0 The skill bundle provides a structured tiered strategy for conversation context compression and long-term memory management. It includes instructions for the agent to categorize information into preservation layers and provides a template (`memory-template.md`) for maintaining state. The configuration hooks in `setup-hook.md` use standard local shell commands and Python one-liners to inject instructions into the agent's context, with no evidence of data exfiltration, unauthorized remote execution, or malicious prompt injection.
能力标签
cryptocan-make-purchases
能力评估
Purpose & Capability
The skill claims only to compress/summarize conversation context, which is reasonable. However the documentation repeatedly references reading/writing user config locations (e.g., ~/.claude/..., OpenClaw hooks config) and explicitly instructs preserving 'Key credentials or config' in the memory file. Asking to touch home-directory config and to persist credentials is not proportionate to a pure compression/summarization utility and is a mismatch with the minimal declared requirements (no env, no binaries).
Instruction Scope
SKILL.md and setup-hook.md instruct the operator/agent to read and write files under ~/.claude and to update agent hook config; the PreCompact example includes an actual shell command that cats SKILL.md and pipes it to python3. The instructions therefore go beyond 'summarize text' — they direct filesystem access, persistent writes, and running shell/python code. The skill also explicitly recommends saving 'accounts, paths, config' and 'Key credentials or config' in memory, which broadens the scope to storing secrets.
Install Mechanism
This is instruction-only (no install spec, no code files to execute), which is low install risk. However the provided hook examples call system binaries (cat, python3) and ask the user to edit config files; those operations assume availability of system tools not declared by the skill and could cause remote/automatic execution if wired into hooks.
Credentials
The skill declares no required credentials or env vars, yet its content instructs preserving and writing 'Key credentials or config' and other account/path details into persistent memory. That is disproportionate: a compressor should not recommend collecting or storing secrets. The skill also references config paths (~/.claude) which provide access to other agent/system settings.
Persistence & Privilege
While 'always' is false and autonomous invocation is normal, the skill encourages adding PreCompact/PostCompact hooks that will make compression run automatically and to write persistent memory files under user home. Combined with instructions to persist credentials, this increases the blast radius of any misconfiguration. The skill also provides example hook commands that execute shell/python on the host, which could run arbitrary code if misapplied.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install context-compression-claude-code-custom
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /context-compression-claude-code-custom 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release of the context-compression skill, providing structured, tiered conversation compression based on conversation scenario. - Implements a three-layer strategy: must-preserve content, summarized content, and discardable content. - Supports both manual and automatic compression triggers, including PreCompact hook integration. - Outputs a structured memory file to retain key long-term information. - Includes special handling for multi-channel and group chat scenarios, with user-focused retention rules.
元数据
Slug context-compression-claude-code-custom
版本 1.0.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 1
常见问题

Context Compression Claude Code Custom 是什么?

Use this skill whenever the conversation context is getting long, when a user asks to "compress", "summarize", or "clean up" the conversation, or when you de... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 107 次。

如何安装 Context Compression Claude Code Custom?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install context-compression-claude-code-custom」即可一键安装,无需额外配置。

Context Compression Claude Code Custom 是免费的吗?

是的,Context Compression Claude Code Custom 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Context Compression Claude Code Custom 支持哪些平台?

Context Compression Claude Code Custom 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Context Compression Claude Code Custom?

由 c595390153-a11y(@c595390153-a11y)开发并维护,当前版本 v1.0.0。

💬 留言讨论