continuous-improvement 1.0.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.
- package/LICENSE +21 -0
- package/README.md +175 -0
- package/agents/observer-loop.sh +282 -0
- package/agents/observer.md +145 -0
- package/agents/start-observer.sh +115 -0
- package/config.json +9 -0
- package/docs/failure-taxonomy.md +153 -0
- package/docs/integration-guide.md +105 -0
- package/docs/philosophy.md +127 -0
- package/docs/superpowers/plans/2026-04-05-mulahazah-implementation.md +1666 -0
- package/docs/superpowers/specs/2026-04-05-mulahazah-instinct-learning-design.md +636 -0
- package/hooks/observe.sh +133 -0
- package/package.json +23 -0
- package/prompts/coding-agent.md +67 -0
- package/prompts/core.md +115 -0
- package/prompts/minimal.md +17 -0
- package/prompts/product-agent.md +59 -0
- package/prompts/research-agent.md +59 -0
- package/scripts/install.js +433 -0
- package/skills/continuous-improvement/SKILL.md +111 -0
|
@@ -0,0 +1,636 @@
|
|
|
1
|
+
# Mulahazah: Instinct-Based Behavioral Learning for continuous-improve
|
|
2
|
+
|
|
3
|
+
**Date:** 2026-04-05
|
|
4
|
+
**Status:** Design approved, pending implementation
|
|
5
|
+
**Author:** Naim Katiman
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Summary
|
|
10
|
+
|
|
11
|
+
Upgrade continuous-improve from a static 6-law discipline framework to a 7-law learning system. The new system (codename **Mulahazah** — Arabic for "observation") adds instinct-based behavioral learning: hooks observe every session, a background agent detects patterns, and learned instincts get stronger or weaker over time based on evidence.
|
|
12
|
+
|
|
13
|
+
This is a Claude Code-only upgrade. Self-contained, no external dependencies.
|
|
14
|
+
|
|
15
|
+
## Decisions
|
|
16
|
+
|
|
17
|
+
| Decision | Choice | Rationale |
|
|
18
|
+
|----------|--------|-----------|
|
|
19
|
+
| Goal | Make continuous-improve learn | Laws should get smarter over time |
|
|
20
|
+
| Relationship to ECC v2 | Fork and embed — no ECC dependency | Self-contained package, own the implementation |
|
|
21
|
+
| Reflection + observation | Both layers — passive hooks + active reflection | Passive catches what you miss; active captures reasoning |
|
|
22
|
+
| Confidence behavior | Graduated — silent / suggest / auto-apply | Balance between learning speed and user control |
|
|
23
|
+
| Scope | Learning + project scoping | Project isolation is hard to retrofit; evolution/export later |
|
|
24
|
+
| Background observer | Included from day one | Continuous pattern detection, not just on-demand |
|
|
25
|
+
| Contribution target | Fork Kiyoraka/Project-AI-MemoryCore | Mulahazah as a new Feature module, complementary to Forge |
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Architecture
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
+--------------------------------------------------+
|
|
33
|
+
| Claude Code Session |
|
|
34
|
+
| |
|
|
35
|
+
| 7 Laws govern behavior |
|
|
36
|
+
| Instincts inform decisions (graduated) |
|
|
37
|
+
+------------------+-------------------------------+
|
|
38
|
+
|
|
|
39
|
+
v
|
|
40
|
+
+--------------------------------------------------+
|
|
41
|
+
| observe.sh (PreToolUse/PostToolUse) |
|
|
42
|
+
| |
|
|
43
|
+
| - Detect project (git remote -> 12-char hash) |
|
|
44
|
+
| - Append 1 JSONL line per event (<50ms) |
|
|
45
|
+
| - Write to projects/<hash>/observations.jsonl |
|
|
46
|
+
| - Global fallback if no git repo |
|
|
47
|
+
+----------+----------------------+----------------+
|
|
48
|
+
| |
|
|
49
|
+
+-----v------+ +-----v-----------------+
|
|
50
|
+
| Background | | On-Demand Analysis |
|
|
51
|
+
| Observer | | |
|
|
52
|
+
| (Haiku) | | - Law 5 Reflection |
|
|
53
|
+
| | | (auto, high conf.) |
|
|
54
|
+
| Every 5min | | - /continuous-improve |
|
|
55
|
+
| when 20+ | | (user-triggered) |
|
|
56
|
+
| obs accum. | | |
|
|
57
|
+
+-----+------+ +-----+-----------------+
|
|
58
|
+
| |
|
|
59
|
+
v v
|
|
60
|
+
+--------------------------------------------------+
|
|
61
|
+
| Instinct Store |
|
|
62
|
+
| |
|
|
63
|
+
| ~/.claude/mulahazah/ |
|
|
64
|
+
| +-- projects.json (registry) |
|
|
65
|
+
| +-- config.json (observer settings) |
|
|
66
|
+
| +-- observer.pid (background PID) |
|
|
67
|
+
| +-- instincts/personal/ (global instincts) |
|
|
68
|
+
| +-- projects/<hash>/ |
|
|
69
|
+
| +-- project.json (metadata) |
|
|
70
|
+
| +-- observations.jsonl (raw events) |
|
|
71
|
+
| +-- observations.archive/ (rotated) |
|
|
72
|
+
| +-- instincts/personal/ (project instincts) |
|
|
73
|
+
| |
|
|
74
|
+
| Confidence -> Behavior: |
|
|
75
|
+
| 0.3-0.5 silent (stored only) |
|
|
76
|
+
| 0.5-0.7 suggested inline |
|
|
77
|
+
| 0.7+ auto-applied |
|
|
78
|
+
+--------------------------------------------------+
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Three analysis channels feed one instinct store:
|
|
82
|
+
1. **Background observer** (Haiku, periodic) — catches patterns continuously
|
|
83
|
+
2. **Law 5 reflection** (automatic) — higher-confidence deliberate insights
|
|
84
|
+
3. **`/continuous-improve`** (user-initiated) — on-demand review and analysis
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## The 7 Laws
|
|
89
|
+
|
|
90
|
+
Laws 1-6 remain unchanged. Law 7 is new:
|
|
91
|
+
|
|
92
|
+
### Law 7: Learn From Every Session
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
Your sessions create knowledge. Capture it.
|
|
96
|
+
|
|
97
|
+
- Patterns you repeat become instincts (automatic via hooks)
|
|
98
|
+
- Rules you discover become instincts (explicit via reflection)
|
|
99
|
+
- Corrections you receive reduce confidence in wrong behaviors
|
|
100
|
+
- Instincts you confirm strengthen over time
|
|
101
|
+
|
|
102
|
+
Low-confidence instincts suggest. High-confidence instincts apply.
|
|
103
|
+
If the user corrects you, the instinct weakens. If they don't, it strengthens.
|
|
104
|
+
|
|
105
|
+
Nothing learned is permanent. Everything decays without reinforcement.
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
**The updated loop:**
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
Research -> Plan -> Execute (one thing) -> Verify -> Reflect -> Learn -> Iterate
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Separation of concerns:**
|
|
115
|
+
- Law 5 (Reflect) = produce the reflection block (what worked, failed, what to do differently)
|
|
116
|
+
- Law 7 (Learn) = persist knowledge as instincts (observe, score, apply, decay)
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## The Instinct Model
|
|
121
|
+
|
|
122
|
+
Each instinct is a single YAML file:
|
|
123
|
+
|
|
124
|
+
```yaml
|
|
125
|
+
---
|
|
126
|
+
id: prefer-grep-before-edit
|
|
127
|
+
trigger: "when modifying code"
|
|
128
|
+
confidence: 0.65
|
|
129
|
+
domain: "workflow"
|
|
130
|
+
source: "session-observation"
|
|
131
|
+
scope: project
|
|
132
|
+
project_id: "a1b2c3d4e5f6"
|
|
133
|
+
project_name: "my-app"
|
|
134
|
+
created: "2026-04-05"
|
|
135
|
+
last_observed: "2026-04-05"
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
# Prefer Grep Before Edit
|
|
139
|
+
|
|
140
|
+
## Action
|
|
141
|
+
Always search with Grep to confirm location before using Edit.
|
|
142
|
+
|
|
143
|
+
## Evidence
|
|
144
|
+
- Observed 6 times in sessions on 2026-04-05
|
|
145
|
+
- User corrected blind edit on 2026-04-03
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Properties
|
|
149
|
+
|
|
150
|
+
| Field | Purpose |
|
|
151
|
+
|-------|---------|
|
|
152
|
+
| `id` | Unique identifier (kebab-case), used for dedup and promotion |
|
|
153
|
+
| `trigger` | When the instinct is relevant — matched against current context |
|
|
154
|
+
| `confidence` | Drives graduated behavior: silent (0.3-0.5), suggest (0.5-0.7), auto-apply (0.7+) |
|
|
155
|
+
| `domain` | One of: `code-style`, `testing`, `git`, `debugging`, `workflow`, `security`, `architecture` |
|
|
156
|
+
| `source` | How created: `session-observation` (passive), `reflection` (Law 5), `imported` |
|
|
157
|
+
| `scope` | `project` (default) or `global` |
|
|
158
|
+
| `project_id` | 12-char hash from git remote URL (project-scoped only) |
|
|
159
|
+
| `project_name` | Human-readable project name (project-scoped only) |
|
|
160
|
+
| `evidence` | What observations back this up — no raw code, only patterns |
|
|
161
|
+
|
|
162
|
+
### Scope Decision
|
|
163
|
+
|
|
164
|
+
| Pattern Type | Scope | Examples |
|
|
165
|
+
|-------------|-------|---------|
|
|
166
|
+
| Language/framework conventions | **project** | "Use React hooks", "Follow Django REST patterns" |
|
|
167
|
+
| File structure preferences | **project** | "Tests in `__tests__`/", "Components in src/components/" |
|
|
168
|
+
| Code style | **project** | "Use functional style", "Prefer dataclasses" |
|
|
169
|
+
| Error handling strategies | **project** | "Use Result type for errors" |
|
|
170
|
+
| Security practices | **global** | "Validate user input", "Sanitize SQL" |
|
|
171
|
+
| General best practices | **global** | "Write tests first", "Always handle errors" |
|
|
172
|
+
| Tool workflow preferences | **global** | "Grep before Edit", "Read before Write" |
|
|
173
|
+
| Git practices | **global** | "Conventional commits", "Small focused commits" |
|
|
174
|
+
|
|
175
|
+
**Default to `project` scope.** Promote later when pattern appears in 2+ projects.
|
|
176
|
+
|
|
177
|
+
### Confidence Scoring
|
|
178
|
+
|
|
179
|
+
**Initial confidence by source:**
|
|
180
|
+
|
|
181
|
+
| Source | Initial Confidence |
|
|
182
|
+
|--------|-------------------|
|
|
183
|
+
| Observer: 1-2 observations | 0.3 |
|
|
184
|
+
| Observer: 3-5 observations | 0.5 |
|
|
185
|
+
| Observer: 6-10 observations | 0.7 |
|
|
186
|
+
| Observer: 11+ observations | 0.85 |
|
|
187
|
+
| Law 5 reflection "Rule to add" | 0.6 (boosted start) |
|
|
188
|
+
|
|
189
|
+
**Confidence adjustments:**
|
|
190
|
+
|
|
191
|
+
| Event | Change |
|
|
192
|
+
|-------|--------|
|
|
193
|
+
| Confirming observation | +0.05 |
|
|
194
|
+
| User explicitly accepts suggestion | +0.15 |
|
|
195
|
+
| User corrects/rejects | -0.1 |
|
|
196
|
+
| Law 5 reflection matches existing instinct | +0.2 (two sources agree) |
|
|
197
|
+
| No observation for 1 week | -0.02 (decay) |
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## Hook System
|
|
202
|
+
|
|
203
|
+
Two hooks in `~/.claude/settings.json`: `PreToolUse` and `PostToolUse`, both calling `observe.sh`.
|
|
204
|
+
|
|
205
|
+
### observe.sh Contract
|
|
206
|
+
|
|
207
|
+
Must complete in <50ms. Never blocks the session.
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
1. Read hook input from stdin (JSON: tool name, input/output, session ID)
|
|
211
|
+
2. Detect project:
|
|
212
|
+
- $CLAUDE_PROJECT_DIR env var (highest priority)
|
|
213
|
+
- git remote get-url origin -> SHA-256 -> first 12 chars
|
|
214
|
+
- git rev-parse --show-toplevel -> SHA-256 -> first 12 chars
|
|
215
|
+
- fallback: global
|
|
216
|
+
3. Append one JSONL line:
|
|
217
|
+
{
|
|
218
|
+
"ts": "2026-04-05T10:30:00Z",
|
|
219
|
+
"event": "tool_start" | "tool_complete",
|
|
220
|
+
"session": "abc123",
|
|
221
|
+
"tool": "Edit",
|
|
222
|
+
"input_summary": "<truncated to 500 chars>",
|
|
223
|
+
"output_summary": "<truncated to 200 chars>",
|
|
224
|
+
"project_id": "a1b2c3d4e5f6",
|
|
225
|
+
"project_name": "my-app"
|
|
226
|
+
}
|
|
227
|
+
4. Exit 0
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
**Rules:**
|
|
231
|
+
- No analysis in the hook — append only
|
|
232
|
+
- Truncate input/output to keep JSONL manageable
|
|
233
|
+
- Never log file contents or secrets — only tool names, patterns, summaries
|
|
234
|
+
- Auto-create project directory on first observation
|
|
235
|
+
- Update `projects.json` registry if new project detected
|
|
236
|
+
- Rotate observations.jsonl to `observations.archive/YYYY-MM-DD.jsonl` when exceeding 10,000 lines
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
## Background Observer Agent
|
|
241
|
+
|
|
242
|
+
A Haiku agent that runs periodically, reads observations, and creates/updates instincts.
|
|
243
|
+
|
|
244
|
+
### Lifecycle
|
|
245
|
+
|
|
246
|
+
```
|
|
247
|
+
start-observer.sh
|
|
248
|
+
+-- observer-loop.sh (runs every 5 min)
|
|
249
|
+
+-- Check: 20+ new observations? If not, skip.
|
|
250
|
+
+-- Launch Haiku agent with observer.md prompt
|
|
251
|
+
| +-- Read observations.jsonl
|
|
252
|
+
| +-- Read existing instincts (project + global)
|
|
253
|
+
| +-- Detect patterns
|
|
254
|
+
| +-- Create/update instinct YAML files
|
|
255
|
+
| +-- Exit
|
|
256
|
+
+-- Sleep 5 min, repeat
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
**Process management:**
|
|
260
|
+
- `start-observer.sh` writes PID to `~/.claude/mulahazah/observer.pid`
|
|
261
|
+
- Session guardian can auto-start if configured (`config.json: observer.enabled: true`)
|
|
262
|
+
- Graceful shutdown on SIGTERM; SIGUSR1 forces immediate analysis
|
|
263
|
+
|
|
264
|
+
### Pattern Detection
|
|
265
|
+
|
|
266
|
+
| Pattern | Signal | Instinct Created |
|
|
267
|
+
|---------|--------|-----------------|
|
|
268
|
+
| User corrections | "No, use X instead" / immediate undo+redo | "When doing X, prefer Y" |
|
|
269
|
+
| Error -> fix sequences | Tool error -> next tools fix it | "When error X occurs, try Y" |
|
|
270
|
+
| Repeated workflows | Same tool sequence 3+ times | "When doing X, follow steps A->B->C" |
|
|
271
|
+
| Tool preferences | Consistently choosing one tool over another | "For task X, use tool Y" |
|
|
272
|
+
| Rejected suggestions | User declines or reverts agent output | "Don't do X in this context" |
|
|
273
|
+
|
|
274
|
+
### Observer Rules
|
|
275
|
+
|
|
276
|
+
- Conservative — only create instincts for 3+ observations
|
|
277
|
+
- Merge similar — update existing instinct rather than duplicate
|
|
278
|
+
- Default to project scope
|
|
279
|
+
- Never include raw code in instincts, only patterns
|
|
280
|
+
- Read existing instincts before creating — avoid contradictions
|
|
281
|
+
|
|
282
|
+
### Configuration
|
|
283
|
+
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"version": "2.0",
|
|
287
|
+
"observer": {
|
|
288
|
+
"enabled": true,
|
|
289
|
+
"run_interval_minutes": 5,
|
|
290
|
+
"min_observations_to_analyze": 20,
|
|
291
|
+
"model": "haiku"
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Law 5 Integration
|
|
299
|
+
|
|
300
|
+
Law 5 still produces the reflection block. Now it also feeds the instinct system.
|
|
301
|
+
|
|
302
|
+
**Enhanced output:**
|
|
303
|
+
|
|
304
|
+
```
|
|
305
|
+
## Reflection
|
|
306
|
+
- What worked: In-memory cache was simpler than Redis
|
|
307
|
+
- What failed: nothing
|
|
308
|
+
- What I'd do differently: nothing
|
|
309
|
+
- Rule to add: For single-server, start with in-memory cache
|
|
310
|
+
|
|
311
|
+
## Instinct created
|
|
312
|
+
- id: prefer-in-memory-cache-single-server
|
|
313
|
+
- confidence: 0.6 (reflection source -> boosted start)
|
|
314
|
+
- scope: global (general best practice)
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Behavior:**
|
|
318
|
+
1. Law 5 reflection fires as before (after non-trivial tasks)
|
|
319
|
+
2. The "Rule to add" field is parsed into an instinct
|
|
320
|
+
3. Instinct gets 0.6 starting confidence (higher than observer's 0.3)
|
|
321
|
+
4. If a matching instinct already exists from passive observation, confidence gets +0.2 boost
|
|
322
|
+
5. Instinct is written to the appropriate scope
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
## The /continuous-improve Command
|
|
327
|
+
|
|
328
|
+
One master command with subcommands:
|
|
329
|
+
|
|
330
|
+
```
|
|
331
|
+
/continuous-improve # Full dashboard (default)
|
|
332
|
+
/continuous-improve status # Instinct overview
|
|
333
|
+
/continuous-improve projects # List all projects
|
|
334
|
+
/continuous-improve analyze # Force analysis now
|
|
335
|
+
/continuous-improve reflect # Trigger Law 5 + Law 7 manually
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Default behavior (no args)
|
|
339
|
+
|
|
340
|
+
Runs the full loop — ideal after shipping long code:
|
|
341
|
+
|
|
342
|
+
1. **REFLECT** — Auto-generate Law 5 reflection for this session
|
|
343
|
+
2. **ANALYZE** — Process pending observations, create/update instincts
|
|
344
|
+
3. **STATUS** — Show current instincts dashboard
|
|
345
|
+
4. **SUGGEST** — Surface actionable insights
|
|
346
|
+
|
|
347
|
+
### Example output
|
|
348
|
+
|
|
349
|
+
```
|
|
350
|
+
=== continuous-improve ===
|
|
351
|
+
|
|
352
|
+
## Reflection (Law 5)
|
|
353
|
+
- What worked: TDD approach caught the auth bug early
|
|
354
|
+
- What failed: First attempt at caching hit rate limit
|
|
355
|
+
- What I'd do differently: Check API rate limits before choosing polling interval
|
|
356
|
+
- Rule to add: Always check rate limits before setting intervals
|
|
357
|
+
|
|
358
|
+
## Session Learning (Law 7)
|
|
359
|
+
NEW prefer-tdd-for-auth testing 0.6 (from reflection)
|
|
360
|
+
NEW check-rate-limits-first workflow 0.6 (from reflection)
|
|
361
|
+
^ grep-before-edit workflow 0.65 -> 0.70 (3 more observations)
|
|
362
|
+
^ use-react-hooks code-style 0.60 -> 0.65 (2 more observations)
|
|
363
|
+
|
|
364
|
+
## Dashboard
|
|
365
|
+
PROJECT: my-app (a1b2c3d4e5f6) -- 6 instincts
|
|
366
|
+
* [0.85] prefer-functional-style code-style auto-apply
|
|
367
|
+
* [0.70] grep-before-edit workflow auto-apply
|
|
368
|
+
* [0.65] use-react-hooks code-style suggest
|
|
369
|
+
* [0.60] prefer-tdd-for-auth testing suggest
|
|
370
|
+
* [0.60] check-rate-limits-first workflow suggest
|
|
371
|
+
o [0.35] prefer-barrel-exports architecture silent
|
|
372
|
+
|
|
373
|
+
GLOBAL -- 3 instincts
|
|
374
|
+
* [0.90] validate-user-input security auto-apply
|
|
375
|
+
o [0.45] conventional-commits git silent
|
|
376
|
+
o [0.40] small-focused-commits git silent
|
|
377
|
+
|
|
378
|
+
## Suggestions
|
|
379
|
+
-> grep-before-edit crossed 0.7 -- now auto-applying
|
|
380
|
+
-> 47 unprocessed observations pending
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## File Structure
|
|
386
|
+
|
|
387
|
+
### What ships in the continuous-improve package
|
|
388
|
+
|
|
389
|
+
```
|
|
390
|
+
continuous-improve/
|
|
391
|
+
+-- skills/
|
|
392
|
+
| +-- continuous-improve/
|
|
393
|
+
| +-- SKILL.md # The 7 Laws + instinct behavior
|
|
394
|
+
+-- hooks/
|
|
395
|
+
| +-- observe.sh # PreToolUse/PostToolUse hook
|
|
396
|
+
+-- agents/
|
|
397
|
+
| +-- observer.md # Background Haiku observer prompt
|
|
398
|
+
| +-- observer-loop.sh # Periodic runner
|
|
399
|
+
| +-- start-observer.sh # Launcher
|
|
400
|
+
+-- scripts/
|
|
401
|
+
| +-- install.js # npx continuous-improve install
|
|
402
|
+
+-- config.json # Default observer config
|
|
403
|
+
+-- package.json
|
|
404
|
+
+-- README.md
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
### Runtime directory
|
|
408
|
+
|
|
409
|
+
```
|
|
410
|
+
~/.claude/mulahazah/
|
|
411
|
+
+-- projects.json # Registry: hash -> name/path/remote
|
|
412
|
+
+-- config.json # Observer settings
|
|
413
|
+
+-- observer.pid # Background observer PID
|
|
414
|
+
+-- observations.jsonl # Global fallback observations
|
|
415
|
+
+-- instincts/
|
|
416
|
+
| +-- personal/ # Global auto-learned instincts
|
|
417
|
+
+-- projects/
|
|
418
|
+
+-- a1b2c3d4e5f6/
|
|
419
|
+
| +-- project.json # Project metadata
|
|
420
|
+
| +-- observations.jsonl # Project observations
|
|
421
|
+
| +-- observations.archive/ # Rotated logs
|
|
422
|
+
| +-- instincts/
|
|
423
|
+
| +-- personal/ # Project-scoped instincts
|
|
424
|
+
+-- f6e5d4c3b2a1/
|
|
425
|
+
+-- ...
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### Install flow (npx continuous-improve install --claude)
|
|
429
|
+
|
|
430
|
+
1. Copy SKILL.md content -> append to CLAUDE.md
|
|
431
|
+
2. Copy observe.sh -> skill-relative path
|
|
432
|
+
3. Patch ~/.claude/settings.json with PreToolUse/PostToolUse hooks
|
|
433
|
+
4. Create ~/.claude/mulahazah/ directory structure
|
|
434
|
+
5. Copy observer agent files
|
|
435
|
+
6. Write default config.json (observer.enabled: true)
|
|
436
|
+
7. Print instructions for starting the background observer
|
|
437
|
+
8. Print: "Installed. Run /continuous-improve after your next session."
|
|
438
|
+
|
|
439
|
+
**Note:** The background observer is enabled in config but does not auto-start as a daemon. Users start it manually with `start-observer.sh` or it can be added to shell profile for auto-start. Hooks capture observations regardless of whether the observer is running — analysis just happens on-demand via `/continuous-improve` until the observer is started.
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
## MemoryCore Contribution Strategy
|
|
444
|
+
|
|
445
|
+
After updating continuous-improve, fork Kiyoraka/Project-AI-MemoryCore and add Mulahazah as a new Feature module.
|
|
446
|
+
|
|
447
|
+
### Why Mulahazah is a new feature, not a Forge duplicate
|
|
448
|
+
|
|
449
|
+
| Forge | Mulahazah |
|
|
450
|
+
|-------|-----------|
|
|
451
|
+
| Deliberate — detects when AI/user notices a pattern | Automatic — hooks observe every session |
|
|
452
|
+
| Requires 3+ occurrences + human approval | Creates tentative instincts from first sighting |
|
|
453
|
+
| Creates full skills | Creates atomic instincts (smaller than skills) |
|
|
454
|
+
| No confidence scoring | 0.3-0.9 confidence with decay |
|
|
455
|
+
| No project isolation | Project-scoped by default |
|
|
456
|
+
| No background processing | Background Haiku observer |
|
|
457
|
+
|
|
458
|
+
**Forge = conscious skill creation.** "I noticed I keep doing X, let me make a skill."
|
|
459
|
+
**Mulahazah = unconscious behavioral adaptation.** The system quietly learns preferences.
|
|
460
|
+
|
|
461
|
+
### Synergy with existing MemoryCore features
|
|
462
|
+
|
|
463
|
+
| Feature | Integration |
|
|
464
|
+
|---------|------------|
|
|
465
|
+
| Forge | High-confidence instinct clusters become Forge proposals |
|
|
466
|
+
| Observation System | Mulahazah feeds instincts into Refine quality checks |
|
|
467
|
+
| Decision Log | Instinct promotions logged as decisions |
|
|
468
|
+
| Save Diary | Session learning summary in diary entries |
|
|
469
|
+
| Memory Consolidation | Instincts as a new memory type |
|
|
470
|
+
|
|
471
|
+
### MemoryCore file structure
|
|
472
|
+
|
|
473
|
+
```
|
|
474
|
+
Feature/Mulahazah-System/
|
|
475
|
+
+-- README.md
|
|
476
|
+
+-- SKILL.md
|
|
477
|
+
+-- install-mulahazah.md
|
|
478
|
+
+-- hooks/
|
|
479
|
+
| +-- observe.sh
|
|
480
|
+
+-- agents/
|
|
481
|
+
| +-- observer.md
|
|
482
|
+
| +-- observer-loop.sh
|
|
483
|
+
| +-- start-observer.sh
|
|
484
|
+
+-- config.json
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
---
|
|
488
|
+
|
|
489
|
+
## Competitive Landscape: Observation & Learning Systems
|
|
490
|
+
|
|
491
|
+
### Comparison Matrix
|
|
492
|
+
|
|
493
|
+
| System | Observation Method | Learning Unit | Confidence | Project Scope | Background | Daily Workflow Fit |
|
|
494
|
+
|--------|-------------------|---------------|------------|---------------|------------|-------------------|
|
|
495
|
+
| **Mulahazah** | PreToolUse/PostToolUse hooks (100%) | Atomic instinct (YAML) | 0.3-0.9, decays | Yes (hash-based) | Haiku observer | One command: `/continuous-improve` |
|
|
496
|
+
| **MemoryCore Forge** | Skill-triggered (~50-80%) | Full skill (SKILL.md) | None | No | No | Manual: "create skill", "forge this" |
|
|
497
|
+
| **MemoryCore Observation** | On-demand (user triggers) | Report (no persistence) | None | No | No | Manual: "survey", "investigate" |
|
|
498
|
+
| **Homunculus v2** | PreToolUse/PostToolUse hooks (100%) | Instinct (YAML) | 0.3-0.9 weighted | Yes (v2.1) | Haiku observer | CLI commands |
|
|
499
|
+
| **ECC continuous-learning v1** | Stop hook (session end) | Skill file | None | No | No | `/learn` at milestones |
|
|
500
|
+
| **ECC continuous-learning v2** | Hooks (100%) | Instinct (YAML) | 0.3-0.9 | Yes (v2.1) | Haiku observer | 6 commands |
|
|
501
|
+
| **Claude Code auto-memory** | Built-in (always on) | Memory file (.md) | None | Yes (project dirs) | No | Automatic, no command |
|
|
502
|
+
| **Cursor .cursorrules** | None (static) | Rule file | None | Yes (per-project) | No | Manual edits |
|
|
503
|
+
| **Windsurf Memories** | Session end | Memory entry | None | No | No | Automatic |
|
|
504
|
+
| **Aider conventions** | None (static) | .aider.conf.yml | None | Yes (per-project) | No | Manual edits |
|
|
505
|
+
|
|
506
|
+
### What Mulahazah does differently
|
|
507
|
+
|
|
508
|
+
1. **100% observation + graduated behavior** — no other system combines deterministic hook capture with confidence-based application. Claude's auto-memory captures facts but doesn't score or decay them. Forge requires human recognition of patterns.
|
|
509
|
+
|
|
510
|
+
2. **Three learning channels** — passive (hooks), active (reflection), manual (command). Other systems have one channel at most.
|
|
511
|
+
|
|
512
|
+
3. **Confidence decay** — instincts weaken without reinforcement. No other system models forgetting. This prevents stale rules from accumulating indefinitely.
|
|
513
|
+
|
|
514
|
+
4. **One master command** — `/continuous-improve` replaces the fragmented command surfaces of ECC v2 (6 commands) and MemoryCore (per-feature commands).
|
|
515
|
+
|
|
516
|
+
### Gaps to close (future roadmap)
|
|
517
|
+
|
|
518
|
+
| Gap | What's Missing | When |
|
|
519
|
+
|-----|---------------|------|
|
|
520
|
+
| Forge integration | Instinct clusters don't auto-propose Forge skills yet | v2.1 |
|
|
521
|
+
| Team sharing | No export/import of instinct libraries across developers | v2.2 |
|
|
522
|
+
| IDE integration | No VS Code/JetBrains panel showing active instincts | v2.3 |
|
|
523
|
+
| Cross-agent | Only Claude Code — no Codex, Cursor, Aider support | v3.0 |
|
|
524
|
+
| Analytics | No dashboard showing learning velocity, instinct health over time | v2.2 |
|
|
525
|
+
|
|
526
|
+
---
|
|
527
|
+
|
|
528
|
+
## Daily Workflow Integration
|
|
529
|
+
|
|
530
|
+
The system must disappear into the developer's natural rhythm — not add ceremony.
|
|
531
|
+
|
|
532
|
+
### The Natural Developer Loop
|
|
533
|
+
|
|
534
|
+
```
|
|
535
|
+
Morning: open project, start coding
|
|
536
|
+
|
|
|
537
|
+
| Hooks silently capture every tool call (zero friction)
|
|
538
|
+
| High-confidence instincts auto-apply (invisible)
|
|
539
|
+
| Medium instincts suggest inline (gentle nudges)
|
|
540
|
+
|
|
|
541
|
+
Midday: finish a feature or fix
|
|
542
|
+
|
|
|
543
|
+
| Law 5 reflection fires automatically
|
|
544
|
+
| "Rule to add" becomes an instinct (0.6 confidence)
|
|
545
|
+
| Background observer processes pending observations
|
|
546
|
+
|
|
|
547
|
+
End of session: run /continuous-improve
|
|
548
|
+
|
|
|
549
|
+
| See what the system learned today
|
|
550
|
+
| Review new instincts, confirm or correct
|
|
551
|
+
| Dashboard shows confidence changes
|
|
552
|
+
|
|
|
553
|
+
Next day: instincts from yesterday inform today's work
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
### Zero-Friction Integration Points
|
|
557
|
+
|
|
558
|
+
| Developer Action | Mulahazah Behavior | Friction |
|
|
559
|
+
|-----------------|-------------------|---------|
|
|
560
|
+
| Write code normally | Hooks capture tool usage silently | **Zero** — hooks run in <50ms |
|
|
561
|
+
| Make a mistake, get corrected | Instinct created: "don't do X" | **Zero** — automatic |
|
|
562
|
+
| Repeat a workflow 3+ times | Instinct created: "when X, do Y->Z" | **Zero** — observer detects |
|
|
563
|
+
| Finish a task | Law 5 reflection, instinct from "Rule to add" | **Low** — reflection is already part of the 6 Laws |
|
|
564
|
+
| End a long session | Run `/continuous-improve` | **Low** — one command, full picture |
|
|
565
|
+
| Start a new project | Project auto-detected from git remote | **Zero** — hash-based isolation |
|
|
566
|
+
| Switch between projects | Correct instincts load per-project | **Zero** — automatic scoping |
|
|
567
|
+
|
|
568
|
+
### Anti-Patterns to Avoid
|
|
569
|
+
|
|
570
|
+
| Anti-Pattern | Why It Kills Adoption | How Mulahazah Avoids It |
|
|
571
|
+
|-------------|----------------------|------------------------|
|
|
572
|
+
| Requiring manual tagging | Developers won't tag consistently | Hooks auto-capture, observer auto-analyzes |
|
|
573
|
+
| Too many commands to remember | Cognitive overhead | One command: `/continuous-improve` |
|
|
574
|
+
| Noisy suggestions | Alert fatigue | Graduated: silent until 0.5, suggest until 0.7, then auto-apply |
|
|
575
|
+
| Learning that never applies | "What's the point?" | Auto-apply at 0.7+ means instincts visibly change behavior |
|
|
576
|
+
| No way to correct bad learning | Frustration, distrust | User corrections reduce confidence by -0.1; decay removes stale instincts |
|
|
577
|
+
| Cross-project contamination | React rules breaking Python | Project-scoped by default |
|
|
578
|
+
| Slow hooks | Breaks flow | <50ms, append-only, no analysis in hook |
|
|
579
|
+
|
|
580
|
+
### Adoption Ladder
|
|
581
|
+
|
|
582
|
+
```
|
|
583
|
+
Level 0: Install
|
|
584
|
+
- npx continuous-improve install --claude
|
|
585
|
+
- Hooks start capturing immediately
|
|
586
|
+
- No behavior change yet — just observation
|
|
587
|
+
|
|
588
|
+
Level 1: Passive Learning (Week 1)
|
|
589
|
+
- Observer creates first instincts
|
|
590
|
+
- All below 0.5 — silent, no suggestions
|
|
591
|
+
- Developer doesn't notice anything different
|
|
592
|
+
- /continuous-improve shows what's been learned
|
|
593
|
+
|
|
594
|
+
Level 2: Suggestions (Week 2-3)
|
|
595
|
+
- Instincts cross 0.5 from repeated observations
|
|
596
|
+
- Inline suggestions appear: "Consider using Grep before Edit"
|
|
597
|
+
- Developer confirms or corrects — confidence adjusts
|
|
598
|
+
|
|
599
|
+
Level 3: Auto-Apply (Month 1+)
|
|
600
|
+
- Strongest instincts cross 0.7
|
|
601
|
+
- Agent behavior subtly adapts without prompting
|
|
602
|
+
- "It just knows how I work now"
|
|
603
|
+
- /continuous-improve shows a mature instinct library
|
|
604
|
+
|
|
605
|
+
Level 4: Cross-Project (Month 2+)
|
|
606
|
+
- Same patterns seen in multiple projects
|
|
607
|
+
- Global instincts emerge naturally
|
|
608
|
+
- New projects start with a baseline of learned behavior
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
### Measuring Success
|
|
612
|
+
|
|
613
|
+
How a developer knows Mulahazah is working:
|
|
614
|
+
|
|
615
|
+
| Signal | Metric |
|
|
616
|
+
|--------|--------|
|
|
617
|
+
| Fewer corrections needed | User correction events decrease over time |
|
|
618
|
+
| Faster sessions | Time-to-completion for similar tasks decreases |
|
|
619
|
+
| Instinct library grows | `/continuous-improve` shows 10+ instincts after 2 weeks |
|
|
620
|
+
| Auto-apply instincts exist | At least 3 instincts at 0.7+ confidence after 1 month |
|
|
621
|
+
| Cross-project learning | Global instincts emerge from 2+ projects |
|
|
622
|
+
|
|
623
|
+
---
|
|
624
|
+
|
|
625
|
+
## Out of Scope (v1)
|
|
626
|
+
|
|
627
|
+
- Instinct evolution into full skills/commands/agents (future v2.1)
|
|
628
|
+
- Export/import instincts (future v2.2)
|
|
629
|
+
- `/promote` command for project->global promotion (future v2.1)
|
|
630
|
+
- `/evolve` command for clustering instincts (future v2.1)
|
|
631
|
+
- Integration with OpenClaw memory-core-plus (different platform)
|
|
632
|
+
- Inherited instinct libraries (future v2.2)
|
|
633
|
+
- Cross-machine instinct sync (future v2.2)
|
|
634
|
+
- IDE panel for instinct visibility (future v2.3)
|
|
635
|
+
- Analytics dashboard (future v2.2)
|
|
636
|
+
- Multi-agent support beyond Claude Code (future v3.0)
|