create-merlin-brain 3.11.0 → 3.12.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/bin/install.cjs +146 -22
- package/bin/runtime-adapters.cjs +396 -0
- package/dist/server/cost/tracker.d.ts +38 -2
- package/dist/server/cost/tracker.d.ts.map +1 -1
- package/dist/server/cost/tracker.js +87 -15
- package/dist/server/cost/tracker.js.map +1 -1
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +74 -30
- package/dist/server/server.js.map +1 -1
- package/dist/server/tools/adaptive.js +1 -1
- package/dist/server/tools/adaptive.js.map +1 -1
- package/dist/server/tools/agents-index.js +3 -3
- package/dist/server/tools/agents-index.js.map +1 -1
- package/dist/server/tools/agents.js +5 -5
- package/dist/server/tools/agents.js.map +1 -1
- package/dist/server/tools/behaviors.js +4 -4
- package/dist/server/tools/behaviors.js.map +1 -1
- package/dist/server/tools/context.js +7 -7
- package/dist/server/tools/context.js.map +1 -1
- package/dist/server/tools/cost.d.ts +3 -1
- package/dist/server/tools/cost.d.ts.map +1 -1
- package/dist/server/tools/cost.js +66 -13
- package/dist/server/tools/cost.js.map +1 -1
- package/dist/server/tools/discoveries.js +6 -6
- package/dist/server/tools/discoveries.js.map +1 -1
- package/dist/server/tools/index.d.ts +4 -0
- package/dist/server/tools/index.d.ts.map +1 -1
- package/dist/server/tools/index.js +4 -0
- package/dist/server/tools/index.js.map +1 -1
- package/dist/server/tools/learning.d.ts +12 -0
- package/dist/server/tools/learning.d.ts.map +1 -0
- package/dist/server/tools/learning.js +269 -0
- package/dist/server/tools/learning.js.map +1 -0
- package/dist/server/tools/project.js +7 -7
- package/dist/server/tools/project.js.map +1 -1
- package/dist/server/tools/promote.d.ts +11 -0
- package/dist/server/tools/promote.d.ts.map +1 -0
- package/dist/server/tools/promote.js +315 -0
- package/dist/server/tools/promote.js.map +1 -0
- package/dist/server/tools/route.d.ts.map +1 -1
- package/dist/server/tools/route.js +65 -24
- package/dist/server/tools/route.js.map +1 -1
- package/dist/server/tools/session-restore.d.ts +18 -0
- package/dist/server/tools/session-restore.d.ts.map +1 -0
- package/dist/server/tools/session-restore.js +154 -0
- package/dist/server/tools/session-restore.js.map +1 -0
- package/dist/server/tools/session-search.d.ts +16 -0
- package/dist/server/tools/session-search.d.ts.map +1 -0
- package/dist/server/tools/session-search.js +240 -0
- package/dist/server/tools/session-search.js.map +1 -0
- package/dist/server/tools/sights-index.js +2 -2
- package/dist/server/tools/sights-index.js.map +1 -1
- package/dist/server/tools/smart-route.d.ts.map +1 -1
- package/dist/server/tools/smart-route.js +4 -5
- package/dist/server/tools/smart-route.js.map +1 -1
- package/dist/server/tools/verification.js +1 -1
- package/dist/server/tools/verification.js.map +1 -1
- package/files/agents/code-organization-supervisor.md +1 -0
- package/files/agents/context-guardian.md +1 -0
- package/files/agents/docs-keeper.md +1 -0
- package/files/agents/dry-refactor.md +1 -0
- package/files/agents/elite-code-refactorer.md +1 -0
- package/files/agents/hardening-guard.md +1 -0
- package/files/agents/implementation-dev.md +1 -0
- package/files/agents/merlin-access-control-reviewer.md +248 -0
- package/files/agents/merlin-codebase-mapper.md +1 -1
- package/files/agents/merlin-dependency-auditor.md +216 -0
- package/files/agents/merlin-executor.md +1 -0
- package/files/agents/merlin-input-validator.md +247 -0
- package/files/agents/merlin-reviewer.md +1 -0
- package/files/agents/merlin-sast-reviewer.md +182 -0
- package/files/agents/merlin-secret-scanner.md +203 -0
- package/files/agents/tests-qa.md +1 -0
- package/files/commands/merlin/execute-phase.md +94 -197
- package/files/commands/merlin/execute-plan.md +116 -180
- package/files/commands/merlin/health.md +385 -0
- package/files/commands/merlin/loop-recipes.md +93 -36
- package/files/commands/merlin/optimize-prompts.md +158 -0
- package/files/commands/merlin/profiles.md +215 -0
- package/files/commands/merlin/promote.md +176 -0
- package/files/commands/merlin/quick.md +229 -0
- package/files/commands/merlin/resume-work.md +27 -1
- package/files/commands/merlin/route.md +43 -1
- package/files/commands/merlin/sandbox.md +359 -0
- package/files/commands/merlin/usage.md +55 -0
- package/files/docker/Dockerfile.merlin +20 -0
- package/files/docker/docker-compose.merlin.yml +23 -0
- package/files/hook-templates/auto-commit.sh +64 -0
- package/files/hook-templates/auto-format.sh +95 -0
- package/files/hook-templates/auto-test.sh +117 -0
- package/files/hook-templates/branch-protection.sh +72 -0
- package/files/hook-templates/changelog-reminder.sh +76 -0
- package/files/hook-templates/complexity-check.sh +112 -0
- package/files/hook-templates/import-audit.sh +83 -0
- package/files/hook-templates/license-header.sh +84 -0
- package/files/hook-templates/pr-description.sh +100 -0
- package/files/hook-templates/todo-tracker.sh +80 -0
- package/files/hooks/check-file-size.sh +17 -4
- package/files/hooks/config-change.sh +44 -16
- package/files/hooks/instructions-loaded.sh +22 -5
- package/files/hooks/notify-desktop.sh +157 -0
- package/files/hooks/notify-webhook.sh +141 -0
- package/files/hooks/pre-edit-sights-check.sh +76 -9
- package/files/hooks/security-scanner.sh +153 -0
- package/files/hooks/session-end-memory-sync.sh +97 -0
- package/files/hooks/session-end.sh +274 -1
- package/files/hooks/session-start.sh +19 -6
- package/files/hooks/smart-approve.sh +270 -0
- package/files/hooks/teammate-idle-verify.sh +87 -12
- package/files/hooks/worktree-create.sh +20 -3
- package/files/hooks/worktree-remove.sh +21 -3
- package/files/merlin/references/plan-format.md +37 -9
- package/files/merlin/sandbox.json +9 -0
- package/files/merlin/security.json +11 -0
- package/files/merlin/templates/ci/docs-update.yml +81 -0
- package/files/merlin/templates/ci/pr-review.yml +50 -0
- package/files/merlin/templates/ci/security-audit.yml +74 -0
- package/files/merlin/templates/config.json +9 -1
- package/files/rules/api-rules.md +30 -0
- package/files/rules/frontend-rules.md +25 -0
- package/files/rules/hooks-rules.md +36 -0
- package/files/rules/mcp-rules.md +30 -0
- package/files/rules/worker-rules.md +29 -0
- package/package.json +1 -1
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: merlin:health
|
|
3
|
+
description: Validate .planning/ directory integrity and auto-repair common issues
|
|
4
|
+
argument-hint: "[--repair]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Bash
|
|
8
|
+
- Glob
|
|
9
|
+
- Grep
|
|
10
|
+
- Write
|
|
11
|
+
- AskUserQuestion
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
<objective>
|
|
15
|
+
Check the health of the .planning/ directory and Merlin configuration.
|
|
16
|
+
|
|
17
|
+
Runs 10 checks covering file existence, structural validity, phase consistency,
|
|
18
|
+
hook registration, and MCP config. Reports issues with clear status indicators.
|
|
19
|
+
|
|
20
|
+
With `--repair`: auto-fixes issues that are safe to fix without user input.
|
|
21
|
+
Confirms before destructive actions (e.g., removing orphaned directories).
|
|
22
|
+
</objective>
|
|
23
|
+
|
|
24
|
+
<context>
|
|
25
|
+
Arguments: $ARGUMENTS
|
|
26
|
+
|
|
27
|
+
Check for repair mode:
|
|
28
|
+
- `--repair` flag present → run in repair mode after checks complete
|
|
29
|
+
- No flag → read-only check, suggest repair at end
|
|
30
|
+
</context>
|
|
31
|
+
|
|
32
|
+
<process>
|
|
33
|
+
|
|
34
|
+
## Step 1: Parse Mode
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
REPAIR_MODE=false
|
|
38
|
+
echo "$ARGUMENTS" | grep -q "\-\-repair" && REPAIR_MODE=true
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Step 2: Run All Checks
|
|
42
|
+
|
|
43
|
+
Run each check and collect results. Track pass/fail/warn counts.
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
### Check 1: PROJECT.md exists and has required sections
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
cat .planning/PROJECT.md 2>/dev/null
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- PASS: file exists AND contains "Vision" AND "Stack" AND "Architecture"
|
|
54
|
+
- WARN: file exists but missing one or more sections
|
|
55
|
+
- FAIL: file does not exist
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
### Check 2: ROADMAP.md exists and phases are numbered correctly
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
cat .planning/ROADMAP.md 2>/dev/null
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
- PASS: file exists AND phases are numbered sequentially (01, 02, 03... or 1, 2, 3...)
|
|
66
|
+
- WARN: file exists but numbering has gaps (01, 02, 04 — missing 03)
|
|
67
|
+
- FAIL: file does not exist
|
|
68
|
+
|
|
69
|
+
Extract:
|
|
70
|
+
- Total phase count
|
|
71
|
+
- Milestone count (count `## Milestone` or `## v` headers)
|
|
72
|
+
- List of phase numbers for cross-referencing in later checks
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### Check 3: REQUIREMENTS.md exists (if roadmap references requirements)
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Check if roadmap mentions requirements
|
|
80
|
+
grep -i "requirement\|REQUIREMENTS" .planning/ROADMAP.md 2>/dev/null | head -3
|
|
81
|
+
|
|
82
|
+
cat .planning/REQUIREMENTS.md 2>/dev/null | head -5
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
- PASS: REQUIREMENTS.md exists
|
|
86
|
+
- WARN: roadmap mentions requirements but REQUIREMENTS.md is missing
|
|
87
|
+
- SKIP: roadmap does not reference requirements — note "not required"
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
### Check 4: STATE.md exists and has valid current position
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
cat .planning/STATE.md 2>/dev/null
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Check:
|
|
98
|
+
- File exists
|
|
99
|
+
- Contains a current phase reference
|
|
100
|
+
- Note the last-modified date:
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Get last modified timestamp
|
|
104
|
+
stat -f "%Sm" -t "%Y-%m-%d" .planning/STATE.md 2>/dev/null || \
|
|
105
|
+
stat --format="%y" .planning/STATE.md 2>/dev/null | cut -d' ' -f1
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
- PASS: exists and was modified within the last 7 days
|
|
109
|
+
- WARN: exists but last modified more than 7 days ago (note how many days)
|
|
110
|
+
- FAIL: file does not exist
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
### Check 5: Phase directories match roadmap phases
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# List actual phase directories
|
|
118
|
+
ls -d .planning/phases/*/ 2>/dev/null | xargs -I{} basename {} 2>/dev/null
|
|
119
|
+
|
|
120
|
+
# Cross-reference with phase numbers extracted in Check 2
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
Compare:
|
|
124
|
+
- Phase numbers in ROADMAP.md vs directories in `.planning/phases/`
|
|
125
|
+
- Identify MISSING directories (in roadmap but not on disk)
|
|
126
|
+
- Identify ORPHANED directories (on disk but not in roadmap)
|
|
127
|
+
|
|
128
|
+
- PASS: all roadmap phases have directories, no orphans
|
|
129
|
+
- WARN: minor mismatch (1-2 issues)
|
|
130
|
+
- FAIL: multiple missing or orphaned directories
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
### Check 6: PLAN.md files are valid (have tasks)
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
# Find all PLAN.md files
|
|
138
|
+
find .planning/phases -name "*-PLAN.md" 2>/dev/null | head -20
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
For each PLAN.md found, check it contains at least one `<task>` element or task list item.
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# Quick check for task content
|
|
145
|
+
grep -l "<task\|## Task\|- \[ \]" .planning/phases/**/*-PLAN.md 2>/dev/null | wc -l
|
|
146
|
+
grep -rL "<task\|## Task\|- \[ \]" .planning/phases/ 2>/dev/null | grep "PLAN.md"
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
- PASS: all PLAN.md files have task content
|
|
150
|
+
- WARN: one or more PLAN.md files appear empty or lack task markers
|
|
151
|
+
- SKIP: no PLAN.md files exist yet (project may be in early planning)
|
|
152
|
+
|
|
153
|
+
---
|
|
154
|
+
|
|
155
|
+
### Check 7: No orphaned phase directories
|
|
156
|
+
|
|
157
|
+
Already computed in Check 5. Report here as a dedicated line item.
|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
### Check 8: No missing phase directories
|
|
162
|
+
|
|
163
|
+
Already computed in Check 5. Report here as a dedicated line item.
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
### Check 9: .merlin/config.json exists and has valid API key format
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
cat .merlin/config.json 2>/dev/null
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Also check global config:
|
|
174
|
+
```bash
|
|
175
|
+
cat ~/.claude/merlin/settings.json 2>/dev/null | grep -i "apiKey\|api_key\|key" | head -3
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
- PASS: config exists AND apiKey field matches pattern `mrln_[a-zA-Z0-9]{20,}`
|
|
179
|
+
- WARN: config exists but apiKey format looks unusual
|
|
180
|
+
- FAIL: config does not exist or apiKey is missing/empty
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
### Check 10: Hooks registered in Claude settings
|
|
185
|
+
|
|
186
|
+
```bash
|
|
187
|
+
# Check local settings first
|
|
188
|
+
cat .claude/settings.local.json 2>/dev/null | grep -o '"hooks"' | head -1
|
|
189
|
+
cat .claude/settings.json 2>/dev/null | grep -o '"hooks"' | head -1
|
|
190
|
+
|
|
191
|
+
# Count hook entries
|
|
192
|
+
cat .claude/settings.local.json 2>/dev/null | grep -o '"command"' | wc -l
|
|
193
|
+
cat .claude/settings.json 2>/dev/null | grep -o '"command"' | wc -l
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
For each hook file referenced, verify it exists on disk:
|
|
197
|
+
```bash
|
|
198
|
+
# Extract hook commands from settings and check each file exists
|
|
199
|
+
cat .claude/settings.local.json 2>/dev/null | grep '"command"' | grep -o '"[^"]*\.sh[^"]*"' | tr -d '"' | while read f; do
|
|
200
|
+
# Expand $HOME
|
|
201
|
+
expanded="${f/\$HOME/$HOME}"
|
|
202
|
+
[ -f "$expanded" ] && echo "OK: $f" || echo "MISSING: $f"
|
|
203
|
+
done
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
- PASS: hooks key exists AND all referenced files exist
|
|
207
|
+
- WARN: hooks registered but one or more hook files missing on disk
|
|
208
|
+
- FAIL: hooks key not found in either settings file
|
|
209
|
+
|
|
210
|
+
## Step 3: Compile Score and Display Results
|
|
211
|
+
|
|
212
|
+
Count:
|
|
213
|
+
- PASS checks → contribute 1 point each
|
|
214
|
+
- WARN checks → contribute 0.5 points each
|
|
215
|
+
- FAIL checks → contribute 0 points each
|
|
216
|
+
- SKIP checks → excluded from denominator
|
|
217
|
+
|
|
218
|
+
Score = sum of points / number of applicable checks * 10 (rounded to nearest integer)
|
|
219
|
+
|
|
220
|
+
Display:
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
════════════════════════════════════════
|
|
224
|
+
Merlin Health Check
|
|
225
|
+
════════════════════════════════════════
|
|
226
|
+
|
|
227
|
+
[1] PROJECT.md — {PASS/WARN/FAIL} {detail}
|
|
228
|
+
[2] ROADMAP.md — {PASS/WARN/FAIL} ({N} phases, {M} milestones)
|
|
229
|
+
[3] REQUIREMENTS.md — {PASS/WARN/SKIP} {detail}
|
|
230
|
+
[4] STATE.md — {PASS/WARN/FAIL} {detail, e.g., "last updated 3 days ago"}
|
|
231
|
+
[5] Phase dirs match — {PASS/WARN/FAIL} {detail}
|
|
232
|
+
[6] PLAN.md validity — {PASS/WARN/SKIP} {detail}
|
|
233
|
+
[7] No orphaned dirs — {PASS/WARN/FAIL} {list orphans if any}
|
|
234
|
+
[8] No missing dirs — {PASS/WARN/FAIL} {list missing if any}
|
|
235
|
+
[9] Merlin config — {PASS/WARN/FAIL} {detail}
|
|
236
|
+
[10] Hooks registered — {PASS/WARN/FAIL} ({N} hooks, all files present)
|
|
237
|
+
|
|
238
|
+
────────────────────────────────────────
|
|
239
|
+
Score: {X}/10 ({N} issues found)
|
|
240
|
+
────────────────────────────────────────
|
|
241
|
+
|
|
242
|
+
{If issues > 0 and not in repair mode:}
|
|
243
|
+
Run `/merlin:health --repair` to auto-fix safe issues.
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
If score is 10/10:
|
|
247
|
+
```
|
|
248
|
+
Everything looks healthy. No action needed.
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Step 4: Repair (only if --repair flag present)
|
|
252
|
+
|
|
253
|
+
If no issues found, skip this step.
|
|
254
|
+
|
|
255
|
+
Group issues by repair safety:
|
|
256
|
+
|
|
257
|
+
**Auto-fix (no confirmation needed):**
|
|
258
|
+
- Missing STATE.md → create with sensible defaults
|
|
259
|
+
- Missing phase directories (referenced in roadmap) → create empty directories
|
|
260
|
+
- Missing REQUIREMENTS.md → note it, do not auto-create (content requires user input)
|
|
261
|
+
|
|
262
|
+
**Confirm before fixing:**
|
|
263
|
+
- Orphaned phase directories → ask before removing
|
|
264
|
+
|
|
265
|
+
---
|
|
266
|
+
|
|
267
|
+
### Repair: Missing STATE.md
|
|
268
|
+
|
|
269
|
+
```bash
|
|
270
|
+
cat > .planning/STATE.md << 'EOF'
|
|
271
|
+
# State
|
|
272
|
+
|
|
273
|
+
## Current Position
|
|
274
|
+
- Phase: 1
|
|
275
|
+
- Status: planning
|
|
276
|
+
|
|
277
|
+
## Recent Decisions
|
|
278
|
+
(none yet)
|
|
279
|
+
|
|
280
|
+
## Blockers
|
|
281
|
+
(none)
|
|
282
|
+
|
|
283
|
+
## Notes
|
|
284
|
+
(auto-created by /merlin:health --repair)
|
|
285
|
+
EOF
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Report: "Created .planning/STATE.md with defaults."
|
|
289
|
+
|
|
290
|
+
---
|
|
291
|
+
|
|
292
|
+
### Repair: Missing phase directories
|
|
293
|
+
|
|
294
|
+
For each phase in roadmap that lacks a directory:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
mkdir -p ".planning/phases/{phase-dir-name}"
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
Report: "Created .planning/phases/{dir}/"
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
### Repair: Orphaned phase directories
|
|
305
|
+
|
|
306
|
+
For each orphaned directory, ask:
|
|
307
|
+
|
|
308
|
+
```
|
|
309
|
+
Found orphaned directory: .planning/phases/{dir}/
|
|
310
|
+
This directory is not referenced in ROADMAP.md.
|
|
311
|
+
|
|
312
|
+
Remove it? (y/n)
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Use AskUserQuestion if multiple orphans exist — confirm all at once with a list.
|
|
316
|
+
|
|
317
|
+
If confirmed:
|
|
318
|
+
```bash
|
|
319
|
+
rm -rf ".planning/phases/{dir}"
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
Report: "Removed .planning/phases/{dir}/"
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
### Repair: Phase numbering gaps in ROADMAP.md
|
|
327
|
+
|
|
328
|
+
If gaps detected in phase numbering (e.g., 01, 02, 04 — missing 03):
|
|
329
|
+
|
|
330
|
+
Report the gap but do NOT auto-rename — renumbering phases can break STATE.md references and directory names. Suggest the user fix manually or use `/merlin:insert-phase`.
|
|
331
|
+
|
|
332
|
+
```
|
|
333
|
+
Phase numbering gap detected: phases jump from 02 to 04.
|
|
334
|
+
Manual fix recommended — use /merlin:insert-phase to add the missing phase,
|
|
335
|
+
or edit ROADMAP.md directly and update STATE.md to match.
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
---
|
|
339
|
+
|
|
340
|
+
### Repair Summary
|
|
341
|
+
|
|
342
|
+
After all repairs:
|
|
343
|
+
|
|
344
|
+
```
|
|
345
|
+
════════════════════════════════════════
|
|
346
|
+
Repair Complete
|
|
347
|
+
════════════════════════════════════════
|
|
348
|
+
|
|
349
|
+
Fixed:
|
|
350
|
+
{list of auto-fixed items}
|
|
351
|
+
|
|
352
|
+
Skipped (manual action required):
|
|
353
|
+
{list of items that need manual attention}
|
|
354
|
+
|
|
355
|
+
────────────────────────────────────────
|
|
356
|
+
Run `/merlin:health` to verify.
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
</process>
|
|
360
|
+
|
|
361
|
+
<check_reference>
|
|
362
|
+
|
|
363
|
+
| # | Check | PASS | WARN | FAIL | Auto-Repair |
|
|
364
|
+
|---|-------|------|------|------|-------------|
|
|
365
|
+
| 1 | PROJECT.md | exists + 3 sections | exists, missing sections | missing | No |
|
|
366
|
+
| 2 | ROADMAP.md | exists + sequential | exists, gaps in numbering | missing | No |
|
|
367
|
+
| 3 | REQUIREMENTS.md | exists | missing but referenced | n/a | No |
|
|
368
|
+
| 4 | STATE.md | exists, <7 days old | exists, >7 days old | missing | Yes — create with defaults |
|
|
369
|
+
| 5 | Phase dirs match | all match | 1-2 mismatches | many mismatches | Partial |
|
|
370
|
+
| 6 | PLAN.md validity | all have tasks | some empty | n/a | No |
|
|
371
|
+
| 7 | No orphans | no orphans | 1-2 orphans | many orphans | Yes — with confirmation |
|
|
372
|
+
| 8 | No missing dirs | none missing | 1-2 missing | many missing | Yes — mkdir |
|
|
373
|
+
| 9 | Merlin config | key + valid format | key present, odd format | missing | No |
|
|
374
|
+
| 10 | Hooks | registered + files exist | files missing | not registered | No |
|
|
375
|
+
|
|
376
|
+
</check_reference>
|
|
377
|
+
|
|
378
|
+
<success_criteria>
|
|
379
|
+
- [ ] All 10 checks run and reported
|
|
380
|
+
- [ ] Score calculated and displayed
|
|
381
|
+
- [ ] --repair mode applies safe fixes without confirmation
|
|
382
|
+
- [ ] Orphaned directory removal always confirmed first
|
|
383
|
+
- [ ] Phase renumbering explicitly deferred to manual action
|
|
384
|
+
- [ ] Final output is scannable in under 20 seconds
|
|
385
|
+
</success_criteria>
|
|
@@ -17,57 +17,114 @@ Output ONLY the reference content below. Do NOT add:
|
|
|
17
17
|
<reference>
|
|
18
18
|
# Merlin Loop Recipes
|
|
19
19
|
|
|
20
|
-
Pre-built `/loop` patterns for common Merlin workflows. Copy and
|
|
20
|
+
Pre-built `/loop` patterns for common Merlin workflows. Copy and paste directly into Claude Code.
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
---
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
- `/loop 2m check build status and report any failures` — CI monitoring
|
|
26
|
-
- `/loop 10m /merlin:standup` — Running standup summary
|
|
27
|
-
- `/loop 15m check if any new errors appeared in the logs` — Log monitoring
|
|
24
|
+
## How to Use
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
```
|
|
27
|
+
/loop <interval> <command or prompt>
|
|
28
|
+
```
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
- `/loop 1h review recent changes for security issues` — Security patrol
|
|
33
|
-
- `/loop 4h check if documentation is up to date with recent code changes` — Doc freshness
|
|
34
|
-
- `/loop 2h scan for duplicate code or functions that do the same thing` — DRY check
|
|
30
|
+
Intervals: `2m`, `5m`, `10m`, `30m`, `1h`, `4h` — natural language also works.
|
|
35
31
|
|
|
36
|
-
|
|
32
|
+
---
|
|
37
33
|
|
|
38
|
-
|
|
39
|
-
- `/loop 1h merlin_lite_refresh()` — Refresh local Sights analysis
|
|
40
|
-
- `/loop 6h run /merlin:map-codebase to keep codebase index fresh` — Index freshness
|
|
34
|
+
## Recipes
|
|
41
35
|
|
|
42
|
-
|
|
36
|
+
### Progress Check
|
|
37
|
+
**Command:** `/loop 5m /merlin:progress`
|
|
38
|
+
**Interval:** 5 minutes
|
|
39
|
+
**What it does:** Runs `/merlin:progress` on each tick to summarize what has been completed, what is in progress, and what is blocked.
|
|
40
|
+
**When to use:** Active development sessions where you want a live project status dashboard without manually checking in.
|
|
43
41
|
|
|
44
|
-
|
|
45
|
-
- `/loop 5m check if PR checks have passed` — PR monitoring
|
|
46
|
-
- `/loop 10m check if the staging environment is healthy` — Staging health
|
|
42
|
+
---
|
|
47
43
|
|
|
48
|
-
|
|
44
|
+
### Standup Generator
|
|
45
|
+
**Command:** `/loop 10m /merlin:standup`
|
|
46
|
+
**Interval:** 10 minutes
|
|
47
|
+
**What it does:** Generates a running standup summary — what was done, what is next, any blockers — updated every 10 minutes.
|
|
48
|
+
**When to use:** Long coding sessions, pair programming, or async team work where stakeholders need regular updates.
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
- `/loop 24h /merlin:standup and create a brief daily summary` — Daily digest
|
|
50
|
+
---
|
|
52
51
|
|
|
53
|
-
|
|
52
|
+
### Sights Warm
|
|
53
|
+
**Command:** `/loop 30m call merlin_get_context with current task summary to keep Sights context fresh`
|
|
54
|
+
**Interval:** 30 minutes
|
|
55
|
+
**What it does:** Calls `merlin_get_context` with a summary of current work so the Merlin Sights knowledge layer stays warm and fast.
|
|
56
|
+
**When to use:** Long sessions where you want instant context retrieval without cold-start delays throughout the day.
|
|
54
57
|
|
|
55
|
-
|
|
58
|
+
---
|
|
56
59
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
+
### CI Monitor
|
|
61
|
+
**Command:** `/loop 2m check gh run list --limit 3 and report status of each run`
|
|
62
|
+
**Interval:** 2 minutes
|
|
63
|
+
**What it does:** Polls the last 3 GitHub Actions runs and reports pass/fail/in-progress status with links to failing jobs.
|
|
64
|
+
**When to use:** After pushing a branch or opening a PR — keep eyes on CI without switching tabs.
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### Security Scan
|
|
69
|
+
**Command:** `/loop 1h scan for any new dependencies added since last check and report known vulnerabilities`
|
|
70
|
+
**Interval:** 1 hour
|
|
71
|
+
**What it does:** Checks for newly added packages in package.json / requirements.txt and flags any with known CVEs or suspicious origins.
|
|
72
|
+
**When to use:** Active feature development where new packages are being pulled in, or any session touching the dependency tree.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
### Doc Freshness
|
|
77
|
+
**Command:** `/loop 4h check if any .md files are outdated relative to recent code changes and list what needs updating`
|
|
78
|
+
**Interval:** 4 hours
|
|
79
|
+
**What it does:** Compares recent code diffs against documentation files and surfaces docs that reference changed APIs, configs, or behaviors.
|
|
80
|
+
**When to use:** Background monitoring during a sprint to avoid docs rot accumulating unnoticed.
|
|
81
|
+
|
|
82
|
+
---
|
|
60
83
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
84
|
+
### Test Runner
|
|
85
|
+
**Command:** `/loop 3m run the test suite and report any new failures compared to the last run`
|
|
86
|
+
**Interval:** 3 minutes
|
|
87
|
+
**What it does:** Runs the project test suite on each tick and highlights any tests that newly broke since the previous iteration.
|
|
88
|
+
**When to use:** TDD workflows or refactoring sessions where you want immediate feedback on regressions without running tests manually.
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
### Cost Tracker
|
|
93
|
+
**Command:** `/loop 15m call merlin_session_cost and report the current session token spend`
|
|
94
|
+
**Interval:** 15 minutes
|
|
95
|
+
**What it does:** Calls `merlin_session_cost` to report cumulative token usage and estimated cost for the current session.
|
|
96
|
+
**When to use:** Long autonomous sessions or when working with expensive models — prevents bill surprises on unattended runs.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## More Patterns
|
|
101
|
+
|
|
102
|
+
### Development Monitoring
|
|
103
|
+
|
|
104
|
+
- `/loop 2m check Railway deployment status and report if unhealthy`
|
|
105
|
+
- `/loop 5m check if PR checks have passed and summarize results`
|
|
106
|
+
- `/loop 15m check if any new errors appeared in the logs`
|
|
107
|
+
|
|
108
|
+
### Code Quality
|
|
109
|
+
|
|
110
|
+
- `/loop 30m scan for files over 400 lines and list them`
|
|
111
|
+
- `/loop 2h scan for duplicate code or functions that do the same thing`
|
|
112
|
+
|
|
113
|
+
### Sights & Context
|
|
114
|
+
|
|
115
|
+
- `/loop 1h run /merlin:map-codebase to keep codebase index fresh`
|
|
116
|
+
|
|
117
|
+
### Planning
|
|
118
|
+
|
|
119
|
+
- `/loop 1h /merlin:check-todos and summarize what is pending`
|
|
120
|
+
- `/loop 24h /merlin:standup and write a brief daily digest`
|
|
121
|
+
|
|
122
|
+
---
|
|
67
123
|
|
|
68
124
|
## Tips
|
|
69
125
|
|
|
70
|
-
-
|
|
71
|
-
-
|
|
72
|
-
-
|
|
126
|
+
- Use shorter intervals (2–5m) during active deploys; longer (1h+) for background checks.
|
|
127
|
+
- Chain recipes: let one loop inform what the next checks.
|
|
128
|
+
- Loops auto-expire after 3 days and are session-scoped.
|
|
129
|
+
- Default interval when none is specified: 10 minutes.
|
|
73
130
|
</reference>
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: merlin:optimize-prompts
|
|
3
|
+
description: Analyze agent prompt effectiveness and surface actionable improvement suggestions
|
|
4
|
+
argument-hint: "[agent-name]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- mcp__merlin__merlin_prompt_suggestions
|
|
7
|
+
- mcp__merlin__merlin_get_behaviors
|
|
8
|
+
- AskUserQuestion
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
<objective>
|
|
12
|
+
Review how well each agent is performing based on session outcome data, then walk through
|
|
13
|
+
improvement suggestions one by one. You never auto-modify any agent file — the user approves
|
|
14
|
+
each suggestion and applies it manually.
|
|
15
|
+
</objective>
|
|
16
|
+
|
|
17
|
+
<process>
|
|
18
|
+
|
|
19
|
+
## Step 1: Parse Arguments
|
|
20
|
+
|
|
21
|
+
Extract from $ARGUMENTS (optional):
|
|
22
|
+
- **agent-name**: Focus the report on one specific agent
|
|
23
|
+
|
|
24
|
+
Store as `TARGET_AGENT` (may be empty).
|
|
25
|
+
|
|
26
|
+
## Step 2: Fetch Effectiveness Report
|
|
27
|
+
|
|
28
|
+
Call `merlin_prompt_suggestions` with `agentFilter: TARGET_AGENT` (omit if empty).
|
|
29
|
+
|
|
30
|
+
If the result says "No outcome data yet":
|
|
31
|
+
```
|
|
32
|
+
No outcome data has been collected yet.
|
|
33
|
+
|
|
34
|
+
Outcome tracking starts automatically at session end. Run a few sessions,
|
|
35
|
+
then come back to /merlin:optimize-prompts.
|
|
36
|
+
```
|
|
37
|
+
Stop here.
|
|
38
|
+
|
|
39
|
+
## Step 3: Display the Report
|
|
40
|
+
|
|
41
|
+
Print the full effectiveness report exactly as returned. It includes:
|
|
42
|
+
- A score table (all agents or filtered agent)
|
|
43
|
+
- Suggestions section for low-scoring agents
|
|
44
|
+
- High-confidence behavior hints (if any)
|
|
45
|
+
|
|
46
|
+
## Step 4: Check for Suggestions
|
|
47
|
+
|
|
48
|
+
Scan the report for the **Suggestions** section.
|
|
49
|
+
|
|
50
|
+
If it says "All tracked agents are performing above the threshold":
|
|
51
|
+
```
|
|
52
|
+
All agents are performing well — no prompt changes needed at this time.
|
|
53
|
+
|
|
54
|
+
Check back after more sessions to track trends.
|
|
55
|
+
```
|
|
56
|
+
Stop here.
|
|
57
|
+
|
|
58
|
+
## Step 5: Walk Through Each Suggestion
|
|
59
|
+
|
|
60
|
+
For each suggestion in the report, present it clearly:
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Suggestion for: {agent-name} (score: {score}%)
|
|
64
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
65
|
+
|
|
66
|
+
Suggested addition:
|
|
67
|
+
"{suggestion text}"
|
|
68
|
+
|
|
69
|
+
Evidence: {evidence}
|
|
70
|
+
Confidence: {confidence}
|
|
71
|
+
|
|
72
|
+
Agent file: ~/.claude/agents/{agent-name}.md
|
|
73
|
+
|
|
74
|
+
[A] Apply — show me exactly what to add
|
|
75
|
+
[S] Skip this suggestion
|
|
76
|
+
[Q] Stop reviewing
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Ask the user to choose A, S, or Q.
|
|
80
|
+
|
|
81
|
+
## Step 6: Show Exact Text to Add (if Approved)
|
|
82
|
+
|
|
83
|
+
If the user chooses **A**:
|
|
84
|
+
|
|
85
|
+
Show the exact text block they should paste into the agent's .md file.
|
|
86
|
+
Put it inside a fenced code block so they can copy it easily:
|
|
87
|
+
|
|
88
|
+
```
|
|
89
|
+
Add the following to ~/.claude/agents/{agent-name}.md
|
|
90
|
+
(paste into the relevant section of the agent prompt):
|
|
91
|
+
|
|
92
|
+
\`\`\`markdown
|
|
93
|
+
## Effectiveness Note
|
|
94
|
+
{suggestion text}
|
|
95
|
+
\`\`\`
|
|
96
|
+
|
|
97
|
+
Apply this change manually — Merlin never edits agent files directly.
|
|
98
|
+
After applying, run a few more sessions to see if the score improves.
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Do NOT call any edit or write tool. The user applies the change themselves.
|
|
102
|
+
|
|
103
|
+
Then move to the next suggestion (if any).
|
|
104
|
+
|
|
105
|
+
## Step 7: Handle Behavior Hints
|
|
106
|
+
|
|
107
|
+
If the report includes a "High-Confidence Behaviors Ready for Agent Prompts" section,
|
|
108
|
+
show it after all suggestions are handled:
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
High-Confidence Behaviors
|
|
112
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
113
|
+
These behaviors have been validated enough to embed into agent prompts:
|
|
114
|
+
|
|
115
|
+
{list from report}
|
|
116
|
+
|
|
117
|
+
To promote a behavior into a skill first, run /merlin:promote.
|
|
118
|
+
To embed directly, add the action text to the agent .md under a "Learned Patterns" section.
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Ask if the user wants to see the promote workflow: if yes, tell them to run `/merlin:promote`.
|
|
122
|
+
|
|
123
|
+
## Step 8: Summary
|
|
124
|
+
|
|
125
|
+
After all suggestions are reviewed:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
Optimize-Prompts complete
|
|
129
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
130
|
+
|
|
131
|
+
Applied: {N} suggestion(s) shown for manual apply
|
|
132
|
+
Skipped: {M} suggestion(s)
|
|
133
|
+
|
|
134
|
+
Changes to agent .md files take effect in the next session.
|
|
135
|
+
Run /merlin:optimize-prompts again after 5+ sessions to track improvement.
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
</process>
|
|
139
|
+
|
|
140
|
+
<design_notes>
|
|
141
|
+
- This command is a guided UX wrapper around merlin_prompt_suggestions
|
|
142
|
+
- NEVER auto-edit agent .md files — always show text for manual copy-paste
|
|
143
|
+
- The tool does the analysis; this command handles the UX conversation
|
|
144
|
+
- Outcome data is collected automatically by session-end.sh — users don't need to do anything
|
|
145
|
+
- Scores improve when agents complete sessions that end with file changes and no errors
|
|
146
|
+
</design_notes>
|
|
147
|
+
|
|
148
|
+
<error_handling>
|
|
149
|
+
|
|
150
|
+
| Condition | Action |
|
|
151
|
+
|-----------|--------|
|
|
152
|
+
| No outcomes.jsonl | Explain collection is automatic, suggest running sessions first |
|
|
153
|
+
| All agents scoring well | Confirm good health, no action needed |
|
|
154
|
+
| Only 1-2 sessions tracked | Note low confidence, suggest waiting for more data |
|
|
155
|
+
| User rejects all suggestions | Exit cleanly with "Nothing applied" message |
|
|
156
|
+
| Behavior hints fetch fails | Skip that section silently, show the score table anyway |
|
|
157
|
+
|
|
158
|
+
</error_handling>
|