Skip to main content
Store user preferences persistently so your AI assistant remembers them across sessions.

Use Case

An AI assistant that helps users with coding tasks. It should remember:
  • Preferred programming languages
  • Editor settings
  • Notification preferences
  • Timezone

Implementation

Store Preferences

memoclaw store "Prefers TypeScript over JavaScript" \
  --importance 0.9 --type preference --namespace user-prefs

memoclaw store "Uses VS Code with Vim extension" \
  --importance 0.8 --type preference --namespace user-prefs

memoclaw store "Prefers dark mode" \
  --importance 0.85 --type preference --namespace user-prefs

memoclaw store "Timezone is PST" \
  --importance 0.95 --type preference --namespace user-prefs
from memoclaw import MemoClaw

client = MemoClaw()

preferences = [
    ("Prefers TypeScript over JavaScript", 0.9),
    ("Uses VS Code with Vim extension", 0.8),
    ("Prefers dark mode", 0.85),
    ("Timezone is PST", 0.95),
]

for pref, importance in preferences:
    client.store(
        content=pref,
        importance=importance,
        memory_type="preference",
        namespace="user-prefs"
    )
import { MemoClawClient } from "memoclaw";

const client = new MemoClawClient();

const preferences = [
  { content: "Prefers TypeScript over JavaScript", importance: 0.9 },
  { content: "Uses VS Code with Vim extension", importance: 0.8 },
  { content: "Prefers dark mode", importance: 0.85 },
  { content: "Timezone is PST", importance: 0.95 },
];

for (const pref of preferences) {
  await client.store({
    content: pref.content,
    importance: pref.importance,
    memory_type: "preference",
    namespace: "user-prefs",
  });
}

Recall on Session Start

memoclaw recall "user preferences for coding assistant" \
  --namespace user-prefs --limit 10
memories = client.recall(
    query="user preferences for coding assistant",
    namespace="user-prefs",
    limit=10
)

context = "\n".join([
    f"- {m.content}" 
    for m in memories.memories
])
print(f"User preferences:\n{context}")

const memories = await client.recall({
  query: "user preferences for coding assistant",
  namespace: "user-prefs",
  limit: 10,
});

const context = memories.memories
  .map((m) => `- ${m.content}`)
  .join("\n");
console.log(`User preferences:\n${context}`);

Update When Changed

memoclaw update <memory-id> \
  --content "Now prefers React over Vue" \
  --importance 0.9
client.update(
    memory_id="existing-memory-id",
    content="Now prefers React over Vue",
    importance=0.9
)

await client.update("existing-memory-id", {
  content: "Now prefers React over Vue",
  importance: 0.9,
});

Memory Types

Use memory_type: "preference" for user preferences. This gives them a 180-day half-life, meaning they persist for a long time but eventually decay if not reinforced.

Next Steps