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
@@ -0,0 +1,327 @@
1
+ # Focused Analysis Examples
2
+
3
+ When using the `--focus` flag, narrow the analysis to specific aspects of the repository. This is especially useful for:
4
+ - Very large repositories (>5000 files)
5
+ - Time-constrained analysis
6
+ - Specific adoption goals
7
+ - Deep study of one component
8
+
9
+ ## How Focus Mode Works
10
+
11
+ 1. **Narrows file exploration** to relevant paths only
12
+ 2. **Focuses comparison** on the specific aspect
13
+ 3. **Targets recommendations** to the focused area
14
+ 4. **Reduces context usage** for faster analysis
15
+ 5. **Produces smaller** influence documents
16
+
17
+ ## Example Focus Topics
18
+
19
+ ### Testing Strategy
20
+
21
+ ```bash
22
+ /study-repo /tmp/repo --focus="testing strategy"
23
+ ```
24
+
25
+ **What to analyze**:
26
+ - Test files and directory structure (spec/, test/)
27
+ - Test framework choice (RSpec, Minitest, etc.)
28
+ - CI configuration (.github/workflows/, .circleci/)
29
+ - Test coverage tools and reporting
30
+ - Mocking/stubbing patterns
31
+ - Integration vs unit test balance
32
+ - Test factories and fixtures
33
+ - Performance test practices
34
+
35
+ **Output focus**:
36
+ - How they organize tests
37
+ - What patterns they use for test data
38
+ - How they achieve high coverage
39
+ - CI/CD testing pipeline design
40
+
41
+ ---
42
+
43
+ ### MCP Integration
44
+
45
+ ```bash
46
+ /study-repo /tmp/repo --focus="MCP server implementation"
47
+ ```
48
+
49
+ **What to analyze**:
50
+ - MCP server files (mcp/, server/)
51
+ - Tool definitions and schemas
52
+ - Request/response handling
53
+ - Error handling approach
54
+ - Tool composition and organization
55
+ - JSON-RPC implementation
56
+ - Streaming support
57
+ - Authentication/security
58
+
59
+ **Output focus**:
60
+ - How tools are structured
61
+ - Best practices for tool design
62
+ - Error handling patterns
63
+ - Performance optimizations
64
+
65
+ ---
66
+
67
+ ### Database Schema
68
+
69
+ ```bash
70
+ /study-repo /tmp/repo --focus="database design"
71
+ ```
72
+
73
+ **What to analyze**:
74
+ - Schema files (db/schema.rb, migrations/)
75
+ - Index strategies
76
+ - Query optimization patterns
77
+ - Transaction management
78
+ - Connection pooling
79
+ - Database abstraction layer
80
+ - Migration practices
81
+ - Backup/restore approaches
82
+
83
+ **Output focus**:
84
+ - Schema design decisions
85
+ - Performance optimizations
86
+ - Migration safety patterns
87
+ - Query efficiency techniques
88
+
89
+ ---
90
+
91
+ ### CLI Architecture
92
+
93
+ ```bash
94
+ /study-repo /tmp/repo --focus="CLI design"
95
+ ```
96
+
97
+ **What to analyze**:
98
+ - Entry points (bin/, exe/)
99
+ - Command organization (commands/, lib/commands/)
100
+ - Argument parsing (Thor, OptionParser, etc.)
101
+ - Help text and documentation
102
+ - Error messages and exit codes
103
+ - Subcommand structure
104
+ - Configuration file handling
105
+ - Output formatting
106
+
107
+ **Output focus**:
108
+ - Command organization patterns
109
+ - User experience considerations
110
+ - Error handling best practices
111
+ - Testing CLI commands
112
+
113
+ ---
114
+
115
+ ### Performance Optimizations
116
+
117
+ ```bash
118
+ /study-repo /tmp/repo --focus="performance"
119
+ ```
120
+
121
+ **What to analyze**:
122
+ - Caching strategies (Redis, in-memory)
123
+ - Batch processing patterns
124
+ - Query optimization
125
+ - Resource management
126
+ - Profiling and metrics
127
+ - Lazy loading techniques
128
+ - Memory efficiency
129
+ - Concurrency patterns
130
+
131
+ **Output focus**:
132
+ - What they optimize and how
133
+ - Benchmarking approaches
134
+ - Trade-offs made
135
+ - Performance monitoring
136
+
137
+ ---
138
+
139
+ ### Error Handling
140
+
141
+ ```bash
142
+ /study-repo /tmp/repo --focus="error handling"
143
+ ```
144
+
145
+ **What to analyze**:
146
+ - Exception hierarchy
147
+ - Error class organization
148
+ - Recovery strategies
149
+ - User-facing error messages
150
+ - Logging practices
151
+ - Retry logic
152
+ - Graceful degradation
153
+ - Error reporting/telemetry
154
+
155
+ **Output focus**:
156
+ - Exception design patterns
157
+ - Error communication to users
158
+ - Debugging support
159
+ - Resilience patterns
160
+
161
+ ---
162
+
163
+ ### Configuration Management
164
+
165
+ ```bash
166
+ /study-repo /tmp/repo --focus="configuration"
167
+ ```
168
+
169
+ **What to analyze**:
170
+ - Config file formats (YAML, JSON, TOML)
171
+ - Environment variable handling
172
+ - Default value strategies
173
+ - Configuration validation
174
+ - Secret management
175
+ - Multi-environment support
176
+ - Configuration discovery
177
+ - Override precedence
178
+
179
+ **Output focus**:
180
+ - Configuration architecture
181
+ - Validation and defaults
182
+ - Security practices
183
+ - User experience
184
+
185
+ ---
186
+
187
+ ### Domain Modeling
188
+
189
+ ```bash
190
+ /study-repo /tmp/repo --focus="domain model"
191
+ ```
192
+
193
+ **What to analyze**:
194
+ - Core domain objects
195
+ - Value objects vs entities
196
+ - Aggregate boundaries
197
+ - Repository pattern usage
198
+ - Domain events
199
+ - Business logic organization
200
+ - Validation rules
201
+ - Domain services
202
+
203
+ **Output focus**:
204
+ - How domain is modeled
205
+ - Separation of concerns
206
+ - Business rule implementation
207
+ - Pattern usage
208
+
209
+ ---
210
+
211
+ ### Dependency Injection
212
+
213
+ ```bash
214
+ /study-repo /tmp/repo --focus="dependency injection"
215
+ ```
216
+
217
+ **What to analyze**:
218
+ - DI container (if any)
219
+ - Constructor injection patterns
220
+ - Service locator usage
221
+ - Factory patterns
222
+ - Testability approaches
223
+ - Configuration of dependencies
224
+ - Lifecycle management
225
+ - Interface abstractions
226
+
227
+ **Output focus**:
228
+ - DI strategy and patterns
229
+ - Testing benefits
230
+ - Complexity vs benefits
231
+ - Best practices
232
+
233
+ ---
234
+
235
+ ### API Design
236
+
237
+ ```bash
238
+ /study-repo /tmp/repo --focus="API design"
239
+ ```
240
+
241
+ **What to analyze**:
242
+ - REST/GraphQL/RPC patterns
243
+ - Endpoint organization
244
+ - Request/response formats
245
+ - Versioning strategy
246
+ - Authentication/authorization
247
+ - Rate limiting
248
+ - Documentation (OpenAPI, etc.)
249
+ - Client SDK design
250
+
251
+ **Output focus**:
252
+ - API structure and conventions
253
+ - Versioning approach
254
+ - Documentation practices
255
+ - Client experience
256
+
257
+ ---
258
+
259
+ ## Custom Focus Topics
260
+
261
+ You can specify any aspect you want to focus on:
262
+
263
+ ```bash
264
+ /study-repo /tmp/repo --focus="logging and observability"
265
+ /study-repo /tmp/repo --focus="file system abstraction"
266
+ /study-repo /tmp/repo --focus="plugin architecture"
267
+ /study-repo /tmp/repo --focus="webhook handling"
268
+ ```
269
+
270
+ The skill will adapt the analysis to your specified topic.
271
+
272
+ ## When to Use Focus Mode
273
+
274
+ ### Use Focus When:
275
+ - Repository has >1000 files
276
+ - You have a specific adoption goal
277
+ - You want deep analysis of one aspect
278
+ - Time is limited
279
+ - You're comparing specific features
280
+
281
+ ### Use Full Analysis When:
282
+ - Repository is small (<500 files)
283
+ - You want comprehensive overview
284
+ - Architecture understanding is the goal
285
+ - Time allows for thorough exploration
286
+ - Making major adoption decisions
287
+
288
+ ## Output Differences
289
+
290
+ ### Full Analysis Output:
291
+ ```
292
+ docs/influence/project-name.md
293
+ - All sections populated
294
+ - Broad recommendations
295
+ - Comprehensive comparison
296
+ - 10-20 pages typical
297
+ ```
298
+
299
+ ### Focused Analysis Output:
300
+ ```
301
+ docs/influence/project-name-focus.md
302
+ - Focused sections only
303
+ - Targeted recommendations
304
+ - Specific comparison
305
+ - 3-8 pages typical
306
+ ```
307
+
308
+ ## Combining Focuses
309
+
310
+ For very large projects, run multiple focused analyses:
311
+
312
+ ```bash
313
+ # Study different aspects separately
314
+ /study-repo /tmp/big-repo --focus="MCP implementation"
315
+ /study-repo /tmp/big-repo --focus="testing strategy"
316
+ /study-repo /tmp/big-repo --focus="database design"
317
+ ```
318
+
319
+ Each produces a separate influence document focused on that aspect.
320
+
321
+ ## Tips for Effective Focus
322
+
323
+ 1. **Be specific**: "MCP server" is better than "server stuff"
324
+ 2. **Match their terminology**: Use terms from their docs/code
325
+ 3. **Start broad, then focus**: Run full analysis first to identify interesting areas
326
+ 4. **Combine with grep**: Search for keywords related to your focus
327
+ 5. **Review examples**: Look at their tests for the focused component
data/CHANGELOG.md CHANGED
@@ -4,6 +4,139 @@ All notable changes to this project will be documented in this file.
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ ### Added
8
+
9
+ ### Changed
10
+
11
+ ### Fixed
12
+
13
+ ### Documentation
14
+
15
+ ### Internal
16
+
17
+ ## [0.3.0] - 2026-01-29
18
+
19
+ ### Added
20
+
21
+ **Setup & Initialization**
22
+ - Version markers in CLAUDE.md files for upgrade detection
23
+ - HTML comment format: `<!-- ClaudeMemory vX.Y.Z -->`
24
+ - Enables version comparison and upgrade workflows
25
+ - `memory.check_setup` MCP tool for initialization detection
26
+ - Returns status: healthy, needs_upgrade, partially_initialized, not_initialized
27
+ - Checks databases, CLAUDE.md, version, and hooks configuration
28
+ - Provides actionable recommendations
29
+ - `/setup-memory` skill for installation guidance
30
+ - Comprehensive troubleshooting documentation
31
+ - Step-by-step setup instructions
32
+ - Links to diagnostic tools
33
+
34
+ **Database & Infrastructure**
35
+ - Schema version 6 with new tables:
36
+ - `operation_progress` - Track long-running operation state (index generation, migrations)
37
+ - `schema_health` - Record schema validation results and migration history
38
+ - WAL (Write-Ahead Logging) mode for better concurrency and crash recovery
39
+ - Incremental sync with `source_mtime` tracking to avoid re-processing unchanged files
40
+ - Atomic migrations with per-migration transactions for safety
41
+ - Configuration class for centralized ENV access and testability
42
+
43
+ **Search & Recall**
44
+ - `index` command to generate TF-IDF embeddings for semantic search
45
+ - Index command resumability with checkpoints (recover from interruption)
46
+ - Semantic search capabilities using TF-IDF embeddings
47
+ - Improved full-text search with empty query handling
48
+
49
+ **Session Intelligence**
50
+ - Session metadata extraction:
51
+ - Git branch tracking (`git_branch`)
52
+ - Working directory context (`cwd`)
53
+ - Claude version tracking (`claude_version`)
54
+ - Tool usage patterns (`tool_calls`)
55
+ - Session-aware fact extraction for better provenance
56
+
57
+ **Developer Tools**
58
+ - Enhanced `doctor` command with:
59
+ - Schema validation and integrity checks
60
+ - Migration history verification
61
+ - Recovery suggestions for corrupted databases
62
+ - `stats` command for database statistics
63
+ - Recovery command for stuck long-running operations
64
+ - Transaction wrapper for ingestion atomicity
65
+
66
+ **Quality Improvements**
67
+ - Quality review workflow with Ruby expert perspectives:
68
+ - `/review-for-quality` skill for comprehensive codebase review
69
+ - Expert analysis from Sandi Metz, Jeremy Evans, Kent Beck, Avdi Grimm, Gary Bernhardt
70
+ - Automated quality documentation generation
71
+ - Infrastructure abstractions (FileSystem, InMemoryFileSystem) for testability
72
+ - Domain model enhancements with immutable, self-validating objects
73
+
74
+ **Repository Analysis**
75
+ - `/study-repo` skill for deep analysis of external repositories
76
+ - Systematic exploration through 6 phases (context, architecture, patterns, quality, comparison, adoption)
77
+ - Generates comprehensive influence documents in `docs/influence/`
78
+ - Updates `docs/improvements.md` with prioritized recommendations
79
+ - Focus mode support for targeted analysis (testing, MCP, database, CLI, performance)
80
+ - Integration with `/improve` workflow
81
+
82
+ **Error Handling**
83
+ - Graceful error messages when databases are missing or not accessible
84
+ - Structured error responses with recommendations
85
+ - Directs users to `memory.check_setup` for diagnosis
86
+
87
+ ### Changed
88
+ - **IMPORTANT**: Switched from sqlite3 to extralite as required dependency
89
+ - Extralite provides better concurrency and performance
90
+ - Fixes database lock contention between MCP server and hooks
91
+ - Extralite (~> 2.14) is now the only SQLite adapter
92
+ - Ingestion now tracks file modification time to skip unchanged content
93
+ - Migration process now uses per-migration transactions for atomicity
94
+ - Doctor command now includes schema validation and recovery guidance
95
+ - Index operations can resume from checkpoints after interruption
96
+ - MCP tool descriptions now emphasize memory-first workflow
97
+ - Tool descriptions are more directive ("Check FIRST", "Use BEFORE")
98
+ - Init command now adds version markers to generated CLAUDE.md files
99
+
100
+ ### Fixed
101
+ - **Critical**: Database lock contention between MCP server and hooks
102
+ - Switched to extralite adapter for better concurrent access
103
+ - Improved busy timeout handling
104
+ - Database busy error handling for both SQLite adapters
105
+ - Concurrent access test for extralite adapter
106
+ - Public keyword placement in SQLiteStore (Ruby style conformance)
107
+ - Transaction safety for multi-step database operations
108
+
109
+ ### Documentation
110
+ - Complete getting started guide (GETTING_STARTED.md)
111
+ - Enhanced plugin documentation with setup workflows
112
+ - Comprehensive examples for all features
113
+ - Architecture documentation updates
114
+ - Updated all documentation to reflect current codebase metrics
115
+ - 20 commands (was documented as 16)
116
+ - 18 MCP tools (was documented as 7-8)
117
+ - 985 test examples (was documented as 583/426)
118
+ - Auto-initialization and upgrade design document (docs/auto_init_design.md)
119
+ - Multi-phase upgrade strategy documentation
120
+
121
+ ### Internal
122
+ - Consolidated ENV access via Configuration class
123
+ - Registered new infrastructure modules in main loader
124
+ - Improved test coverage for new features
125
+ - Major code quality improvements with component extraction:
126
+ - `Core::FactQueryBuilder` - Query construction logic from Recall
127
+ - `Core::SetupStatusAnalyzer` - Setup status analysis from MCP Tools
128
+ - `MCP::ToolDefinitions` - Tool definitions separated from server logic
129
+ - `MCP::ResponseFormatter` - Response formatting with multiple query types
130
+ - `Core::TextBuilder` - Text building utilities
131
+ - `Core::ResultSorter` - Result sorting logic
132
+ - `Core::EmbeddingCandidateBuilder` - Embedding candidate construction
133
+ - `Core::FactCollector` - Fact collection logic
134
+ - `Core::ResultBuilder` - Result building logic
135
+ - Init command test suite (19 examples)
136
+ - Setup detection test suite (25 examples)
137
+ - Error handling test suite (4 examples)
138
+ - Comprehensive test coverage (53 new tests)
139
+
7
140
  ## [0.2.0] - 2026-01-22
8
141
 
9
142
  ### Added
data/CLAUDE.md CHANGED
@@ -9,7 +9,7 @@ ClaudeMemory is a Ruby gem that provides long-term, self-managed memory for Clau
9
9
  **Key dependencies:**
10
10
  - Ruby 3.2.0+
11
11
  - Sequel (~> 5.0) for database access
12
- - SQLite3 (~> 2.0) for storage
12
+ - Extralite (~> 2.14) for high-performance SQLite storage
13
13
 
14
14
  ## Development Commands
15
15
 
@@ -85,7 +85,7 @@ Transcripts → Ingest → Index (FTS5)
85
85
  - Each command is a separate class (HelpCommand, DoctorCommand, etc.)
86
86
  - All commands inherit from BaseCommand
87
87
  - Dependency injection for I/O (stdout, stderr, stdin)
88
- - 16 commands total, each focused on single responsibility
88
+ - 20 commands total, each focused on single responsibility
89
89
 
90
90
  - **`Configuration`**: Centralized ENV access (`configuration.rb`)
91
91
  - Single source of truth for paths and environment variables
@@ -236,7 +236,7 @@ Single-value predicates (like "uses_database") supersede old values. Multi-value
236
236
 
237
237
  - `lib/claude_memory.rb`: Main module, requires, database path helpers
238
238
  - `lib/claude_memory/cli.rb`: Thin command router (41 lines)
239
- - `lib/claude_memory/commands/`: Individual command classes (16 commands)
239
+ - `lib/claude_memory/commands/`: Individual command classes (20 commands)
240
240
  - `lib/claude_memory/configuration.rb`: Centralized configuration and ENV access
241
241
  - `lib/claude_memory/domain/`: Domain models (Fact, Entity, Provenance, Conflict)
242
242
  - `lib/claude_memory/core/`: Value objects and null objects
@@ -251,14 +251,15 @@ Single-value predicates (like "uses_database") supersede old values. Multi-value
251
251
 
252
252
  The gem includes an MCP server (`claude-memory serve-mcp`) that exposes memory operations as tools. Configuration should be in `.mcp.json` at project root.
253
253
 
254
- Available MCP tools:
255
- - `memory.recall` - Search for relevant facts (scope filtering supported)
256
- - `memory.explain` - Get detailed fact provenance
257
- - `memory.promote` - Promote project fact to global
258
- - `memory.status` - Health check for both databases
259
- - `memory.changes` - Recent fact updates
260
- - `memory.conflicts` - Open contradictions
261
- - `memory.sweep_now` - Run maintenance
254
+ Available MCP tools (18 total):
255
+ - **Query & Recall**: `memory.recall`, `memory.recall_index`, `memory.recall_details`, `memory.recall_semantic`, `memory.search_concepts`
256
+ - **Provenance**: `memory.explain`
257
+ - **Shortcuts**: `memory.decisions`, `memory.conventions`, `memory.architecture`
258
+ - **Context**: `memory.facts_by_tool`, `memory.facts_by_context`
259
+ - **Management**: `memory.promote`, `memory.store_extraction`
260
+ - **Monitoring**: `memory.status`, `memory.stats`, `memory.changes`, `memory.conflicts`
261
+ - **Maintenance**: `memory.sweep_now`
262
+ - **Setup**: `memory.check_setup`
262
263
 
263
264
  ## Hook Integration
264
265
 
@@ -285,3 +286,121 @@ Key conventions:
285
286
  - Prefer explicit returns only when control flow is complex
286
287
  - Use Sequel's dataset methods (avoid raw SQL where possible)
287
288
  - Keep CLI commands focused; extract complex logic to dedicated classes
289
+
290
+ ## Custom Commands
291
+
292
+ ### `/review-for-quality`
293
+
294
+ Runs a comprehensive quality review of the entire codebase.
295
+
296
+ **What it does:**
297
+ 1. Launches a Plan agent to thoroughly explore the codebase
298
+ 2. Critically reviews code for Ruby best-practices, idiom use, and overall quality
299
+ 3. Analyzes through the perspectives of 5 Ruby experts:
300
+ - **Sandi Metz** - POODR principles, single responsibility, small objects
301
+ - **Jeremy Evans** - Sequel best practices, performance, simplicity
302
+ - **Kent Beck** - Test-driven development, simple design, revealing intent
303
+ - **Avdi Grimm** - Confident Ruby, explicit code, null objects, tell-don't-ask
304
+ - **Gary Bernhardt** - Boundaries, functional core/imperative shell, fast tests
305
+ 4. Updates `docs/quality_review.md` with findings including:
306
+ - Specific file:line references for every issue
307
+ - Which expert's principle is violated
308
+ - Concrete improvement suggestions with code examples
309
+ - Priority levels (Critical 🔴 / High / Medium 🟡 / Low)
310
+ - Metrics comparison showing progress since last review
311
+ - Quick wins that can be done immediately
312
+
313
+ **Usage:**
314
+ ```
315
+ /review-for-quality
316
+ ```
317
+
318
+ **Output:** Updated `docs/quality_review.md` with dated review and actionable refactoring recommendations.
319
+
320
+ ### `/review-commit`
321
+
322
+ Quick quality review of staged changes for pre-commit validation through expert perspectives.
323
+
324
+ **What it does:**
325
+ 1. Reviews only staged Ruby files (fast, < 30 seconds)
326
+ 2. Applies Ruby best practices from 5 experts:
327
+ - **Sandi Metz**: SRP, small methods (<15 lines), DRY, frozen_string_literal
328
+ - **Jeremy Evans**: Sequel datasets over raw SQL, transaction safety, no N+1 queries
329
+ - **Kent Beck**: Simple design, revealing names, Command-Query Separation
330
+ - **Avdi Grimm**: Null objects, explicit returns, Law of Demeter, tell-don't-ask
331
+ - **Gary Bernhardt**: Functional core/imperative shell, immutable values, fast tests
332
+ 3. Returns clear BLOCK / WARNING / PASS verdict with expert attributions
333
+ 4. Designed for headless mode (runs in git pre-commit hook)
334
+
335
+ **Critical checks (BLOCK):**
336
+ - Missing frozen_string_literal, methods >15 lines, classes >200 lines
337
+ - Raw SQL, DB writes without transactions, N+1 queries
338
+ - Nested conditionals >3 levels, Command-Query violations
339
+ - Implicit nil returns, defensive nil checks, bare rescue
340
+ - I/O mixed with logic, mutable value objects, I/O in tests
341
+ - New public methods without tests
342
+
343
+ **Warning checks:**
344
+ - Methods 10-15 lines, classes 100-200 lines, >3 parameters
345
+ - Poor naming, methods doing multiple things
346
+ - Law of Demeter violations, ask-don't-tell patterns
347
+ - Missing value objects, business logic in imperative shell
348
+
349
+ **Usage:**
350
+ ```
351
+ /review-commit
352
+ ```
353
+
354
+ **Output:** Console output with file:line references, expert attributions, and concrete fixes.
355
+
356
+ **Hook Integration:** Automatically runs via lefthook pre-commit hook when Ruby files are staged.
357
+
358
+ ### `/study-repo`
359
+
360
+ Deep analysis of an external repository's architecture, patterns, and design decisions.
361
+
362
+ **What it does:**
363
+ 1. Requires user to manually clone the target repository first
364
+ 2. Performs systematic exploration through 6 phases:
365
+ - Repository Context (metadata, dependencies, purpose)
366
+ - Architecture Mapping (structure, modules, components)
367
+ - Pattern Recognition (design patterns, conventions)
368
+ - Code Quality Assessment (testing, docs, performance)
369
+ - Comparative Analysis (vs ClaudeMemory's approach)
370
+ - Adoption Opportunities (prioritized recommendations)
371
+ 3. Creates comprehensive influence document in `docs/influence/<project>.md`
372
+ 4. Updates `docs/improvements.md` with high-priority recommendations
373
+ 5. Follows QMD analysis format with priority markers
374
+
375
+ **Usage:**
376
+ ```bash
377
+ # Step 1: Clone repository to study
378
+ git clone --depth 1 https://github.com/user/project /tmp/study-repos/project
379
+
380
+ # Step 2: Run analysis
381
+ /study-repo /tmp/study-repos/project
382
+
383
+ # Optional: Focus on specific aspect
384
+ /study-repo /tmp/study-repos/project --focus="MCP implementation"
385
+
386
+ # Step 3: Review generated documents
387
+ # - docs/influence/project.md (detailed analysis)
388
+ # - docs/improvements.md (updated with recommendations)
389
+
390
+ # Step 4: Implement selected improvements
391
+ /improve
392
+ ```
393
+
394
+ **Output:**
395
+ - `docs/influence/<project_name>.md` - Comprehensive analysis with code examples
396
+ - `docs/improvements.md` - Updated with dated section of recommendations
397
+ - Console summary of key findings and priorities
398
+
399
+ **Integration with `/improve`:**
400
+ The recommendations added to `docs/improvements.md` can be implemented using the `/improve` skill, creating a complete workflow:
401
+ ```
402
+ /study-repo → adds recommendations → /improve → implements features
403
+ ```
404
+
405
+ **Focus Mode:**
406
+ Use `--focus` to narrow analysis to specific aspects (testing, MCP, database, CLI, performance). See `.claude/skills/study-repo/focus-examples.md` for examples.