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,229 @@
1
+ ---
2
+ name: quality-update
3
+ description: Incrementally implement code quality improvements from docs/quality_review.md with tests and atomic commits. Run after /review-for-quality to apply fixes.
4
+ agent: general-purpose
5
+ allowed-tools: Read, Grep, Edit, Write, Bash
6
+ ---
7
+
8
+ # Quality Update - Incremental Implementation
9
+
10
+ Systematically implement code quality improvements from the review document, making tested, atomic commits for each fix.
11
+
12
+ ## Process Overview
13
+
14
+ 1. **Read the quality review** from `docs/quality_review.md`
15
+ 2. **Prioritize improvements** (start with Quick Wins, then High Priority)
16
+ 3. **Implement fixes incrementally** (one logical change at a time)
17
+ 4. **Run tests after each change** to ensure nothing breaks
18
+ 5. **Make atomic commits** that capture the change and its purpose
19
+ 6. **Update review document** to track progress
20
+
21
+ ## Detailed Steps
22
+
23
+ ### Step 1: Read and Parse Review
24
+
25
+ ```bash
26
+ # Read the current quality review
27
+ Read docs/quality_review.md
28
+ ```
29
+
30
+ Focus on these sections in priority order:
31
+ 1. **Appendix B: Quick Wins** - Start here (fast, low risk)
32
+ 2. **High Priority (This Week)** - Critical improvements
33
+ 3. **Medium Priority (Next Week)** - Important but not urgent
34
+ 4. Skip Low Priority items for now
35
+
36
+ ### Step 2: Select Next Improvement
37
+
38
+ Choose improvements based on:
39
+ - **Risk**: Low risk first (refactoring, style fixes)
40
+ - **Dependencies**: Prerequisites before dependent work
41
+ - **Atomicity**: Each commit should be one logical change
42
+ - **Test coverage**: Ensure tests exist or add them
43
+
44
+ ### Step 3: Implement the Fix
45
+
46
+ For each improvement:
47
+
48
+ 1. **Read affected files** to understand current state
49
+ 2. **Make the change** using Edit or Write
50
+ 3. **Run linter** to ensure style compliance:
51
+ ```bash
52
+ bundle exec rake standard:fix
53
+ ```
54
+ 4. **Run tests** to verify correctness:
55
+ ```bash
56
+ bundle exec rspec
57
+ ```
58
+ 5. **Fix any test failures** before proceeding
59
+
60
+ ### Step 4: Make Atomic Commit
61
+
62
+ **Commit Message Format:**
63
+ ```
64
+ [Quality] Brief description of what was fixed
65
+
66
+ - Specific change made (e.g., "Extract DatabaseCheck from DoctorCommand")
67
+ - Why this improves quality (e.g., "Improves SRP and testability")
68
+ - Expert principle applied (e.g., "Sandi Metz: Single Responsibility")
69
+
70
+ Addresses: docs/quality_review.md [section reference]
71
+ ```
72
+
73
+ **Example Commit:**
74
+ ```bash
75
+ git add -A
76
+ git commit -m "[Quality] Fix public keyword placement in SQLiteStore
77
+
78
+ - Move all public methods to top of class
79
+ - Keep all private methods at bottom
80
+ - Improves code readability and conventional Ruby structure
81
+
82
+ Addresses: docs/quality_review.md (Jeremy Evans - Inconsistent Visibility)
83
+ "
84
+ ```
85
+
86
+ ### Step 5: Document Progress
87
+
88
+ After each successful commit:
89
+ - Note which item was completed
90
+ - Track how many items remain in current priority
91
+ - Identify any blockers encountered
92
+
93
+ ### Step 6: Continue or Report
94
+
95
+ **Continue** to next improvement if:
96
+ - Tests pass ✅
97
+ - Commit successful ✅
98
+ - No blockers encountered ✅
99
+
100
+ **Stop and report** if:
101
+ - Tests fail after multiple fix attempts ❌
102
+ - Change introduces unexpected complexity ❌
103
+ - External dependency issue (gem version, etc.) ❌
104
+
105
+ ## Commit Strategy
106
+
107
+ ### Grouping Guidelines
108
+
109
+ **✅ Good atomic commits:**
110
+ - "Fix public keyword placement in SQLiteStore" (single file, style fix)
111
+ - "Extract DatabaseCheck from DoctorCommand" (single responsibility extraction)
112
+ - "Replace nil returns with NullExplanation in Recall" (consistent pattern)
113
+ - "Consolidate ENV access via Configuration class" (centralize pattern)
114
+
115
+ **❌ Too large (split these):**
116
+ - "Refactor Recall class" (too broad - split into multiple commits)
117
+ - "Fix all Sandi Metz violations" (too many changes at once)
118
+ - "Update database and add tests" (should be separate commits)
119
+
120
+ **❌ Too small (combine these):**
121
+ - "Fix typo in comment" + "Fix another typo" (combine style fixes)
122
+ - "Add space after comma" (use standard:fix instead)
123
+
124
+ ### When to Split Work
125
+
126
+ Split into multiple commits when:
127
+ - Touching multiple files that serve different purposes
128
+ - Making structural change + adding tests (commit structure first, tests second)
129
+ - Fixing multiple unrelated issues from review
130
+
131
+ ## Testing Requirements
132
+
133
+ **Before each commit:**
134
+ ```bash
135
+ # 1. Run linter
136
+ bundle exec rake standard:fix
137
+
138
+ # 2. Run full test suite
139
+ bundle exec rspec
140
+
141
+ # 3. Check for any warnings
142
+ bundle exec rake
143
+ ```
144
+
145
+ **If tests fail:**
146
+ 1. Fix the test failures first
147
+ 2. If fix is complex, it might need its own commit
148
+ 3. Never commit broken tests
149
+
150
+ ## Progress Tracking
151
+
152
+ Keep a running count:
153
+ - ✅ Quick Wins completed: X/Y
154
+ - ✅ High Priority completed: X/Y
155
+ - ⏳ Currently working on: [description]
156
+ - ❌ Blocked: [description + reason]
157
+
158
+ ## Success Criteria
159
+
160
+ The skill completes successfully when:
161
+ - All Quick Wins from Appendix B are implemented ✅
162
+ - Or at least 3-5 High Priority items are completed ✅
163
+ - All tests pass ✅
164
+ - All commits follow the format above ✅
165
+ - Progress report provided ✅
166
+
167
+ ## Important Notes
168
+
169
+ - **Never skip tests** - each change must pass tests before committing
170
+ - **Keep commits focused** - one logical change per commit
171
+ - **Use standard:fix** - auto-fix linting issues before committing
172
+ - **Read before editing** - understand context before making changes
173
+ - **Conservative approach** - if unsure about a change, skip it and report
174
+ - **Track time** - if a fix takes > 30 minutes, it might need planning first
175
+
176
+ ## Example Session
177
+
178
+ ```
179
+ 1. Read docs/quality_review.md
180
+ 2. Start with Quick Win: "Fix public keyword placement in SQLiteStore"
181
+ 3. Read lib/claude_memory/store/sqlite_store.rb
182
+ 4. Move public methods to top, private to bottom
183
+ 5. Run: bundle exec rake standard:fix
184
+ 6. Run: bundle exec rspec
185
+ 7. Commit: "[Quality] Fix public keyword placement in SQLiteStore..."
186
+ 8. Next: "Consolidate ENV access via Configuration"
187
+ 9. [Continue process...]
188
+ 10. Report: "Completed 5/5 Quick Wins, started 2/6 High Priority items"
189
+ ```
190
+
191
+ ## Error Handling
192
+
193
+ If you encounter issues:
194
+ - **Test failures**: Debug and fix, or skip and report
195
+ - **Merge conflicts**: Stop and report (user intervention needed)
196
+ - **Missing dependencies**: Stop and report
197
+ - **Unclear requirements**: Skip item and note in report
198
+
199
+ ## Final Report Format
200
+
201
+ ```
202
+ ## Quality Update Session Report
203
+
204
+ ### Completed ✅
205
+ 1. [Quick Win] Fixed public keyword placement in SQLiteStore (commit: abc123)
206
+ 2. [Quick Win] Consolidated ENV access via Configuration (commit: def456)
207
+ 3. [High Priority] Extracted BatchQueryBuilder from Recall (commit: ghi789)
208
+
209
+ ### In Progress ⏳
210
+ - Working on: Extract DatabaseCheck from DoctorCommand
211
+ - Status: 60% complete, tests passing
212
+
213
+ ### Blocked ❌
214
+ - [High Priority] Split Recall.rb god object
215
+ - Reason: Requires architectural planning, too large for automated fix
216
+ - Recommendation: Run /review-for-quality again after completing other items
217
+
218
+ ### Summary
219
+ - Quick Wins: 5/5 completed ✅
220
+ - High Priority: 2/6 completed
221
+ - Tests: All passing ✅
222
+ - Commits: 5 atomic commits made
223
+ - Time: ~2 hours
224
+
225
+ ### Next Steps
226
+ 1. Continue with remaining High Priority items
227
+ 2. Consider running /review-for-quality again to assess progress
228
+ 3. Plan architectural refactoring for Recall.rb god object
229
+ ```
@@ -0,0 +1,346 @@
1
+ # Implementation Guide for Quality Updates
2
+
3
+ ## Fix Categories & Approach
4
+
5
+ ### Category 1: Style & Convention Fixes (Low Risk)
6
+ **Examples:**
7
+ - Moving public/private method groups
8
+ - Consistent method parentheses
9
+ - Fixing attr_reader placement
10
+ - Consolidating ENV access
11
+
12
+ **Approach:**
13
+ - Safe to do immediately
14
+ - Run standard:fix after changes
15
+ - Verify tests still pass
16
+ - Commit individually
17
+
18
+ ### Category 2: Simple Refactoring (Low-Medium Risk)
19
+ **Examples:**
20
+ - Extract small methods from long methods
21
+ - Rename for clarity
22
+ - Remove duplicate code
23
+ - Add guard clauses
24
+
25
+ **Approach:**
26
+ - Read surrounding code first
27
+ - Make change incrementally
28
+ - Run tests frequently
29
+ - Commit when tests pass
30
+
31
+ ### Category 3: Structural Changes (Medium Risk)
32
+ **Examples:**
33
+ - Extract new classes
34
+ - Introduce value objects
35
+ - Add null objects
36
+ - Create parameter objects
37
+
38
+ **Approach:**
39
+ - Plan the extraction first
40
+ - Create new class/file
41
+ - Move code incrementally
42
+ - Update tests as you go
43
+ - Commit the structure, then usage
44
+
45
+ ### Category 4: Database Changes (Medium-High Risk)
46
+ **Examples:**
47
+ - Migration framework changes
48
+ - Schema modifications
49
+ - DateTime conversions
50
+ - Transaction additions
51
+
52
+ **Approach:**
53
+ - Test with backup database first
54
+ - Ensure backward compatibility
55
+ - Update tests for new behavior
56
+ - May need multiple commits
57
+ - Consider skipping and reporting if complex
58
+
59
+ ### Category 5: Architectural Changes (High Risk)
60
+ **Examples:**
61
+ - Splitting god objects (500+ lines)
62
+ - Changing abstraction boundaries
63
+ - Introducing new patterns
64
+ - Major refactoring
65
+
66
+ **Approach:**
67
+ - **SKIP these** - too large for automated fixes
68
+ - Report that they need manual planning
69
+ - Suggest running /review-for-quality after other fixes
70
+ - These need dedicated planning sessions
71
+
72
+ ## Prioritization Algorithm
73
+
74
+ ### Start with Quick Wins (Appendix B)
75
+ 1. Read all Quick Wins from docs/quality_review.md
76
+ 2. Sort by risk (lowest first)
77
+ 3. Implement in order
78
+ 4. Goal: Complete all Quick Wins in first pass
79
+
80
+ ### Move to High Priority Items
81
+ 1. Read all High Priority items
82
+ 2. Filter out Category 5 (Architectural) - skip these
83
+ 3. Sort remaining by:
84
+ - Risk (low to high)
85
+ - Dependencies (prerequisites first)
86
+ - Impact (high impact first if equal risk)
87
+ 4. Implement sorted list
88
+ 5. Goal: Complete 3-5 items before stopping
89
+
90
+ ### Skip Medium/Low Priority
91
+ - Only tackle these if explicitly requested
92
+ - Focus on Quick Wins + High Priority for automated fixes
93
+
94
+ ## Common Patterns & Solutions
95
+
96
+ ### Pattern: God Object (500+ lines)
97
+ **Assessment:** Category 5 - Architectural
98
+ **Action:** SKIP - Report that this needs manual planning
99
+ **Reason:** Too complex for automated incremental fixes
100
+
101
+ ### Pattern: Duplicate Code (DRY violation)
102
+ **Assessment:** Category 2 - Simple Refactoring
103
+ **Action:** Extract to shared method/class
104
+ **Steps:**
105
+ 1. Identify all occurrences
106
+ 2. Create extracted method/class
107
+ 3. Replace first occurrence
108
+ 4. Test
109
+ 5. Replace remaining occurrences
110
+ 6. Test
111
+ 7. Commit
112
+
113
+ ### Pattern: Nil Checks Everywhere
114
+ **Assessment:** Category 3 - Structural (Null Object)
115
+ **Action:** Introduce NullObject pattern
116
+ **Steps:**
117
+ 1. Create NullObject class (e.g., NullFact)
118
+ 2. Implement required interface
119
+ 3. Replace `return nil` with `return NullFact.new`
120
+ 4. Remove nil checks in callers
121
+ 5. Test incrementally
122
+ 6. Commit structure first, then usage changes
123
+
124
+ ### Pattern: Raw SQL Instead of Sequel
125
+ **Assessment:** Category 2 - Simple Refactoring
126
+ **Action:** Replace with Sequel datasets
127
+ **Steps:**
128
+ 1. Read the SQL query
129
+ 2. Translate to Sequel dataset methods
130
+ 3. Test the query returns same results
131
+ 4. Replace in code
132
+ 5. Test
133
+ 6. Commit
134
+
135
+ ### Pattern: Long Method (> 20 lines)
136
+ **Assessment:** Category 2 - Simple Refactoring
137
+ **Action:** Extract smaller methods
138
+ **Steps:**
139
+ 1. Identify logical sections
140
+ 2. Extract one section to private method
141
+ 3. Name method clearly
142
+ 4. Test
143
+ 5. Commit
144
+ 6. Repeat for remaining sections
145
+
146
+ ### Pattern: Mixed I/O and Logic
147
+ **Assessment:** Category 3-4 - Structural
148
+ **Action:** Extract pure logic to separate method/class
149
+ **Steps:**
150
+ 1. Identify pure logic (no I/O)
151
+ 2. Extract to separate method/class
152
+ 3. Pass data as parameters
153
+ 4. Call from original method
154
+ 5. Test both paths
155
+ 6. Commit
156
+
157
+ ## Decision Tree
158
+
159
+ ```
160
+ Start with next item from review
161
+
162
+ Is it Category 5 (Architectural)?
163
+ ├─ YES → SKIP, report as "needs planning"
164
+ └─ NO → Continue
165
+
166
+ Does it have dependencies?
167
+ ├─ YES → Are dependencies complete?
168
+ │ ├─ NO → SKIP, note dependency
169
+ │ └─ YES → Continue
170
+ └─ NO → Continue
171
+
172
+ Can you understand the code?
173
+ ├─ NO → SKIP, report as "unclear"
174
+ └─ YES → Continue
175
+
176
+ Implement the fix
177
+
178
+ Run tests
179
+
180
+ Tests pass?
181
+ ├─ NO → Can fix in < 15 min?
182
+ │ ├─ YES → Fix and retry
183
+ │ └─ NO → SKIP, report as "complex"
184
+ └─ YES → Continue
185
+
186
+ Commit with quality message
187
+
188
+ Next item
189
+ ```
190
+
191
+ ## Time Budgets
192
+
193
+ Set time limits to avoid getting stuck:
194
+
195
+ - **Quick Win**: Max 15 minutes per item
196
+ - **High Priority**: Max 30 minutes per item
197
+ - **Debug test failure**: Max 15 minutes
198
+ - **Understand code**: Max 10 minutes
199
+
200
+ If time limit exceeded: SKIP and report reason
201
+
202
+ ## Testing Strategy
203
+
204
+ ### Test Frequency
205
+ - After every file edit: Run relevant spec file
206
+ - After every commit: Run full suite
207
+ - If >5 files changed: Run full suite
208
+
209
+ ### Test Commands
210
+ ```bash
211
+ # Single file
212
+ bundle exec rspec spec/claude_memory/store/sqlite_store_spec.rb
213
+
214
+ # Full suite
215
+ bundle exec rspec
216
+
217
+ # With linting
218
+ bundle exec rake
219
+ ```
220
+
221
+ ### Test Failure Response
222
+ 1. Read error message carefully
223
+ 2. Check if your change caused it
224
+ 3. If yes: Fix the change
225
+ 4. If no: Might be pre-existing, note and continue
226
+ 5. If unsure: Revert change and skip item
227
+
228
+ ## Git Best Practices
229
+
230
+ ### Before Committing
231
+ ```bash
232
+ # Check status
233
+ git status
234
+
235
+ # Review changes
236
+ git diff
237
+
238
+ # Stage specific files (not -A if unnecessary)
239
+ git add lib/claude_memory/store/sqlite_store.rb
240
+
241
+ # Or stage all if appropriate
242
+ git add -A
243
+
244
+ # Commit with quality message
245
+ git commit -m "[Quality] ..."
246
+ ```
247
+
248
+ ### Commit Message Template
249
+ ```
250
+ [Quality] <what was fixed in <50 chars>
251
+
252
+ - <specific change>
253
+ - <why this improves quality>
254
+ - <expert principle>
255
+
256
+ Addresses: docs/quality_review.md (<section>)
257
+ ```
258
+
259
+ ### After Committing
260
+ ```bash
261
+ # Verify commit
262
+ git log -1 --oneline
263
+
264
+ # Continue to next item
265
+ ```
266
+
267
+ ## Red Flags - When to Stop
268
+
269
+ Stop implementing and report if you encounter:
270
+ - 🚩 Tests fail after 2 fix attempts
271
+ - 🚩 Change requires modifying >10 files
272
+ - 🚩 Change requires new gem dependencies
273
+ - 🚩 Change touches critical path (authentication, data integrity)
274
+ - 🚩 Unclear what the correct fix should be
275
+ - 🚩 Time budget exceeded
276
+ - 🚩 Git conflicts or merge issues
277
+
278
+ ## Success Metrics
279
+
280
+ Good session results:
281
+ - ✅ 5+ commits made
282
+ - ✅ All tests passing
283
+ - ✅ All Quick Wins completed
284
+ - ✅ 3-5 High Priority items completed
285
+ - ✅ Clear report of progress
286
+ - ✅ No broken code left behind
287
+
288
+ ## Example Full Session
289
+
290
+ ```
291
+ Session Start: 2026-01-26 10:00
292
+
293
+ 1. Read docs/quality_review.md
294
+ - Found 5 Quick Wins
295
+ - Found 6 High Priority items
296
+ - Plan: Complete all Quick Wins first
297
+
298
+ 2. Quick Win #1: Fix public keyword in SQLiteStore
299
+ - Read lib/claude_memory/store/sqlite_store.rb
300
+ - Moved public methods to top (lines 10-350)
301
+ - Moved private methods to bottom (lines 351-542)
302
+ - Run: bundle exec rspec spec/claude_memory/store/sqlite_store_spec.rb ✅
303
+ - Commit: [Quality] Fix public keyword placement... ✅
304
+
305
+ 3. Quick Win #2: Consolidate ENV access
306
+ - Read lib/claude_memory/configuration.rb
307
+ - Added global_db_path and project_db_path methods
308
+ - Updated 3 files to use Configuration
309
+ - Run: bundle exec rspec ✅
310
+ - Commit: [Quality] Consolidate ENV access via Configuration ✅
311
+
312
+ 4. Quick Win #3: Extract BatchQueryBuilder
313
+ - Created lib/claude_memory/recall/batch_query_builder.rb
314
+ - Extracted logic from batch_find_facts and batch_find_receipts
315
+ - Updated recall.rb to use new class
316
+ - Run: bundle exec rspec ✅
317
+ - Commit: [Quality] Extract BatchQueryBuilder from Recall ✅
318
+
319
+ 5. Quick Win #4: Fix boolean logic in option parsing
320
+ - Found in lib/claude_memory/commands/recall_command.rb
321
+ - Simplified double-negative logic
322
+ - Run: bundle exec rspec ✅
323
+ - Commit: [Quality] Simplify boolean logic in option parsing ✅
324
+
325
+ 6. Quick Win #5: Extract Formatter from MCP Tools
326
+ - Created lib/claude_memory/mcp/formatter.rb
327
+ - Moved formatting methods
328
+ - Updated tools.rb to use Formatter
329
+ - Run: bundle exec rspec ✅
330
+ - Commit: [Quality] Extract Formatter from MCP Tools ✅
331
+
332
+ 7. High Priority #1: Extract DatabaseCheck from DoctorCommand
333
+ - Started work...
334
+ - TIME LIMIT EXCEEDED (45 minutes)
335
+ - SKIP - Too complex, needs planning
336
+
337
+ Session End: 2026-01-26 11:30
338
+ Duration: 1.5 hours
339
+
340
+ Results:
341
+ - Quick Wins: 5/5 completed ✅
342
+ - High Priority: 0/6 completed (1 attempted)
343
+ - Commits: 5 atomic commits
344
+ - Tests: All passing ✅
345
+ - Issues: High Priority items need more planning time
346
+ ```