docs/images/agents/en/claude-code.md
Add cross-project, cross-session long-term memory to Claude Code. After installation, every conversation automatically recalls relevant memories and captures new content, with no tool calls required from the model.
Source: examples/claude-code-memory-plugin | Blog: motivation and demo
bash <(curl -fsSL https://ovrelease.tos-cn-beijing.volces.com/claude-code-memory-plugin/tos-install.sh)
The installer checks dependencies, configures the OpenViking connection, and installs the plugin. Each step is idempotent, so it is safe to rerun.
After installation, activate the claude wrapper in your current terminal, or simply open a new terminal window:
source ~/.openviking/openviking-repo/examples/claude-code-memory-plugin/setup-helper/wrapper.sh
Launch Claude Code through a custom command? A wrapper script like
cc-custom, or a multi-word launcher (a base command plus a sub-command) — list it at the installer's "Extra launch commands" step (or passOPENVIKING_CC_WRAP_EXTRA='cc-custom') to inject credentials there too.
After using it for a while, start a new conversation and ask about something you mentioned earlier. It should remember.
<details> <summary><b>Manual installation</b></summary>If you prefer to install manually:
Wrap claude - Add these two lines to the end of ~/.zshrc (for zsh) or ~/.bashrc (for bash), replacing <repo-path> with the absolute path to your local checkout. Each claude invocation then injects OPENVIKING_URL and OPENVIKING_API_KEY from ~/.openviking/ovcli.conf, keeping the API key scoped to the claude process tree:
_ov_wrapper="<repo-path>/examples/claude-code-memory-plugin/setup-helper/wrapper.sh"
[ -f "$_ov_wrapper" ] && source "$_ov_wrapper"
For the function implementation and why a global export is not used, see the plugin README -> Configuring MCP.
Install the plugin from the OpenViking repository root:
claude plugin marketplace add "$(pwd)/examples"
claude plugin install claude-code-memory-plugin@openviking-plugins-local
Start Claude Code and run /mcp to confirm the OpenViking entry shows your server URL.
</details>No
ovcli.confyet? Create it first via Deployment Guide -> CLI.Pure local mode (
http://127.0.0.1:1933, no auth)? Skip step 1. The plugin uses the local defaults.Claude Code < 2.0? See the compatibility mode section in the plugin README.
type claude # Expected: claude is a shell function
If the previous command printed a path instead of
shell function, the wrapper isn't active yet. Re-source it (or open a new terminal) before launchingclaude, otherwise it silently connects to127.0.0.1with no auth.
Launch claude from the terminal where type claude reports a shell function, then:
/plugins -> Find openviking-memory under Installed. Its openviking MCP entry should be connected./mcp -> The OpenViking entry should show your server URL and valid authentication./openviking-memory:ov -> Shows server status, identity, recall/injection stats, and toggle state.If the plugin does not appear to work, set OPENVIKING_DEBUG=1 and inspect ~/.openviking/logs/cc-hooks.log.
The plugin hooks into the Claude Code lifecycle:
All writes run asynchronously, so they never block your workflow.
<details> <summary><b>Configuration</b></summary>Configuration priority: environment variables > ovcli.conf > ov.conf > built-in defaults (http://127.0.0.1:1933, no auth).
| Environment variable | Default | Description |
|---|---|---|
OPENVIKING_AUTO_RECALL | true | Automatically recall before each user prompt |
OPENVIKING_RECALL_LIMIT | 6 | Maximum memories injected per turn |
OPENVIKING_RECALL_TOKEN_BUDGET | 2000 | Token budget for inline memory content |
OPENVIKING_AUTO_CAPTURE | true | Automatically capture after each turn |
OPENVIKING_BYPASS_SESSION | false | Skip all hooks for the current session |
OPENVIKING_BYPASS_SESSION_PATTERNS | "" | CSV glob patterns for automatic bypass |
OPENVIKING_MEMORY_ENABLED | (auto) | Force enable or disable |
OPENVIKING_DEBUG | false | Write logs to ~/.openviking/logs/cc-hooks.log |
For multi-tenant deployments, set OPENVIKING_ACCOUNT and OPENVIKING_USER. See the plugin README for the full environment variable list.
The plugin renders OpenViking status below the Claude Code input box: connection health, recall count, capture progress, and session state are visible at a glance. See STATUSLINE.md for the full status levels and customization recipes.
| Symptom | Cause | Fix |
|---|---|---|
| Plugin is not active | ov.conf / ovcli.conf cannot be found | Run Step 1: Install, or set OPENVIKING_MEMORY_ENABLED=1 plus URL/API_KEY |
| Hooks run but recall is empty | Server is down or URL is wrong | curl "$(jq -r '.url' ~/.openviking/ovcli.conf)/health" |
MCP tools connect to 127.0.0.1 instead of remote | Missing shell function wrapper | Confirm type claude returns "shell function"; see Step 1: Install |
type claude shows a path instead of a shell function (wrapper inactive) | The rc wasn't sourced after install, or you launched from a terminal that didn't load it | Run source ~/.zshrc (or ~/.bashrc on bash), or open a new terminal |
Launching via an alias (e.g. cc) injects no credentials | The alias name was listed in OPENVIKING_CC_WRAP_EXTRA (alias names are skipped), or the alias's target command isn't wrapped | Wrap the command the alias points to, not the alias: alias cc=claude needs nothing; for alias cc=claude-custom, add claude-custom |
| Remote auth returns 401 / 403 | API key is wrong or tenant headers are missing | Check OPENVIKING_API_KEY; for multi-tenant deployments also verify OPENVIKING_ACCOUNT / OPENVIKING_USER |