claude-recall 0.8.4 → 0.8.6

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/.claude/CLAUDE.md CHANGED
@@ -1,407 +1,14 @@
1
- # Claude Recall - Skills Integration
1
+ # Claude Recall - Memory-First Development
2
2
 
3
- **Note**: Claude Recall now uses Claude Code Skills for better memory management.
4
- See [.claude/skills/memory-management/SKILL.md](./.claude/skills/memory-management/SKILL.md) for details.
3
+ This project uses Claude Code Skills for memory management.
5
4
 
6
- ---
5
+ **Primary Documentation:** [SKILL.md](./skills/memory-management/SKILL.md)
7
6
 
8
- # Claude Recall - Memory-First Development with Learning Loop
7
+ The skill provides:
8
+ - Memory search workflow (search before acting)
9
+ - Automatic failure capture with counterfactual reasoning
10
+ - Project scoping (universal vs project-specific)
11
+ - DevOps pattern priority (Priority 0 - highest)
12
+ - Privacy & security guidelines
9
13
 
10
- This file provides instructions to Claude Code when working with projects that use Claude Recall for persistent memory.
11
-
12
- ## Core Principle: Never Repeat Yourself
13
-
14
- **The user should NEVER have to repeat preferences or explain what worked/didn't work.**
15
-
16
- Your job is to:
17
- 1. Remember stated preferences permanently
18
- 2. Learn from failures and corrections (what didn't work, how it was fixed)
19
- 3. Capture meaningful success patterns (when overcoming challenges, not trivial actions)
20
- 4. Apply learned patterns automatically
21
-
22
- ## The Learning Loop Workflow
23
-
24
- ### Phase 1: Pre-Action (BEFORE doing any task)
25
-
26
- **Search memories directly** using the MCP search tool:
27
-
28
- ```
29
- mcp__claude-recall__search("[task keywords] preferences success failure correction")
30
- ```
31
-
32
- **What this finds automatically:**
33
- - **Preferences**: User-stated preferences for this type of task
34
- - **Successes**: Past approaches that worked well
35
- - **Failures**: Past approaches that failed (avoid these!)
36
- - **Corrections**: User fixes (HIGHEST PRIORITY - user explicitly said "no, do this")
37
-
38
- **Example search:**
39
- ```
40
- Task: "Create authentication module"
41
- Search: mcp__claude-recall__search("authentication module TypeScript testing")
42
- Finds:
43
- - "I prefer TypeScript with strict mode"
44
- - "Created auth module with JWT - SUCCESS"
45
- - "Session-based auth failed - use JWT instead"
46
- ```
47
-
48
- ### Phase 2: Execution
49
-
50
- Apply what you found:
51
- - **Follow preferences**: Use user's stated style/tools/conventions
52
- - **Repeat successes**: Use approaches that worked before
53
- - **Avoid failures**: Don't try approaches that failed
54
- - **Prioritize corrections**: User explicitly fixed these - highest priority!
55
-
56
- ### Phase 3: Post-Action (AFTER task completion)
57
-
58
- **Capture meaningful outcomes** for future learning:
59
-
60
- **If user corrects** ("No, do it this way", "Change X to Y"):
61
- ```
62
- mcp__claude-recall__store_memory({
63
- content: "CORRECTION: [User's fix/preference]",
64
- metadata: { type: "correction", priority: "high" }
65
- })
66
- ```
67
-
68
- **If task fails** (errors, "That didn't work"):
69
- ```
70
- Failures are AUTO-CAPTURED with counterfactual reasoning.
71
- No manual storage needed - the system detects failures automatically.
72
- ```
73
-
74
- **If task succeeds AFTER overcoming challenges** (fail → correct → success):
75
- ```
76
- ONLY store success when there was a learning cycle:
77
- - After you tried approach A, failed, then approach B worked
78
- - After user corrected your approach and THEN it succeeded
79
- - When task required multiple iterations to get right
80
-
81
- DO NOT store success for:
82
- - Trivial tool executions (creating files, running commands)
83
- - First-try successes with no challenges
84
- - Actions that just followed existing preferences
85
-
86
- Example of meaningful success:
87
- mcp__claude-recall__store_memory({
88
- content: "Tried session-based auth (failed), switched to JWT tokens (SUCCESS) - JWT works better for stateless API",
89
- metadata: { type: "success", task: "authentication", learning_cycle: true }
90
- })
91
- ```
92
-
93
- ## Available MCP Tools
94
-
95
- Claude Recall provides these MCP tools (access via `mcp__claude-recall__*`):
96
-
97
- - **`mcp__claude-recall__search`**: Search memories by query (use this before tasks)
98
- - **`mcp__claude-recall__store_memory`**: Store new memories (use this for outcomes)
99
- - **`mcp__claude-recall__retrieve_memory`**: Retrieve specific memory by ID
100
- - **`mcp__claude-recall__get_stats`**: View memory statistics
101
- - **`mcp__claude-recall__clear_context`**: Clear session context
102
-
103
- ## Intelligence & Evolution (v0.7.0+)
104
-
105
- ### Automatic Failure Learning
106
-
107
- Claude Recall now **automatically captures failures with counterfactual reasoning**:
108
- - **What failed**: The approach or action that didn't work
109
- - **Why it failed**: Root cause analysis (file not found, permission denied, etc.)
110
- - **What should be done instead**: Counterfactual suggestion (the right approach)
111
- - **Preventative checks**: Steps to prevent the failure from recurring
112
-
113
- **No manual storage needed** - failures are auto-detected from:
114
- - Error messages and exceptions
115
- - User corrections ("That didn't work", "Failed", "Error")
116
-
117
- ### Sophistication Tracking
118
-
119
- Every memory is **automatically classified by sophistication level**:
120
- - **L1 Procedural**: Basic tool use, simple actions
121
- - **L2 Self-Reflection**: Error checking, corrections, learning from failures
122
- - **L3 Adaptive**: Systematic workflows, devops patterns
123
- - **L4 Compositional**: Multi-constraint reasoning, complex decision-making
124
-
125
- View your agent's evolution: `npx claude-recall evolution`
126
-
127
- ### New CLI Commands (v0.7.0+)
128
-
129
- **View memory evolution metrics:**
130
- ```bash
131
- npx claude-recall evolution # Last 30 days
132
- npx claude-recall evolution --days 60 # Last 60 days
133
- npx claude-recall evolution --project my-app # Filter by project
134
- ```
135
-
136
- Shows:
137
- - Progression score (0-100)
138
- - Sophistication breakdown (L1-L4 percentages)
139
- - Confidence trends (improving/stable/declining)
140
- - Failure rate trends (improving/stable/worsening)
141
-
142
- **View failure memories with counterfactual learning:**
143
- ```bash
144
- npx claude-recall failures # Last 10 failures
145
- npx claude-recall failures --limit 20 # Show 20 most recent
146
- npx claude-recall failures --project my-app # Filter by project
147
- ```
148
-
149
- Shows:
150
- - What failed and why
151
- - What should have been done instead
152
- - Preventative checks to avoid recurrence
153
- - Alternative approaches to consider
154
-
155
- ## Memory Types
156
-
157
- Memories are categorized by type (sorted by priority):
158
-
159
- 1. **correction**: User corrections - HIGHEST PRIORITY (user explicitly said "no, do this")
160
- 2. **preference**: User preferences (coding style, tool choices, conventions)
161
- 3. **success**: What worked in past tasks
162
- 4. **failure**: What didn't work (avoid these approaches)
163
- 5. **project-knowledge**: Project-specific info (configs, APIs, architecture)
164
- 6. **tool-use**: Tool execution history
165
-
166
- ## Example: Complete Learning Loop
167
-
168
- ### First Time - User States Preference
169
-
170
- **User:** "I prefer Python for scripts"
171
-
172
- **You (Claude Code):**
173
- ```
174
- mcp__claude-recall__store_memory({
175
- content: "I prefer Python for scripts",
176
- metadata: { type: "preference", language: "python" }
177
- })
178
- ```
179
- Confirm: "✓ Stored preference"
180
-
181
- ### Second Time - User Requests Task
182
-
183
- **User:** "Create a test script"
184
-
185
- **You (Claude Code):**
186
- ```
187
- 1. Search: mcp__claude-recall__search("scripts python test preferences")
188
- Finds: "I prefer Python for scripts"
189
-
190
- 2. Create test.py (not test.sh) - applying preference
191
-
192
- 3. User responds: "Perfect!"
193
-
194
- 4. ✗ DO NOT store success - this was just applying a known preference
195
- No challenge overcome, no learning cycle.
196
- ```
197
-
198
- ### Third Time - Automatic Application
199
-
200
- **User:** "Create a build script"
201
-
202
- **You (Claude Code):**
203
- ```
204
- 1. Search: mcp__claude-recall__search("scripts build python")
205
- Finds: "I prefer Python for scripts" (preference)
206
-
207
- 2. Create build.py automatically - preference applied!
208
- User doesn't have to repeat themselves ✓
209
- ```
210
-
211
- ### Learning Cycle Example - When to Store Success
212
-
213
- **User:** "Set up authentication"
214
-
215
- **You (Claude Code):**
216
- ```
217
- 1. Try approach: Create session-based auth with cookies
218
- 2. Error: "CORS issues in stateless API"
219
- 3. User feedback: "This is a stateless API, sessions won't work"
220
- 4. Try approach: JWT tokens with Bearer authentication
221
- 5. Success! Works correctly.
222
-
223
- 6. ✓ STORE THIS - it's a learning cycle:
224
- mcp__claude-recall__store_memory({
225
- content: "Session auth failed for stateless API (CORS). JWT tokens work - use Bearer authentication for stateless APIs",
226
- metadata: { type: "success", task: "authentication", learning_cycle: true }
227
- })
228
- ```
229
-
230
- ### User Makes Correction
231
-
232
- **User:** "No, put scripts in scripts/ directory not root"
233
-
234
- **You (Claude Code):**
235
- ```
236
- 1. Store correction: mcp__claude-recall__store_memory({
237
- content: "CORRECTION: Scripts go in scripts/ directory not root",
238
- metadata: { type: "correction", priority: "high" }
239
- })
240
-
241
- 2. Move file immediately
242
-
243
- 3. Next time: Search finds correction and applies it automatically
244
- ```
245
-
246
- ## When to Store Memories
247
-
248
- **Store immediately when user:**
249
- - States a preference ("I prefer X", "Always use Y", "Never do Z")
250
- - Makes a decision ("We're using X framework")
251
- - Provides project info ("Our API uses X pattern")
252
- - Makes a correction ("No, do it this way", "Change X to Y")
253
-
254
- **Store after task completion (ONLY for learning cycles):**
255
- - **Success (rare!)**: Only when overcoming challenges - "Tried X (failed), then Y (SUCCESS)"
256
- - **Failure (auto-captured)**: System detects automatically, no manual storage needed
257
- - **Correction**: Always store user corrections with high priority
258
-
259
- **DO NOT store:**
260
- - Trivial successes (file creation, simple tool execution)
261
- - First-try successes with no challenges
262
- - Actions that just followed existing preferences
263
-
264
- ## Critical Guidelines
265
-
266
- 1. **Search before acting**: Always call `mcp__claude-recall__search` before file operations
267
- 2. **Never repeat questions**: If preference exists in search results, apply it automatically
268
- 3. **Capture outcomes**: Store success/failure/correction after tasks
269
- 4. **Prioritize corrections**: User explicitly fixed these - highest priority!
270
- 5. **Use broad search terms**: Include task type + language + preferences + success/failure/correction
271
- 6. **Close the loop**: Pre-action search → Execute → Post-action outcome storage
272
-
273
- ## Project Scoping (v0.7.2+)
274
-
275
- Claude Recall now supports **project-specific memory isolation** to keep universal preferences separate from project-specific information.
276
-
277
- ### Three Memory Scopes
278
-
279
- 1. **Universal** (`scope='universal'`): Available in all projects
280
- - User says: "Remember everywhere: I prefer TypeScript with strict mode"
281
- - Stored as universal memory, accessible from any project
282
-
283
- 2. **Project** (`scope='project'`): Only available in current project
284
- - User says: "For this project, we use PostgreSQL"
285
- - Stored with project_id, only accessible from this project
286
-
287
- 3. **Unscoped** (`scope=null`, default): Available everywhere (backward compatible)
288
- - User says: "I prefer Jest for testing"
289
- - Stored without scope, works like v0.7.1 and earlier
290
-
291
- ### Auto-Detection
292
-
293
- When storing memories, the system automatically detects scope from user language:
294
-
295
- **Universal indicators**:
296
- - "remember everywhere"
297
- - "for all projects"
298
- - "globally"
299
- - "always use"
300
-
301
- **Project indicators**:
302
- - "for this project"
303
- - "project-specific"
304
- - "only here"
305
- - "in this project"
306
-
307
- **Default**: If no indicator, memory is unscoped (available everywhere)
308
-
309
- ### How Search Works
310
-
311
- **Default behavior** (project + universal):
312
- ```
313
- mcp__claude-recall__search("database")
314
- ```
315
- Returns: Current project memories + universal memories + unscoped memories
316
-
317
- **Global search** (all projects):
318
- ```
319
- mcp__claude-recall__search("database", filters: { globalSearch: true })
320
- ```
321
- Returns: All memories from all projects
322
-
323
- ### CLI Usage
324
-
325
- ```bash
326
- # Current project stats
327
- npx claude-recall stats
328
-
329
- # Global stats (all projects)
330
- npx claude-recall stats --global
331
-
332
- # Search current project
333
- npx claude-recall search "database"
334
-
335
- # Search specific project
336
- npx claude-recall search "database" --project my-app
337
-
338
- # Search all projects
339
- npx claude-recall search "database" --global
340
- ```
341
-
342
- ### Use Cases
343
-
344
- **Universal memories**: Preferences that apply across all your work
345
- - Coding style: "Always use TypeScript with strict mode"
346
- - Tools: "Prefer Jest for testing"
347
- - Conventions: "Name files with kebab-case"
348
-
349
- **Project memories**: Project-specific details
350
- - Database: "This project uses PostgreSQL"
351
- - API: "Base URL is https://api.example.com"
352
- - Build: "Run npm run build:prod for production"
353
-
354
- ## Advanced: Optional Context-Manager Agent
355
-
356
- For complex multi-step research, a `context-manager` agent is available at `.claude/agents/context-manager.md`.
357
-
358
- **When to use the agent (optional):**
359
- - Complex workflows requiring multiple coordinated searches
360
- - Multi-step research across different memory types
361
- - Most tasks DON'T need it - direct MCP calls are faster
362
-
363
- **For most tasks:** Use direct MCP search (fast, simple, effective)
364
-
365
- ## Integration with Development Workflow
366
-
367
- Claude Recall creates a **learning loop**:
368
- ```
369
- User states preference → Stored in database
370
-
371
- Task requested → Search finds preference
372
-
373
- Execute with preference → Apply automatically
374
-
375
- User approves/corrects → Outcome stored
376
-
377
- Next similar task → Search finds preference + outcome
378
-
379
- Apply automatically (learned pattern!)
380
-
381
- User never repeats themselves ✓
382
- ```
383
-
384
- Data storage:
385
- - Local SQLite database (`~/.claude-recall/claude-recall.db`)
386
- - 100% local and private (no cloud sync)
387
- - Export/import available: `npx claude-recall export/import`
388
-
389
- ## Troubleshooting
390
-
391
- **If memories aren't being found:**
392
- 1. Verify MCP server: `claude mcp list` (should show `claude-recall`)
393
- 2. Test search: `npx claude-recall search "your query"`
394
- 3. Check stats: `npx claude-recall stats`
395
-
396
- **If searches seem incomplete:**
397
- - Use broad search terms: "authentication TypeScript success failure correction"
398
- - Search returns all matching memories across all types
399
- - Prioritize corrections > preferences > successes > failures
400
-
401
- **If outcomes aren't being stored:**
402
- - Make sure to call `mcp__claude-recall__store_memory` after task completion
403
- - Include proper metadata (`type: "success"/"failure"/"correction"`)
404
-
405
- ---
406
-
407
- **Remember:** The goal is making the user never repeat themselves. The learning loop (search → execute → store outcome) ensures preferences are remembered, successes are repeated, and failures are avoided. Fast direct MCP calls, no agent overhead!
14
+ For project architecture and development commands, see [CLAUDE.md](../CLAUDE.md) in the project root.
package/docs/faq.md CHANGED
@@ -221,6 +221,9 @@ Project-specific keys ensure:
221
221
  - no cross-project leakage
222
222
  - clean agent shutdown
223
223
 
224
+ **Recommended**: Create your own free keys for production:
225
+ [Create PubNub Keys](https://www.pubnub.com/how-to/admin-portal-create-keys/)
226
+
224
227
  ---
225
228
 
226
229
  ## What if I want to reset everything?
@@ -37,6 +37,10 @@ Then restart **Claude Code**.
37
37
 
38
38
  Claude will automatically detect the MCP server and begin using persistent memory.
39
39
 
40
+ Installation creates `.claude/skills/memory-management/` with:
41
+ - SKILL.md (main skill definition)
42
+ - references/ (examples, patterns, troubleshooting)
43
+
40
44
  ---
41
45
 
42
46
  ## Global Install (Not Recommended)
@@ -19,6 +19,17 @@ This enables:
19
19
 
20
20
  ---
21
21
 
22
+ ## Automatic Memory Scoping
23
+
24
+ Claude Recall automatically manages memory scope:
25
+ - **Universal memories** (coding style, tool preferences) → reused across all projects
26
+ - **Project memories** (database configs, APIs) → isolated per project
27
+
28
+ System auto-detects from language ("remember everywhere" vs "for this project").
29
+ No user configuration needed.
30
+
31
+ ---
32
+
22
33
  ## Presence Channel
23
34
 
24
35
  Memory Agent publishes heartbeats:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "claude-recall",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "Persistent memory for Claude Code with fire-and-forget PubNub architecture, automatic capture, failure learning, and project scoping via MCP server",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -1,160 +0,0 @@
1
- # Architecture Overview
2
-
3
- Claude Recall consists of three integrated subsystems:
4
-
5
- 1. **Local Memory Engine (SQLite)**
6
- 2. **Realtime Event Bus (PubNub)**
7
- 3. **Claude Code Hooks + MCP Server**
8
-
9
- Together, they form a fast, private, adaptive memory layer for Claude.
10
-
11
- ---
12
-
13
- # 1. Local Memory Engine (SQLite)
14
-
15
- All persistent knowledge is stored locally:
16
-
17
- - preferences
18
- - workflow patterns
19
- - project architecture
20
- - mistakes + corrections
21
- - reasoning heuristics
22
- - coding standards
23
- - naming conventions
24
-
25
- The database:
26
- - is located at `~/.claude-recall/memories.db`
27
- - is indexed for fast semantic search
28
- - uses structured, typed memory records
29
- - prunes & evolves data over time
30
-
31
- The Memory Engine guarantees:
32
- - **zero cloud storage**
33
- - **full user control**
34
- - **review, edit, export, delete**
35
-
36
- ---
37
-
38
- # 2. Realtime Event Bus (PubNub)
39
-
40
- PubNub enables Claude Recall's **low-latency, non-blocking architecture**.
41
-
42
- ### Why PubNub?
43
-
44
- Claude Code hooks run inside time-sensitive workflows.
45
- Traditional synchronous CLI calls were slow (50–500ms).
46
- PubNub reduces them to **sub-10ms**.
47
-
48
- ### What PubNub Transmits
49
- Only *lightweight metadata*, for example:
50
-
51
- - tool name
52
- - file path
53
- - event type
54
- - prompt token counts (never text)
55
- - memory suggestion IDs
56
- - agent lifecycle heartbeat
57
-
58
- ### What PubNub Does *NOT* Transmit
59
- - code
60
- - conversation text
61
- - memory contents
62
- - embeddings
63
- - prompts
64
- - project data
65
- - file contents
66
-
67
- PubNub is a **coordination mechanism**, not storage and not transport of user content.
68
-
69
- ### Event Flow
70
-
71
- ```
72
- Claude Code Hook
73
- ↓ publish (metadata only)
74
- PubNub Channel
75
- ↓ subscribe
76
- Memory Agent
77
- ↓ analyze
78
- Memory Engine (SQLite)
79
- ↓ suggestions
80
- PubNub Channel
81
- ↓ subscribe
82
- Claude Code
83
- ```
84
-
85
- ### Channels Used
86
-
87
- | Channel | Purpose |
88
- |---------|---------|
89
- | `claude-tool-events` | File write/edit events from hooks |
90
- | `claude-prompt-stream` | Prompt token metadata |
91
- | `claude-memory-context` | Contextual memory suggestions |
92
- | `claude-presence` | Agent heartbeat & lifecycle |
93
-
94
- ### Architecture Benefits
95
- - Hooks are instantaneous
96
- - Memory is processed asynchronously
97
- - Claude remains responsive
98
- - Multiple events can be buffered in parallel
99
- - Agent can evolve memory without blocking anything
100
-
101
- ---
102
-
103
- # 3. Claude Code Hooks + MCP Server
104
-
105
- Claude Recall integrates deeply with Claude Code:
106
-
107
- ### Pre-Action Hook
108
- - Fired before Claude writes or edits files
109
- - Publishes event metadata
110
- - Requests relevant memories
111
- - Injects memory into planning
112
-
113
- ### Planning Hook
114
- - Performs advanced reasoning
115
- - Uses previous memories
116
- - Returns structured plan
117
- - Reduces hallucination & mistakes
118
-
119
- ### Post-Action Hook
120
- - Captures new knowledge
121
- - Classifies memory type
122
- - Publishes metadata via PubNub
123
- - Evolves memory asynchronously
124
-
125
- ### MCP Server
126
- Handles:
127
- - semantic search
128
- - memory retrieval
129
- - memory creation/updating
130
- - project registration
131
- - skills activation
132
-
133
- ---
134
-
135
- # Summary Diagram
136
-
137
- ```
138
- ┌──────────────┐
139
- │ Claude Code │
140
- └───────┬──────┘
141
- │ Hooks
142
-
143
- ┌─────────────────────┐
144
- │ PubNub Event Bus │
145
- └───────┬────────────┘
146
- │ metadata only
147
-
148
- ┌───────────────────────┐
149
- │ Memory Agent (Local) │
150
- └───────┬──────────────┘
151
-
152
-
153
- ┌─────────────────────────────┐
154
- │ SQLite Memory Engine │
155
- └─────────────────────────────┘
156
- ```
157
-
158
- ---
159
-
160
- Next: Learn about the [Learning Loop](learning-loop.md).