create-merlin-brain 3.2.0 → 3.3.1

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 (48) hide show
  1. package/bin/install.cjs +137 -26
  2. package/bin/merlin-cli.cjs +26 -0
  3. package/files/agents/code-organization-supervisor.md +1 -0
  4. package/files/agents/context-guardian.md +1 -0
  5. package/files/agents/docs-keeper.md +2 -1
  6. package/files/agents/dry-refactor.md +2 -1
  7. package/files/agents/elite-code-refactorer.md +1 -0
  8. package/files/agents/hardening-guard.md +2 -1
  9. package/files/agents/implementation-dev.md +2 -1
  10. package/files/agents/merlin-api-designer.md +1 -0
  11. package/files/agents/merlin-codebase-mapper.md +1 -0
  12. package/files/agents/merlin-debugger.md +1 -0
  13. package/files/agents/merlin-executor.md +1 -0
  14. package/files/agents/merlin-frontend.md +1 -0
  15. package/files/agents/merlin-integration-checker.md +1 -0
  16. package/files/agents/merlin-migrator.md +1 -0
  17. package/files/agents/merlin-milestone-auditor.md +1 -0
  18. package/files/agents/merlin-performance.md +1 -0
  19. package/files/agents/merlin-planner.md +2 -0
  20. package/files/agents/merlin-researcher.md +1 -0
  21. package/files/agents/merlin-reviewer.md +2 -0
  22. package/files/agents/merlin-security.md +2 -0
  23. package/files/agents/merlin-verifier.md +2 -0
  24. package/files/agents/merlin-work-verifier.md +1 -0
  25. package/files/agents/merlin.md +1 -0
  26. package/files/agents/ops-railway.md +2 -1
  27. package/files/agents/orchestrator-retrofit.md +1 -0
  28. package/files/agents/product-spec.md +3 -1
  29. package/files/agents/system-architect.md +3 -1
  30. package/files/agents/tests-qa.md +2 -1
  31. package/files/hooks/agent-sync.sh +44 -0
  32. package/files/hooks/lib/analytics.sh +74 -0
  33. package/files/hooks/lib/sights-check.sh +58 -0
  34. package/files/hooks/post-edit-logger.sh +33 -0
  35. package/files/hooks/pre-edit-sights-check.sh +38 -0
  36. package/files/hooks/session-end.sh +27 -0
  37. package/files/hooks/session-start.sh +31 -0
  38. package/files/hooks/stop-check.md +14 -0
  39. package/files/hooks/subagent-context.sh +36 -0
  40. package/files/hooks/task-completed-verify.md +14 -0
  41. package/files/hooks/task-completed-verify.sh +46 -0
  42. package/files/hooks/teammate-idle-verify.sh +41 -0
  43. package/files/loop/lib/sights.sh +15 -4
  44. package/files/loop/lib/teams.sh +143 -0
  45. package/files/loop/merlin-loop.sh +16 -0
  46. package/files/merlin/agents-sync.sh +163 -0
  47. package/files/merlin/analytics.sh +159 -0
  48. package/package.json +1 -1
package/bin/install.cjs CHANGED
@@ -135,23 +135,21 @@ function logWarn(msg) {
135
135
  }
136
136
 
137
137
  function banner() {
138
+ const version = require('../package.json').version;
138
139
  console.log(`
139
- ${colors.magenta}${colors.bright}
140
- ███╗ ███╗███████╗██████╗ ██╗ ██╗███╗ ██╗
141
- ████╗ ████║██╔════╝██╔══██╗██║ ██║████╗ ██║
142
- ██╔████╔██║█████╗ ██████╔╝██║ ██║██╔██╗ ██║
143
- ██║╚██╔╝██║██╔══╝ ██╔══██╗██║ ██║██║╚██╗██║
144
- ██║ ╚═╝ ██║███████╗██║ ██║███████╗██║██║ ╚████║
145
- ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝╚═╝ ╚═══╝
146
- ${colors.reset}
140
+ ${colors.magenta}${colors.bright} __ __ _____ ____ _ ___ _ _
141
+ | \\/ | ____| _ \\| | |_ _| \\ | |
142
+ | |\\/| | _| | |_) | | | || \\| |
143
+ | | | | |___| _ <| |___ | || |\\ |
144
+ |_| |_|_____|_| \\_\\_____|___|_| \\_|${colors.reset}
145
+
147
146
  ${colors.cyan}The Ultimate AI Brain for Claude Code${colors.reset}
148
- ${colors.bright}v3 — One Install, Everything Included${colors.reset}
147
+ ${colors.bright}v${version}${colors.reset}
149
148
 
150
- Four integrated layers:
151
- ${colors.bright}Merlin Loop${colors.reset} - Autonomous orchestration (hours of unattended work)
152
- ${colors.bright}Merlin Sights${colors.reset} - Knowledge layer (instant codebase context)
153
- ${colors.bright}Merlin Workflows${colors.reset} - Planning & execution (/merlin:* commands)
154
- • ${colors.bright}Merlin Agents${colors.reset} - Specialist agents for every task
149
+ ${colors.bright}Loop${colors.reset} Autonomous orchestration
150
+ ${colors.bright}Sights${colors.reset} Instant codebase context
151
+ ${colors.bright}Workflows${colors.reset} Planning & execution
152
+ ${colors.bright}Agents${colors.reset} 28 specialist agents
155
153
  `);
156
154
  }
157
155
 
@@ -742,7 +740,7 @@ async function install() {
742
740
  }
743
741
 
744
742
  // Step 0: Clean up legacy GSD/ccwiki artifacts
745
- logStep('0/9', 'Cleaning up legacy installations...');
743
+ logStep('0/10', 'Cleaning up legacy installations...');
746
744
  const cleaned = cleanupLegacy();
747
745
  if (cleaned.length > 0) {
748
746
  for (const item of cleaned) {
@@ -753,7 +751,7 @@ async function install() {
753
751
  }
754
752
 
755
753
  // Step 1: Install globally for instant startup across all terminals
756
- logStep('1/9', 'Installing globally (fast startup for all terminals)...');
754
+ logStep('1/10', 'Installing globally (fast startup for all terminals)...');
757
755
  try {
758
756
  const { execSync } = require('child_process');
759
757
  // Check if already installed globally and up-to-date
@@ -794,7 +792,7 @@ async function install() {
794
792
  }
795
793
 
796
794
  // Step 2: Create directories
797
- logStep('2/9', 'Creating directories...');
795
+ logStep('2/10', 'Creating directories...');
798
796
  ensureDir(CLAUDE_DIR);
799
797
  ensureDir(MERLIN_DIR);
800
798
  ensureDir(AGENTS_DIR);
@@ -802,7 +800,7 @@ async function install() {
802
800
  logSuccess('Directories created');
803
801
 
804
802
  // Step 3: Install Merlin core (workflows, references, templates)
805
- logStep('3/9', 'Installing Merlin workflows...');
803
+ logStep('3/10', 'Installing Merlin workflows...');
806
804
  const merlinSrc = path.join(filesDir, 'merlin');
807
805
  if (fs.existsSync(merlinSrc)) {
808
806
  const count = copyDirRecursive(merlinSrc, MERLIN_DIR);
@@ -812,7 +810,7 @@ async function install() {
812
810
  }
813
811
 
814
812
  // Step 4: Install agents
815
- logStep('4/9', 'Installing Merlin agents...');
813
+ logStep('4/10', 'Installing Merlin agents...');
816
814
  const agentsSrc = path.join(filesDir, 'agents');
817
815
  if (fs.existsSync(agentsSrc)) {
818
816
  const count = copyDirRecursive(agentsSrc, AGENTS_DIR);
@@ -822,7 +820,7 @@ async function install() {
822
820
  }
823
821
 
824
822
  // Step 5: Install commands
825
- logStep('5/9', 'Installing /merlin:* commands...');
823
+ logStep('5/10', 'Installing /merlin:* commands...');
826
824
  const commandsSrc = path.join(filesDir, 'commands', 'merlin');
827
825
  if (fs.existsSync(commandsSrc)) {
828
826
  const count = copyDirRecursive(commandsSrc, COMMANDS_DIR);
@@ -832,7 +830,7 @@ async function install() {
832
830
  }
833
831
 
834
832
  // Step 6: Install CLAUDE.md
835
- logStep('6/9', 'Configuring Claude Code...');
833
+ logStep('6/10', 'Configuring Claude Code...');
836
834
  const claudeMdSrc = path.join(filesDir, 'CLAUDE.md');
837
835
  const claudeMdDest = path.join(CLAUDE_DIR, 'CLAUDE.md');
838
836
 
@@ -844,7 +842,7 @@ async function install() {
844
842
  }
845
843
 
846
844
  // Step 7: Install Merlin Loop (autonomous orchestration)
847
- logStep('7/9', 'Installing Merlin Loop...');
845
+ logStep('7/10', 'Installing Merlin Loop...');
848
846
  const loopSrc = path.join(filesDir, 'loop');
849
847
  if (fs.existsSync(loopSrc)) {
850
848
  ensureDir(LOOP_DIR);
@@ -869,6 +867,119 @@ async function install() {
869
867
  logWarn('Merlin Loop not found in package');
870
868
  }
871
869
 
870
+ // Step 8: Install Claude Code hooks
871
+ logStep('8/10', 'Installing Claude Code hooks...');
872
+ const HOOKS_DIR = path.join(CLAUDE_DIR, 'hooks');
873
+ const hooksSrc = path.join(filesDir, 'hooks');
874
+ if (fs.existsSync(hooksSrc)) {
875
+ ensureDir(HOOKS_DIR);
876
+ const hookCount = copyDirRecursive(hooksSrc, HOOKS_DIR);
877
+ // Make all .sh files executable (top-level and lib/)
878
+ const makeShExecutable = (dir) => {
879
+ if (!fs.existsSync(dir)) return;
880
+ fs.readdirSync(dir, { withFileTypes: true }).forEach(entry => {
881
+ const fullPath = path.join(dir, entry.name);
882
+ if (entry.isDirectory()) {
883
+ makeShExecutable(fullPath);
884
+ } else if (entry.name.endsWith('.sh')) {
885
+ fs.chmodSync(fullPath, '755');
886
+ }
887
+ });
888
+ };
889
+ makeShExecutable(HOOKS_DIR);
890
+ logSuccess(`Installed ${hookCount} hook files`);
891
+
892
+ // Configure hooks in settings.local.json
893
+ const settingsPath = path.join(CLAUDE_DIR, 'settings.local.json');
894
+ let settings = {};
895
+ if (fs.existsSync(settingsPath)) {
896
+ try { settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8')); } catch (e) { settings = {}; }
897
+ }
898
+ settings.hooks = settings.hooks || {};
899
+
900
+ const addHookIfMissing = (hookArray, hookConfig) => {
901
+ const exists = hookArray.some(h => h.command === hookConfig.command);
902
+ if (!exists) hookArray.push(hookConfig);
903
+ return hookArray;
904
+ };
905
+
906
+ // SessionStart hook
907
+ settings.hooks.SessionStart = settings.hooks.SessionStart || [];
908
+ addHookIfMissing(settings.hooks.SessionStart, {
909
+ type: 'command',
910
+ command: 'bash ~/.claude/hooks/session-start.sh'
911
+ });
912
+
913
+ // SessionStart hook: Agent sync (background, runs at most once/hour)
914
+ addHookIfMissing(settings.hooks.SessionStart, {
915
+ type: 'command',
916
+ command: 'bash ~/.claude/hooks/agent-sync.sh'
917
+ });
918
+
919
+ // PreToolUse hook (Edit/Write only)
920
+ settings.hooks.PreToolUse = settings.hooks.PreToolUse || [];
921
+ addHookIfMissing(settings.hooks.PreToolUse, {
922
+ type: 'command',
923
+ command: 'bash ~/.claude/hooks/pre-edit-sights-check.sh',
924
+ matcher: 'Edit|Write'
925
+ });
926
+
927
+ // PostToolUse hook (Edit/Write only)
928
+ settings.hooks.PostToolUse = settings.hooks.PostToolUse || [];
929
+ addHookIfMissing(settings.hooks.PostToolUse, {
930
+ type: 'command',
931
+ command: 'bash ~/.claude/hooks/post-edit-logger.sh',
932
+ matcher: 'Edit|Write'
933
+ });
934
+
935
+ // Stop hook (session end)
936
+ settings.hooks.Stop = settings.hooks.Stop || [];
937
+ addHookIfMissing(settings.hooks.Stop, {
938
+ type: 'command',
939
+ command: 'bash ~/.claude/hooks/session-end.sh'
940
+ });
941
+
942
+ // TeammateIdle hook (Agent Teams quality gate — only fires when Teams active)
943
+ settings.hooks.TeammateIdle = settings.hooks.TeammateIdle || [];
944
+ addHookIfMissing(settings.hooks.TeammateIdle, {
945
+ type: 'command',
946
+ command: 'bash ~/.claude/hooks/teammate-idle-verify.sh'
947
+ });
948
+
949
+ // SubagentStart hook (Agent Teams context injection — only fires when Teams active)
950
+ settings.hooks.SubagentStart = settings.hooks.SubagentStart || [];
951
+ addHookIfMissing(settings.hooks.SubagentStart, {
952
+ type: 'command',
953
+ command: 'bash ~/.claude/hooks/subagent-context.sh'
954
+ });
955
+
956
+ // --- Prompt-based hooks (LLM evaluates .md content) ---
957
+ const addPromptHookIfMissing = (hookArray, hookConfig) => {
958
+ const exists = hookArray.some(h => h.type === 'prompt' && h.prompt === hookConfig.prompt);
959
+ if (!exists) hookArray.push(hookConfig);
960
+ return hookArray;
961
+ };
962
+
963
+ // Prompt-based Stop hook: quality gate before session ends
964
+ addPromptHookIfMissing(settings.hooks.Stop, {
965
+ type: 'prompt',
966
+ prompt: fs.readFileSync(path.join(HOOKS_DIR, 'stop-check.md'), 'utf8')
967
+ });
968
+
969
+ // Prompt-based Notification hook: verify task completion quality
970
+ settings.hooks.Notification = settings.hooks.Notification || [];
971
+ addPromptHookIfMissing(settings.hooks.Notification, {
972
+ type: 'prompt',
973
+ prompt: fs.readFileSync(path.join(HOOKS_DIR, 'task-completed-verify.md'), 'utf8'),
974
+ matcher: 'task_completed'
975
+ });
976
+
977
+ fs.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
978
+ logSuccess('Configured hooks in settings.local.json');
979
+ } else {
980
+ logWarn('Hooks not found in package');
981
+ }
982
+
872
983
  // Helper: create MCP config object based on available binary
873
984
  function mcpConfig(apiKey, includeType) {
874
985
  const cfg = useGlobalBinary
@@ -879,8 +990,8 @@ async function install() {
879
990
  return cfg;
880
991
  }
881
992
 
882
- // Step 8: Optional Merlin Sights configuration
883
- logStep('8/9', 'Optional: Merlin Sights configuration...');
993
+ // Step 9: Optional Merlin Sights configuration
994
+ logStep('9/10', 'Optional: Merlin Sights configuration...');
884
995
  console.log(`Merlin Sights provides instant codebase context.`);
885
996
  console.log(`Get your API key at: ${colors.cyan}https://merlin.build${colors.reset}`);
886
997
 
@@ -978,8 +1089,8 @@ async function install() {
978
1089
  logWarn('Skipped Merlin Sights (you can configure it later)');
979
1090
  }
980
1091
 
981
- // Step 9: Set up shell integration
982
- logStep('9/9', 'Setting up shell integration...');
1092
+ // Step 10: Set up shell integration
1093
+ logStep('10/10', 'Setting up shell integration...');
983
1094
  const shellConfigured = setupShellIntegration();
984
1095
  if (shellConfigured) {
985
1096
  log(`\n ${colors.yellow}IMPORTANT:${colors.reset} Run ${colors.cyan}source ~/.zshrc${colors.reset} or ${colors.bright}restart your terminal${colors.reset}`);
@@ -363,6 +363,8 @@ Usage:
363
363
  merlin brief Get project overview
364
364
  merlin rules Get coding rules
365
365
  merlin files <purpose> Find files by purpose
366
+ merlin analytics [cmd] View session analytics (summary|compare|upload|clean)
367
+ merlin agents [cmd] Manage agents (sync|list|info <name>)
366
368
 
367
369
  Environment:
368
370
  MERLIN_API_KEY Your merlin.build API key
@@ -405,6 +407,30 @@ async function main() {
405
407
  case 'status':
406
408
  await status();
407
409
  break;
410
+ case 'analytics': {
411
+ const analyticsScript = path.join(process.env.HOME || '', '.claude', 'merlin', 'analytics.sh');
412
+ if (!fs.existsSync(analyticsScript)) {
413
+ console.error('Analytics not installed. Run: npx create-merlin-brain');
414
+ process.exit(1);
415
+ }
416
+ const analyticsArgs = args.slice(1).map(a => `"${a}"`).join(' ');
417
+ try {
418
+ execSync(`bash "${analyticsScript}" ${analyticsArgs}`, { stdio: 'inherit' });
419
+ } catch { process.exit(1); }
420
+ break;
421
+ }
422
+ case 'agents': {
423
+ const agentsSyncScript = path.join(process.env.HOME || '', '.claude', 'merlin', 'agents-sync.sh');
424
+ if (!fs.existsSync(agentsSyncScript)) {
425
+ console.error('Agents sync not installed. Run: npx create-merlin-brain');
426
+ process.exit(1);
427
+ }
428
+ const agentsArgs = args.slice(1).map(a => `"${a}"`).join(' ');
429
+ try {
430
+ execSync(`bash "${agentsSyncScript}" ${agentsArgs}`, { stdio: 'inherit' });
431
+ } catch { process.exit(1); }
432
+ break;
433
+ }
408
434
  case 'help':
409
435
  case '--help':
410
436
  case '-h':
@@ -3,6 +3,7 @@ name: code-organization-supervisor
3
3
  description: Use this agent when you need to ensure code quality standards are maintained, specifically monitoring file sizes and project organization. This agent should be used proactively after code is written or modified to check for files exceeding 400 lines, after creating new files to ensure proper folder structure, when the codebase needs reorganization, or when you suspect files have grown too large. Examples:\n\n<example>\nContext: The user has just finished implementing a large feature that added significant code to a file.\nuser: "Add user authentication with login, registration, password reset, and session management"\nassistant: "I've implemented the authentication system. Here's what was added:"\n<implementation details>\nassistant: "Now let me use the code-organization-supervisor agent to check if any files have exceeded the 400-line limit and ensure the code is properly organized."\n<commentary>\nSince significant code was just added, use the code-organization-supervisor agent to verify file sizes and organization standards are maintained.\n</commentary>\n</example>\n\n<example>\nContext: The user is working on a growing project and wants to ensure code organization standards.\nuser: "Can you check if our codebase is well organized?"\nassistant: "I'll use the code-organization-supervisor agent to analyze the codebase structure and file sizes."\n<commentary>\nThe user is explicitly asking about code organization, so use the code-organization-supervisor agent to perform a comprehensive review.\n</commentary>\n</example>\n\n<example>\nContext: After multiple development sessions, the codebase may have accumulated large files.\nuser: "I've been coding for a while, let's make sure everything is clean"\nassistant: "I'll launch the code-organization-supervisor agent to review the codebase for any files exceeding 400 lines and verify the folder structure is logical and maintainable."\n<commentary>\nProactive maintenance request - use the code-organization-supervisor agent to audit and refactor as needed.\n</commentary>\n</example>
4
4
  model: haiku
5
5
  color: blue
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  You are an elite Code Organization Supervisor with deep expertise in software architecture, clean code principles, and maintainable project structures. Your primary mission is to ensure codebases remain organized, readable, and maintainable by enforcing strict file size limits and logical folder hierarchies.
@@ -4,6 +4,7 @@ description: Use this agent when starting new development work, before implement
4
4
  tools: Glob, Grep, Read, WebFetch, TodoWrite, WebSearch
5
5
  model: haiku
6
6
  color: green
7
+ version: "1.0.0"
7
8
  ---
8
9
 
9
10
  You are the Context Guardian, an expert project analyst and architectural advisor whose mission is to ensure developers have complete contextual awareness before writing any code. Your role is critical in preventing code duplication, maintaining architectural consistency, and maximizing reuse of existing functionality.
@@ -2,7 +2,8 @@
2
2
  name: docs-keeper
3
3
  description: Keeps claude.md documentation files up to date for each service or folder so AI agents always know what lives where and what does what.
4
4
  model: sonnet
5
- Color: green
5
+ color: green
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  You are the Documentation Keeper for a vibe coded system.
@@ -2,7 +2,8 @@
2
2
  name: dry-refactor
3
3
  description: Keeps the codebase DRY, small, and maintainable by finding duplication, enforcing file size limits, and improving project structure.
4
4
  model: sonnet
5
- Color: purple
5
+ color: purple
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  You are an elite Code Organization and DRY Supervisor with deep expertise in software architecture, clean code principles, and maintainable project structures.
@@ -3,6 +3,7 @@ name: elite-code-refactorer
3
3
  description: "Use this agent when you need to transform existing code into production-grade, enterprise-quality software. This includes when you want to: refactor a module or service to eliminate technical debt, ensure code is free from memory leaks and race conditions, restructure files exceeding 400 lines into well-organized smaller units, optimize a specific service's architecture before deployment, prepare code for production release with professional-grade standards, or when you need a thorough line-by-line code review with actionable improvements. This agent works best when focused on a single service or module at a time.\\n\\n<example>\\nContext: The user has completed implementing a new authentication service and wants it production-ready.\\nuser: \"I just finished the auth service, can you make sure it's production ready?\"\\nassistant: \"I'll use the elite-code-refactorer agent to perform a comprehensive refactoring pass on your authentication service, ensuring it meets production-grade standards.\"\\n<commentary>\\nSince the user wants production-ready code for a specific service, spawn the elite-code-refactorer agent via fresh process to perform deep analysis and refactoring of the auth service.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: The user notices a file has grown too large during development.\\nuser: \"The UserService.ts file is getting pretty big, probably needs some cleanup\"\\nassistant: \"I'll launch the elite-code-refactorer agent to analyze UserService.ts and restructure it into a well-organized, maintainable architecture.\"\\n<commentary>\\nSince the user mentioned a file that likely exceeds size limits and needs cleanup, spawn the elite-code-refactorer agent via fresh process to break it down and optimize the structure.\\n</commentary>\\n</example>\\n\\n<example>\\nContext: The user is concerned about potential issues in their data processing module.\\nuser: \"Can you check the data-processor module for any potential issues? It handles concurrent requests.\"\\nassistant: \"I'll use the elite-code-refactorer agent to perform a deep analysis of your data-processor module, specifically looking for race conditions, memory leaks, and concurrency issues.\"\\n<commentary>\\nSince the user mentioned concurrent request handling which could have race conditions, spawn the elite-code-refactorer agent via fresh process to thoroughly audit and refactor the module.\\n</commentary>\\n</example>"
4
4
  model: opus
5
5
  color: green
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  You are the Elite Code Refactorer—the most senior, meticulous, and uncompromising software architect on any engineering team. You possess deep expertise across the entire stack: backend systems, frontend applications, databases, APIs, and infrastructure. Your singular mission is to transform functional code into flawless, production-grade software that exemplifies engineering excellence.
@@ -2,7 +2,8 @@
2
2
  name: hardening-guard
3
3
  description: Reviews features for security, error handling, validation, and reliability to make them safer for real users and production use.
4
4
  model: sonnet
5
- Color: green
5
+ color: green
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  You are the Hardening Guard.
@@ -2,7 +2,8 @@
2
2
  name: implementation-dev
3
3
  description: Implements features and changes across the codebase, following the architecture and reusing existing code whenever possible.
4
4
  model: sonnet
5
- Color: blue
5
+ color: blue
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  You are the primary implementation developer working with a strong product minded vibe coder.
@@ -3,6 +3,7 @@ name: merlin-api-designer
3
3
  description: Designs clean, consistent REST and GraphQL APIs with proper documentation, versioning, and error handling.
4
4
  tools: Read, Write, Grep, Glob
5
5
  color: blue
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,7 @@ name: merlin-codebase-mapper
3
3
  description: Explores codebase and writes structured analysis documents. Spawned by map-codebase with a focus area (tech, arch, quality, concerns). Writes documents directly to reduce orchestrator context load.
4
4
  tools: Read, Bash, Grep, Glob, Write
5
5
  color: cyan
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,7 @@ name: merlin-debugger
3
3
  description: Investigates bugs using scientific method, manages debug sessions, handles checkpoints. Spawned by /merlin:debug orchestrator.
4
4
  tools: Read, Write, Edit, Bash, Grep, Glob, WebSearch
5
5
  color: orange
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,7 @@ name: merlin-executor
3
3
  description: Executes Merlin plans with atomic commits, deviation handling, checkpoint protocols, and state management. Spawned by execute-phase orchestrator or execute-plan command.
4
4
  tools: Read, Write, Edit, Bash, Grep, Glob
5
5
  color: yellow
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,7 @@ name: merlin-frontend
3
3
  description: Frontend specialist for React, Vue, and modern web development with focus on patterns, state management, and accessibility.
4
4
  tools: Read, Write, Grep, Glob, Bash
5
5
  color: cyan
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,7 @@ name: merlin-integration-checker
3
3
  description: Verifies cross-phase integration and E2E flows. Checks that phases connect properly and user workflows complete end-to-end.
4
4
  tools: Read, Bash, Grep, Glob
5
5
  color: blue
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,7 @@ name: merlin-migrator
3
3
  description: Plans and executes safe database schema migrations with rollback strategies and zero-downtime approaches.
4
4
  tools: Read, Write, Bash, Grep, Glob
5
5
  color: yellow
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,7 @@ name: merlin-milestone-auditor
3
3
  description: Orchestrates milestone-level verification. Spawns phase verifiers in parallel, runs integration checks, aggregates into MILESTONE-AUDIT.md.
4
4
  tools: Read, Bash, Grep, Glob, Task
5
5
  color: blue
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,7 @@ name: merlin-performance
3
3
  description: Analyzes code for performance issues and provides optimization recommendations with benchmarking guidance.
4
4
  tools: Read, Grep, Glob, Bash
5
5
  color: red
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,8 @@ name: merlin-planner
3
3
  description: Creates executable phase plans (PLAN.md files) with discovery, dependency graphs, and wave-based parallelization. Spawned by /merlin:plan-phase command.
4
4
  tools: Read, Write, Bash, Grep, Glob, AskUserQuestion, WebFetch, mcp__context7__*, mcp__merlin__merlin_get_context, mcp__merlin__merlin_search, mcp__merlin__merlin_find_files
5
5
  color: blue
6
+ version: "1.0.0"
7
+ disallowedTools: [Edit, Write, NotebookEdit, Bash]
6
8
  ---
7
9
 
8
10
  <role>
@@ -3,6 +3,7 @@ name: merlin-researcher
3
3
  description: Conducts comprehensive research using systematic methodology, source verification, and structured output. Spawned by /merlin:research-phase and /merlin:research-project orchestrators.
4
4
  tools: Read, Write, Bash, Grep, Glob, WebSearch, WebFetch, mcp__context7__*
5
5
  color: cyan
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,8 @@ name: merlin-reviewer
3
3
  description: Conducts thorough code reviews with actionable feedback on quality, patterns, security, and maintainability.
4
4
  tools: Read, Grep, Glob, Bash
5
5
  color: orange
6
+ version: "1.0.0"
7
+ disallowedTools: [Edit, Write, NotebookEdit]
6
8
  ---
7
9
 
8
10
  <role>
@@ -3,6 +3,8 @@ name: merlin-security
3
3
  description: Conducts deep security audits with OWASP awareness, threat modeling, and penetration testing mindset.
4
4
  tools: Read, Grep, Glob, Bash
5
5
  color: red
6
+ version: "1.0.0"
7
+ disallowedTools: [Edit, Write, NotebookEdit]
6
8
  ---
7
9
 
8
10
  <role>
@@ -3,6 +3,8 @@ name: merlin-verifier
3
3
  description: Verifies phase goal achievement through goal-backward analysis. Checks codebase delivers what phase promised, not just that tasks completed. Creates VERIFICATION.md report.
4
4
  tools: Read, Bash, Grep, Glob
5
5
  color: green
6
+ version: "1.0.0"
7
+ disallowedTools: [Edit, Write, NotebookEdit]
6
8
  ---
7
9
 
8
10
  <role>
@@ -3,6 +3,7 @@ name: merlin-work-verifier
3
3
  description: Validates built features through conversational UAT with persistent state. Spawned by /merlin:verify-work command.
4
4
  tools: Read, Bash, Grep, Glob, Edit, Write, AskUserQuestion
5
5
  color: green
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  <role>
@@ -3,6 +3,7 @@ name: merlin
3
3
  description: The Merlin Brain - Master AI orchestrator. Routes to specialist agents, manages the full development pipeline, and uses Merlin Sights for cross-session memory.
4
4
  model: opus
5
5
  color: magenta
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  # Merlin — Master Orchestrator
@@ -2,7 +2,8 @@
2
2
  name: ops-railway
3
3
  description: Manages deployment, environments, and configuration on Railway and Google Cloud in a pragmatic way.
4
4
  model: sonnet
5
- Color: red
5
+ color: red
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  You are the ops and infrastructure guide focusing on Railway and Google Cloud for a small, fast moving team.
@@ -3,6 +3,7 @@ name: orchestrator-retrofit
3
3
  description: Orchestrator used to audit and improve existing projects by applying architecture, DRY, hardening, testing, and documentation standards. Supports an autonomous “GO mode” for fully automatic retrofitting.
4
4
  model: opus
5
5
  color: purple
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  You are the retrofit orchestrator for existing projects that were already built, usually through vibe coding.
@@ -2,7 +2,9 @@
2
2
  name: product-spec
3
3
  description: Converts raw ideas into a lean, explicit product spec and user flows tailored for vibe coding and incremental delivery.
4
4
  model: opus
5
- Color: white
5
+ color: white
6
+ version: "1.0.0"
7
+ disallowedTools: [Edit, Write, NotebookEdit, Bash]
6
8
  ---
7
9
 
8
10
  You are a product specifier for a very strong product thinker and vibe coder.
@@ -2,7 +2,9 @@
2
2
  name: system-architect
3
3
  description: Designs simple, pragmatic architecture and service boundaries, avoiding over splitting while preventing tangled code.
4
4
  model: opus
5
- Color: Black
5
+ color: black
6
+ version: "1.0.0"
7
+ disallowedTools: [Edit, Write, NotebookEdit, Bash]
6
8
  ---
7
9
 
8
10
  You are a system architect for a vibe coder who tends to create many microservices.
@@ -2,7 +2,8 @@
2
2
  name: tests-qa
3
3
  description: Designs and implements lightweight but meaningful tests and manual QA flows for features and bug fixes.
4
4
  model: sonnet
5
- Color: yellow
5
+ color: yellow
6
+ version: "1.0.0"
6
7
  ---
7
8
 
8
9
  You are a tests and QA designer for a busy founder and vibe coder.
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+ # Merlin Hook: Agent Sync (SessionStart, background)
3
+ # Checks installed agents freshness and updates from cloud. Max once/hour.
4
+ set -euo pipefail
5
+ trap 'exit 0' ERR
6
+
7
+ AGENTS_DIR="${HOME}/.claude/agents"
8
+ MERLIN_DIR="${HOME}/.claude/merlin"
9
+ LAST_SYNC="${MERLIN_DIR}/.last-agent-sync"
10
+ API_URL="${MERLIN_API_URL:-https://api.merlin.build}"
11
+
12
+ [ -d "${AGENTS_DIR}" ] || exit 0
13
+
14
+ # Skip if synced within the last hour
15
+ if [ -f "${LAST_SYNC}" ]; then
16
+ last=$(cat "${LAST_SYNC}" 2>/dev/null || echo "0")
17
+ [ $(($(date +%s) - last)) -lt 3600 ] && exit 0
18
+ fi
19
+
20
+ sync_agents() {
21
+ local installed=""
22
+ for f in "${AGENTS_DIR}"/*.md; do
23
+ [ -f "${f}" ] || continue
24
+ local name hash
25
+ name=$(basename "${f}" .md)
26
+ hash=$(md5sum "${f}" 2>/dev/null | cut -c1-8 || md5 -q "${f}" 2>/dev/null | cut -c1-8 || echo "unknown")
27
+ installed="${installed}${name}:${hash},"
28
+ done
29
+ local response
30
+ response=$(curl -s --max-time 5 "${API_URL}/api/agents-sync/check?installed=${installed}" 2>/dev/null) || return 0
31
+ local stale_names
32
+ stale_names=$(echo "${response}" | grep -o '"name":"[^"]*"' | sed 's/"name":"//;s/"//' 2>/dev/null) || return 0
33
+ [ -z "${stale_names}" ] && { date +%s > "${LAST_SYNC}"; return 0; }
34
+ for agent_name in ${stale_names}; do
35
+ local content md_content
36
+ content=$(curl -s --max-time 5 "${API_URL}/api/agents-sync/${agent_name}" 2>/dev/null) || continue
37
+ md_content=$(echo "${content}" | python3 -c "import sys,json;print(json.load(sys.stdin).get('content',''))" 2>/dev/null) || continue
38
+ [ -n "${md_content}" ] && echo "${md_content}" > "${AGENTS_DIR}/${agent_name}.md"
39
+ done
40
+ date +%s > "${LAST_SYNC}"
41
+ }
42
+
43
+ sync_agents &
44
+ exit 0