cache-optimizer-openclaw

Prompt cache optimizer: diagnose cache efficiency, merge redundant memory files, compress volatile content, and produce an optimization report. Trigger phrases include cache diagnosis, optimize cache, cache compression, cache report, or "cache optimize".

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "cache-optimizer-openclaw" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-7626b11c9040ce16b3577b2b9892aec139080ec449a9f6ae11f5af3d3630eb33. Verify the upstream source and version against https://skillhub.cn/skills/user_2dd795db/cache-optimizer-openclaw before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Prompt cache optimizer: diagnose cache efficiency, merge redundant memory files, compress volatile content, and produce an optimization report. Trigger phrases include cache diagnosis, optimize cache, cache compression, cache report, or "cache optimize".

0 Downloads

Introduction source: third_party · user_2dd795db · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: cache-optimizer
description: 提示词缓存优化器——诊断缓存效率、合并冗余记忆文件、压缩易变内容、输出优化报告。触发词:缓存诊断、优化缓存、缓存压缩、缓存报告、cache optimize。

提示词缓存优化器(OpenClaw 版)

背景

OpenClaw 使用 lossless-claw 插件进行上下文管理,支持缓存感知压缩(cacheAwareCompaction):

  • 自动管理上下文窗口,保留热缓存内容
  • 缓存 TTL 300 秒(5分钟),过期后需要重新加载
  • 热缓存压力因子为 5,预算缓冲比 25%

缓存命中的关键是上下文稳定性:系统提示 → 角色配置 → 记忆文件 → 会话历史这条链上,越靠前的部分越要保持不变。

核心功能

1. 缓存诊断 (/cache-diagnose)

分析当前缓存健康状态:

执行流程:

  1. 扫描工作区目录(默认 ~/.qclaw/workspace/)的记忆文件
  2. 扫描数据目录(默认 ~/.claude-db/)的关键文件
  3. 对每个文件分类:stable(稳定)、volatile(每次变化)、growing(持续增长)、feedback(用户反馈)
  4. 输出诊断报告

输出格式:

📊 缓存健康诊断报告 (2026-06-12)

📁 自动注入文件
├── workspace/ 目录: X 文件, YKB
│   ├── 稳定的: X 文件, YKB
│   ├── Feedback: X 文件, YKB
│   └── 其他: X 文件, YKB
├── ~/.claude-db/ 关键文件: YKB
│   ├── context.md: YKB (每次变化 🔴)
│   ├── experience.md: YKB (持续增长 🟡)
│   └── ...
└── 总计注入: ZKB (变化部分: WKB, 占比: V%)

🔑 缓存失效风险
├── 最大杀手: context.md (每次会话都变)
├── 冗余文件: X 个 feedback 文件可合并
└── 增长失控: experience.md 持续增长无上限

💡 建议
├── 运行 /cache-compact 合并 feedback 文件(预计节省 ~XKB)
└── 设置 context.md 体积上限(建议 < 8KB)

2. 缓存压缩 (/cache-compact)

合并冗余文件、归档历史数据、减少注入体积。

执行流程:

2.1 分析 feedback 文件

  • 读取每个 feedback-*.md 文件
  • 检查其规则是否已在 MEMORY.md 或 experience.md 中存在
  • 分类:重复(可归档)/ 可合并 / 保留

2.2 合并到 MEMORY.md

  • 将 feedback 中的新规则合并到 MEMORY.md 的铁律表或路标表
  • 格式保持和现有条目一致

2.3 归档操作

  • 重复的 feedback 文件 → 移动到 ~/.claude-db/archive/feedback-legacy/
  • 不删除,保留可恢复

2.4 输出压缩报告

🗜️ 缓存压缩完成

📦 归档文件
├── feedback-follow-skill.md → 规则已在 MEMORY.md 中存在
├── feedback-no-guessing.md → 规则已在 MEMORY.md 中存在
└── ... (共 X 个文件)

📝 合并到 MEMORY.md
├── feedback-no-loop-on-edit.md → 添加到铁律表
└── feedback-bang-command.md → 添加到路标表

📊 压缩效果
├── workspace/ 文件数: 21 → X
├── 注入体积: YKB → ZKB (减少 WKB)
└── 预计缓存稳定性提升: V%

3. 缓存报告 (/cache-report)

查看历史指标趋势。

执行流程:

  1. 读取 ~/.claude-db/cache-metrics.jsonl 获取历时数据
  2. 计算趋势:对比最早和最新的 total_size_bytes、volatile_kb、stable_kb
  3. 稳定性评分 = 100 - (平均每次 session 体积变化 / 总注入体积 × 100)
  4. 输出报告

输出格式:

📈 缓存指标趋势报告

📅 统计周期: 最近 N 个 session

📊 注入体积趋势
├── 起始: YKB
├── 当前: ZKB
├── 变化: +WKB (V%)
└── 日均增长: XKB/天

🔄 变化频率
├── 平均每次 session 体积变化: XKB
├── 缓存稳定性评分: V/100
└── 状态: ✅ 良好 / ⚠️ 需关注 / 🔴 需压缩

⏰ 下次建议压缩: X 天后(当体积超过 YKB 时)

关键路径

路径 用途 环境变量
~/.qclaw/workspace/ OpenClaw 工作区记忆文件 OPENCLAW_WORKSPACE
~/.claude-db/ 跨会话持久化数据 OPENCLAW_DB_DIR
~/.claude-db/cache-metrics.jsonl 时序指标数据 -

路径可通过环境变量自定义,详见 README.md

与 lossless-claw 的配合

OpenClaw 的 lossless-claw 插件会自动管理上下文压缩,本 Skill 的作用是:

  1. 预防性优化:在 lossless-claw 压缩前,减少不必要的注入体积
  2. 文件级优化:lossless-claw 管理会话级压缩,本 Skill 管理文件级优化
  3. 指标追踪:提供历时趋势,帮助判断是否需要手动干预

设计原则

  • 只读诊断:诊断和报告只读不写,不修改任何文件
  • 压缩手动触发:合并/归档只有用户执行 /cache-compact 时才发生
  • 归档不删除:feedback 文件移到 archive/feedback-legacy/,可随时恢复
  • 低开销:诊断应在 3 秒内完成

注意事项

  • 合并 feedback 文件前,会先做完整诊断确保不丢失信息
  • MEMORY.md 的格式和结构不会被破坏
  • 所有归档操作可逆
  • 与 lossless-claw 的自动压缩互补,不冲突

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value78/100

Highlights

  • 提供缓存诊断、压缩、报告三大核心功能,解决 OpenClaw 缓存效率与冗余管理的实际痛点
  • 与 lossless-claw 插件互补,形成预防性优化闭环
Trigger Precision85/100

Highlights

  • 触发词覆盖缓存相关操作,边界清晰,用户易理解
Structure and Standards92/100

Highlights

  • Phase 划分清晰,含端到端示例和关键路径说明
  • frontmatter 完整,文档结构规范
Execution Reliability88/100

Highlights

  • 工具来源明确,归档操作可逆,异常处理覆盖主要场景
Evidence Verifiability (mean of the first four)86/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.