rocky-know-how

Learning knowledge skill v3.4.8 — vector search with bge-large-zh-v1.5, auto-fallback to keyword search, preprocessing for numbers/English/spell-correction. Tested & verified: deepseek-v4, glm-5.1, minimax-m2.7.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "rocky-know-how" with this command: npx skills add rockytian-top/rocky-know-how

rocky-know-how v3.4.8

Experience & Knowledge Auto-Learning System for OpenClaw Agents

让 AI Agent 从失败中学习,在成功后自动记录,形成经验闭环。


🎯 When to Use / 适用场景

Scenario 场景Action 操作
Failed 2+ times 失败≥2次bash scripts/search.sh "关键词"
Solved after failures 解决后bash scripts/record.sh "问题" "踩坑" "方案" "预防" "tags" "area"
Auto on compaction 压缩时before_compaction driven — pending → LLM extract → write experiences.md
Auto on reset 重置时Fully automatic — Hook saves pending context
Tag used 3x/7days 晋升bash scripts/promote.sh
Tag unused 30days 降级bash scripts/demote.sh

🏗️ Architecture / 架构

Triple-Layer Storage / 三层存储

~/.openclaw/.learnings/
├── experiences.md    ← Main data (v1 compatible, all experiences)
├── memory.md         ← HOT layer (≤100 lines, always loaded)
├── domains/          ← WARM layer (by area: infra, code, wx...)
│   ├── infra.md
│   ├── code.md
│   └── global.md
├── projects/         ← WARM layer (by project)
├── archive/          ← COLD layer (90+ days)
├── drafts/           ← Auto-generated drafts (LLM judged)
├── pending/          ← Session context (before processing)
└── corrections.md    ← Correction log (auto-dedup)

Event-Driven Integration / 事件驱动

Event 事件Trigger 触发Function 功能
agent:bootstrapAgent startup 启动Inject experience reminder into systemPrompt + process old drafts
before_compactionBefore compaction (auto)Core: save pending → LLM extract → write experiences.md → auto-review
before_resetBefore session reset 重置前Save context as pending (fallback)

v3.1.1: before_compaction hook now properly triggers experience recording (LLM extract + write). memoryFlush still used for memory/*.md files.


🔄 Experience Recording Flow / 经验记录流程

before_compaction-Driven (Core) / before_compaction 驱动(核心)

v3.1.1: Hook triggers synchronously during compaction, before compact() executes.

before_compaction hook fires
    │
    ▼
① Save session context 保存上下文
    └─ handler.js → pending/*.json
    │
    ▼
② Extract & write 提取并写入
    ├─ processPendingItem() → LLM judgment
    └─ experiences.md written
    │
    ▼
③ Auto-review  auto-review.sh
    ├─ Similar experience detection
    └─ Tag → TOOLS.md promotion check
    │
    ▼
Compaction continues (compact() executes)

bootstrap (Startup) / 启动时

agent:bootstrap triggers
    ├─ Load domains/*.md → inject experience reminder into systemPrompt
    └─ Check drafts/ → process old drafts (fallback)

before_reset (Fallback) / 重置兜底

/reset or /new triggers
    └─ handler.js saves context → pending/*.json

🛡️ Safety & Security / 安全机制

Mechanism 机制Implementation 实现
Regex injection prevention 正则注入防护escape_grep() sed escaping
Path traversal filtering 路径穿越过滤replace(/[^a-zA-Z0-9_-]/g, '')
Concurrent write lock 并发写锁.write_lock/ directory atomic lock
Tag dedup promotion Tag去重晋升record.sh dedup + promote.sh threshold
Graceful degradation 降级容错LLM → keyword → write fallback chain

📊 Scripts Reference / 脚本说明

Script 脚本Lines 行数Function 功能
handler.js1,110Core hook handler (4 events, LLM integration)
search.sh539Search experiences (keyword / preview / all)
record.sh476Write new experience (with dedup & lock)
demote.sh371Demote HOT tags to WARM
compact.sh348Compress layers when exceeding limits
clean.sh247Remove test/invalid entries
vectors.sh232Vector search via LM Studio embeddings
promote.sh185Promote WARM tags to HOT (≥3x/7days)
import.sh172Import experiences from other sources
archive.sh167Archive old experiences to COLD
install.sh161Install skill to workspace
stats.sh153Show statistics dashboard
auto-review.sh136Auto-review pending drafts
append-record.sh100Append solution to existing experience
summarize-drafts.sh80Summarize and process drafts
update-record.sh77Update existing experience
common.sh41Shared utility functions
uninstall.sh37Remove skill
Total 共计4,632

✅ Verified Testing / 测试验证

Models Tested / 已测试模型

Model 模型ProviderForward Test 正向Reverse Test 逆向Status
deepseek-v4deepseek (api-key)✅ Pass✅ Pass (144/150)Verified
glm-5.1zai (api-key)✅ Pass✅ Pass (146/150)Verified
MiniMax-M2.7-highspeedminimax-portal (OAuth)✅ Pass✅ Pass (146/150)Verified

Test Coverage / 测试覆盖

Test 测试Result 结果
agent:bootstrap → systemPrompt injection✅ 12→952 chars
before_compaction → pending + LLM write✅ pending → LLM → experiences.md → auto-review
memoryFlush → memory/*.md write✅ Still used for memory file writing
before_reset → fallback save✅ pending saved
record.sh write + search✅ Write & find
auto-review.sh process draft✅ Draft → archive
compact.sh dry-run✅ All layers healthy
promote.sh tag promotion✅ Threshold check
stats.sh dashboard✅ Full panel
5 safety mechanisms✅ All present

🚀 Installation / 安装

1. Install Skill / 安装技能

# Clone
git clone https://gitee.com/rocky_tian/skill.git
cd skill/rocky-know-how

# Install
bash scripts/install.sh

# Verify
bash scripts/stats.sh

2. Configure memoryFlush / 配置 memoryFlush(重要)

This config is for memory/*.md file writing only (v3.1.1). Experience recording is now handled by before_compaction hook.

Add the following to your ~/.openclaw/openclaw.json:

{
  "agents": {
    "defaults": {
      "compaction": {
        "memoryFlush": {
          "enabled": true,
          "softThresholdTokens": 8000,
          "prompt": "会话即将压缩。请按以下流程处理经验,再写记忆:\n\n【第一步:处理旧草稿】\n检查 ~/.openclaw/.learnings/drafts/ 目录是否有旧草稿:\n  - 旧草稿 + 当前对话没提到同问题 → 说明已解决 → 调 record.sh 转正式经验\n  - 旧草稿 + 当前对话还在处理同问题 → 保留草稿不动\n\n【第二步:提取新经验】\n扫描当前对话,遇到以下情况值得记录:\n  - 同一问题失败≥2次后解决\n  - 踩坑后找到正确方案\n  - 发现重要配置/命令/技巧\n判断逻辑:\n  - 无旧草稿 + 第1轮就搞定 → 直接 record.sh 写正式经验\n  - 同问题有旧草稿(多轮调试)→ 写/更新草稿到 drafts/\n  - 没有值得记录的 → 跳过\n\n【第三步:写记忆文件】\n将重要记忆追加到 memory/YYYY-MM-DD.md(已有则追加,不覆盖)\n\n完成后回复 NO_REPLY。\n\nrecord.sh 用法:bash ~/.openclaw/skills/rocky-know-how/scripts/record.sh \"问题\" \"踩坑过程\" \"正确方案\" \"预防措施\" \"tag1,tag2\" \"领域\"",
          "systemPrompt": "会话即将压缩。按顺序处理:旧草稿→新经验→记忆文件。经验优先,记忆精简。"
        }
      }
    }
  }
}

Why softThresholdTokens: 8000?

OpenClaw default is 4000, but experience recording (judge + record.sh + memory write) needs ~3000-5500 tokens. 8000 provides enough headroom.

Why not use default 4000?

4000 tokens is too tight. If there are old drafts to process or the memory content is long, it may exceed the budget and cause the flush to fail.

3. Configure Hooks / 配置 Hook

# Add hook config to openclaw.json (under hooks.internal.entries)
# install.sh does this automatically

Hooks needed:

  • agent:bootstrap → handler (inject experience reminder)
  • before_reset → handler (fallback save)

📈 Key Advantages / 核心优势

  1. before_compaction-driven auto-learning — Experience recording triggered before every compaction
  2. LLM dual-judgment — First judges if worth saving, then decides create vs append
  3. Triple degradation — LLM → keyword → write, never loses data
  4. Multi-provider — Supports OpenAI, Anthropic, OAuth providers (zai/stepfun/minimax)
  5. Production proven — 45+ real experiences, 2.6MB data, stable operation
  6. Safety first — 5 security mechanisms (regex injection, path traversal, write lock, etc.)

Version: 3.4.8 | Tested: 2026-04-25 | License: MIT

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Research

Batch Content Factory

Multi-platform content production line. Automates the entire workflow from topic research to content creation. Suitable for self-media operators producing hi...

Registry SourceRecently Updated
Research

Fund Analyzer Pro

[何时使用]当用户需要基金深度分析时;当用户说"分析这个基金""基金对比""基金诊断""基金经理分析"时;当检测到基金代码/基金名称/投顾策略时触发。整合天天基金 API+ 且慢 MCP,提供单一基金分析/基金比较/基金诊断/持仓诊断/基金经理/机会分析/投资方式/报告信号八大模块。新增信号监控提醒功能(sign...

Registry SourceRecently Updated
Research

FN Portrait Toolkit

Financial report footnote extraction and analysis tool for Chinese A-share listed companies. Use when: (1) User wants to extract financial note data from ann...

Registry SourceRecently Updated
Research

流式AI检索问答技能

通用流式AI检索问答技能 — 为任意行业应用提供四步流式分析交互界面。 触发场景:用户输入关键词 → AI自动执行:理解意图 → 检索知识库 → 流式生成 → 来源标记 → 完整回答。 当需要实现以下任意场景时激活: (1) AI搜索框 / 智能咨询组件重构 (2) 知识库问答(医疗/法律/金融/教育等垂直领域)...

Registry SourceRecently Updated