---
title: "Memories and Chat Commands"
canonical: "https://test.abhinandan.one/cli-overview/cli-memories-and-chat"
markdown_url: "https://test.abhinandan.one/cli-overview/cli-memories-and-chat.md"
publisher: "Primitive SDKs"
kind: "guide"
content_type: "reference"
category: "CLI"
parent: "cli-overview"
description: "The primitive memories command group reads and writes durable JSON key-value records, and primitive chat opens an interactive REPL against your account."
keywords: ["primitive memories set", "primitive memories get", "primitive memories search", "primitive memories delete", "primitive chat", "function-scoped memories"]
last_modified: "2026-08-11T18:54:56.417775+00:00"
published_at: "2026-08-11T18:54:56.201423+00:00"
sections:
  - {anchor: "prerequisites", title: "Prerequisites"}
  - {anchor: "store-and-retrieve-memories", title: "Store and retrieve memories"}
  - {anchor: "step-set-a-memory-value", title: "Set a memory value"}
  - {anchor: "step-get-a-memory-value", title: "Get a memory value"}
  - {anchor: "step-search-memories-by-key-prefix", title: "Search memories by key prefix"}
  - {anchor: "step-delete-a-memory", title: "Delete a memory"}
  - {anchor: "function-scoped-memories", title: "Function-scoped memories"}
  - {anchor: "interactive-chat-repl", title: "Interactive chat REPL"}
  - {anchor: "next-steps", title: "Next steps"}
---

> Documentation index: https://test.abhinandan.one/llms.txt

# Memories and Chat Commands

Store, fetch, and search durable JSON records from the terminal with primitive memories, and use the interactive primitive chat REPL for testing conversational flows against your account.

The `primitive memories` command group reads and writes [Primitive Memories](https://test.abhinandan.one/node-sdk-api-client.md), the durable JSON key-value record store, directly from the terminal. `primitive chat` opens an interactive REPL for testing conversational flows against your account without writing a script first.

Use `memories` when you're debugging what a function or agent has stored, seeding state before a test run, or clearing stale keys. Use `chat` when you want a quick interactive session without standing up a client.

Values must be valid JSON, and `memories search` matches key prefixes only, not free text.

## Prerequisites

- The CLI installed and authenticated. See [Authentication: login, signup, logout, whoami](https://test.abhinandan.one/cli-overview/cli-authentication.md).
- A Primitive API key, either from `primitive login` credentials or `PRIMITIVE_API_KEY`.

## Store and retrieve memories

Use `primitive memories set`, `get`, `search`, and `delete` to manage durable JSON records from the terminal. Memories default to org scope. Pass `--function <function-id>` to read or write the same key under a function's scope instead; the value must be the function's id UUID, not its name.

### 1. Set a memory value

Values must be valid JSON. Quote plain strings as JSON strings.

```bash
primitive memories set thread:latest '{"email_id":"em_123"}'
primitive memories set greeting '"hello"'
```

Values must be valid JSON, so a plain string has to be quoted as a JSON string: use `'"hello"'`, not `hello`.

### 2. Get a memory value

```bash
primitive memories get thread:latest
```

### 3. Search memories by key prefix

`memories search` is key-prefix search, not free-text or semantic search. For free-text mail search use `primitive search` or `primitive semantic-search` instead.

```bash
primitive memories search thread:
```

Pass `--metadata-only` to list matching keys without fetching each value, useful for a quick inventory scan:

```bash
primitive memories search thread: --metadata-only
```

### 4. Delete a memory

```bash
primitive memories delete thread:latest
```

### Function-scoped memories

Pass `--function <function-id>` on any of the four subcommands to read or write the same key under a specific function's scope instead of the org's:

```bash
primitive memories set state '{"step":2}' --function <function-id>
primitive memories get state --function <function-id>
```

> **Tip:** The `--function` value is the function's id UUID, not its name. If you only have the name, look the id up with `primitive functions list`.

> **Warning:** `primitive memories delete` is permanent. There is no undo and no trash/recovery period for a deleted key.

## Interactive chat REPL

`primitive chat` opens an interactive REPL against your account, so you can exercise a conversational flow without writing a throwaway script.

```bash
primitive chat
```

Inside the REPL, reply to the active thread the same way the SDK's `client.reply` would, including attachments:

```bash
primitive chat reply "See attached" --attachment ./report.pdf
```

> **Note:** `primitive logout --force` clears local CLI credentials, pending email-code auth state, and stale credential locks without contacting Primitive. Reach for it when an interrupted auth command leaves the CLI reporting that another credential operation is already in progress. See [Authentication: login, signup, logout, whoami](https://test.abhinandan.one/cli-overview/cli-authentication.md).
