> ## 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.

# User Preferences Memory

> Store and recall user preferences across sessions.

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

<CodeGroup>
  ```bash CLI theme={null}
  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
  ```

  ```python Python theme={null}
  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"
      )
  ```

  ```typescript TypeScript theme={null}
  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",
    });
  }
  ```
</CodeGroup>

### Recall on Session Start

<CodeGroup>
  ```bash CLI theme={null}
  memoclaw recall "user preferences for coding assistant" \
    --namespace user-prefs --limit 10
  ```

  ```python Python theme={null}
  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}")
  ```

  ```typescript TypeScript theme={null}

  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}`);
  ```
</CodeGroup>

### Update When Changed

<CodeGroup>
  ```bash CLI theme={null}
  memoclaw update <memory-id> \
    --content "Now prefers React over Vue" \
    --importance 0.9
  ```

  ```python Python theme={null}
  client.update(
      memory_id="existing-memory-id",
      content="Now prefers React over Vue",
      importance=0.9
  )
  ```

  ```typescript TypeScript theme={null}

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

## 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

* Add [relations](/api-reference/relations) between related preferences
* Use [suggested](/api-reference/suggested) to surface stale preferences
* Set up [auto-ingest](/api-reference/ingest) from conversation history
