> ## Documentation Index
> Fetch the complete documentation index at: https://docs.memoclaw.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate from OpenClaw

> Import your OpenClaw memory files to MemoClaw in one command.

OpenClaw stores memories as local markdown files (`memory/YYYY-MM-DD.md`, `MEMORY.md`). MemoClaw can import these directly — each `##` section becomes a separate, searchable memory with auto-detected importance, tags, and type.

## CLI migration (recommended)

```bash theme={null}
# Install & init (skip if already done)
npm install -g memoclaw
memoclaw init

# Migrate your memory files
memoclaw migrate ~/.openclaw/workspace/memory/
```

The CLI reads all `.md` files in the directory, splits them by `##` headers, and sends them to the `/v1/migrate` endpoint.

```
✔ Scanned 42 files
✔ Created 187 memories (12 deduplicated)
✔ Migration complete
```

<Info>
  Migration is **idempotent** — running it twice won't create duplicates. Each memory chunk is content-hashed and checked against existing memories.
</Info>

## What gets imported

Each `##` section in a markdown file becomes one memory:

| Source                       | MemoClaw field                                           |
| ---------------------------- | -------------------------------------------------------- |
| Section body                 | `content`                                                |
| Keywords in content          | `memory_type` (decision, preference, correction, etc.)   |
| Header words + filename date | `tags` (e.g., `date:2026-01-30`, `migrated`, `openclaw`) |
| Content heuristics           | `importance` (0.6–0.9 based on keywords)                 |

Files without `##` headers are stored as a single memory.

## API migration

If you prefer direct API access, use `POST /v1/migrate`:

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST https://api.memoclaw.com/v1/migrate \
    -H "Content-Type: application/json" \
    -d '{
      "files": [
        {
          "filename": "2026-01-30.md",
          "content": "## Project Setup\nDecided to use PostgreSQL with pgvector.\n\n## Editor Config\nUser prefers vim keybindings and dark mode."
        },
        {
          "filename": "MEMORY.md",
          "content": "## Long-term preferences\nAlways use TypeScript over JavaScript."
        }
      ]
    }'
  ```

  ```python Python theme={null}
  import httpx

  files = []
  for path in Path("~/.openclaw/workspace/memory").expanduser().glob("*.md"):
      files.append({
          "filename": path.name,
          "content": path.read_text()
      })

  response = httpx.post(
      "https://api.memoclaw.com/v1/migrate",
      json={"files": files}
  )
  print(response.json())
  ```

  ```typescript TypeScript theme={null}
  import { readdir, readFile } from "fs/promises";
  import { join } from "path";

  const dir = `${process.env.HOME}/.openclaw/workspace/memory`;
  const entries = await readdir(dir);
  const files = await Promise.all(
    entries
      .filter((f) => f.endsWith(".md"))
      .map(async (f) => ({
        filename: f,
        content: await readFile(join(dir, f), "utf-8"),
      }))
  );

  const res = await fetch("https://api.memoclaw.com/v1/migrate", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ files }),
  });
  console.log(await res.json());
  ```
</CodeGroup>

### Response

```json theme={null}
{
  "files_processed": 2,
  "memories_created": 3,
  "memories_deduplicated": 0
}
```

If any files fail, partial results are returned with an `errors` array:

```json theme={null}
{
  "files_processed": 1,
  "memories_created": 2,
  "memories_deduplicated": 0,
  "errors": [
    { "filename": "bad-file.md", "error": "Content too short" }
  ]
}
```

## Limits

* **Max 50 files** per request
* Each section truncated to **8,000 characters**
* Sections shorter than 10 characters are skipped
* Requires x402 payment or free tier credits

## Install OpenClaw hooks (recommended)

After migrating your files, install the MemoClaw hooks so your agent automatically stores and recalls memories going forward — no manual commands needed.

```bash theme={null}
# Install the hook pack
openclaw hooks install memoclaw-hooks
openclaw hooks enable memoclaw
```

Set your wallet key in your environment (same wallet you used for migration):

```bash theme={null}
export MEMOCLAW_PRIVATE_KEY=0x...
```

Restart the gateway:

```bash theme={null}
openclaw gateway restart
```

Verify everything is wired up:

```bash theme={null}
openclaw hooks list --verbose
```

The hooks automatically handle:

| Event                  | What happens                                            |
| ---------------------- | ------------------------------------------------------- |
| **Session start**      | Recalls relevant memories based on the first message    |
| **Context compaction** | Saves important context before the window is compressed |
| **/new command**       | Extracts and stores key info before session reset       |
| **Heartbeat**          | Periodic consolidation to merge duplicate memories      |

<Tip>
  With hooks installed, you can remove memory-related instructions from your `AGENTS.md` and `SOUL.md` — MemoClaw handles it automatically.
</Tip>

## After migration

Your memories are now searchable by meaning:

```bash theme={null}
memoclaw recall "What database are we using?"
# [0.92] Decided to use PostgreSQL with pgvector.
#   tags: date:2026-01-30, project, setup, migrated, openclaw
```

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/get-started/quickstart">
    New to MemoClaw? Start here.
  </Card>

  <Card title="API Reference: Migrate" icon="code" href="/api-reference/migrate">
    Full endpoint documentation.
  </Card>
</CardGroup>
