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
You need Claude Code itself first. If the commands below fail withcommand not found: claude, Claude Code isn’t installed or isn’t on your PATH: install it, open a new terminal, and check that claude --version works.
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:
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.user (global); pass --scope project or --scope local to confine the plugin to a single repo.
On the first clean launch you’ll see a “Cognee Memory Connected” message, and the Cognee status row shows the dataset, the mode, and what memory is doing.
2. Point it at Cognee Cloud
Write both variables once into~/.cognee/.env, using your tenant base URL (the API base URL in the Connection panel of the API Keys page) and an API key from Create new key on the same page. The file is created with a commented template on the first session start, is shared with the Codex plugin, and its values act like shell exports — except you only set them once, and they survive closing the terminal:
- macOS / Linux (bash, zsh)
- Windows (PowerShell)
- Windows (cmd.exe)
claude launch.
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.LLM_API_KEY in the same file is fine: cloud still wins, because a configured URL is what selects cloud. To send one terminal to local instead, export COGNEE_BACKEND=local before launching — unset COGNEE_BASE_URL does not work, because the env file re-injects the URL at the next launch. See Which mode wins.
3. Choose a dataset
All writes go to a single dataset, selected with theCOGNEE_PLUGIN_DATASET environment variable. By default both the Claude Code and Codex plugins use agent_sessions, so memory is shared across both integrations automatically. On your tenant that sharing is real rather than nominal: where the tenant gives each machine its own plugin key, each plugin authenticates as its own agent sub-user (otherwise it runs as your own user — see Keys and multiple machines), and they join one cognee-agent role holding read and write on your datasets, which the plugins then address by canonical UUID. Set COGNEE_SHARED_AGENT_MEMORY=false for separated memory, and pair it with COGNEE_PLUGIN_IDENTITY=true — on its own it leaves a fresh install running as your own user, which sees everything anyway. See Sessions & datasets.
Set a custom dataset at launch:
4. Pick a session (optional)
By default thesession_id is derived from the Claude Code session, so a new conversation starts a new one and claude --resume continues the same one. Set COGNEE_SESSION_ID to pin a specific named session, or to deliberately share one live session across two terminals:
A-Z a-z 0-9 - _ . — accented and non-Latin letters included — becomes _, and the result is capped at 120 characters. The rule is the same in every Cognee agent integration, so one name pins the same session from Claude Code and Codex alike.
5. Verify
Restart Claude Code soSessionStart 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. The status line should say
cloud, and the conversation appears on the Sessions page; if it doesn’t, see No sessions showing.
The connection persists: every later claude launch reads ~/.cognee/.env and reconnects, so there is nothing to redo after a restart. To end a session, quit Claude Code (/exit); the session syncs into your graph on the way out. You can also invoke the skills explicitly:
Where Claude Code loads plugin hooks modules, Claude can also call
mcp__cognee-memory__search and mcp__cognee-memory__remember directly, and /cognee-dataset <name> switches datasets from the prompt (/cognee-dataset pin and /cognee-dataset auto change only the recall mode) — see Memory tools and commands.
In cloud mode the plugin turns off Claude Code’s own auto-memory (autoMemoryEnabled in ~/.claude/settings.json) from the next session on, unless you set that value yourself. It restores the previous setting when you leave cloud mode, or when you set COGNEE_DISABLE_AUTO_MEMORY=false. The diagnostic shows the current state.
What reaches your tenant. Prompts, tool traces, and answers are captured automatically, with credential paths (.env, *.pem, */.ssh/*, and the rest) skipped outright and common secrets redacted before anything is sent. Anything you wrap in <private>…</private> is replaced with [private] before it is stored, logged, or sent as a query — in automatic capture and in explicit remembers alike — and no setting turns that off. COGNEE_CAPTURE_TOOLS and COGNEE_CAPTURE_DENY_TOOLS narrow which tool calls are sent, down to individual Bash commands (Bash(git:*)). COGNEE_CAPTURE=false stops automatic capture entirely while leaving recall and explicit remember working — see What gets captured.
Two things about the code graph differ against a Cloud tenant. Repositories are not indexed automatically — the plugin only auto-indexes against a local server, so a private checkout is never shipped to a hosted tenant on its own initiative. Ask for it with /cognee-memory:cognee-code and give it a git URL: your tenant clones the repo rather than reading your disk, which is also why the graph reflects your last pushed commit rather than your working tree. A local path is not an option here — the server cannot see it. For the same reason, the file’s code map from file context on Read, which Claude gets before it reads a file, is not available for a repository indexed by URL. See Code graph.
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.
Against a tenant, the status line carries your workspace credit balance after the dataset and mode —
cognee auto (agent_sessions) · cloud · … · credits: $2.04, where auto (…) means recall is auto and names the dataset saves go to. On the line below the prompt the balance follows what memory is doing; on the row drawn above the prompt it comes before it, and its top up link is clickable. Every billable request the plugin makes — recall, session saves, /cognee-memory:cognee-remember, and distillation runs — is refused with HTTP 402 when the balance is too low, and the line says which of them that happened to (a refused distillation renders as not enough for improve):- refused with credit left:
credits: $2.04 (not enough for recall)— the refusal is red, the balance is not; - $1.00 or less left: the balance itself turns red, followed by
top up: https://platform.cognee.ai/billing. The threshold is a dollar rather than zero because the tenant stops serving before the balance reaches zero; - refused with no balance reading at all:
credits: not enough for recall, with the same top-up link.
api.<env>.cognee.ai alongside tenant-<id>.<env>.cognee.ai), which you can override with COGNEE_PLATFORM_API_URL. The platform API is shared across clouds, so for a workspace on Google Cloud (tenant-<id>.gcp.cognee.ai) the derived api.gcp.cognee.ai is the wrong host: set COGNEE_PLATFORM_API_URL=https://api.aws.cognee.ai. See When credits run out.More than one machine or Claude Code account
On another machine, repeat steps 1 and 2 with the same base URL and API key. On one machine, every Claude Code login reads the same~/.cognee/.env, so they all reach the same workspace without extra setup. There is nothing to provision by hand: on its first session start against your tenant, the plugin gets its own key for that machine, and all machines share the same memory. Each plugin agent holds a capped number of machine keys; when a new machine starts on your personal key instead, run /cognee-memory:cognee-keys and revoke an old machine’s key. See Keys and multiple machines.
Configuration reference
Precedence: environment variables →~/.cognee/.env → defaults. There is no config.json; older versions wrote one, and SessionStart now deletes a leftover file. The COGNEE_BACKEND / COGNEE_CLAUDE_BACKEND mode switch follows the same precedence. Wherever it is set, it pins that terminal’s mode regardless of where the connection variables are defined.
See the full integration guide for the session-distillation and idle-watcher variables; the advanced session-sync and update-notification knobs are covered in the plugin README.
Full integration guide
Hooks reference, session sync, and debugging
Codex
The same memory plugin for the Codex CLI