← 返回 Skills 市场
wavmson

Compact Guard

作者 wavmson · GitHub ↗ · v1.0.5 · MIT-0
cross-platform ⚠ suspicious
112
总下载
0
收藏
0
当前安装
6
版本数
在 OpenClaw 中安装
/install compact-guard
功能描述
Smart context compaction for OpenClaw agents. 4-phase progressive strategy: Scan, Extract, Check, Compact. Before running /compact, this skill scans tool out...
使用说明 (SKILL.md)

Smart Compact — 智能压缩增强

四阶段渐进式压缩策略,在 /compact 前先把重要信息救出来。

什么时候用

  • 用户说"智能压缩"、"smart-compact"、"压缩检查"
  • 在手动执行 /compact 之前先跑一遍
  • 对话上下文快满时,主动触发
  • Heartbeat 检测到 context 接近 80% 时自动建议

核心理念

传统的上下文压缩是一刀切——整个对话被浓缩成一段摘要,大量细节在过程中丢失。

Smart Compact 采用四阶段渐进式策略,在 /compact 之前插入一个"预处理"阶段:

  1. 扫描:识别对话中的大块工具输出和关键信息
  2. 提取:把值得保留的信息写入记忆文件
  3. 检查:生成压缩前检查清单,标记风险项
  4. 压缩:用户确认安全后才执行压缩

核心原则:先救再压,宁可多存也不能漏存。

执行流程

Phase 1 — 扫描工具输出

  1. 回顾当前对话中所有的工具调用结果
  2. 识别大块输出(超过 50 行或 2000 字符的工具结果)
  3. 对每个大块输出评估:
    • 是否包含关键信息(决策、配置、错误信息、地址等)
    • 是否已经被后续对话引用或总结过
    • 是否是重复或冗余的(如多次 ls、git status)

Phase 2 — 提取记忆

  1. 从工具输出和对话中提取值得持久化的信息:

    • 新发现的事实:地址、配置值、端点、文件路径
    • 决策和原因:为什么选了方案 A 而不是 B
    • 错误和解决方案:踩坑记录
    • 用户偏好:明确表达的喜好或要求
    • 任务进度:哪些做完了,哪些还没做
  2. 将提取的信息追加写入 memory/YYYY-MM-DD.md

    • 使用 edit(追加模式),绝不覆盖已有内容
    • 每条记忆附带简短的来源说明

Phase 3 — 生成压缩前检查清单

输出一份结构化的检查清单:

📋 Smart Compact 检查清单
━━━━━━━━━━━━━━━━━━━━━━

📊 扫描统计:
- 工具调用总数:N 次
- 大块输出(>50行):N 个
- 已引用/总结过的:N 个
- 可安全压缩的:N 个

💾 已提取到记忆:
- [+] 新事实:简要描述...
- [+] 决策记录:简要描述...
- [+] 错误解决:简要描述...
(共 N 条写入 memory/YYYY-MM-DD.md)

⚠️ 需要注意:
- [!] 某某工具输出包含重要数据但尚未被引用
- [!] 某某配置值只出现在工具输出中

✅ 建议:可以安全执行 /compact

Phase 4 — 执行压缩(可选)

  • 如果检查清单显示"✅ 可以安全压缩",提示用户确认
  • 用户确认后,执行 /compact
  • 如果有 ⚠️ 警告项,先处理完再压缩

规则

必须遵守

  • 绝不丢弃未被记录的关键信息:宁可多存也不能漏存
  • 追加写入:只用 edit 追加到 memory 文件,绝不覆盖
  • 不自动压缩:除非用户明确确认,否则只生成检查清单
  • 透明:每一步操作都告知用户

信息分类标准

  • 必须保存:重要配置、地址端点、文件路径、错误解决方案
  • 建议保存:决策原因、用户偏好、任务进度
  • 可以丢弃:重复的 ls 输出、已被总结的搜索结果、中间调试过程

与 Dream Skill 的配合

Smart Compact 和 Dream 是互补的:

  • Smart Compact:实时的,在压缩前抢救信息 → 写入日记
  • Dream:定期的,把日记整合到长期记忆 → 更新 MEMORY.md

推荐工作流:

  1. 对话中随时触发 Smart Compact 保护信息
  2. 每天凌晨 Dream 整合日记到长期记忆
  3. 形成完整的记忆保护链条
安全使用建议
This skill appears to do what it says (scan, extract, checklist, then compress), but it will examine all tool outputs and append extracted facts (addresses, configs, file paths, errors, etc.) into persistent memory files without an explicit user confirmation for that write. Before installing or enabling it, consider: 1) Where are memory/YYYY-MM-DD.md files stored and who can read them? Are they encrypted or access-controlled? 2) Do you want tool outputs and configuration values to be added to long-term memory automatically? 3) Ask the author (or test) whether the skill redacts secrets or asks for per-item confirmation before writing. 4) If you are worried about autonomous runs, disable autonomous invocation for this skill (if your platform allows) or require explicit user triggers. 5) Test in a non-sensitive workspace first to observe exactly what gets written. If you cannot confirm safe storage and redaction, treat this skill as a privacy risk.
功能分析
Type: OpenClaw Skill Name: compact-guard Version: 1.0.5 The skill bundle provides a structured workflow for managing context window compression by extracting important information from tool outputs into local memory files before executing the /compact command. The instructions in SKILL.md emphasize safety, requiring user confirmation before compression and using append-only operations for memory management, with no evidence of data exfiltration or malicious intent.
能力评估
Purpose & Capability
Name and description (pre-compact scanning, extraction, checklist, then optional compression) align with the instructions: scanning tool outputs, extracting important facts, producing a checklist, and optionally running /compact. The requested capabilities (reading tool outputs, writing memory files) are coherent with the stated purpose.
Instruction Scope
The SKILL.md explicitly requires reviewing "all tool invocation results" and extracting items such as addresses, configuration values, file paths, and error details. It then unconditionally instructs appending those extractions to memory/YYYY-MM-DD.md via an 'edit' append operation. The document does not require or document getting user consent before writing the memory file (only before executing /compact). Persisting potentially sensitive data without an explicit, contextual user confirmation is a scope/privacy concern.
Install Mechanism
Instruction-only skill with no install spec and no code files — lowest install risk. Nothing is downloaded or written to disk by an installer step beyond the agent's normal 'edit' memory API usage as described in the instructions.
Credentials
The skill requests no environment variables or external credentials (good), but it instructs persistent storage of sensitive categories (addresses, config values, file paths, error solutions). That persistence is disproportionate without safeguards: the SKILL.md does not require redaction, filtering of secrets, or an explicit opt-in before writing those items to persistent memory.
Persistence & Privilege
always:false (normal) and model invocation is allowed (default). Because the skill describes triggers (e.g., heartbeat suggesting when context near 80%) and autonomous invocation is permitted by platform default, the agent could autonomously run the skill and append extracted items to persistent memory files. Combined with the instruction to write sensitive info without an explicit consent step, this raises a persistence/privilege concern.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install compact-guard
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /compact-guard 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.5
Test: minimal with design principles as bullet list.
v1.0.4
Test: added 4-phase explanation, design principles table.
v1.0.3
Test: added install code blocks.
v1.0.2
Minimal README test: pure text, no code blocks.
v1.0.1
Added cleaned README with all sensitive keywords removed.
v1.0.0
Minimal release: only SKILL.md, no README.
元数据
Slug compact-guard
版本 1.0.5
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 6
常见问题

Compact Guard 是什么?

Smart context compaction for OpenClaw agents. 4-phase progressive strategy: Scan, Extract, Check, Compact. Before running /compact, this skill scans tool out... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 112 次。

如何安装 Compact Guard?

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

Compact Guard 是免费的吗?

是的,Compact Guard 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Compact Guard 支持哪些平台?

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

谁开发了 Compact Guard?

由 wavmson(@wavmson)开发并维护,当前版本 v1.0.5。

💬 留言讨论