Skip to content

Commit 9139719

Browse files
authored
docs(claude-code): tidy configuration reference and sync README (#706)
* docs(claude-code): tidy configuration reference and sync README Add missing settings (retainMode, retainToolCalls, retainTags, retainMetadata, embedPackagePath, llmApiKeyEnv, agentName, and several recall options) that existed in code but not in docs. Restructure config tables with prose introductions, clearer descriptions, and consistent layout across both files. * refactor(claude-code): remove recallTopK setting Unused client-side cap — Hindsight server already controls result count via recallBudget and recallMaxTokens.
1 parent fd88c0e commit 9139719

File tree

5 files changed

+142
-85
lines changed

5 files changed

+142
-85
lines changed

hindsight-docs/docs/sdks/integrations/claude-code.md

Lines changed: 71 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -81,69 +81,107 @@ export ANTHROPIC_API_KEY="your-key"
8181
export HINDSIGHT_LLM_PROVIDER=claude-code # No API key needed
8282
```
8383

84-
The model is selected automatically by the Hindsight API. To override, set `HINDSIGHT_API_LLM_MODEL`.
84+
The model is selected automatically by the Hindsight API. To override, set `HINDSIGHT_LLM_MODEL`.
8585

8686
### 3. Existing Local Server
8787

8888
If you already have `hindsight-embed` running, leave `hindsightApiUrl` empty and set `apiPort` to match your server's port. The plugin will detect it automatically.
8989

9090
## Configuration
9191

92-
All settings are in `~/.hindsight/claude-code.json`. Every setting can also be overridden via environment variables.
92+
All settings live in `~/.hindsight/claude-code.json`. Every setting can also be overridden via environment variables. The plugin ships with sensible defaults — you only need to configure what you want to change.
93+
94+
**Loading order** (later entries win):
95+
1. Built-in defaults (hardcoded in the plugin)
96+
2. Plugin `settings.json` (ships with the plugin, at `CLAUDE_PLUGIN_ROOT/settings.json`)
97+
3. User config (`~/.hindsight/claude-code.json` — recommended for your overrides)
98+
4. Environment variables
99+
100+
---
93101

94102
### Connection & Daemon
95103

96-
| Setting | Default | Env Var | Description |
104+
These settings control how the plugin connects to the Hindsight API.
105+
106+
| Setting | Env Var | Default | Description |
97107
|---------|---------|---------|-------------|
98-
| `hindsightApiUrl` | `""` | `HINDSIGHT_API_URL` | External Hindsight API URL. Empty = use local daemon. |
99-
| `hindsightApiToken` | `null` | `HINDSIGHT_API_TOKEN` | Auth token for external API |
100-
| `apiPort` | `9077` | `HINDSIGHT_API_PORT` | Port for local Hindsight daemon |
101-
| `daemonIdleTimeout` | `0` | `HINDSIGHT_DAEMON_IDLE_TIMEOUT` | Seconds before idle daemon shuts down (0 = never) |
102-
| `embedVersion` | `"latest"` | `HINDSIGHT_EMBED_VERSION` | `hindsight-embed` version for `uvx` |
108+
| `hindsightApiUrl` | `HINDSIGHT_API_URL` | `""` (empty) | URL of an external Hindsight API server. When empty, the plugin uses a local daemon instead. |
109+
| `hindsightApiToken` | `HINDSIGHT_API_TOKEN` | `null` | Authentication token for the external API. Only needed when `hindsightApiUrl` is set. |
110+
| `apiPort` | `HINDSIGHT_API_PORT` | `9077` | Port used by the local `hindsight-embed` daemon. Change this if you run multiple instances or have a port conflict. |
111+
| `daemonIdleTimeout` | `HINDSIGHT_DAEMON_IDLE_TIMEOUT` | `0` | Seconds of inactivity before the local daemon shuts itself down. `0` means the daemon stays running until the session ends. |
112+
| `embedVersion` | `HINDSIGHT_EMBED_VERSION` | `"latest"` | Which version of `hindsight-embed` to install via `uvx`. Pin to a specific version (e.g. `"0.5.2"`) for reproducibility. |
113+
| `embedPackagePath` | `HINDSIGHT_EMBED_PACKAGE_PATH` | `null` | Local filesystem path to a `hindsight-embed` checkout. When set, the plugin runs from this path instead of installing via `uvx`. Useful for development. |
103114

104-
### LLM Provider (daemon mode only)
115+
---
105116

106-
| Setting | Default | Env Var | Description |
117+
### LLM Provider (local daemon only)
118+
119+
These settings configure which LLM the local daemon uses for fact extraction. They are **ignored** when connecting to an external API (the server uses its own LLM configuration).
120+
121+
| Setting | Env Var | Default | Description |
107122
|---------|---------|---------|-------------|
108-
| `llmProvider` | auto-detect | `HINDSIGHT_LLM_PROVIDER` | LLM provider: `openai`, `anthropic`, `gemini`, `groq`, `ollama`, `openai-codex`, `claude-code` |
109-
| `llmModel` | provider default | `HINDSIGHT_LLM_MODEL` | Model override |
123+
| `llmProvider` | `HINDSIGHT_LLM_PROVIDER` | auto-detect | Which LLM provider to use. Supported values: `openai`, `anthropic`, `gemini`, `groq`, `ollama`, `openai-codex`, `claude-code`. When omitted, the plugin auto-detects by checking for API key env vars in order: `OPENAI_API_KEY``ANTHROPIC_API_KEY``GEMINI_API_KEY``GROQ_API_KEY`. |
124+
| `llmModel` | `HINDSIGHT_LLM_MODEL` | provider default | Override the default model for the chosen provider (e.g. `"gpt-4o"`, `"claude-sonnet-4-20250514"`). When omitted, the Hindsight API picks a sensible default for each provider. |
125+
| `llmApiKeyEnv` || provider standard | Name of the environment variable that holds the API key. Normally auto-detected (e.g. `OPENAI_API_KEY` for the `openai` provider). Set this only if your key is in a non-standard env var. |
110126

111-
Auto-detection checks these env vars in order: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `GEMINI_API_KEY`, `GROQ_API_KEY`.
127+
---
112128

113129
### Memory Bank
114130

115-
| Setting | Default | Env Var | Description |
131+
A **bank** is an isolated memory store — like a separate "brain." These settings control which bank the plugin reads from and writes to.
132+
133+
| Setting | Env Var | Default | Description |
116134
|---------|---------|---------|-------------|
117-
| `bankId` | `"claude_code"` | `HINDSIGHT_BANK_ID` | Static bank ID (when `dynamicBankId` is false) |
118-
| `bankMission` | generic assistant | `HINDSIGHT_BANK_MISSION` | Agent identity/purpose for the memory bank |
119-
| `retainMission` | extraction prompt || Custom retain mission (what to extract from conversations) |
120-
| `dynamicBankId` | `false` | `HINDSIGHT_DYNAMIC_BANK_ID` | Enable per-context memory banks |
121-
| `dynamicBankGranularity` | `["agent", "project"]` || Fields for dynamic bank ID: `agent`, `project`, `session`, `channel`, `user` |
122-
| `bankIdPrefix` | `""` || Prefix for all bank IDs (e.g. `"prod"`) |
135+
| `bankId` | `HINDSIGHT_BANK_ID` | `"claude_code"` | The bank ID to use when `dynamicBankId` is `false`. All sessions share this single bank. |
136+
| `bankMission` | `HINDSIGHT_BANK_MISSION` | generic assistant prompt | A short description of the agent's identity and purpose. Sent to Hindsight when creating or updating the bank, and used during recall to contextualize results. |
137+
| `retainMission` || extraction prompt | Instructions for the fact extraction LLM — tells it *what* to extract from conversations (e.g. "Extract technical decisions and user preferences"). |
138+
| `dynamicBankId` | `HINDSIGHT_DYNAMIC_BANK_ID` | `false` | When `true`, the plugin derives a unique bank ID from context fields (see `dynamicBankGranularity`), giving each combination its own isolated memory. |
139+
| `dynamicBankGranularity` || `["agent", "project"]` | Which context fields to combine when building a dynamic bank ID. Available fields: `agent` (agent name), `project` (working directory), `session` (session ID), `channel` (channel ID), `user` (user ID). |
140+
| `bankIdPrefix` || `""` | A string prepended to all bank IDs — both static and dynamic. Useful for namespacing (e.g. `"prod"` or `"staging"`). |
141+
| `agentName` | `HINDSIGHT_AGENT_NAME` | `"claude-code"` | Name used for the `agent` field in dynamic bank ID derivation. |
142+
143+
---
123144

124145
### Auto-Recall
125146

126-
| Setting | Default | Env Var | Description |
147+
Auto-recall runs on every user prompt. It queries Hindsight for relevant memories and injects them into Claude's context as invisible `additionalContext` (the user doesn't see them in the chat transcript).
148+
149+
| Setting | Env Var | Default | Description |
127150
|---------|---------|---------|-------------|
128-
| `autoRecall` | `true` | `HINDSIGHT_AUTO_RECALL` | Enable automatic memory recall |
129-
| `recallBudget` | `"mid"` | `HINDSIGHT_RECALL_BUDGET` | Recall effort: `low`, `mid`, `high` |
130-
| `recallMaxTokens` | `1024` | `HINDSIGHT_RECALL_MAX_TOKENS` | Max tokens in recall response |
131-
| `recallContextTurns` | `1` | `HINDSIGHT_RECALL_CONTEXT_TURNS` | Prior turns for query composition |
151+
| `autoRecall` | `HINDSIGHT_AUTO_RECALL` | `true` | Master switch for auto-recall. Set to `false` to disable memory retrieval entirely. |
152+
| `recallBudget` | `HINDSIGHT_RECALL_BUDGET` | `"mid"` | Controls how hard Hindsight searches for memories. `"low"` = fast, fewer strategies; `"mid"` = balanced; `"high"` = thorough, slower. Affects latency directly. |
153+
| `recallMaxTokens` | `HINDSIGHT_RECALL_MAX_TOKENS` | `1024` | Maximum number of tokens in the recalled memory block. Lower values reduce context usage but may truncate relevant memories. |
154+
| `recallTypes` || `["world", "experience"]` | Which memory types to retrieve. `"world"` = general facts; `"experience"` = personal experiences; `"observation"` = raw observations. |
155+
| `recallContextTurns` | `HINDSIGHT_RECALL_CONTEXT_TURNS` | `1` | How many prior conversation turns to include when composing the recall query. `1` = only the latest user message; higher values give more context but may dilute the query. |
156+
| `recallMaxQueryChars` | `HINDSIGHT_RECALL_MAX_QUERY_CHARS` | `800` | Maximum character length of the query sent to Hindsight. Longer queries are truncated. |
157+
| `recallRoles` || `["user", "assistant"]` | Which message roles to include when building the recall query from prior turns. |
158+
| `recallPromptPreamble` || built-in string | Text placed above the recalled memories in the injected context block. Customize this to change how Claude interprets the memories. |
159+
160+
---
132161

133162
### Auto-Retain
134163

135-
| Setting | Default | Env Var | Description |
164+
Auto-retain runs after Claude responds. It extracts the conversation transcript and sends it to Hindsight for long-term storage and fact extraction.
165+
166+
| Setting | Env Var | Default | Description |
136167
|---------|---------|---------|-------------|
137-
| `autoRetain` | `true` | `HINDSIGHT_AUTO_RETAIN` | Enable automatic retention |
138-
| `retainEveryNTurns` | `10` || Retain every Nth turn (sliding window) |
139-
| `retainOverlapTurns` | `2` || Extra overlap turns for continuity |
140-
| `retainRoles` | `["user", "assistant"]` || Which message roles to retain |
168+
| `autoRetain` | `HINDSIGHT_AUTO_RETAIN` | `true` | Master switch for auto-retain. Set to `false` to disable memory storage entirely. |
169+
| `retainMode` | `HINDSIGHT_RETAIN_MODE` | `"full-session"` | Retention strategy. `"full-session"` sends the full conversation transcript (with chunking). |
170+
| `retainEveryNTurns` || `10` | How often to retain. `1` = every turn; `10` = every 10th turn. Higher values reduce API calls but delay memory capture. Values > 1 enable **chunked retention** with a sliding window. |
171+
| `retainOverlapTurns` || `2` | When chunked retention fires, this many extra turns from the previous chunk are included for continuity. Total window size = `retainEveryNTurns + retainOverlapTurns`. |
172+
| `retainRoles` || `["user", "assistant"]` | Which message roles to include in the retained transcript. |
173+
| `retainToolCalls` || `true` | Whether to include tool calls (function invocations and results) in the retained transcript. Captures structured actions like file reads, searches, and code edits. |
174+
| `retainTags` || `["{session_id}"]` | Tags attached to the retained document. Supports `{session_id}` placeholder which is replaced with the current session ID at runtime. |
175+
| `retainMetadata` || `{}` | Arbitrary key-value metadata attached to the retained document. |
176+
| `retainContext` || `"claude-code"` | A label attached to retained memories identifying their source. Useful when multiple integrations write to the same bank. |
177+
178+
---
141179

142-
### Miscellaneous
180+
### Debug
143181

144-
| Setting | Default | Env Var | Description |
182+
| Setting | Env Var | Default | Description |
145183
|---------|---------|---------|-------------|
146-
| `debug` | `false` | `HINDSIGHT_DEBUG` | Enable debug logging to stderr |
184+
| `debug` | `HINDSIGHT_DEBUG` | `false` | Enable verbose logging to stderr. All log lines are prefixed with `[Hindsight]`. Useful for diagnosing connection issues, recall/retain behavior, and bank ID derivation. |
147185

148186
## Claude Code Channels
149187

0 commit comments

Comments
 (0)