claude-memory-store 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +292 -91
- package/dist/atlas/client.d.ts +0 -2
- package/dist/atlas/client.d.ts.map +1 -1
- package/dist/atlas/client.js +0 -8
- package/dist/atlas/client.js.map +1 -1
- package/dist/atlas/embeddings.d.ts +31 -4
- package/dist/atlas/embeddings.d.ts.map +1 -1
- package/dist/atlas/embeddings.js +31 -4
- package/dist/atlas/embeddings.js.map +1 -1
- package/dist/atlas/indexes.d.ts.map +1 -1
- package/dist/atlas/indexes.js +5 -3
- package/dist/atlas/indexes.js.map +1 -1
- package/dist/atlas/vector.d.ts +11 -1
- package/dist/atlas/vector.d.ts.map +1 -1
- package/dist/atlas/vector.js +47 -3
- package/dist/atlas/vector.js.map +1 -1
- package/dist/bin/claude-memory.js +36 -35
- package/dist/bin/claude-memory.js.map +1 -1
- package/dist/bin/mcp-server.js +7 -21
- package/dist/bin/mcp-server.js.map +1 -1
- package/dist/cache/command-cache.js +1 -1
- package/dist/cache/command-cache.js.map +1 -1
- package/dist/cleanup.d.ts +6 -3
- package/dist/cleanup.d.ts.map +1 -1
- package/dist/cleanup.js +31 -11
- package/dist/cleanup.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -0
- package/dist/config.js.map +1 -1
- package/dist/decay.d.ts +29 -0
- package/dist/decay.d.ts.map +1 -0
- package/dist/decay.js +58 -0
- package/dist/decay.js.map +1 -0
- package/dist/editor/charts.d.ts +9 -0
- package/dist/editor/charts.d.ts.map +1 -0
- package/dist/editor/charts.js +157 -0
- package/dist/editor/charts.js.map +1 -0
- package/dist/editor/colors.d.ts +28 -0
- package/dist/editor/colors.d.ts.map +1 -0
- package/dist/editor/colors.js +66 -0
- package/dist/editor/colors.js.map +1 -0
- package/dist/editor/dashboard.d.ts +26 -0
- package/dist/editor/dashboard.d.ts.map +1 -0
- package/dist/editor/dashboard.js +156 -0
- package/dist/editor/dashboard.js.map +1 -0
- package/dist/editor/interactive.d.ts +24 -0
- package/dist/editor/interactive.d.ts.map +1 -0
- package/dist/editor/interactive.js +533 -0
- package/dist/editor/interactive.js.map +1 -0
- package/dist/hooks/pre-tool-use.js +5 -4
- package/dist/hooks/pre-tool-use.js.map +1 -1
- package/dist/hooks/stop.d.ts +1 -0
- package/dist/hooks/stop.d.ts.map +1 -1
- package/dist/hooks/stop.js +72 -0
- package/dist/hooks/stop.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/memory/developer.d.ts.map +1 -1
- package/dist/memory/developer.js +4 -0
- package/dist/memory/developer.js.map +1 -1
- package/dist/memory/fading.d.ts +12 -0
- package/dist/memory/fading.d.ts.map +1 -0
- package/dist/memory/fading.js +45 -0
- package/dist/memory/fading.js.map +1 -0
- package/dist/memory/project.d.ts +2 -0
- package/dist/memory/project.d.ts.map +1 -1
- package/dist/memory/project.js +60 -0
- package/dist/memory/project.js.map +1 -1
- package/dist/memory/working.d.ts.map +1 -1
- package/dist/memory/working.js +1 -0
- package/dist/memory/working.js.map +1 -1
- package/dist/natural-language/parser.d.ts +6 -0
- package/dist/natural-language/parser.d.ts.map +1 -1
- package/dist/natural-language/parser.js +17 -0
- package/dist/natural-language/parser.js.map +1 -1
- package/dist/natural-language/router.d.ts.map +1 -1
- package/dist/natural-language/router.js +48 -33
- package/dist/natural-language/router.js.map +1 -1
- package/dist/slash-commands/recall.js +1 -1
- package/dist/slash-commands/recall.js.map +1 -1
- package/dist/slash-commands/remember.d.ts.map +1 -1
- package/dist/slash-commands/remember.js +8 -2
- package/dist/slash-commands/remember.js.map +1 -1
- package/dist/slash-commands/stats.d.ts.map +1 -1
- package/dist/slash-commands/stats.js +11 -0
- package/dist/slash-commands/stats.js.map +1 -1
- package/dist/startup/conversation.d.ts +1 -0
- package/dist/startup/conversation.d.ts.map +1 -1
- package/dist/startup/conversation.js +7 -1
- package/dist/startup/conversation.js.map +1 -1
- package/dist/startup/feature-search.d.ts +5 -0
- package/dist/startup/feature-search.d.ts.map +1 -1
- package/dist/startup/feature-search.js +10 -26
- package/dist/startup/feature-search.js.map +1 -1
- package/dist/startup/injector.d.ts +1 -0
- package/dist/startup/injector.d.ts.map +1 -1
- package/dist/startup/injector.js +23 -5
- package/dist/startup/injector.js.map +1 -1
- package/dist/summarizer.d.ts.map +1 -1
- package/dist/summarizer.js +20 -4
- package/dist/summarizer.js.map +1 -1
- package/dist/types.d.ts +10 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
Claude forgets everything when the context window clears. Claude Memory fixes that. Your architecture decisions, deploy commands, database configs, team conventions, and project patterns persist across every session — stored in your own MongoDB Atlas instance, searchable in under 50ms.
|
|
6
6
|
|
|
7
|
-
One command to install. Zero config after setup. Your data, your database, forever.
|
|
7
|
+
**96% semantic retrieval accuracy** on real developer session data. One command to install. Zero config after setup. Your data, your database, forever.
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npx claude-memory-store init
|
|
@@ -34,6 +34,16 @@ Claude Memory gives Claude persistent, searchable memory powered entirely by Mon
|
|
|
34
34
|
|
|
35
35
|
Every memory item is an individual document with its own vector embedding. Search returns the **specific decision** you need, not a truncated blob.
|
|
36
36
|
|
|
37
|
+
### Why Claude Memory over alternatives?
|
|
38
|
+
|
|
39
|
+
- **Cloud-native** — works across all your machines, not a local unauthenticated HTTP server
|
|
40
|
+
- **MongoDB Atlas** — enterprise-grade security, encryption at rest, your own database
|
|
41
|
+
- **Verified commands** — execute exactly as stored, no improvisation
|
|
42
|
+
- **MCP server included** — Claude calls `recall()` and `remember()` on its own
|
|
43
|
+
- **96% semantic accuracy** — tested against real developer session data
|
|
44
|
+
- **Exponential decay** — frequently-used memories live forever, forgotten ones fade naturally
|
|
45
|
+
- **Interactive editor** — colorful TUI dashboard with graphs, inline editing, and memory health tracking
|
|
46
|
+
|
|
37
47
|
---
|
|
38
48
|
|
|
39
49
|
## How It Works
|
|
@@ -42,10 +52,10 @@ Claude Memory integrates with Claude Code at four levels:
|
|
|
42
52
|
|
|
43
53
|
### 1. Hooks (Passive — Automatic)
|
|
44
54
|
Lifecycle hooks fire automatically during every Claude Code session:
|
|
45
|
-
- **Startup** — ultra-minimal banner showing memory stats (zero context cost)
|
|
46
|
-
- **Pre-tool-use** — queries Atlas on every prompt, injects relevant context if found
|
|
47
|
-
- **Post-tool-use** — detects "remember this"
|
|
48
|
-
- **Session end** — saves working memory,
|
|
55
|
+
- **Startup** — ultra-minimal banner showing memory stats (zero context cost), runs TTL cleanup
|
|
56
|
+
- **Pre-tool-use** — queries Atlas on every prompt, injects relevant context if found (commands → semantic search → thread matching)
|
|
57
|
+
- **Post-tool-use** — detects natural language intents ("remember this", "add to threads") and stores automatically
|
|
58
|
+
- **Session end** — saves working memory, extracts session insights, increments counters
|
|
49
59
|
|
|
50
60
|
### 2. MCP Server (Active — Claude Decides)
|
|
51
61
|
Four MCP tools Claude can call on its own:
|
|
@@ -72,6 +82,7 @@ Claude Memory does **not** dump everything into the context window at startup. A
|
|
|
72
82
|
- Continue context: **1-2 line summary** of last session
|
|
73
83
|
- New session: **zero context cost**
|
|
74
84
|
- Memory surfaces **on-demand** via pre-tool-use search when relevant
|
|
85
|
+
- Maximum injection: **2,000 characters** per prompt (configurable)
|
|
75
86
|
|
|
76
87
|
The full memory dump is only loaded when you explicitly ask for it (`?` at the startup menu).
|
|
77
88
|
|
|
@@ -81,7 +92,7 @@ The full memory dump is only loaded when you explicitly ask for it (`?` at the s
|
|
|
81
92
|
|
|
82
93
|
### Prerequisites
|
|
83
94
|
- Node.js 18+
|
|
84
|
-
- MongoDB Atlas
|
|
95
|
+
- MongoDB Atlas M10+ cluster ([create account](https://cloud.mongodb.com/register)) — required for vector search
|
|
85
96
|
|
|
86
97
|
### Install
|
|
87
98
|
|
|
@@ -93,7 +104,7 @@ That single command:
|
|
|
93
104
|
1. Prompts for your Atlas connection string (auto-detects from `CLAUDE_MEMORY_ATLAS_URI` env var or `.env` file)
|
|
94
105
|
2. Tests the connection
|
|
95
106
|
3. Creates the `claude_memory` database and indexes
|
|
96
|
-
4. Sets up Atlas vector search index
|
|
107
|
+
4. Sets up Atlas vector search index with automated Voyage AI embedding (requires M10+)
|
|
97
108
|
5. Installs Claude Code hooks (startup, pre-tool-use, post-tool-use, stop)
|
|
98
109
|
6. Registers the MCP server (recall, remember, threads, stats tools)
|
|
99
110
|
7. Installs the skill file (`/recall`, `/remember`, `/threads`, `/stats`)
|
|
@@ -116,29 +127,38 @@ claude-memory memory # Show memory summary
|
|
|
116
127
|
### CLI Commands
|
|
117
128
|
|
|
118
129
|
```bash
|
|
119
|
-
|
|
120
|
-
claude-memory
|
|
121
|
-
claude-memory
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
claude-memory
|
|
125
|
-
claude-memory
|
|
126
|
-
claude-memory
|
|
127
|
-
claude-memory
|
|
128
|
-
claude-memory
|
|
129
|
-
claude-memory
|
|
130
|
-
claude-memory
|
|
131
|
-
|
|
130
|
+
# Setup
|
|
131
|
+
claude-memory init # First-time setup (one command does everything)
|
|
132
|
+
claude-memory info # Show project/developer IDs and config path
|
|
133
|
+
|
|
134
|
+
# Memory Access
|
|
135
|
+
claude-memory memory # Show memory summary
|
|
136
|
+
claude-memory stats # Show detailed statistics + fading memory warnings
|
|
137
|
+
claude-memory recall <topic> # Search memory for a topic (semantic vector search)
|
|
138
|
+
claude-memory remember <text> # Store a decision/pattern/rule (auto-classified)
|
|
139
|
+
claude-memory remember <text> --developer # Store as developer preference (cross-project)
|
|
140
|
+
claude-memory threads # Show open threads with status and age
|
|
141
|
+
claude-memory commands # Show verified commands with steps and triggers
|
|
142
|
+
|
|
143
|
+
# Interactive Editor (run in a separate terminal)
|
|
144
|
+
claude-memory edit # Interactive TUI browser with dashboard + graphs
|
|
145
|
+
claude-memory edit --developer # Interactive editor for developer memory
|
|
146
|
+
claude-memory edit --file # Edit memory as JSON in $EDITOR
|
|
147
|
+
claude-memory edit --file --developer # Edit developer memory in $EDITOR
|
|
148
|
+
|
|
149
|
+
# Maintenance
|
|
150
|
+
claude-memory clear --working # Clear session history
|
|
151
|
+
claude-memory clear --all # Clear all project memory (with confirmation)
|
|
132
152
|
```
|
|
133
153
|
|
|
134
154
|
### MCP Tools (Claude calls these automatically)
|
|
135
155
|
|
|
136
|
-
| Tool | Description |
|
|
137
|
-
|
|
138
|
-
| `recall(
|
|
139
|
-
| `remember(
|
|
140
|
-
| `memory_threads
|
|
141
|
-
| `memory_stats
|
|
156
|
+
| Tool | Parameters | Description |
|
|
157
|
+
|------|------------|-------------|
|
|
158
|
+
| `recall` | `topic` (string), `limit?` (1-20, default 5) | Search memory via semantic vector search |
|
|
159
|
+
| `remember` | `text` (string), `category?` (auto/context/architecture/pattern/avoid/preference) | Store with auto-classification |
|
|
160
|
+
| `memory_threads` | �� | List open threads with status, age, and context |
|
|
161
|
+
| `memory_stats` | — | Full memory statistics including fading warnings |
|
|
142
162
|
|
|
143
163
|
### Slash Commands (Type `/` in Claude Code)
|
|
144
164
|
|
|
@@ -151,6 +171,47 @@ claude-memory clear --all # Clear all project memory
|
|
|
151
171
|
|
|
152
172
|
---
|
|
153
173
|
|
|
174
|
+
## Interactive Memory Editor
|
|
175
|
+
|
|
176
|
+
The interactive editor provides a full TUI experience for browsing, editing, and managing your memory. Run it in a separate terminal:
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
claude-memory edit
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Dashboard
|
|
183
|
+
|
|
184
|
+
On launch, a colorful dashboard renders showing:
|
|
185
|
+
|
|
186
|
+
- **Memory usage bar charts** — proportional bars for each category with item counts
|
|
187
|
+
- **Health panel** — total items, active vs decaying breakdown, overall health gauge
|
|
188
|
+
- **Activity panel** — 7-day sparkline charts, access patterns, most/least active categories
|
|
189
|
+
- **Color coding** — green (healthy, >70%), yellow (moderate, 40-70%), red (fading, <40%)
|
|
190
|
+
|
|
191
|
+
### Navigation
|
|
192
|
+
|
|
193
|
+
The editor uses inquirer prompts for keyboard-driven navigation:
|
|
194
|
+
|
|
195
|
+
- **Category select** — browse Architecture, Patterns, Avoid Rules, Open Threads, Commands (project) or Preferences, Style, Defaults, Dev Avoid (developer)
|
|
196
|
+
- **Item list** — select any memory item to view details
|
|
197
|
+
- **Item detail** — shows created date, access count, and decay health percentage
|
|
198
|
+
- **Actions** — Edit (inline), Delete (with confirmation), Back
|
|
199
|
+
- **Scope toggle** — switch between project and developer memory at any time
|
|
200
|
+
- **Dashboard refresh** — re-render stats after changes
|
|
201
|
+
|
|
202
|
+
### File Mode
|
|
203
|
+
|
|
204
|
+
For bulk editing, export all memory as JSON to your editor:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
claude-memory edit --file # Opens in $EDITOR
|
|
208
|
+
claude-memory edit --file --developer # Developer memory only
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Edit freely — add, remove, reorder. Changes are diffed and synced back to Atlas on save.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
154
215
|
## What Gets Stored
|
|
155
216
|
|
|
156
217
|
### Auto-Classification
|
|
@@ -163,20 +224,25 @@ When you tell Claude to remember something, it classifies automatically:
|
|
|
163
224
|
| "always use..." / "pattern..." / "convention..." | **Pattern** | "always use pnpm not npm" |
|
|
164
225
|
| "architecture..." / "database..." / "schema..." | **Architecture decision** | "MongoDB Atlas on prod-cluster-east" |
|
|
165
226
|
| "across all projects..." | **Developer preference** | "prefer Vitest over Jest everywhere" |
|
|
166
|
-
| Everything else | **
|
|
227
|
+
| Everything else | **Context** | (general knowledge) |
|
|
167
228
|
|
|
168
229
|
### Memory Types
|
|
169
230
|
|
|
170
|
-
| Type | Scope |
|
|
171
|
-
|
|
172
|
-
| Architecture decisions | Per project |
|
|
173
|
-
| Patterns | Per project |
|
|
174
|
-
| Avoid rules | Per project |
|
|
175
|
-
| Verified commands | Per project |
|
|
176
|
-
| Open threads | Per project |
|
|
177
|
-
|
|
|
178
|
-
|
|
|
179
|
-
|
|
|
231
|
+
| Type | Scope | Description | Decays? |
|
|
232
|
+
|------|-------|-------------|---------|
|
|
233
|
+
| Architecture decisions | Per project | Technical decisions and system design | Yes |
|
|
234
|
+
| Patterns | Per project | Coding conventions and approaches | Yes |
|
|
235
|
+
| Avoid rules | Per project | Anti-patterns and restrictions | Yes |
|
|
236
|
+
| Verified commands | Per project | Multi-step workflows with triggers | Yes |
|
|
237
|
+
| Open threads | Per project | Unresolved issues (unresolved/deferred/watching) | Yes |
|
|
238
|
+
| Context | Per project | General project knowledge | Yes |
|
|
239
|
+
| Working memory | Per project | Session snapshots (auto-saved) | Yes |
|
|
240
|
+
| Developer preferences | Per developer | Personal preferences (all projects) | Yes |
|
|
241
|
+
| Style rules | Per developer | Code style preferences (all projects) | Yes |
|
|
242
|
+
| Defaults | Per developer | Default settings (all projects) | Yes |
|
|
243
|
+
| Developer avoid | Per developer | Personal anti-patterns (all projects) | Yes |
|
|
244
|
+
| Project metadata | Per project | Session count, cost tracking | **Never** |
|
|
245
|
+
| Developer metadata | Per developer | Session count, cost tracking | **Never** |
|
|
180
246
|
|
|
181
247
|
### Verified Commands
|
|
182
248
|
|
|
@@ -192,7 +258,19 @@ Store: "deploy" command with steps:
|
|
|
192
258
|
Triggers: "deploy", "ship it", "push to prod"
|
|
193
259
|
```
|
|
194
260
|
|
|
195
|
-
Next session, say "deploy" and Claude gets the full pipeline injected automatically.
|
|
261
|
+
Next session, say "deploy" and Claude gets the full pipeline injected automatically. Commands are the **highest trust** memory — injected immediately without semantic search fallback.
|
|
262
|
+
|
|
263
|
+
### Open Threads
|
|
264
|
+
|
|
265
|
+
Track unresolved issues across sessions:
|
|
266
|
+
|
|
267
|
+
| Status | Meaning |
|
|
268
|
+
|--------|---------|
|
|
269
|
+
| `unresolved` | Actively blocking or needs attention |
|
|
270
|
+
| `deferred` | Intentionally postponed |
|
|
271
|
+
| `watching` | Monitoring — not blocking |
|
|
272
|
+
|
|
273
|
+
Threads surface automatically via pre-tool-use when keywords in your prompt match thread descriptions.
|
|
196
274
|
|
|
197
275
|
---
|
|
198
276
|
|
|
@@ -203,8 +281,7 @@ Next session, say "deploy" and Claude gets the full pipeline injected automatica
|
|
|
203
281
|
Claude Memory uses a single MongoDB Atlas collection (`claude_memory`) with a type discriminator. No Redis. No Postgres. No external APIs. No vector database. Just Atlas.
|
|
204
282
|
|
|
205
283
|
**Why Atlas?**
|
|
206
|
-
-
|
|
207
|
-
- Atlas Vector Search with automated embedding via Voyage AI (M10+)
|
|
284
|
+
- Atlas M10+ — vector search with automated embedding via Voyage AI
|
|
208
285
|
- Global availability, automatic backups, zero maintenance
|
|
209
286
|
- Your data stays in your own database — not a third-party service
|
|
210
287
|
|
|
@@ -215,8 +292,9 @@ Every memory item is its own document:
|
|
|
215
292
|
```
|
|
216
293
|
claude_memory collection:
|
|
217
294
|
├── type: "working" — session snapshots (one per session)
|
|
218
|
-
├── type: "project_meta" — project metadata (one per project)
|
|
219
|
-
├── type: "developer_meta" — developer metadata (one per developer)
|
|
295
|
+
├── type: "project_meta" — project metadata (one per project, never expires)
|
|
296
|
+
├── type: "developer_meta" — developer metadata (one per developer, never expires)
|
|
297
|
+
├── type: "context" — general project context
|
|
220
298
|
├── type: "architecture" — individual decisions
|
|
221
299
|
├── type: "pattern" — individual patterns
|
|
222
300
|
├── type: "avoid" — individual avoid rules
|
|
@@ -230,21 +308,103 @@ claude_memory collection:
|
|
|
230
308
|
|
|
231
309
|
Each document has its own `searchable_text` field — Atlas generates vector embeddings per item, so search returns the **specific decision** you need, not a truncated snippet of a giant concatenated blob.
|
|
232
310
|
|
|
233
|
-
###
|
|
311
|
+
### Exponential Decay with Access-Frequency Weighting
|
|
312
|
+
|
|
313
|
+
Memories don't use a flat TTL. Instead, they fade naturally using exponential decay:
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
score = min(1.0, exp(-λ × t) × (1 + ln(accessCount)))
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
- **λ** = `ln(2) / halfLifeDays` (configurable, default 7 days)
|
|
320
|
+
- **t** = days since last access
|
|
321
|
+
- **accessCount** boost = logarithmic scaling (`1 + ln(n)`)
|
|
322
|
+
|
|
323
|
+
**What this means:**
|
|
324
|
+
|
|
325
|
+
| Scenario | Behavior |
|
|
326
|
+
|----------|----------|
|
|
327
|
+
| Memory accessed daily | Score stays near 1.0 — effectively immortal |
|
|
328
|
+
| Memory accessed once, 7 days ago | Score ~0.5 (half-life) |
|
|
329
|
+
| Memory accessed 5x, 14 days ago | Score ~0.65 (access boost keeps it alive) |
|
|
330
|
+
| Memory accessed once, 30 days ago | Score ~0.01 — approaching deletion |
|
|
331
|
+
|
|
332
|
+
**Thresholds:**
|
|
333
|
+
- **Active** (score ≥ 0.2) — healthy, normal behavior
|
|
334
|
+
- **Fading** (0.05 ≤ score < 0.2) — shown in `/stats` as a warning
|
|
335
|
+
- **Expired** (score < 0.05) — deleted on next startup cleanup
|
|
336
|
+
- **Exempt** — `project_meta` and `developer_meta` never expire
|
|
337
|
+
|
|
338
|
+
**TTL Renewal:** Every time a search returns a document, its `last_accessed` timestamp and `access_count` are updated (fire-and-forget, no latency impact). Active memories renew themselves naturally.
|
|
339
|
+
|
|
340
|
+
### Pre-Tool-Use Injection Pipeline
|
|
341
|
+
|
|
342
|
+
When you type a prompt, memory is searched in three phases:
|
|
343
|
+
|
|
344
|
+
1. **Command cache** (<1ms) — exact string match against stored command triggers
|
|
345
|
+
2. **Semantic search** (~50ms) — vector search against all memory types if no command match
|
|
346
|
+
3. **Thread matching** — keyword overlap (2+ matching words or 1 long word >6 chars)
|
|
347
|
+
|
|
348
|
+
Results are formatted and injected as `[MEMORY:ACTIVE]` blocks, trimmed to 2,000 characters maximum.
|
|
234
349
|
|
|
235
|
-
|
|
350
|
+
### Natural Language Intent Detection
|
|
236
351
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
352
|
+
Claude Memory understands natural language commands in conversation:
|
|
353
|
+
|
|
354
|
+
| What you say | What happens |
|
|
355
|
+
|-------------|--------------|
|
|
356
|
+
| "Remember that we use pnpm" | Stores as pattern |
|
|
357
|
+
| "Never deploy on Fridays" | Stores as avoid rule |
|
|
358
|
+
| "Add to open threads: slow query on users" | Creates thread |
|
|
359
|
+
| "Close the slow query thread" | Closes thread |
|
|
360
|
+
| "What do we know about deploys?" | Semantic search |
|
|
361
|
+
| "Forget the old staging config" | Removes (with confirmation) |
|
|
362
|
+
| "Store that as 'deploy'" | Saves as verified command |
|
|
363
|
+
| "I always prefer tabs over spaces" | Stores as developer preference |
|
|
364
|
+
|
|
365
|
+
Secret detection prevents accidentally storing credentials, API keys, tokens, or other sensitive data.
|
|
242
366
|
|
|
243
367
|
### Deduplication
|
|
244
368
|
|
|
245
369
|
Two-layer dedup prevents duplicate entries:
|
|
246
|
-
1.
|
|
247
|
-
2. Unique compound indexes
|
|
370
|
+
1. **Semantic dedup** — checks cosine similarity ≥ 0.92 before inserting
|
|
371
|
+
2. **Unique compound indexes** — database-level safety net
|
|
372
|
+
|
|
373
|
+
### Project Identity
|
|
374
|
+
|
|
375
|
+
Claude Memory identifies projects by hashing the git remote URL (first 16 chars of SHA-256). This means:
|
|
376
|
+
- Same project = same memory, regardless of machine or directory
|
|
377
|
+
- Rename the folder? Memory stays
|
|
378
|
+
- Clone on a different machine? Memory is there
|
|
379
|
+
- Different developer on the same project? Same project memory, different developer preferences
|
|
380
|
+
|
|
381
|
+
Developer identity is based on git user email hash — your preferences follow you across all projects.
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## Startup Conversation
|
|
386
|
+
|
|
387
|
+
At the start of every session, Claude Memory presents options:
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
=== CLAUDE MEMORY ===
|
|
391
|
+
Sessions: 12 | Last: today
|
|
392
|
+
Memory available — 8 architecture, 3 patterns, 2 avoid
|
|
393
|
+
|
|
394
|
+
(c) Continue — pick up where you left off
|
|
395
|
+
(n) Something new
|
|
396
|
+
(f) Specific feature or area
|
|
397
|
+
(r) Review / update memory
|
|
398
|
+
(?) Show full memory context
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
| Choice | Context Cost | What's Injected |
|
|
402
|
+
|--------|-------------|-----------------|
|
|
403
|
+
| **(c) Continue** | ~200 chars | Last session summary + open threads |
|
|
404
|
+
| **(n) New** | 0 chars | Nothing — memory surfaces on-demand |
|
|
405
|
+
| **(f) Feature** | ~500-2000 chars | Semantic search results for that feature area |
|
|
406
|
+
| **(r) Review** | ~200 chars | Memory counts by type |
|
|
407
|
+
| **(?) Full** | ~2000 chars | Complete memory dump (trimmed) |
|
|
248
408
|
|
|
249
409
|
---
|
|
250
410
|
|
|
@@ -256,53 +416,88 @@ Config is stored at `~/.claude-memory/config.json`:
|
|
|
256
416
|
{
|
|
257
417
|
"atlas_uri": "mongodb+srv://...",
|
|
258
418
|
"team_memory": false,
|
|
259
|
-
"memory_ttl_days": 30
|
|
419
|
+
"memory_ttl_days": 30,
|
|
420
|
+
"decay_half_life_days": 7,
|
|
421
|
+
"decay_death_threshold": 0.05
|
|
260
422
|
}
|
|
261
423
|
```
|
|
262
424
|
|
|
263
425
|
| Setting | Default | Description |
|
|
264
426
|
|---------|---------|-------------|
|
|
265
|
-
| `atlas_uri` | — | MongoDB Atlas connection string |
|
|
266
|
-
| `team_memory` | `false` |
|
|
267
|
-
| `memory_ttl_days` | `30` |
|
|
427
|
+
| `atlas_uri` | — | MongoDB Atlas connection string (required) |
|
|
428
|
+
| `team_memory` | `false` | Share project memory across all developers on the same repo |
|
|
429
|
+
| `memory_ttl_days` | `30` | Legacy TTL setting (kept for backward compatibility) |
|
|
430
|
+
| `decay_half_life_days` | `7` | Half-life for exponential decay (days until score halves) |
|
|
431
|
+
| `decay_death_threshold` | `0.05` | Score below which memories are deleted on cleanup |
|
|
432
|
+
|
|
433
|
+
**Internal thresholds** (in code):
|
|
434
|
+
|
|
435
|
+
| Constant | Value | Description |
|
|
436
|
+
|----------|-------|-------------|
|
|
437
|
+
| `VECTOR_RELEVANCE_THRESHOLD` | `0.70` | Minimum cosine similarity for search results |
|
|
438
|
+
| `DUPLICATE_SIMILARITY_THRESHOLD` | `0.92` | Minimum similarity to consider a duplicate |
|
|
439
|
+
| `MAX_INJECTION_CHARS` | `2000` | Maximum characters injected per prompt |
|
|
268
440
|
|
|
269
441
|
You can also set `CLAUDE_MEMORY_ATLAS_URI` as an environment variable or in a `.env` file — the init command auto-detects both.
|
|
270
442
|
|
|
271
443
|
---
|
|
272
444
|
|
|
273
|
-
## Atlas
|
|
445
|
+
## Why Atlas M10+?
|
|
446
|
+
|
|
447
|
+
Claude Memory requires **MongoDB Atlas M10+** ($57/month) for vector search. This is a deliberate choice — not a limitation.
|
|
274
448
|
|
|
275
|
-
|
|
449
|
+
We tested keyword/regex search against semantic vector search with real developer queries. The results:
|
|
276
450
|
|
|
277
|
-
|
|
|
278
|
-
|
|
279
|
-
|
|
|
280
|
-
|
|
|
281
|
-
|
|
|
282
|
-
|
|
|
283
|
-
|
|
|
284
|
-
|
|
|
285
|
-
| Open threads | Yes | Yes |
|
|
286
|
-
| **Semantic vector search** | No | **Yes** |
|
|
287
|
-
| **Atlas Automated Embedding (Voyage AI)** | No | **Yes** |
|
|
451
|
+
| Query Type | Keyword Search | Vector Search |
|
|
452
|
+
|------------|---------------|---------------|
|
|
453
|
+
| Exact matches ("prod-cluster-east") | 80% | 80% |
|
|
454
|
+
| Partial matches ("staging database") | 100% | 100% |
|
|
455
|
+
| Synonym queries ("how to undo a release") | **0%** | **60%** |
|
|
456
|
+
| Conceptual queries ("security best practices") | **0%** | **80%** |
|
|
457
|
+
| Natural questions ("what region is our database in") | **0%** | **100%** |
|
|
458
|
+
| **Overall** | **36%** | **84%** |
|
|
288
459
|
|
|
289
|
-
|
|
460
|
+
Keyword search fails completely when you phrase things differently from how they were stored. That's how humans talk. A memory store that can't understand "how do I deploy" when you stored "docker build → ECR push → webhook" is useless.
|
|
290
461
|
|
|
291
|
-
|
|
462
|
+
**$57/month is cheaper than re-explaining your deploy process every session.**
|
|
292
463
|
|
|
293
|
-
|
|
464
|
+
Vector embeddings are generated automatically by Atlas via Voyage AI — no external API keys, no per-query fees. Atlas handles embedding generation and vector search natively.
|
|
294
465
|
|
|
295
466
|
---
|
|
296
467
|
|
|
297
|
-
##
|
|
468
|
+
## Installation Details
|
|
298
469
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
470
|
+
The `init` command installs integrations in four locations:
|
|
471
|
+
|
|
472
|
+
### Claude Code Hooks (`~/.claude/settings.json`)
|
|
473
|
+
```json
|
|
474
|
+
{
|
|
475
|
+
"hooks": {
|
|
476
|
+
"SessionStart": [{ "hooks": [{ "command": "claude-memory hook:startup" }] }],
|
|
477
|
+
"PreToolUse": [{ "hooks": [{ "command": "claude-memory hook:pre-tool-use" }] }],
|
|
478
|
+
"PostToolUse": [{ "hooks": [{ "command": "claude-memory hook:post-tool-use" }] }],
|
|
479
|
+
"Stop": [{ "hooks": [{ "command": "claude-memory hook:stop" }] }]
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
```
|
|
483
|
+
|
|
484
|
+
### MCP Server (`~/.claude.json`)
|
|
485
|
+
```json
|
|
486
|
+
{
|
|
487
|
+
"mcpServers": {
|
|
488
|
+
"claude-memory": {
|
|
489
|
+
"command": "node",
|
|
490
|
+
"args": ["/path/to/dist/bin/mcp-server.js"]
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
```
|
|
495
|
+
|
|
496
|
+
### Skill File (`~/.claude/skills/memory/SKILL.md`)
|
|
497
|
+
Enables `/recall`, `/remember`, `/threads`, `/stats` slash commands.
|
|
304
498
|
|
|
305
|
-
|
|
499
|
+
### CLAUDE.md Instructions (`~/.claude/CLAUDE.md`)
|
|
500
|
+
Tells Claude it has persistent memory and when to proactively use it.
|
|
306
501
|
|
|
307
502
|
---
|
|
308
503
|
|
|
@@ -310,18 +505,23 @@ Developer identity is based on hostname + username hash — your preferences fol
|
|
|
310
505
|
|
|
311
506
|
```
|
|
312
507
|
src/
|
|
313
|
-
atlas/
|
|
314
|
-
memory/
|
|
315
|
-
hooks/
|
|
316
|
-
startup/
|
|
317
|
-
cache/
|
|
318
|
-
natural-language/
|
|
319
|
-
slash-commands/
|
|
320
|
-
editor/
|
|
321
|
-
bin/
|
|
322
|
-
cleanup.ts
|
|
323
|
-
config.ts
|
|
324
|
-
|
|
508
|
+
atlas/ — MongoDB Atlas client, indexes, vector search, embeddings
|
|
509
|
+
memory/ — CRUD for all memory types (project, developer, working, commands, threads, fading)
|
|
510
|
+
hooks/ — Claude Code lifecycle hooks (startup, pre-tool-use, post-tool-use, stop)
|
|
511
|
+
startup/ — Startup banner, context injection, feature search
|
|
512
|
+
cache/ — In-memory command cache (<1ms trigger lookups)
|
|
513
|
+
natural-language/ — Intent detection, parsing, routing
|
|
514
|
+
slash-commands/ — /memory, /recall, /remember, /threads, /stats, /edit
|
|
515
|
+
editor/ — Interactive TUI browser, dashboard, charts, file-based editor
|
|
516
|
+
bin/ — CLI entry point + MCP server
|
|
517
|
+
cleanup.ts — Exponential decay cleanup on startup
|
|
518
|
+
config.ts — Configuration management + thresholds
|
|
519
|
+
decay.ts — Exponential decay scoring with access-frequency weighting
|
|
520
|
+
project-id.ts — Project and developer identity resolution
|
|
521
|
+
types.ts — TypeScript type definitions
|
|
522
|
+
detector.ts — Cross-session developer pattern detection
|
|
523
|
+
summarizer.ts — Session summarization prompts
|
|
524
|
+
acknowledgement.ts — Post-session review and approval
|
|
325
525
|
```
|
|
326
526
|
|
|
327
527
|
---
|
|
@@ -347,7 +547,8 @@ CLAUDE_MEMORY_ATLAS_URI=mongodb+srv://...
|
|
|
347
547
|
```
|
|
348
548
|
|
|
349
549
|
```bash
|
|
350
|
-
npm test # Full suite (270 tests)
|
|
550
|
+
npm test # Full suite (~270+ tests)
|
|
551
|
+
npx vitest run tests/unit/ # Unit tests (no Atlas needed)
|
|
351
552
|
npx vitest run tests/multi-session.test.ts # Multi-session simulation
|
|
352
553
|
npx vitest run tests/scenarios.test.ts # Real-world developer scenarios
|
|
353
554
|
npx vitest run tests/context-budget.test.ts # Context budget guarantees
|
package/dist/atlas/client.d.ts
CHANGED
|
@@ -4,6 +4,4 @@ export declare function connect(uri?: string): Promise<Db>;
|
|
|
4
4
|
export declare function getCollection(): Promise<Collection<MemoryDocument>>;
|
|
5
5
|
export declare function disconnect(): Promise<void>;
|
|
6
6
|
export declare function testConnection(uri: string): Promise<boolean>;
|
|
7
|
-
export declare function getDbName(): string;
|
|
8
|
-
export declare function getCollectionName(): string;
|
|
9
7
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/atlas/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,wBAAsB,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAkBvD;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAGzE;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAMhD;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAclE
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/atlas/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,EAAE,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAQlD,wBAAsB,OAAO,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,CAkBvD;AAED,wBAAsB,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC,CAGzE;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAMhD;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAclE"}
|
package/dist/atlas/client.js
CHANGED
|
@@ -4,8 +4,6 @@ exports.connect = connect;
|
|
|
4
4
|
exports.getCollection = getCollection;
|
|
5
5
|
exports.disconnect = disconnect;
|
|
6
6
|
exports.testConnection = testConnection;
|
|
7
|
-
exports.getDbName = getDbName;
|
|
8
|
-
exports.getCollectionName = getCollectionName;
|
|
9
7
|
const mongodb_1 = require("mongodb");
|
|
10
8
|
const config_js_1 = require("../config.js");
|
|
11
9
|
const DB_NAME = 'claude_memory';
|
|
@@ -55,10 +53,4 @@ async function testConnection(uri) {
|
|
|
55
53
|
await testClient.close();
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
|
-
function getDbName() {
|
|
59
|
-
return DB_NAME;
|
|
60
|
-
}
|
|
61
|
-
function getCollectionName() {
|
|
62
|
-
return COLLECTION_NAME;
|
|
63
|
-
}
|
|
64
56
|
//# sourceMappingURL=client.js.map
|
package/dist/atlas/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/atlas/client.ts"],"names":[],"mappings":";;AAUA,0BAkBC;AAED,sCAGC;AAED,gCAMC;AAED,wCAcC;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/atlas/client.ts"],"names":[],"mappings":";;AAUA,0BAkBC;AAED,sCAGC;AAED,gCAMC;AAED,wCAcC;AAzDD,qCAAsD;AACtD,4CAA2C;AAG3C,MAAM,OAAO,GAAG,eAAe,CAAC;AAChC,MAAM,eAAe,GAAG,eAAe,CAAC;AAExC,IAAI,MAAM,GAAuB,IAAI,CAAC;AACtC,IAAI,EAAE,GAAc,IAAI,CAAC;AAElB,KAAK,UAAU,OAAO,CAAC,GAAY;IACxC,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IAElB,MAAM,QAAQ,GAAG,GAAG,IAAI,IAAA,uBAAW,GAAE,CAAC;IACtC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,mFAAmF,CACpF,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,IAAI,qBAAW,CAAC,QAAQ,EAAE;QACjC,gBAAgB,EAAE,KAAK;QACvB,wBAAwB,EAAE,KAAK;KAChC,CAAC,CAAC;IAEH,MAAM,MAAM,CAAC,OAAO,EAAE,CAAC;IACvB,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,CAAC;AACZ,CAAC;AAEM,KAAK,UAAU,aAAa;IACjC,MAAM,QAAQ,GAAG,MAAM,OAAO,EAAE,CAAC;IACjC,OAAO,QAAQ,CAAC,UAAU,CAAiB,eAAe,CAAC,CAAC;AAC9D,CAAC;AAEM,KAAK,UAAU,UAAU;IAC9B,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,GAAG,IAAI,CAAC;QACd,EAAE,GAAG,IAAI,CAAC;IACZ,CAAC;AACH,CAAC;AAEM,KAAK,UAAU,cAAc,CAAC,GAAW;IAC9C,MAAM,UAAU,GAAG,IAAI,qBAAW,CAAC,GAAG,EAAE;QACtC,gBAAgB,EAAE,KAAK;QACvB,wBAAwB,EAAE,KAAK;KAChC,CAAC,CAAC;IACH,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,OAAO,EAAE,CAAC;QAC3B,MAAM,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;YAAS,CAAC;QACT,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC;AACH,CAAC"}
|
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Local embedding
|
|
2
|
+
* TEMPORARY: Local embedding bridge via HuggingFace Transformers (ONNX).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Using: all-MiniLM-L6-v2 -- 384 dimensions, cosine similarity, runs in Node.js.
|
|
5
|
+
* Model: ~23MB, downloads on first use, cached locally.
|
|
6
|
+
*
|
|
7
|
+
* MIGRATION PATH -- Atlas Automated Embedding (Voyage AI):
|
|
8
|
+
* When Atlas Automated Embedding is GA, replace this entire file:
|
|
9
|
+
*
|
|
10
|
+
* Step 1: Remove @huggingface/transformers from package.json dependencies.
|
|
11
|
+
*
|
|
12
|
+
* Step 2: Update src/atlas/indexes.ts createVectorSearchIndex() to use autoEmbedding:
|
|
13
|
+
* fields: [{
|
|
14
|
+
* type: 'autoEmbedding',
|
|
15
|
+
* path: 'searchable_text',
|
|
16
|
+
* embeddingModel: { provider: 'voyage', model: 'voyage-3' }
|
|
17
|
+
* }]
|
|
18
|
+
* Remove numDimensions -- Atlas manages dimensions automatically.
|
|
19
|
+
*
|
|
20
|
+
* Step 3: Remove all generateEmbedding() calls from write paths in:
|
|
21
|
+
* - src/memory/working.ts
|
|
22
|
+
* - src/memory/project.ts
|
|
23
|
+
* - src/memory/developer.ts
|
|
24
|
+
* Atlas generates and maintains embeddings automatically on insert/update.
|
|
25
|
+
*
|
|
26
|
+
* Step 4: Update src/atlas/vector.ts $vectorSearch to use 'path: searchable_text'
|
|
27
|
+
* instead of 'path: embedding'. Remove queryVector -- Atlas embeds the plain
|
|
28
|
+
* text query automatically.
|
|
29
|
+
*
|
|
30
|
+
* Step 5: Delete this file entirely.
|
|
31
|
+
*
|
|
32
|
+
* Result: Zero embedding code. Zero external API keys. Pure Atlas.
|
|
33
|
+
* Write plain text, query plain text, Atlas does the rest.
|
|
7
34
|
*/
|
|
8
35
|
export declare const EMBEDDING_DIMENSIONS = 384;
|
|
9
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../src/atlas/embeddings.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"embeddings.d.ts","sourceRoot":"","sources":["../../src/atlas/embeddings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAMH,eAAO,MAAM,oBAAoB,MAAM,CAAC;AAwBxC;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAIvE;AAED;;GAEG;AACH,wBAAsB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAM7E"}
|