claude_memory 0.2.0 → 0.3.0

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.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/.mind.mv2.o2N83S +0 -0
  3. data/.claude/CLAUDE.md +1 -0
  4. data/.claude/rules/claude_memory.generated.md +28 -9
  5. data/.claude/settings.local.json +9 -1
  6. data/.claude/skills/check-memory/SKILL.md +77 -0
  7. data/.claude/skills/improve/SKILL.md +532 -0
  8. data/.claude/skills/improve/feature-patterns.md +1221 -0
  9. data/.claude/skills/quality-update/SKILL.md +229 -0
  10. data/.claude/skills/quality-update/implementation-guide.md +346 -0
  11. data/.claude/skills/review-commit/SKILL.md +199 -0
  12. data/.claude/skills/review-for-quality/SKILL.md +154 -0
  13. data/.claude/skills/review-for-quality/expert-checklists.md +79 -0
  14. data/.claude/skills/setup-memory/SKILL.md +168 -0
  15. data/.claude/skills/study-repo/SKILL.md +307 -0
  16. data/.claude/skills/study-repo/analysis-template.md +323 -0
  17. data/.claude/skills/study-repo/focus-examples.md +327 -0
  18. data/CHANGELOG.md +133 -0
  19. data/CLAUDE.md +130 -11
  20. data/README.md +117 -10
  21. data/db/migrations/001_create_initial_schema.rb +117 -0
  22. data/db/migrations/002_add_project_scoping.rb +33 -0
  23. data/db/migrations/003_add_session_metadata.rb +42 -0
  24. data/db/migrations/004_add_fact_embeddings.rb +20 -0
  25. data/db/migrations/005_add_incremental_sync.rb +21 -0
  26. data/db/migrations/006_add_operation_tracking.rb +40 -0
  27. data/db/migrations/007_add_ingestion_metrics.rb +26 -0
  28. data/docs/.claude/mind.mv2.lock +0 -0
  29. data/docs/GETTING_STARTED.md +587 -0
  30. data/docs/RELEASE_NOTES_v0.2.0.md +0 -1
  31. data/docs/RUBY_COMMUNITY_POST_v0.2.0.md +0 -2
  32. data/docs/architecture.md +9 -8
  33. data/docs/auto_init_design.md +230 -0
  34. data/docs/improvements.md +557 -731
  35. data/docs/influence/.gitkeep +13 -0
  36. data/docs/influence/grepai.md +933 -0
  37. data/docs/influence/qmd.md +2195 -0
  38. data/docs/plugin.md +257 -11
  39. data/docs/quality_review.md +472 -1273
  40. data/docs/remaining_improvements.md +330 -0
  41. data/lefthook.yml +13 -0
  42. data/lib/claude_memory/commands/checks/claude_md_check.rb +41 -0
  43. data/lib/claude_memory/commands/checks/database_check.rb +120 -0
  44. data/lib/claude_memory/commands/checks/hooks_check.rb +112 -0
  45. data/lib/claude_memory/commands/checks/reporter.rb +110 -0
  46. data/lib/claude_memory/commands/checks/snapshot_check.rb +30 -0
  47. data/lib/claude_memory/commands/doctor_command.rb +12 -129
  48. data/lib/claude_memory/commands/help_command.rb +1 -0
  49. data/lib/claude_memory/commands/hook_command.rb +9 -2
  50. data/lib/claude_memory/commands/index_command.rb +169 -0
  51. data/lib/claude_memory/commands/ingest_command.rb +1 -1
  52. data/lib/claude_memory/commands/init_command.rb +5 -197
  53. data/lib/claude_memory/commands/initializers/database_ensurer.rb +30 -0
  54. data/lib/claude_memory/commands/initializers/global_initializer.rb +85 -0
  55. data/lib/claude_memory/commands/initializers/hooks_configurator.rb +156 -0
  56. data/lib/claude_memory/commands/initializers/mcp_configurator.rb +56 -0
  57. data/lib/claude_memory/commands/initializers/memory_instructions_writer.rb +135 -0
  58. data/lib/claude_memory/commands/initializers/project_initializer.rb +111 -0
  59. data/lib/claude_memory/commands/recover_command.rb +75 -0
  60. data/lib/claude_memory/commands/registry.rb +5 -1
  61. data/lib/claude_memory/commands/stats_command.rb +239 -0
  62. data/lib/claude_memory/commands/uninstall_command.rb +226 -0
  63. data/lib/claude_memory/core/batch_loader.rb +32 -0
  64. data/lib/claude_memory/core/concept_ranker.rb +73 -0
  65. data/lib/claude_memory/core/embedding_candidate_builder.rb +37 -0
  66. data/lib/claude_memory/core/fact_collector.rb +51 -0
  67. data/lib/claude_memory/core/fact_query_builder.rb +154 -0
  68. data/lib/claude_memory/core/fact_ranker.rb +113 -0
  69. data/lib/claude_memory/core/result_builder.rb +54 -0
  70. data/lib/claude_memory/core/result_sorter.rb +25 -0
  71. data/lib/claude_memory/core/scope_filter.rb +61 -0
  72. data/lib/claude_memory/core/text_builder.rb +29 -0
  73. data/lib/claude_memory/embeddings/generator.rb +161 -0
  74. data/lib/claude_memory/embeddings/similarity.rb +69 -0
  75. data/lib/claude_memory/hook/handler.rb +4 -3
  76. data/lib/claude_memory/index/lexical_fts.rb +7 -2
  77. data/lib/claude_memory/infrastructure/operation_tracker.rb +158 -0
  78. data/lib/claude_memory/infrastructure/schema_validator.rb +206 -0
  79. data/lib/claude_memory/ingest/content_sanitizer.rb +6 -7
  80. data/lib/claude_memory/ingest/ingester.rb +99 -15
  81. data/lib/claude_memory/ingest/metadata_extractor.rb +57 -0
  82. data/lib/claude_memory/ingest/tool_extractor.rb +71 -0
  83. data/lib/claude_memory/mcp/response_formatter.rb +331 -0
  84. data/lib/claude_memory/mcp/server.rb +19 -0
  85. data/lib/claude_memory/mcp/setup_status_analyzer.rb +73 -0
  86. data/lib/claude_memory/mcp/tool_definitions.rb +279 -0
  87. data/lib/claude_memory/mcp/tool_helpers.rb +80 -0
  88. data/lib/claude_memory/mcp/tools.rb +330 -320
  89. data/lib/claude_memory/recall/dual_query_template.rb +63 -0
  90. data/lib/claude_memory/recall.rb +304 -237
  91. data/lib/claude_memory/resolve/resolver.rb +52 -49
  92. data/lib/claude_memory/store/sqlite_store.rb +210 -144
  93. data/lib/claude_memory/store/store_manager.rb +6 -6
  94. data/lib/claude_memory/sweep/sweeper.rb +6 -0
  95. data/lib/claude_memory/version.rb +1 -1
  96. data/lib/claude_memory.rb +35 -3
  97. metadata +71 -11
  98. data/.claude/.mind.mv2.aLCUZd +0 -0
  99. data/.claude/memory.sqlite3 +0 -0
  100. data/.mcp.json +0 -11
  101. /data/docs/{feature_adoption_plan.md → plans/feature_adoption_plan.md} +0 -0
  102. /data/docs/{feature_adoption_plan_revised.md → plans/feature_adoption_plan_revised.md} +0 -0
  103. /data/docs/{plan.md → plans/plan.md} +0 -0
  104. /data/docs/{updated_plan.md → plans/updated_plan.md} +0 -0
data/docs/plugin.md CHANGED
@@ -35,6 +35,72 @@ From within Claude Code:
35
35
  # Ask Claude: "check memory status"
36
36
  ```
37
37
 
38
+ ## Setting Up a New Project
39
+
40
+ After installing the plugin, you'll need to set up memory for each project. There are two scenarios:
41
+
42
+ ### Scenario A: First-Time Setup (Fresh Install)
43
+
44
+ If this is your first time using ClaudeMemory:
45
+
46
+ ```bash
47
+ # 1. Navigate to your project
48
+ cd ~/projects/my-app
49
+
50
+ # 2. Initialize both global and project databases
51
+ claude-memory init
52
+
53
+ # Expected output:
54
+ # ✓ Created global database at ~/.claude/memory.sqlite3
55
+ # ✓ Created project database at .claude/memory.sqlite3
56
+ # ✓ Configured hooks for automatic ingestion
57
+ # ✓ MCP server ready
58
+ ```
59
+
60
+ This creates:
61
+ - **Global DB** (`~/.claude/memory.sqlite3`) - One-time, user-wide
62
+ - **Project DB** (`.claude/memory.sqlite3`) - Per-project
63
+
64
+ ### Scenario B: Plugin Already Installed
65
+
66
+ If you already have ClaudeMemory installed globally and are adding it to a new project:
67
+
68
+ ```bash
69
+ # 1. Navigate to your new project
70
+ cd ~/projects/another-app
71
+
72
+ # 2. Initialize project memory (global already exists)
73
+ claude-memory init
74
+
75
+ # Expected output:
76
+ # ✓ Global database exists at ~/.claude/memory.sqlite3
77
+ # ✓ Created project database at .claude/memory.sqlite3
78
+ # ✓ Hooks already configured
79
+ # ✓ Ready to use
80
+ ```
81
+
82
+ The global database is reused; only the project database gets created.
83
+
84
+ ### Quick Start Workflow
85
+
86
+ After initialization:
87
+
88
+ ```bash
89
+ # 3. Start Claude Code
90
+ claude
91
+
92
+ # 4. Let Claude analyze your project (optional but recommended)
93
+ /claude-memory:analyze
94
+
95
+ # 5. Or just talk naturally
96
+ "This is a Rails app with PostgreSQL, deploying to Heroku"
97
+
98
+ # Behind the scenes:
99
+ # - Facts extracted automatically on session stop
100
+ # - Stored in .claude/memory.sqlite3 (project scope)
101
+ # - Available in future conversations
102
+ ```
103
+
38
104
  ## How It Works
39
105
 
40
106
  ### Claude-Powered Fact Extraction
@@ -109,6 +175,33 @@ The `/memory` skill provides manual access:
109
175
  | Global | `~/.claude/memory.sqlite3` | User-wide facts |
110
176
  | Project | `.claude/memory.sqlite3` | Project-specific facts |
111
177
 
178
+ Both databases are queried on every recall. Project facts take precedence over global facts when there's overlap.
179
+
180
+ ### When to Use Global vs Project Memory
181
+
182
+ Understanding scope helps Claude remember the right things in the right places:
183
+
184
+ | Memory Type | Use For | Examples |
185
+ |-------------|---------|----------|
186
+ | **Global** | Personal preferences, coding style, tool choices that apply everywhere | "I prefer descriptive variable names"<br>"I always use single quotes in Ruby"<br>"I like verbose error messages" |
187
+ | **Project** | Tech stack, architecture decisions, project-specific conventions | "This app uses PostgreSQL"<br>"We deploy to Vercel"<br>"This project uses React 18" |
188
+
189
+ **Workflow Examples:**
190
+
191
+ ```bash
192
+ # Setting global preferences
193
+ You: "I always prefer tabs over spaces - remember that for all projects"
194
+ Claude: [stores with scope_hint: global]
195
+
196
+ # Project-specific facts (automatic)
197
+ You: "This app uses Next.js and Supabase"
198
+ Claude: [stores with scope: project]
199
+
200
+ # Promoting project facts to global
201
+ claude-memory promote <fact_id>
202
+ # Or: "Remember that I prefer using Supabase for all my projects"
203
+ ```
204
+
112
205
  ### Scope System
113
206
 
114
207
  Facts are scoped to control where they apply:
@@ -120,6 +213,15 @@ Claude automatically detects scope signals:
120
213
  - "always", "in all projects", "my preference" → global
121
214
  - Project-specific tech choices → project
122
215
 
216
+ You can manually promote facts:
217
+ ```bash
218
+ # From command line
219
+ claude-memory promote <fact_id>
220
+
221
+ # Or naturally in conversation
222
+ "Make that a global preference"
223
+ ```
224
+
123
225
  ## Usage Examples
124
226
 
125
227
  ### Natural Conversation
@@ -159,25 +261,169 @@ Claude: [calls memory.conflicts] "I found 2 conflicts..."
159
261
 
160
262
  ### MCP Tools Not Appearing
161
263
 
162
- 1. Check `claude-memory` is in PATH: `which claude-memory`
163
- 2. Verify plugin is installed: `/plugin` → Installed tab
164
- 3. Check for errors: `/plugin` → Errors tab
165
- 4. Restart Claude Code
264
+ **Problem**: Claude doesn't seem to have access to memory tools
265
+
266
+ **Solutions**:
267
+ 1. Check `claude-memory` is in PATH:
268
+ ```bash
269
+ which claude-memory
270
+ # Should output: /path/to/bin/claude-memory
271
+ ```
272
+
273
+ 2. Verify plugin is installed:
274
+ ```bash
275
+ /plugin
276
+ # Navigate to "Installed" tab, look for "claude-memory"
277
+ ```
278
+
279
+ 3. Check for errors:
280
+ ```bash
281
+ /plugin
282
+ # Navigate to "Errors" tab for any issues
283
+ ```
284
+
285
+ 4. Verify MCP configuration:
286
+ ```bash
287
+ cat .mcp.json
288
+ # Should reference claude-memory serve-mcp
289
+ ```
290
+
291
+ 5. Restart Claude Code:
292
+ ```bash
293
+ # Exit and relaunch
294
+ ```
166
295
 
167
296
  ### Facts Not Being Extracted
168
297
 
169
- 1. Prompt hooks require session to stop (not just pause)
170
- 2. Check if hooks are registered: Run with `claude --debug`
171
- 3. Verify database exists: `claude-memory doctor`
298
+ **Problem**: Claude doesn't remember things from previous conversations
299
+
300
+ **Possible causes**:
301
+
302
+ 1. **Session didn't stop**: Prompt hooks require the session to actually stop (not just pause)
303
+ - Solution: Exit Claude Code properly with `/exit` or Ctrl+D
304
+
305
+ 2. **Hooks not registered**: Check if hooks are configured
306
+ - Solution: Run `claude-memory init` to reconfigure hooks
307
+ - Verify: Check `.claude/settings.json` for hook entries
308
+
309
+ 3. **Database not created**: Missing database files
310
+ - Solution: Run `claude-memory doctor` to diagnose
311
+ - Check: `ls -la .claude/memory.sqlite3`
312
+
313
+ 4. **Extraction failed**: Claude couldn't parse facts from conversation
314
+ - Solution: Be more explicit in your language
315
+ - Instead of: "maybe we could use postgres"
316
+ - Say: "We're using PostgreSQL for the database"
317
+
318
+ ### Project Database Not Created
319
+
320
+ **Problem**: `.claude/memory.sqlite3` doesn't exist after running `claude-memory init`
321
+
322
+ **Solutions**:
323
+
324
+ 1. Check if directory exists:
325
+ ```bash
326
+ ls -la .claude/
327
+ # If missing, create it
328
+ mkdir -p .claude
329
+ ```
330
+
331
+ 2. Check permissions:
332
+ ```bash
333
+ ls -ld .claude
334
+ # Should be writable by your user
335
+ chmod 755 .claude
336
+ ```
337
+
338
+ 3. Verify you're in project root:
339
+ ```bash
340
+ pwd
341
+ # Should be your project directory
342
+ ```
343
+
344
+ 4. Re-run init:
345
+ ```bash
346
+ claude-memory init
347
+ ```
348
+
349
+ ### Facts Going to Wrong Database
350
+
351
+ **Problem**: Project-specific facts stored globally (or vice versa)
352
+
353
+ **Diagnosis**:
354
+ ```bash
355
+ # Check where facts are stored
356
+ claude-memory recall --scope project "database"
357
+ claude-memory recall --scope global "database"
358
+ ```
359
+
360
+ **Solutions**:
361
+
362
+ 1. If facts are in wrong scope, use promote/demote:
363
+ ```bash
364
+ # Move project fact to global
365
+ claude-memory promote <fact_id>
366
+ ```
367
+
368
+ 2. Be explicit in your language:
369
+ - Global: "I **always** prefer X" or "In **all** my projects"
370
+ - Project: "**This app** uses X" or "**We're** using X"
371
+
372
+ ### Verifying Dual-Database Setup
172
373
 
173
- ### Database Issues
374
+ **Check that both databases exist and are working**:
174
375
 
175
376
  ```bash
176
- # Check health
377
+ # 1. Check global database
378
+ ls -lh ~/.claude/memory.sqlite3
379
+ # Should exist with file size > 0
380
+
381
+ # 2. Check project database
382
+ ls -lh .claude/memory.sqlite3
383
+ # Should exist in current project
384
+
385
+ # 3. Run health check
177
386
  claude-memory doctor
178
387
 
179
- # Reinitialize if needed
180
- claude-memory db:init
388
+ # Expected output:
389
+ # ✓ Global database: ~/.claude/memory.sqlite3
390
+ # ✓ Project database: .claude/memory.sqlite3
391
+ # ✓ Both databases healthy
392
+
393
+ # 4. Test recall from both
394
+ claude-memory recall --scope global "preference"
395
+ claude-memory recall --scope project "database"
396
+ ```
397
+
398
+ ### Database Migration Issues
399
+
400
+ **Problem**: Error during schema migration after gem update
401
+
402
+ **What happens automatically**:
403
+ - Schema migrations run on first access after update
404
+ - Migrations are atomic (all-or-nothing)
405
+ - Your data is preserved
406
+
407
+ **If migration fails**:
408
+
409
+ ```bash
410
+ # 1. Check current state
411
+ claude-memory doctor --verbose
412
+
413
+ # 2. Check schema version
414
+ sqlite3 ~/.claude/memory.sqlite3 "PRAGMA user_version;"
415
+ # Should show current schema version
416
+
417
+ # 3. View migration history
418
+ sqlite3 .claude/memory.sqlite3 "SELECT * FROM schema_health;"
419
+
420
+ # 4. If corrupted, try recovery
421
+ claude-memory doctor --recover
422
+
423
+ # 5. Last resort: backup and reinitialize
424
+ mv .claude/memory.sqlite3 .claude/memory.sqlite3.backup
425
+ claude-memory init
426
+ # NOTE: This erases memory for this project
181
427
  ```
182
428
 
183
429
  ## File Structure