#270·LEANN

OpenClaw Integration: Skill + CLI enhancements for memory search

Author: andylizfCreated Feb 26, 2026Updated Feb 26, 2026

Summary

OpenClaw (229K+ GitHub stars) is a self-hosted personal AI assistant running on Mac Mini / Linux. Its memory system stores embeddings in full-precision vectors that grow linearly and never shrink. On a 256GB Mac Mini, heavy users can accumulate 500MB–6GB+ of embedding indexes over time.

LEANN's graph-pruned recomputation architecture (97% storage compression) is a natural fit as an OpenClaw memory search backend. OpenClaw's async message processing model ("sleep time compute") makes LEANN's recomputation latency invisible to end users.

What needs to be done

1. leann search --json flag

The search CLI command currently outputs human-readable text only. OpenClaw agents need structured output to parse results programmatically.

  • Add --json argument to the search subparser
  • When set, serialize SearchResult objects (id, score, text, metadata) as JSON to stdout
  • Keep the existing text output as default

2. leann watch --sync flag

The watch command currently detects file changes (added/removed/modified) via FileSynchronizer but only prints a report. It does not update the index.

  • Add --sync argument to the watch subparser
  • When set, after detecting changes, call update_index() for added/modified files and handle removals
  • This enables automatic re-indexing when OpenClaw memory files change

3. OpenClaw Skill (SKILL.md)

Create a skill directory at packages/leann-openclaw/ containing:

  • SKILL.md — YAML frontmatter + instructions telling the OpenClaw agent how to use leann build and leann search --json for memory search
  • README.md — Setup guide for OpenClaw users (install leann-core, build index on ~/.openclaw/workspace/memory/, configure the skill)

4. MCP server: structured output (optional follow-up)

The existing leann_mcp server returns plain text from CLI subprocess calls. Consider adding a JSON mode or calling the Python API directly for structured results. This would benefit both OpenClaw MCP integration and Claude Code usage.

Context