← 返回 Skills 市场
mystour

Claude Memory Optimizer

作者 陈子昂 · GitHub ↗ · v1.3.0 · MIT-0
cross-platform ✓ 安全检测通过
133
总下载
1
收藏
1
当前安装
4
版本数
在 OpenClaw 中安装
/install claude-memory-optimizer
功能描述
Structured memory system with 4-type classification (user/feedback/project/reference), frontmatter metadata, and automated migration. Based on Claude Code me...
使用说明 (SKILL.md)

Claude Memory Optimizer

Structured memory system for OpenClaw with 4-type classification and automated migration.

When to Use

  • Setting up memory for the first time in OpenClaw
  • Migrating from unstructured memory/*.md to organized categories
  • Improving memory recall with semantic frontmatter
  • Implementing Claude Code-style memory architecture

Features

  • 4-Type Classification: user, feedback, project, reference
  • Frontmatter Metadata: structured name/description/type for semantic search
  • Auto-Migration: one-command refactor of existing memory files
  • Log Mode: optional append-only daily logs (KAIROS style)

Quick Start

Install

clawhub install claude-memory-optimizer

Run Migration

# Auto-detect workspace
node ~/.openclaw/skills/claude-memory-optimizer/scripts/refactor-memory.js

# Or specify explicitly
node ~/.openclaw/skills/claude-memory-optimizer/scripts/refactor-memory.js ~/.openclaw/workspace

Verify

ls -la ~/.openclaw/workspace/memory/
cat ~/.openclaw/workspace/MEMORY.md

Memory Types

Type Purpose Example
user User role, preferences, skills "Data scientist, prefers concise replies"
feedback Behavior corrections/confirmations "No trailing summaries — user can read diffs"
project Project context, decisions, deadlines "Thesis deadline: 2026-06-01"
reference External system pointers "Kaggle: https://kaggle.com/chenziong"

Directory Structure

memory/
├── user/          # User information
├── feedback/      # Behavior guidance
├── project/       # Project context
├── reference/     # External references
└── logs/          # Append-only logs (optional)
    └── YYYY/
        └── MM/
            └── YYYY-MM-DD.md

Memory File Format

Each memory file uses frontmatter metadata:

---
name: Data Science Background
description: User is a data scientist focused on observability and LLMs
type: user
---

User studies at Beijing University of Technology & UCD, GPA 3.95/4.2.
Research: LLM, AI Agents, MCP.

**Skills:** Python, PyTorch, Transformers, NLP

**How to apply:** Use data science terminology, assume ML background.

What NOT to Save

  • Code patterns, architecture, file paths (derivable from codebase)
  • Git history, recent changes (use git log)
  • Debugging solutions (fix is in the code)
  • Content already in CLAUDE.md
  • Ephemeral task details (only useful in current session)

Configuration

OpenClaw Config

{
  "agents": {
    "defaults": {
      "memorySearch": {
        "enabled": true,
        "provider": "local",
        "maxResults": 20,
        "minScore": 0.3
      },
      "compaction": {
        "memoryFlush": {
          "enabled": true,
          "softThresholdTokens": 4000
        }
      }
    }
  }
}

Usage Examples

Save User Preference

User: "Remember, I prefer concise replies without trailing summaries."

AI: Saves to memory/feedback/reply-style.md:

---
name: Reply Style Preference
description: User wants concise replies, no trailing summaries
type: feedback
---

**Rule:** Keep replies concise, no trailing summaries.

**Why:** User said "I can read the diff myself."

**How to apply:** End responses directly after completing work.

Retrieve Memory

User: "What did I say about database testing?"

AI: Runs memory_search query="database testing" → returns memory/feedback/db-testing.md

Verify Memory

User: "Is the experiment design in memory/project/dong-thesis.md still current?"

AI: Runs grep to verify → detects outdated info → updates memory file.

Migration Guide

Before

memory/
├── 2026-03-21.md
├── 2026-03-28.md
├── research-memory.md
└── video-memory.md

After

memory/
├── project/
│   ├── 2026-03-21-.md
│   ├── 2026-03-28-.md
│   └── research-memory.md
├── reference/
│   └── video-memory.md
└── logs/2026/04/2026-04-02.md

Advanced Features

Semantic Retrieval (Future)

async function findRelevantMemories(query: string, memoryDir: string) {
  const memories = await scanMemoryFiles(memoryDir);
  const selected = await selectRelevantMemories(query, memories);
  return selected.slice(0, 5); // Top 5 relevant memories
}

Verification on Recall (Future)

Before recommending from memory:

  1. If memory names a file → ls to verify existence
  2. If memory names a function → grep to confirm
  3. If memory conflicts with current state → trust current observation, update memory

"Memory says X exists" ≠ "X exists now"

Maintenance

Daily (Heartbeat)

  • Append to memory/YYYY-MM-DD.md
  • Record decisions, conversations, learnings

Weekly (Review)

  • Read daily notes
  • Distill important info to MEMORY.md
  • Remove outdated entries

Monthly (Audit)

  • Review project progress
  • Update long-term goals
  • Check .learnings/ records

Troubleshooting

Memory Not Loaded

  • Ensure MEMORY.md exists in workspace root
  • Check agents.defaults.memorySearch.enabled = true
  • Restart OpenClaw gateway

Poor Recall Quality

  • Add specific description in frontmatter
  • Use consistent keywords
  • Adjust minScore (lower = broader matches)

Migration Fails

  • Backup memory/ directory first
  • Run script with --dry-run (if available)
  • Check file permissions

References

  • Claude Code: src/memdir/ (memdir.ts, memoryTypes.ts, findRelevantMemories.ts)
  • OpenClaw Docs: docs/concepts/memory.md
  • Related Skills: memory-setup-openclaw, elite-longterm-memory

License

MIT-0

License

MIT-0

安全使用建议
This tool is coherent for migrating local memory markdown files, but it will read and write files under the workspace you point it at. Before running: 1) Back up your workspace/memory directory (the README also advises this). 2) Expect the script to create new files and an updated MEMORY.md but not to delete original files; you'll need to manually remove originals after review. 3) The SKILL.md mentions --dry-run, but the included script does not implement a dry-run mode — test on a small subset first. 4) The script currently constructs frontmatter but the implementation writes the original file contents to the new path (a functional bug), so verify that migrated files contain the expected frontmatter and index entries. If you are comfortable with these behaviors and test on backups first, the skill appears internally consistent and limited to local workspace operations.
功能分析
Type: OpenClaw Skill Name: claude-memory-optimizer Version: 1.3.0 The skill provides a structured memory management system for OpenClaw agents, mimicking the architecture used by Claude Code. The core logic in 'scripts/refactor-memory.js' performs local file operations to categorize and add metadata to markdown files within a designated workspace memory directory. No evidence of data exfiltration, unauthorized network access, or malicious prompt injection was found; the script's behavior aligns entirely with the stated purpose of organizing and migrating agent memory.
能力评估
Purpose & Capability
Name/description match the provided files and script: the package and SKILL.md declare a migration/structuring tool and the included refactor-memory.js implements detection, creation of categorized directories, index update, and log file creation. No unrelated credentials or remote network access are requested.
Instruction Scope
SKILL.md and README instruct the agent/operator to run local commands (node script, ls, cat, grep). These are within the migration/verification scope, but you should note the script will read many files under WORKSPACE/memory and may run grep over the workspace for verification. Also SKILL.md mentions a '--dry-run' option in troubleshooting, but the provided script does not implement any dry-run flag — a functional mismatch the user should be aware of.
Install Mechanism
No install spec; the skill is instruction-only with a local Node script. There are no downloads from external URLs or extracted archives. Risk surface is limited to running the included local script under node.
Credentials
The skill requires no environment variables, credentials, or config paths. It optionally reads OPENCLAW_WORKSPACE (documented) or uses the working directory; this is appropriate for a filesystem migration tool.
Persistence & Privilege
always is false and model invocation isn't disabled (platform defaults). The skill writes files under the user's workspace/memory and updates MEMORY.md — this is expected behaviour for a migration utility. It does not modify other skills' configs or request permanent elevated privileges.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install claude-memory-optimizer
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /claude-memory-optimizer 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.3.0
Fixed P1 bugs: frontmatter write, workspace detection, date filter. Anonymized examples. Removed PR-DRAFT.md.
v1.2.0
Fixed hard-coded paths: now auto-detects workspace from argv/env/cwd. Added usage examples and error messages. Multi-platform support.
v1.1.0
Rewrote SKILL.md and README.md with professional English format, aligned with top-rated skills
v1.0.0
Initial release: 4-type memory classification, frontmatter support, migration script
元数据
Slug claude-memory-optimizer
版本 1.3.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 4
常见问题

Claude Memory Optimizer 是什么?

Structured memory system with 4-type classification (user/feedback/project/reference), frontmatter metadata, and automated migration. Based on Claude Code me... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 133 次。

如何安装 Claude Memory Optimizer?

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

Claude Memory Optimizer 是免费的吗?

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

Claude Memory Optimizer 支持哪些平台?

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

谁开发了 Claude Memory Optimizer?

由 陈子昂(@mystour)开发并维护,当前版本 v1.3.0。

💬 留言讨论