---
title: "Command Line Setup"
description: "The Command Line Setup allows you to install the Mem0 command-line interface, initialize your user or agent account, and manage credentials directly from your terminal. Whether you are setting up a..."
last_updated: "2026-10-11T17:38:36.472258+00:00"
canonical_url: "https://www.doc0.dev/docs/faa36707-7c28-4f69-a18f-700ff61c704e/guide/getting-started/command-line-setup"
---

## Overview

### Introduction

The Command Line Setup allows you to install the Mem0 command-line interface, initialize your user or agent account, and manage credentials directly from your terminal. Whether you are setting up a standard user account or bootstrapping an unattended agent environment, the initialization wizard guides you through authentication, configuration storage, and identity management.

### Interactive Setup and Authentication

When you first run the setup wizard, you can choose between logging in with your email address or manually entering an API key. 

```mermaid
flowchart TD
    A[Run mem0 init] --> B{Choose Authentication}
    B -->|Option 1| C[Login with Email]
    B -->|Option 2| D[Enter API Key Manually]
    C --> E[Receive Verification Code]
    E --> F[Enter Code in Terminal]
    F --> G[Save Credentials]
    D --> G[Save Credentials]
```

### Step-by-Step Initialization

To configure your terminal environment and connect to Mem0, follow these steps:

1. **Launch the setup wizard:** Run the initialization command in your terminal.
   ```bash
   mem0 init
   ```
2. **Select your authentication method:** When prompted, choose whether to sign in using your email address (recommended) or by providing an API key manually.
3. **Verify your identity:** If you chose email login, enter your email address and type the verification code sent to your inbox when prompted. 
4. **Set your default user scope:** Define a default user identifier to scope your memories, or press Enter to accept the recommended default based on your system username.

> [!NOTE]
> Saved credentials and configuration settings are automatically stored in your user directory at `~/.mem0/config.json`.

---

## Non-Interactive and Automated Setup

### Introduction

For automated scripts, continuous integration environments, or unattended terminal setups, you can pass command-line options directly to skip interactive prompts.

### Command Options

| Option | Description |
| :--- | :--- |
| `--api-key <key>` | Provide an API key directly to skip the setup prompt. |
| `-u, --user-id <id>` | Set a default user ID for scoping your memories. |
| `--email <email>` | Start the email verification login flow. |
| `--code <code>` | Provide the email verification code for non-interactive login. |
| `--agent` | Bootstrap an unattended Agent Mode account without requiring an email. |
| `--source <channel>` | Provide channel attribution for signups (e.g., `github`, `hn`, `ph`). |
| `--agent-caller <name>` | Self-declare your AI agent identity (e.g., `claude-code`, `cursor`). |
| `--force` | Overwrite an existing configuration file without prompting for confirmation. |

### Quick Setup Examples

* **Standard initialization:**
  ```bash
  mem0 init
  ```
* **Non-interactive API key setup:**
  ```bash
  mem0 init --api-key m0-xxx --user-id alice
  ```
* **Non-interactive email login:**
  ```bash
  mem0 init --email you@example.com --code 123456
  ```
* **Unattended Agent Mode bootstrap:**
  ```bash
  mem0 init --agent --agent-caller claude-code
  ```

> [!TIP]
> If you already have a valid API key configured in your environment variables via `MEM0_API_KEY`, the CLI will automatically detect and reuse it during initialization.

---

## Agent Mode and Account Management

### Introduction

Mem0 supports Agent Mode for AI coding assistants and autonomous agents. This allows an agent to bootstrap a functional memory store instantly without requiring a manual email sign-up step.

### Managing Agent Identity

* **Bootstrap Agent Mode:** Run the initialization command with the agent flag to create an unattended account:
  ```bash
  mem0 init --agent
  ```
* **Tag your active agent:** If you did not specify an agent caller during bootstrap, you can tag your active key later using the identify command:
  ```bash
  mem0 identify claude-code
  ```
* **Check your active identity:** Print your current agent identifier (AGENTRUSH identifier) using the whoami command:
  ```bash
  mem0 whoami
  ```

> [!IMPORTANT]
> Supported self-declared agent identities include: `claude-code`, `cursor`, and custom bot names.

### Claiming an Agent Account

If you started using Mem0 in Agent Mode and want to upgrade your account to a permanent human-owned profile linked to your email address, you can claim the account at any time:

```bash
mem0 init --email you@example.com
```

This process uses a verification code sent to your inbox to link your existing agent API key to your email address without changing or invalidating your current key.

## Related

- [Quickstart Overview](https://www.doc0.dev/docs/faa36707-7c28-4f69-a18f-700ff61c704e/guide/getting-started/quickstart-overview)
- [Managing Memories](https://www.doc0.dev/docs/faa36707-7c28-4f69-a18f-700ff61c704e/guide/core-features/managing-memories)


## Sitemap

See the full [sitemap](https://www.doc0.dev/docs/faa36707-7c28-4f69-a18f-700ff61c704e/llms.txt) for all pages in this wiki.
