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,199 @@
1
+ ---
2
+ name: review-commit
3
+ description: Quick quality review of staged changes for pre-commit validation. Checks Ruby best practices and flags critical issues.
4
+ agent: general-purpose
5
+ allowed-tools: Bash, Read, Grep, Glob
6
+ ---
7
+
8
+ # Pre-Commit Quality Review
9
+
10
+ Review the staged changes in this commit for code quality issues before committing.
11
+
12
+ ## Objectives
13
+
14
+ - **Fast**: Complete review in < 30 seconds
15
+ - **Focused**: Only review staged Ruby files
16
+ - **Actionable**: Clear pass/fail with specific fixes
17
+ - **Non-interactive**: Works in headless mode
18
+ - **Expert-driven**: Apply Ruby best practices from industry experts
19
+
20
+ ## Expert Panel
21
+
22
+ Apply principles from these Ruby/software design experts:
23
+
24
+ 1. **Sandi Metz** - POODR principles, small methods/classes, SRP, DRY
25
+ 2. **Jeremy Evans** - Sequel best practices, transaction safety, performance
26
+ 3. **Kent Beck** - Simple design, revealing names, Command-Query Separation
27
+ 4. **Avdi Grimm** - Confident Ruby, null objects, tell-don't-ask, meaningful returns
28
+ 5. **Gary Bernhardt** - Functional core/imperative shell, fast tests, immutability
29
+
30
+ ## Review Process
31
+
32
+ 1. **Get staged files:**
33
+ ```bash
34
+ git diff --cached --name-only --diff-filter=ACM | grep '\.rb$'
35
+ ```
36
+
37
+ 2. **For each staged Ruby file, check:**
38
+ - Get the full diff: `git diff --cached <file>`
39
+ - Review only the added/modified lines (lines starting with `+`)
40
+
41
+ 3. **Look for critical issues (❌ BLOCK):**
42
+
43
+ **Sandi Metz violations:**
44
+ - ❌ Missing `frozen_string_literal: true` in new files
45
+ - ❌ Methods > 15 lines (SRP violation, too complex)
46
+ - ❌ Classes > 200 lines (god object)
47
+ - ❌ Obvious code duplication (DRY violation)
48
+
49
+ **Jeremy Evans (Sequel) violations:**
50
+ - ❌ Raw SQL strings instead of Sequel dataset methods
51
+ - ❌ Database writes without transaction wrapper
52
+ - ❌ N+1 queries (multiple queries in loops)
53
+
54
+ **Kent Beck violations:**
55
+ - ❌ Overly complex solutions (nested conditionals > 3 levels)
56
+ - ❌ Command-Query Separation violation (methods that both mutate and return calculated values)
57
+
58
+ **Avdi Grimm violations:**
59
+ - ❌ Defensive nil checks everywhere (should use null objects)
60
+ - ❌ Implicit nil returns in public methods
61
+ - ❌ Bare `raise` or `rescue` without exception class
62
+
63
+ **Gary Bernhardt violations:**
64
+ - ❌ I/O operations mixed with business logic (should separate)
65
+ - ❌ Mutable state in value objects
66
+ - ❌ Database/file I/O in unit tests (makes tests slow)
67
+
68
+ **Testing:**
69
+ - ❌ New public methods without corresponding tests
70
+
71
+ 4. **Look for medium issues (⚠️ WARNING):**
72
+
73
+ **Sandi Metz:**
74
+ - ⚠️ Methods 10-15 lines (consider extracting)
75
+ - ⚠️ Classes 100-200 lines (approaching god object)
76
+ - ⚠️ Method parameters > 3 (use parameter object)
77
+
78
+ **Jeremy Evans:**
79
+ - ⚠️ Missing indexes on foreign keys
80
+ - ⚠️ Connection not properly managed
81
+
82
+ **Kent Beck:**
83
+ - ⚠️ Poor naming (unclear variable/method names, abbreviations)
84
+ - ⚠️ Methods doing multiple things (and/or in method name)
85
+
86
+ **Avdi Grimm:**
87
+ - ⚠️ Law of Demeter violations (chained method calls like `foo.bar.baz.qux`)
88
+ - ⚠️ Asking instead of telling (lots of getters instead of sending commands)
89
+
90
+ **Gary Bernhardt:**
91
+ - ⚠️ Business logic scattered in imperative shell
92
+ - ⚠️ Missing value objects (primitives passed around)
93
+
94
+ **General:**
95
+ - ⚠️ Missing documentation for public APIs
96
+ - ⚠️ Tight coupling between modules
97
+
98
+ ## Output Format
99
+
100
+ Provide a clear summary with expert attributions:
101
+
102
+ ```
103
+ # Pre-Commit Quality Review
104
+
105
+ ## Files Reviewed
106
+ - file1.rb (23 lines changed)
107
+ - file2.rb (8 lines changed)
108
+
109
+ ## Status: ❌ BLOCK / ✅ PASS / ⚠️ WARNING
110
+
111
+ ### Critical Issues ❌ (must fix before commit)
112
+
113
+ **Sandi Metz violations:**
114
+ - file1.rb:1 - Missing frozen_string_literal: true
115
+ - file2.rb:15-38 - Method too long (24 lines, max 15)
116
+
117
+ **Jeremy Evans violations:**
118
+ - file1.rb:42 - Raw SQL string instead of Sequel dataset method
119
+ - file1.rb:50 - Database write without transaction wrapper
120
+
121
+ **Avdi Grimm violations:**
122
+ - file2.rb:10 - Implicit nil return in public method
123
+
124
+ ### Medium Issues ⚠️ (consider fixing)
125
+
126
+ **Sandi Metz:**
127
+ - file3.rb:20-32 - Method is 13 lines (consider extracting)
128
+
129
+ **Kent Beck:**
130
+ - file2.rb:5 - Variable name `x` is unclear (revealing intent)
131
+
132
+ **Avdi Grimm:**
133
+ - file3.rb:45 - Law of Demeter violation: user.account.settings.theme
134
+
135
+ ### Recommendations
136
+
137
+ 1. Add `frozen_string_literal: true` to file1.rb (Sandi Metz)
138
+ 2. Convert raw SQL at file1.rb:42 to Sequel dataset (Jeremy Evans)
139
+ 3. Wrap database write at file1.rb:50 in transaction (Jeremy Evans)
140
+ 4. Extract file2.rb:15-38 into smaller methods (Sandi Metz)
141
+ 5. Return explicit value instead of nil at file2.rb:10 (Avdi Grimm)
142
+ 6. Rename `x` to describe what it contains (Kent Beck)
143
+ 7. Extract file3.rb:20-32 for better readability (Sandi Metz)
144
+ 8. Use tell-don't-ask at file3.rb:45 (Avdi Grimm)
145
+
146
+ ## Suggested Actions
147
+
148
+ [If BLOCK] Run: git reset HEAD <files> && fix issues && git add <files>
149
+ [If WARNING] Consider fixing before commit or create a follow-up task
150
+ [If PASS] Commit looks good! 🚀
151
+ ```
152
+
153
+ ## Exit Behavior
154
+
155
+ - **Return clear judgment**: BLOCK, WARNING, or PASS
156
+ - **Be specific**: Include file:line references for all issues
157
+ - **Be helpful**: Suggest concrete fixes
158
+ - **Be fast**: Don't over-analyze, focus on obvious problems
159
+
160
+ ## Quick Reference Checklist
161
+
162
+ For each added/modified line in the diff, scan for:
163
+
164
+ **Sandi Metz:**
165
+ - [ ] frozen_string_literal at top?
166
+ - [ ] Methods < 15 lines? (warn at 10+)
167
+ - [ ] Classes < 200 lines? (warn at 100+)
168
+ - [ ] No duplicate code?
169
+ - [ ] Parameters <= 3? (warn if more)
170
+
171
+ **Jeremy Evans:**
172
+ - [ ] Sequel datasets not raw SQL?
173
+ - [ ] DB writes in transactions?
174
+ - [ ] No N+1 queries in loops?
175
+
176
+ **Kent Beck:**
177
+ - [ ] Nested conditionals <= 3?
178
+ - [ ] Clear, revealing names?
179
+ - [ ] Methods do one thing?
180
+ - [ ] Command-Query Separation?
181
+
182
+ **Avdi Grimm:**
183
+ - [ ] Null objects instead of nil checks?
184
+ - [ ] Explicit returns (not implicit nil)?
185
+ - [ ] Specific exception classes?
186
+ - [ ] Law of Demeter (max 2 dots)?
187
+
188
+ **Gary Bernhardt:**
189
+ - [ ] Business logic separate from I/O?
190
+ - [ ] Value objects immutable?
191
+ - [ ] Tests avoid I/O?
192
+
193
+ ## Success Criteria
194
+
195
+ The review is complete when:
196
+ - All staged Ruby files have been checked
197
+ - Clear BLOCK/WARNING/PASS verdict is given
198
+ - All critical issues have file:line references with expert attribution
199
+ - Concrete fix suggestions are provided with expert rationale
@@ -0,0 +1,154 @@
1
+ ---
2
+ name: review-for-quality
3
+ description: Comprehensive code quality review through expert perspectives (Sandi Metz, Jeremy Evans, Kent Beck, Avdi Grimm, Gary Bernhardt). Updates docs/quality_review.md with findings.
4
+ agent: Plan
5
+ allowed-tools: Read, Grep, Glob
6
+ ---
7
+
8
+ # Code Quality Review
9
+
10
+ Critically review this Ruby codebase for best-practices, idiom use, and overall quality through the eyes of Ruby experts.
11
+
12
+ ## Expert Perspectives
13
+
14
+ Analyze the codebase through these 5 perspectives:
15
+
16
+ 1. **Sandi Metz** (POODR principles)
17
+ - Single Responsibility Principle
18
+ - Small, focused methods (< 5 lines ideal)
19
+ - Classes with single purpose
20
+ - DRY principle
21
+ - Clear dependencies
22
+ - High test coverage
23
+
24
+ 2. **Jeremy Evans** (Sequel maintainer)
25
+ - Proper Sequel usage patterns (datasets over raw SQL)
26
+ - Database performance optimization
27
+ - Schema design best practices
28
+ - Connection management
29
+ - Transaction safety
30
+ - Sequel plugins and extensions
31
+
32
+ 3. **Kent Beck** (TDD, Simple Design)
33
+ - Test-first design
34
+ - Simple solutions over complex ones
35
+ - Revealing intent through naming
36
+ - Clear boundaries between components
37
+ - Testability without mocks
38
+ - Command-Query Separation
39
+
40
+ 4. **Avdi Grimm** (Confident Ruby)
41
+ - Confident code (no defensive nil checks everywhere)
42
+ - Tell, don't ask principle
43
+ - Null object pattern
44
+ - Meaningful return values (not nil)
45
+ - Duck typing
46
+ - Result objects over exceptions
47
+
48
+ 5. **Gary Bernhardt** (Boundaries, Fast Tests)
49
+ - Functional core, imperative shell
50
+ - Fast unit tests (no I/O in logic)
51
+ - Clear boundaries between layers
52
+ - Separation of I/O and pure logic
53
+ - Value objects
54
+ - Immutable data structures
55
+
56
+ ## Review Process
57
+
58
+ 1. **Explore the codebase systematically:**
59
+ - `lib/claude_memory/` (all subdirectories)
60
+ - Identify the largest files (> 500 lines)
61
+ - Find code duplication patterns
62
+ - Check architecture and design patterns
63
+
64
+ 2. **Document EVERY issue found** with:
65
+ - Priority: 🔴 Critical / High / 🟡 Medium / Low
66
+ - Specific file:line references
67
+ - Which expert's principle is violated
68
+ - Concrete improvement suggestions with code examples
69
+ - Estimated effort to fix
70
+
71
+ 3. **Track progress:**
72
+ - Compare with previous review date
73
+ - Show metrics (lines of code, god objects, etc.)
74
+ - Identify what's been fixed since last review
75
+ - Highlight new issues that have emerged
76
+
77
+ 4. **Provide actionable recommendations:**
78
+ - High priority items (this week)
79
+ - Medium priority items (next week)
80
+ - Low priority items (later)
81
+ - Quick wins (can do today)
82
+
83
+ ## Output Format
84
+
85
+ Update `docs/quality_review.md` with:
86
+
87
+ ### Structure:
88
+ ```
89
+ # Code Quality Review - Ruby Best Practices
90
+
91
+ **Review Date:** [YYYY-MM-DD]
92
+ **Previous Review:** [YYYY-MM-DD]
93
+
94
+ ## Executive Summary
95
+ [Progress since last review + new critical issues]
96
+
97
+ ## 1. Sandi Metz Perspective
98
+ ### What's Been Fixed ✅
99
+ ### Critical Issues 🔴
100
+ ### Medium Issues 🟡
101
+
102
+ ## 2. Jeremy Evans Perspective
103
+ [Same structure]
104
+
105
+ ## 3. Kent Beck Perspective
106
+ [Same structure]
107
+
108
+ ## 4. Avdi Grimm Perspective
109
+ [Same structure]
110
+
111
+ ## 5. Gary Bernhardt Perspective
112
+ [Same structure]
113
+
114
+ ## 6. General Ruby Idioms
115
+ [Style and convention issues]
116
+
117
+ ## 7. Positive Observations
118
+ [What's working well]
119
+
120
+ ## 8. Priority Refactoring Recommendations
121
+ ### High Priority (This Week)
122
+ ### Medium Priority (Next Week)
123
+ ### Low Priority (Later)
124
+
125
+ ## 9. Conclusion
126
+ [Summary + risk assessment + next steps]
127
+
128
+ ## Appendix A: Metrics Comparison
129
+ [Table showing progress]
130
+
131
+ ## Appendix B: Quick Wins
132
+ [Things that can be done immediately]
133
+
134
+ ## Appendix C: File Size Report
135
+ [Largest files identified]
136
+ ```
137
+
138
+ ## Important Notes
139
+
140
+ - Be thorough and critical - find real issues to improve
141
+ - Every issue needs a specific file:line reference
142
+ - Provide code examples for suggested fixes
143
+ - Don't just praise - identify concrete problems
144
+ - Compare metrics with previous review date
145
+ - Estimate effort for each recommendation (days)
146
+
147
+ ## Success Criteria
148
+
149
+ The review is complete when:
150
+ - `docs/quality_review.md` is updated with dated findings
151
+ - Every issue has file:line references
152
+ - Concrete code examples are provided
153
+ - Metrics comparison table is included
154
+ - Actionable priorities are listed with time estimates
@@ -0,0 +1,79 @@
1
+ # Expert Review Checklists
2
+
3
+ ## Sandi Metz (POODR) Checklist
4
+
5
+ - [ ] Classes under 100 lines
6
+ - [ ] Methods under 5 lines
7
+ - [ ] Method parameters limited (< 4)
8
+ - [ ] Single Responsibility Principle followed
9
+ - [ ] No god objects (classes > 500 lines)
10
+ - [ ] DRY violations eliminated
11
+ - [ ] Dependencies injected, not created
12
+ - [ ] Public interface is minimal
13
+ - [ ] Private methods grouped at bottom
14
+ - [ ] attr_reader used appropriately
15
+
16
+ ## Jeremy Evans (Sequel) Checklist
17
+
18
+ - [ ] Using Sequel datasets, not raw SQL
19
+ - [ ] Transactions wrap multi-step operations
20
+ - [ ] DateTime columns instead of String timestamps
21
+ - [ ] Sequel migrations used (not manual)
22
+ - [ ] Connection pooling configured
23
+ - [ ] Sequel plugins utilized (timestamps, validation_helpers)
24
+ - [ ] No N+1 query patterns
25
+ - [ ] Batch queries used for multiple records
26
+ - [ ] Foreign keys defined properly
27
+ - [ ] Indexes created for common queries
28
+
29
+ ## Kent Beck (TDD, Simple Design) Checklist
30
+
31
+ - [ ] Dependencies can be injected for testing
32
+ - [ ] No side effects in constructors
33
+ - [ ] Methods reveal intent through naming
34
+ - [ ] Complex boolean logic is extracted and named
35
+ - [ ] No large case statements (use polymorphism)
36
+ - [ ] Tests exist for failure modes
37
+ - [ ] Command-Query Separation followed
38
+ - [ ] Simple solutions chosen over complex ones
39
+ - [ ] Test coverage for edge cases
40
+ - [ ] Clear boundaries between components
41
+
42
+ ## Avdi Grimm (Confident Ruby) Checklist
43
+
44
+ - [ ] Null Object pattern used instead of nil checks
45
+ - [ ] Consistent return values (not mixed types)
46
+ - [ ] Result objects for success/failure
47
+ - [ ] Tell, don't ask (no ask-then-do patterns)
48
+ - [ ] Early returns minimized (use guard clauses)
49
+ - [ ] Primitive obsession eliminated (use value objects)
50
+ - [ ] Domain objects instead of hashes
51
+ - [ ] Duck typing enables polymorphism
52
+ - [ ] Meaningful default values
53
+ - [ ] Confident code (no defensive programming everywhere)
54
+
55
+ ## Gary Bernhardt (Boundaries) Checklist
56
+
57
+ - [ ] I/O separated from business logic
58
+ - [ ] Core logic is pure (no side effects)
59
+ - [ ] Fast unit tests (no database/filesystem)
60
+ - [ ] Value objects used for domain concepts
61
+ - [ ] State passed as parameters, not stored in instance variables
62
+ - [ ] Clear layer boundaries (presentation → application → domain → infrastructure)
63
+ - [ ] File I/O abstracted (dependency injection)
64
+ - [ ] Database access abstracted (repository pattern)
65
+ - [ ] Functional core, imperative shell pattern
66
+ - [ ] Immutable data structures preferred
67
+
68
+ ## General Ruby Idioms Checklist
69
+
70
+ - [ ] frozen_string_literal: true in all files
71
+ - [ ] Consistent method parentheses style
72
+ - [ ] Keyword arguments for methods with > 2 params
73
+ - [ ] Parameter objects for long parameter lists
74
+ - [ ] Consistent hash access (symbols vs strings)
75
+ - [ ] Specific exception rescues (not bare rescue)
76
+ - [ ] ENV access centralized
77
+ - [ ] Boolean traps eliminated (use explicit values)
78
+ - [ ] Ruby 3 features used where appropriate
79
+ - [ ] Standard Ruby linter passing
@@ -0,0 +1,168 @@
1
+ ---
2
+ name: setup-memory
3
+ description: Automatically install, configure, or upgrade ClaudeMemory
4
+ ---
5
+
6
+ # ClaudeMemory Setup & Upgrade
7
+
8
+ This skill automatically sets up or upgrades ClaudeMemory based on your current state.
9
+
10
+ ## What This Skill Does
11
+
12
+ When invoked, it will:
13
+
14
+ 1. **Check current installation status**
15
+ - Detect installed gem version
16
+ - Check database existence and health
17
+ - Verify configuration files
18
+
19
+ 2. **Determine required action**
20
+ - Fresh install (no databases)
21
+ - Upgrade (version mismatch)
22
+ - Verification (already up to date)
23
+
24
+ 3. **Execute setup/upgrade automatically**
25
+ - Run `claude-memory doctor` for health check
26
+ - Add version markers to `.claude/CLAUDE.md`
27
+ - Run smoke tests
28
+ - Report results
29
+
30
+ 4. **Provide next steps**
31
+ - Restart recommendations if needed
32
+ - Usage guidance
33
+
34
+ ## Instructions
35
+
36
+ **IMPORTANT**: This skill should take action, not just provide instructions.
37
+
38
+ ### Step 1: Check Installation Status
39
+
40
+ ```bash
41
+ claude-memory --version
42
+ claude-memory doctor
43
+ ```
44
+
45
+ Analyze the output to determine current state.
46
+
47
+ ### Step 2: Determine Action Required
48
+
49
+ - **Not installed**: Databases don't exist
50
+ - Action: Run `claude-memory init` (ask user for --global flag preference)
51
+ - **Installed but outdated**: Version marker missing or old
52
+ - Action: Run upgrade steps (doctor, add version marker, verify)
53
+ - **Up to date**: All healthy
54
+ - Action: Report status only
55
+
56
+ ### Step 3: Execute Required Actions
57
+
58
+ **For Fresh Install:**
59
+ 1. Ask user: "Install globally only or with project memory? [project/global]"
60
+ 2. Run `claude-memory init` (with --global if selected)
61
+ 3. Run `claude-memory doctor` to verify
62
+ 4. Add version marker to `.claude/CLAUDE.md`
63
+ 5. Report success
64
+
65
+ **For Upgrade:**
66
+ 1. Run `claude-memory doctor` (auto-runs migrations)
67
+ 2. Add/update version marker in `.claude/CLAUDE.md`
68
+ 3. Run `claude-memory stats` for smoke test
69
+ 4. Report upgrade complete
70
+
71
+ **For Verification:**
72
+ 1. Run `claude-memory doctor`
73
+ 2. Confirm version in `.claude/CLAUDE.md`
74
+ 3. Report all healthy
75
+
76
+ ### Step 4: Report Results
77
+
78
+ Provide a clear summary:
79
+ - ✅ What was done
80
+ - 📊 Current status (facts, schema version, etc.)
81
+ - 🔄 Next steps (if any)
82
+
83
+ ## After Setup/Upgrade
84
+
85
+ Always remind the user:
86
+
87
+ 1. **Restart Claude Code** if configuration files were modified
88
+ 2. **Test memory tools**: Try `memory.status` or `memory.recall "<topic>"`
89
+ 3. **Use memory-first workflow**: Check memory before reading files
90
+
91
+ ## What Gets Created
92
+
93
+ ### Databases
94
+ - `~/.claude/memory.sqlite3` - Global knowledge (preferences, conventions)
95
+ - `.claude/memory.sqlite3` - Project-specific facts and decisions
96
+
97
+ ### Configuration Files
98
+ - `.claude/CLAUDE.md` - Workflow instructions for memory-first usage
99
+ - `.claude/settings.json` - Hooks for automatic ingestion
100
+ - `.claude.json` - MCP server configuration
101
+ - `.claude/rules/claude_memory.generated.md` - Published snapshot
102
+
103
+ ### Hooks
104
+ ClaudeMemory automatically ingests transcripts on these events:
105
+ - SessionStart - Catch up on previous session
106
+ - Stop - After each response
107
+ - SessionEnd - Final ingestion before closing
108
+ - PreCompact - Before context summarization
109
+
110
+ ## Common Scenarios
111
+
112
+ ### Fresh Install
113
+ User has never installed ClaudeMemory:
114
+ 1. Ask installation preference (project vs global)
115
+ 2. Run `claude-memory init` with appropriate flags
116
+ 3. Verify with `doctor`
117
+ 4. Add version marker
118
+ 5. Report success and next steps
119
+
120
+ ### Upgrade After Gem Update
121
+ User updated gem but not configuration:
122
+ 1. Run `claude-memory doctor` (auto-migrates schema)
123
+ 2. Update version marker in `.claude/CLAUDE.md`
124
+ 3. Verify with smoke tests
125
+ 4. Report upgrade complete
126
+
127
+ ### Verification
128
+ User wants to check current status:
129
+ 1. Run `claude-memory doctor`
130
+ 2. Run `claude-memory stats`
131
+ 3. Check version marker in `.claude/CLAUDE.md`
132
+ 4. Report all findings
133
+
134
+ ## Troubleshooting Guide
135
+
136
+ If automatic setup fails, provide these solutions:
137
+
138
+ **Permission Denied**
139
+ ```bash
140
+ chmod +x $(which claude-memory)
141
+ ```
142
+
143
+ **Database Locked**
144
+ - Close other Claude sessions
145
+ - Run `claude-memory recover`
146
+
147
+ **Missing Ruby**
148
+ ClaudeMemory requires Ruby 3.2.0+. Check with:
149
+ ```bash
150
+ ruby --version
151
+ ```
152
+
153
+ **Hooks Not Working**
154
+ Re-run setup:
155
+ ```bash
156
+ claude-memory init
157
+ ```
158
+
159
+ ## Memory-First Workflow
160
+
161
+ After successful setup, always remind users:
162
+
163
+ 1. **Query memory first**: `memory.recall "<topic>"`
164
+ 2. **Use semantic shortcuts**: `memory.decisions`, `memory.conventions`, `memory.architecture`
165
+ 3. **Check before exploring**: Memory saves time vs reading files
166
+ 4. **Combine knowledge**: Merge recalled facts with code exploration
167
+
168
+ This workflow leverages distilled knowledge from previous sessions.