DEV Community

Ana Julia Bittencourt
Ana Julia Bittencourt

Posted on

Give Your AI Agent Persistent Memory in 5 Minutes (Free)

AI agents forget everything between sessions. Every conversation starts from scratch. Your agent asks the same questions, misses context, and feels... stateless.

MemoClaw fixes this. It's a memory API for AI agents — semantic search, wallet-based identity, and now: 1000 free calls per wallet.

Let's set it up in 5 minutes.


What You'll Build

By the end of this tutorial, your agent will be able to:

  • Store memories that persist across sessions
  • Recall context by meaning, not keywords
  • Remember user preferences, decisions, and corrections

No database setup. No account creation. Just a wallet and a few API calls.


Prerequisites

  • Node.js 18+
  • A wallet private key (any EVM wallet works — create one with cast wallet new or MetaMask)

Step 1: Install the CLI

npm install -g memoclaw
Enter fullscreen mode Exit fullscreen mode

Step 2: Set Your Private Key

export MEMOCLAW_PRIVATE_KEY=0xYourPrivateKeyHere
Enter fullscreen mode Exit fullscreen mode

This wallet becomes your identity. All memories are scoped to your wallet address.

Step 3: Check Your Free Tier

memoclaw status
Enter fullscreen mode Exit fullscreen mode

Output:

Wallet: 0xf39f...2266
Free tier: 1000/1000 calls remaining
Enter fullscreen mode Exit fullscreen mode

You get 1000 free API calls. No payment required — the CLI signs with your wallet to prove ownership.


Step 4: Store Your First Memory

memoclaw store "User prefers dark mode and vim keybindings" \
  --importance 0.8 \
  --tags preferences,editor
Enter fullscreen mode Exit fullscreen mode

Output:

{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "stored": true,
  "tokens_used": 12
}
Enter fullscreen mode Exit fullscreen mode

What's happening:

  • Memory content is embedded into a vector
  • Stored with your wallet as the owner
  • Tagged for easy filtering later

Step 5: Recall by Meaning

memoclaw recall "what editor settings does the user like"
Enter fullscreen mode Exit fullscreen mode

Output:

[0.891] User prefers dark mode and vim keybindings
  tags: preferences, editor
Enter fullscreen mode Exit fullscreen mode

The query "editor settings" matched "vim keybindings" and "dark mode" — that's semantic search. You don't need exact keywords.


Integrate With Your Agent

Here's a simple pattern for any agent:

Before responding, recall context:

const context = await fetch('https://api.memoclaw.com/v1/recall', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-wallet-auth': await getWalletAuth()
  },
  body: JSON.stringify({
    query: 'user preferences and recent context',
    limit: 5
  })
});
Enter fullscreen mode Exit fullscreen mode

After learning something, store it:

await fetch('https://api.memoclaw.com/v1/store', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'x-wallet-auth': await getWalletAuth()
  },
  body: JSON.stringify({
    content: 'User timezone is America/Sao_Paulo',
    importance: 0.7,
    metadata: { tags: ['user-info'] }
  })
});
Enter fullscreen mode Exit fullscreen mode

Wallet Auth Helper

import { privateKeyToAccount } from 'viem/accounts';

const account = privateKeyToAccount(process.env.PRIVATE_KEY);

async function getWalletAuth() {
  const timestamp = Math.floor(Date.now() / 1000);
  const message = `memoclaw-auth:${timestamp}`;
  const signature = await account.signMessage({ message });
  return `${account.address}:${timestamp}:${signature}`;
}
Enter fullscreen mode Exit fullscreen mode

When Free Tier Runs Out

After 1000 calls, the API returns 402 Payment Required. You have two options:

  1. Create a new wallet — Get another 1000 free calls (memories stay with the old wallet)
  2. Fund with USDC — Pay $0.001/call with USDC on Base

The CLI handles the transition automatically. Just make sure your wallet has USDC on Base when you're ready.


What to Store

Do store:

  • User preferences and settings
  • Important decisions and rationale
  • Context that helps future sessions
  • Corrections ("actually, I meant...")

Don't store:

  • Passwords, API keys, secrets
  • Ephemeral conversation
  • Data you already stored (recall first!)

Full Example: Session Start

Here's how an agent might start a new session:

async function initSession() {
  // Recall recent context
  const recent = await memoclaw.recall('recent important context', { limit: 3 });

  // Recall user basics
  const user = await memoclaw.recall('user preferences and info', { limit: 3 });

  // Build context for the LLM
  const context = [
    'Previous context:',
    ...recent.memories.map(m => `- ${m.content}`),
    '',
    'User info:',
    ...user.memories.map(m => `- ${m.content}`)
  ].join('\n');

  return context;
}
Enter fullscreen mode Exit fullscreen mode

Now your agent remembers who it's talking to.


Resources


TL;DR

npm install -g memoclaw
export MEMOCLAW_PRIVATE_KEY=0x...
memoclaw status  # 1000 free calls
memoclaw store "User prefers tabs over spaces" --importance 0.8
memoclaw recall "indentation preference"  # finds it
Enter fullscreen mode Exit fullscreen mode

1000 free calls. No account. No API key. Just semantic memory for your agent.


Built by Ana. Questions? @memoclaw_ai

Top comments (0)