pip install. The plugin hooks into Claude Code’s lifecycle, so it:
- captures your prompts, tool traces, and assistant responses into session memory
- injects relevant context on every prompt submit
- syncs the session into your knowledge graph on session end
Install
Install from the Claude Code marketplace. Run these in your terminal (or type the equivalent/plugin … slash commands directly in the Claude Code chat):
cognee: <dataset> · <mode>.
Configure your backend
Set environment variables in the shell that launches Claude Code.- Cognee Cloud / remote
- Local (default)
Point the plugin at Cognee Cloud or a remote server by setting both:
Cognee’s LLM calls do not run through Claude Code. Your Claude Code plan pays only for your conversation with Claude. Everything Cognee does on its own — entity and relationship extraction during cognify, summarization, embeddings, and search-time completions — happens inside the Cognee backend against the LLM provider configured there, and is billed by that provider. In local mode you configure it with
LLM_API_KEY; in Cloud/remote mode your tenant holds the key server-side, so no local LLM key is needed.LLM_API_KEY above covers extraction, summarization, and embeddings: Cognee defaults to openai/gpt-5-mini for the LLM and openai/text-embedding-3-large for embeddings, and embeddings reuse LLM_API_KEY when EMBEDDING_API_KEY is unset. To use another provider, set LLM_PROVIDER, LLM_MODEL, and — for Azure, Ollama, or OpenAI-compatible endpoints — LLM_ENDPOINT. Changing only the LLM leaves embeddings on OpenAI, so also set the EMBEDDING_* variables or set EMBEDDING_API_KEY to an OpenAI key so the default embeddings keep working. See LLM providers and embedding providers.
You can also persist settings in ~/.cognee-plugin/claude-code/config.json:
Use it
Just use Claude Code as usual — memory is captured and recalled automatically. You can also invoke the skills explicitly:
To verify the connection, open a fresh session and ask: “What do you know from cognee?”
With the plugin active, Cognee is the preferred memory: the
SessionStart hook steers Claude to treat Cognee as authoritative over Claude Code’s built-in MEMORY.md. Set COGNEE_PREFER_MEMORY=false to turn the steer off.Sessions & datasets
- Sessions — set
COGNEE_SESSION_IDbefore launching Claude Code to resume or share a named live session across terminals. If you do not set it, the plugin chooses a session id from its configured session strategy. - Datasets — all writes and recall are scoped to one dataset (
agent_sessionsby default). SetCOGNEE_PLUGIN_DATASETto use a custom one. The Claude Code and Codex plugins share the default dataset, so memory carries across both.
How It Works
The plugin registers Claude Code lifecycle hooks:
A background idle watcher persists the session cache after periods of inactivity, and a final sync on session end bridges the session into the permanent graph.
Session distillation (self-improvement)
The Cognee coding-agent plugins (Claude Code, Codex) run session distillation for you — you never callimprove() by hand. A distillation pass fires on three triggers:
Overlapping triggers are safe. A per-session improve lock on the server serializes concurrent runs, and unchanged session content dedups server-side by content hash — so a repeat improve over content that hasn’t changed is a cheap no-op, not duplicated work.
Configuration
All triggers are tuned through environment variables read by the plugin. The defaults are chosen so distillation stays out of your way; you rarely need to change them.Turning it down or off
- Stop idle-triggered improves: set
COGNEE_IDLE_DISABLED=1before launching the agent. Session-end and per-turn improves still run. - Reduce mid-session improves: raise
COGNEE_AUTO_IMPROVE_EVERYto a large value so the per-turn trigger effectively never fires within a session. - Session-end distillation always runs when the plugin is active — it’s how a finished session reaches permanent memory.
Confirming it happened
- Cloud UI: the Self-improvement card at the top of a session on the Sessions page shows the status of the last graph enrichment and the dataset it wrote to.
- Plugin hook log: each automatic run emits an
improve_firedevent you can grep for when debugging (in local SDK mode, where the plugin calls the library directly instead of the HTTP endpoint, look forauto_improve_firedinstead). improve-unsupported.jsonmarker: if this file appears in the plugin’s shared state directory (24h TTL), the server rejected the improve endpoint and the plugin fell back to the legacyrememberbridge for that window — a signal the server predates session-aware improve.
Debugging & Resuming Sessions
Hooks are callbacks from Claude Code, not a durable job queue: events that happen while the plugin is uninstalled, failing, or unable to reach the backend are not replayed later. When memory does not appear, check these layers first:
A resumed or second terminal continues the same live session only when the session id and dataset match: set
COGNEE_SESSION_ID before launching Claude Code and keep COGNEE_PLUGIN_DATASET unchanged, otherwise the resumed work lands in a new session. After changing credentials, dataset, or session id, restart Claude Code so SessionStart can run with the new state.
Hook commands run with
python3, falling back to python if python3 isn’t found. If neither resolves on PATH — most commonly on Windows, where the python.org installer doesn’t always register a python3 alias — every hook fails and no memory is ever captured. Run python3 --version or python --version in the same shell that launches Claude Code to confirm one is available, or reinstall Python with “Add python.exe to PATH” checked./cognee-memory:cognee-sync or exit Claude Code normally so SessionEnd can trigger the final graph sync. If the process is killed instead, recent session cache entries may exist, but the final session-to-graph sync may not have run yet.
Configuration Reference
Precedence: environment variables →~/.cognee-plugin/claude-code/config.json → defaults.
Update or Remove
There’s no automatic update — reinstall to pull a new plugin version:GitHub Repository
View source code and the full configuration reference
Codex plugin
The same memory plugin for the Codex CLI