Knowledge Management Skill (Local Storage)
Organize your OpenClaw memory files into a structured local knowledge base. Automatically parses MEMORY.md and daily memory files, classifies entries by content type, and stores each as a timestamped markdown file in the appropriate folder.
Available Tools
Core Commands
- -
km sync [options] - Sync memory entries to local files - INLINECODE2 - Parse and classify without storing (JSON output)
- INLINECODE3 - Generate index files for each content type
- INLINECODE4 - Remove orphaned files
- INLINECODE5 - List all available content types
Setup
No API keys needed! The skill uses two locations:
- - Input Workspace: Where
MEMORY.md and memory/ daily files are read from. - Output Directory: Where organized folders (
Research/, Decision/, etc.) are written.
Both are detected automatically:
Input Workspace (source files)
- 1.
OPENCLAWORKSPACE environment variable - INLINECODE11 CLI argument
- Current working directory (if it contains
MEMORY.md) - Default: INLINECODE13
Output Directory (organized files)
- 1.
--output-dir <path> CLI argument (relative to workspace or absolute) - Default: INLINECODE15
The skill will create the output directory and all content-type folders automatically.
If you want to pre-create:
CODEBLOCK0
Usage Examples
Default locations (input at workspace root, output in memory/KM)
CODEBLOCK1
Custom input workspace and output directory
CODEBLOCK2
Using environment variables
CODEBLOCK3
Dry run (preview only)
CODEBLOCK4
Classify entries and export JSON
CODEBLOCK5
Generate index files (default: output directory)
CODEBLOCK6
Preview orphan cleanup
CODEBLOCK7
List content types
CODEBLOCK8
Storage Structure
Assuming default configuration:
- - Input workspace: INLINECODE16
- Output directory: INLINECODE17
CODEBLOCK9
File Naming
Format: INLINECODE18
The 8-character content hash suffix prevents filename collisions when titles are identical but content differs.
File Content (YAML Frontmatter)
CODEBLOCK10
How It Works
- 1. Parses
MEMORY.md and recent daily memory/*.md files - Classifies each entry (content type, domain, certainty, impact, tags, confidence)
- Computes content hash for deduplication
- Checks sync state (
memory/local-sync-state.json) to skip already synced entries - Writes to appropriate folder with timestamp + hash filename
- Updates state mapping (hash → filepath)
- Optional cleanup removes files not in state
Classification Logic
- - Content Type: Keyword matching (Research, Lesson, Decision, Pattern, Tutorial, Reference, Insight)
- Domain: Contextual inference (AI Models, OpenClaw, Cost, Trading, etc.)
- Certainty: Based on language (Verified, Likely, Speculative, Opinion)
- Impact: Importance indicators (High, Medium, Low, Negligible)
- Tags: Auto-extracted from predefined keyword map
- Confidence Score: 1–10 heuristic (source credibility, length, data mentions)
Customize by editing the EntryClassifier class in index-local.js.
State Management
INLINECODE24 maps content hashes to file paths:
CODEBLOCK11
This enables idempotent syncs and fast duplicate detection.
Do not edit manually unless recovering from corruption.
Cron Integration
Automate daily syncs:
CODEBLOCK12
Note: By default, the skill reads MEMORY.md from ~/.openclaw/workspace and writes organized files to ~/.openclaw/workspace/memory/KM. Use --workspace or --output-dir to customize these locations.
Troubleshooting
"km: command not found"
- - Run
npm link in the skill directory, or add ~/workspace/bin to PATH.
No entries found
- - Ensure
MEMORY.md uses ## section headers and ### entry titles within recognized sections.
Files not created
- - Check write permissions; run with
--verbose.
Old entries not syncing
- - They may already be in state. Clear
memory/KM/local-sync-state.json to force re-sync (caution: may duplicate files).
Duplicate files
- - Run
km cleanup to remove orphans, then km sync to create missing files.
Version: 2.0.0
Changed: 2026-02-15 — Switched from Notion to local storage, added hash suffixes for uniqueness.
Author: Claire (OpenClaw Agent)
License: MIT
技能名称:knowledge-management
详细描述:
知识管理技能(本地存储)
将您的 OpenClaw 记忆文件整理成结构化的本地知识库。自动解析 MEMORY.md 和每日记忆文件,按内容类型对条目进行分类,并将每个条目作为带时间戳的 Markdown 文件存储到相应文件夹中。
可用工具
核心命令
- - km sync [选项] - 将记忆条目同步到本地文件
- km classify [选项] - 解析并分类,不存储(输出 JSON)
- km summarize [选项] - 为每种内容类型生成索引文件
- km cleanup [选项] - 删除孤立文件
- km list_types - 列出所有可用的内容类型
设置
无需 API 密钥!该技能使用两个位置:
- - 输入工作区:从中读取 MEMORY.md 和 memory/ 每日文件的位置。
- 输出目录:写入整理好的文件夹(如 Research/、Decision/ 等)的位置。
两者均自动检测:
输入工作区(源文件)
- 1. OPENCLAWORKSPACE 环境变量
- --workspace <路径> 命令行参数
- 当前工作目录(如果包含 MEMORY.md)
- 默认值:~/.openclaw/workspace
输出目录(整理后的文件)
- 1. --output-dir <路径> 命令行参数(相对于工作区或绝对路径)
- 默认值:/memory/KM
该技能会自动创建输出目录及所有内容类型文件夹。
如果您想预先创建:
bash
mkdir -p ~/.openclaw/workspace/memory/KM/{Research,Decision,Insight,Lesson,Pattern,Project,Reference,Tutorial}
使用示例
默认位置(输入在工作区根目录,输出在 memory/KM)
bash
从任意目录执行(工作区自动检测)
km sync --days_back 7 --cleanup
自定义输入工作区和输出目录
bash
km sync --workspace /custom/input/workspace --output-dir /custom/output/KM --days_back 7
使用环境变量
bash
export OPENCLAWORKSPACE=/custom/input/workspace
km sync --output-dir /custom/output/KM --days_back 7
试运行(仅预览)
bash
km sync --dry
run --daysback 1
分类条目并导出 JSON
bash
km classify --days_back 3 > entries.json
生成索引文件(默认:输出目录)
bash
km summarize
或指定其他位置
km summarize --output_dir ~/some/other/folder
预览孤立文件清理
bash
km cleanup --dry_run
列出内容类型
bash
km list_types
存储结构
假设默认配置:
- - 输入工作区:~/.openclaw/workspace
- 输出目录:~/.openclaw/workspace/memory/KM
~/.openclaw/workspace/
├── MEMORY.md (源文件 - 您编辑此文件)
├── memory/ (每日记忆文件)
│ ├── 2025-02-11.md
│ ├── 2025-02-12.md
│ └── ...
└── memory/KM/ (由该技能整理的输出)
├── local-sync-state.json
├── local-sync-log.md
├── Research/
│ ├── 20260215T1448TitleHere_HASH.md
│ └── ...
├── Decision/
├── Insight/
├── Lesson/
├── Pattern/
├── Project/
├── Reference/
├── Tutorial/
├── Research_Index.md
├── Decision_Index.md
└── ... (其他索引文件)
文件命名
格式:YYYYMMDDTHHMMTitleWithUnderscores8CHARHASH.md
8 位内容哈希后缀可防止标题相同但内容不同时的文件名冲突。
文件内容(YAML 前置元数据)
markdown
title: 协议名称
content_type: Research
domain: OpenClaw
certainty: Verified
impact: Medium
confidence_score: 8
tags: [AI, Automation]
source: MEMORY.md
source_file: MEMORY.md
date: 2026-02-11
content_hash: e4b30e75d0f5a662
条目正文内容从此处开始...
工作原理
- 1. 解析 MEMORY.md 和最近的每日 memory/*.md 文件
- 对每个条目进行分类(内容类型、领域、确定性、影响、标签、置信度)
- 计算内容哈希以去重
- 检查同步状态(memory/local-sync-state.json)以跳过已同步的条目
- 写入相应文件夹,文件名包含时间戳和哈希
- 更新状态映射(哈希 → 文件路径)
- 可选清理:删除不在状态中的文件
分类逻辑
- - 内容类型: 关键词匹配(Research、Lesson、Decision、Pattern、Tutorial、Reference、Insight)
- 领域: 上下文推断(AI Models、OpenClaw、Cost、Trading 等)
- 确定性: 基于语言(Verified、Likely、Speculative、Opinion)
- 影响: 重要性指标(High、Medium、Low、Negligible)
- 标签: 从预定义关键词映射中自动提取
- 置信度评分: 1–10 启发式评分(来源可信度、长度、数据提及)
通过编辑 index-local.js 中的 EntryClassifier 类进行自定义。
状态管理
memory/local-sync-state.json 将内容哈希映射到文件路径:
json
{
e4b30e75d0f5a662: /path/to/Research/202602151440Titlee4b30e75.md
}
这实现了幂等同步和快速重复检测。
除非从损坏中恢复,否则请勿手动编辑。
Cron 集成
自动化每日同步:
bash
openclaw cron add \
--name 每日知识同步 \
--cron 0 5 * \
--tz Asia/Singapore \
--session isolated \
--message km sync --days_back 7
注意:默认情况下,该技能从 ~/.openclaw/workspace 读取 MEMORY.md,并将整理后的文件写入 ~/.openclaw/workspace/memory/KM。使用 --workspace 或 --output-dir 自定义这些位置。
故障排除
km: command not found
- - 在技能目录中运行 npm link,或将 ~/workspace/bin 添加到 PATH。
未找到条目
- - 确保 MEMORY.md 在识别的章节中使用 ## 章节标题和 ### 条目标题。
文件未创建
- - 检查写入权限;使用 --verbose 运行。
旧条目未同步
- - 它们可能已在状态中。清除 memory/KM/local-sync-state.json 以强制重新同步(注意:可能导致文件重复)。
重复文件
- - 运行 km cleanup 删除孤立文件,然后运行 km sync 创建缺失文件。
版本: 2.0.0
更改日期: 2026-02-15 — 从 Notion 切换到本地存储,添加哈希后缀以确保唯一性。
作者: Claire(OpenClaw 代理)
许可证: MIT