English · Português
Khala for Claude Code
[!NOTE]
TL;DR: Khala is your team's memory inside Claude Code. It distills each session into short
observations tied to the files behind them, and brings that context back in the next session of
anyone in your organization. Install the plugin and sign in with /khala:login.
Who this is for: people and teams who use Claude Code and have an account on the
Khala console. When you finish reading, you can install the
plugin, connect your organization, tune it, and you know exactly what it sends to the server.
Install
/plugin install khala --marketplace protonss4fun/khala-plugin
On Claude Code versions before 2.1.275, add the marketplace first:
/plugin marketplace add protonss4fun/khala-plugin
/plugin install khala@khala
Then open a new session: hooks, the session bar and the MCP server load when a session starts.
The MCP tools also need your key in the plugin option; see MCP tools.
Sign in
/khala:login
The login uses the device flow (RFC 8628). Claude shows a link and a code; you check that the code
on the page matches and approve in the browser. The key goes to ~/.khala/credentials (file
0600) and covers every project on the machine. To switch organization or server, run the login
again (and update the api_key option too, if you set it: it wins over the login). The connect
button on the session bar runs the same flow without leaving the terminal.
The login does not reach the MCP tools: they read the key only from the plugin option. Open
~/.khala/credentials yourself, copy the value of KHALA_API_KEY, and paste it into
/plugin configure khala@khala.
The login talks to the KHALA_URL of the environment, or to the default
https://console.khala.p4f.app/api. It stores that URL next to the key, and the key is only ever
sent to it.
What the plugin does
| Piece | When it runs | What it does |
|---|
SessionStart | start, resume and compaction | Shows you a summary of the project's memory and gives the model up to 8 recent facts. |
UserPromptSubmit | every prompt | Answers from memory when one fact covers the prompt with high confidence. The per-prompt snippet search (KHALA_CONTEXT_ON_PROMPT=1) is off by default. |
PreToolUse (Read, Bash) | before a file is read | When memory covers a large file and the file has not changed since, hands over the summary instead of the whole file. |
SessionEnd and PreCompact | end of session and compaction | Distills the session into observations and uploads them. |
PostToolUseFailure and PostToolUse (Bash) | a tool fails, or a piped test or build run prints a failure | Looks up how the team fixed that error before. Off by default (KHALA_ERROR_RECALL=1). |
| Session bar | always | Shows connection, cache and cost state. The connect button signs you in. |
MCP server khala | on demand | Six tools served by the Khala API (nothing runs on your machine); see MCP tools. |
/khala:login, /khala:share, /khala debug | when you run them | Sign-in, your shared-memory switch, and a one-line diagnosis of the bar and the credential. |
Without a credential every hook stays silent: nothing breaks the session or blocks compaction.
Each hook is described in detail in hooks/README.md.
MCP tools
| Tool | Who can use it | What it returns |
|---|
search_memory | any member with a key | Semantic (kNN) search over the team's code, docs, ADRs and session observations. |
get_context | any member with a key | The relevant context, already trimmed for a prompt. |
list_observations | admins | Recent observations of the organization or a project. |
memory_cost | admins | The measured cost of memory: injected context tokens, events and latency, per developer. |
dev_status | admins | Observations and measured memory cost of one developer, or of the whole organization. |
list_projects | admins | The organization's indexed projects. |
The MCP server is remote: Claude Code calls https://console.khala.p4f.app/api/mcp over HTTP, with
your key in the x-api-key header. It reads the key only from the plugin option api_key, so set
it there even if you signed in with /khala:login:
/plugin configure khala@khala
The credential that /khala:login writes (~/.khala/credentials) and KHALA_API_KEY serve the
hooks and the session bar, not the MCP tools. The MCP address is fixed to production; the url
option and KHALA_URL do not change it.