clawmem

Lightweight memory management system for OpenClaw with 3-tier retrieval (L0/L1/L2), automatic lifecycle monitoring, and advanced search. Saves 60-80% on token costs while providing efficient memory storage and retrieval.

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 "clawmem" with this command: npx skills add leohuang8688/claw-mem

ClawMem Skill - OpenClaw Memory Management

Overview

ClawMem is a lightweight memory management system designed for OpenClaw agents. It provides efficient memory storage and retrieval with significant token cost optimization.

Features

  • 🎯 3-Tier Retrieval - L0 Index → L1 Timeline → L2 Details
  • 👁️ Automatic Lifecycle Monitoring - Intercepts 5 key OpenClaw events
  • 💰 Token Optimization - Save 60-80% on token costs
  • 🔍 Advanced Search - Keyword/Time/Tag/Session search
  • 🗄️ SQLite Storage - High performance, easy deployment

Quick Start

1. Install Dependencies

cd /root/.openclaw/workspace/projects/clawmem
npm install

2. Configure Environment

cp .env.example .env
# Edit .env with your configuration

3. Initialize Database

npm run db:init

4. Use in OpenClaw

import clawMem from './projects/clawmem/src/index.js';

// Store memory
const recordId = clawMem.storeL0({
  category: 'session',
  summary: 'User queried TSLA stock',
  timestamp: Math.floor(Date.now() / 1000)
});

// Retrieve memory
const result = await clawMem.retrieve({
  category: 'session',
  includeTimeline: true,
  limit: 10
});

Usage Examples

Store Memory

// L0 Index (minimal)
clawMem.storeL0({
  category: 'session',
  summary: 'Short summary (< 100 chars)',
  timestamp: Date.now()
});

// L1 Timeline (semantic)
clawMem.storeL1({
  record_id: recordId,
  session_id: 'session_001',
  event_type: 'query',
  semantic_summary: 'Detailed summary (< 500 chars)',
  tags: ['tag1', 'tag2']
});

// L2 Details (full content, on-demand)
clawMem.storeL2({
  record_id: recordId,
  full_content: 'Full content',
  metadata: { key: 'value' }
});

Search Memory

import { memorySearch } from './projects/clawmem/src/index.js';

// Keyword search
const results = memorySearch.searchByKeyword('keyword', {
  category: 'session',
  limit: 10
});

// Time range search
const results = memorySearch.searchByTimeRange({
  start: oneHourAgo,
  end: Date.now() / 1000
});

// Session search
const session = memorySearch.searchBySession('session_001', {
  includeDetails: true
});

// Advanced search
const result = await memorySearch.advancedSearch({
  keyword: 'stock',
  timeRange: { start, end },
  includeDetails: true,
  limit: 10
});

Lifecycle Monitoring

import { lifecycleMonitor } from './projects/clawmem/src/index.js';

// Start monitoring
lifecycleMonitor.start();

// Intercept events
lifecycleMonitor.intercept('tool.call', {
  tool_name: 'yahoo_finance',
  args: { symbol: 'AAPL' }
});

Configuration

Edit .env file:

# Database
DATABASE_PATH=./clawmem.db
DATABASE_WAL_MODE=true

# L0/L1/L2 Limits
L0_MAX_SUMMARY_LENGTH=100
L1_MAX_SUMMARY_LENGTH=500

# Worker Interval
WORKER_INTERVAL_MS=1000

# LLM Configuration
LLM_PROVIDER=openai
LLM_MODEL=gpt-3.5-turbo

API Reference

ClawMemCore

  • storeL0(record) - Store minimal index
  • storeL1(record) - Store timeline index
  • storeL2(record) - Store full details
  • retrieve(query) - 3-tier retrieval workflow

MemorySearch

  • searchByKeyword(keyword, options) - Keyword search
  • searchByTimeRange(timeRange, options) - Time-based search
  • searchByTags(tags, options) - Tag-based search
  • searchBySession(sessionId, options) - Session search
  • advancedSearch(query) - Combined search
  • getStats() - Get statistics

LifecycleMonitor

  • start() - Start monitoring
  • intercept(eventName, payload) - Intercept event

Performance

MetricValue
L0 Search< 10ms
L1 Search< 50ms
L2 Search< 100ms
Token Savings60-80%

Token Optimization

Traditional: 100 records × 500 tokens = 50,000 tokens

ClawMem:

  • L0: 100 × 25 = 2,500 tokens
  • L1: 50 × 125 = 6,250 tokens
  • L2: 10 × 500 = 5,000 tokens
  • Total: 13,750 tokens (72.5% savings!)

Project Structure

clawmem/
├── src/
│   ├── core/
│   │   ├── retrieval.js
│   │   ├── lifecycle-monitor.js
│   │   └── search.js
│   └── index.js
├── database/
│   └── init.js
├── config/
│   └── loader.js
├── docs/
├── .env.example
├── package.json
└── README.md

License

MIT License

Author

PocketAI for Leo - OpenClaw Community

Repository

https://github.com/leohuang8688/clawmem

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.

General

http-retry

Automatically retries HTTP requests with exponential backoff, timeout control, and connection pooling to handle network errors and rate limits.

Registry SourceRecently Updated
General

Email Resend

Send and receive emails using the Resend API. Use for: (1) sending emails directly via Resend API, (2) receiving email notifications via cron, (3) drafting r...

Registry SourceRecently Updated
1.2K0ivelin
General

Roundtable Adaptive

Adaptive multi-model AI roundtable. Runs up to 4 AI models (configurable) in 2 debate rounds with cross-critique and formal consensus scoring. Requires a con...

Registry SourceRecently Updated
General

EvoMap Node Controller

管理 EvoMap 节点的启动、配置和监控。用于在服务器上启动/停止 EvoMap evolver 循环、配置节点 ID,处理节点绑定等。使用场景:用户要求启动/停止 EvoMap 节点、查看节点状态、配置节点 ID、解决节点连接问题。⚠️ 使用前必须配置环境变量。

Registry SourceRecently Updated