> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Claude Code

> Connect Claude Code to your Cognee Cloud tenant with the memory plugin.

Add persistent memory to [Claude Code](https://www.anthropic.com/claude-code) backed by your Cognee Cloud tenant with the **Cognee memory plugin** — no code and no `pip install`. The plugin hooks into Claude Code's lifecycle: it captures your prompts, tool traces, and answers into session memory, injects relevant context on every prompt, and syncs the session into your knowledge graph on session end.

Sessions are disposable; your memory isn't.

## 1. Install the plugin

Install from the Claude Code marketplace **before** launching Claude Code, so the first `claude` launch is a clean session that runs the plugin bootstrap automatically:

```bash theme={null}
claude plugin marketplace add topoteretes/cognee-integrations
claude plugin install cognee-memory@cognee
```

<Info>
  These CLI subcommands use the same plugin manager as the in-chat `/plugin` commands. If you instead install from inside the chat with `/plugin`, **restart Claude Code** (start a new session) before memory connects — `/reload-plugins` loads the skills but does not run `SessionStart`.
</Info>

<Note>
  Install scope defaults to `user` (global). Pass `--scope project` or `--scope local` to confine the plugin to a single repo.
</Note>

On the first clean launch you'll see a **"Cognee Memory Connected"** message, and the status line shows `cognee: <dataset> · <mode>`.

## 2. Point it at Cognee Cloud

Set both variables in the shell that launches Claude Code, using your tenant base URL and an [API key](/cognee-cloud/ui/api-keys):

```bash theme={null}
export COGNEE_BASE_URL="https://your-tenant.aws.cognee.ai"
export COGNEE_API_KEY="<your-api-key>"
```

<Info>
  When `COGNEE_BASE_URL` is set, the plugin runs as a pure thin HTTP client to your tenant — it does **not** install a local Cognee runtime. When `COGNEE_BASE_URL` is unset, the plugin instead bootstraps a local API at `http://localhost:8011`. Setting the Cloud URL and key is what routes memory to your tenant.
</Info>

## 3. Choose a dataset

All writes and recall are scoped to a **single dataset**, selected with the `COGNEE_PLUGIN_DATASET` environment variable. By default both the Claude Code and Codex plugins use `agent_sessions`, so memory is shared across both integrations automatically.

Set a custom dataset at launch:

```bash theme={null}
export COGNEE_PLUGIN_DATASET="my-project-memory"
```

<Warning>
  The dataset is **fixed for the lifetime of a launch**, and recall searches only the active dataset. To switch datasets, exit Claude Code, change `COGNEE_PLUGIN_DATASET`, and start it again. The `dataset` key in `~/.cognee-plugin/claude-code/config.json` is **informational-only** — runtime dataset selection reads the env var, not the config file.
</Warning>

Data added to the same dataset outside Claude Code (via the SDK or the server) is visible in Claude Code through the plugin.

## 4. Pick a session (optional)

By default a new `session_id` is generated on each launch. Set `COGNEE_SESSION_ID` to resume a specific named session, or to deliberately share one live session across two terminals:

```bash theme={null}
export COGNEE_SESSION_ID="my-project"
```

## 5. Verify

Restart Claude Code so `SessionStart` runs with the new credentials, then open a fresh session and ask:

> What do you know from cognee?

Answering from a clean session confirms it's recalling from your Cloud memory. You can also invoke the skills explicitly:

| Skill                            | Purpose                                    |
| -------------------------------- | ------------------------------------------ |
| `/cognee-memory:cognee-remember` | Store something in memory now              |
| `/cognee-memory:cognee-search`   | Query your memory                          |
| `/cognee-memory:cognee-sync`     | Persist the current session into the graph |

<Note>
  Memory is captured and synced from your sessions over time, and writes build the graph in the background — so a brand-new setup may recall nothing until at least one session has synced. An empty first recall is expected.
</Note>

<Tip>
  Share specific datasets with connected agents from the [Connections](/cognee-cloud/connections/managing-connections) page to grant scoped read access.
</Tip>

## Configuration reference

Precedence: environment variables → `~/.cognee-plugin/claude-code/config.json` → defaults.

| Env var                   | Default                   | Notes                                                                                             |
| ------------------------- | ------------------------- | ------------------------------------------------------------------------------------------------- |
| `COGNEE_BASE_URL`         | unset                     | Your tenant URL; enables Cloud/managed-endpoint mode                                              |
| `COGNEE_API_KEY`          | unset                     | Cloud API key from the [API Keys](/cognee-cloud/ui/api-keys) page; auto-minted only in local mode |
| `COGNEE_PLUGIN_DATASET`   | `agent_sessions`          | Dataset for writes and recall (config value is informational-only)                                |
| `COGNEE_SESSION_ID`       | auto-generated per launch | Override to resume or share a named session                                                       |
| `COGNEE_SESSION_STRATEGY` | `per-directory`           | `per-directory`, `git-branch`, or `static`                                                        |
| `COGNEE_SESSION_PREFIX`   | `cc`                      | Prefix for auto-generated session IDs                                                             |
| `COGNEE_PREFER_MEMORY`    | `true`                    | Inject the `SessionStart` steer treating Cognee as authoritative memory                           |
| `COGNEE_STATUSLINE`       | `true`                    | Auto-configure the `cognee: <dataset> · <mode>` status line                                       |

See the [full integration guide](/integrations/claude-code-integration) for the idle-watcher, session-sync, and update-notification variables.

***

<CardGroup cols={2}>
  <Card title="Full integration guide" icon="book" href="/integrations/claude-code-integration">
    Hooks reference, session sync, and debugging
  </Card>

  <Card title="Codex" icon="terminal" href="/cognee-cloud/agent-integrations/codex">
    The same memory plugin for the Codex CLI
  </Card>
</CardGroup>
