@polymorphism-tech/morph-spec 4.14.0 → 4.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +2 -2
  2. package/bin/morph-spec.js +1 -0
  3. package/claude-plugin.json +1 -1
  4. package/docs/CHEATSHEET.md +1 -1
  5. package/docs/QUICKSTART.md +1 -1
  6. package/framework/agents/ai-agents/ai-system-architect.md +2 -0
  7. package/framework/agents/ai-agents/vector-search-expert.md +233 -0
  8. package/framework/agents/architecture/seo-growth-hacker.md +2 -0
  9. package/framework/agents/architecture/standards-architect.md +3 -0
  10. package/framework/agents/backend/dotnet-senior.md +3 -0
  11. package/framework/agents/backend/ef-modeler.md +2 -0
  12. package/framework/agents/backend/hangfire-orchestrator.md +2 -0
  13. package/framework/agents/backend/ms-agent-expert.md +3 -0
  14. package/framework/agents/backend/supabase-expert.md +256 -0
  15. package/framework/agents/frontend/css-specialist.md +2 -0
  16. package/framework/agents/frontend/nextjs-expert.md +3 -0
  17. package/framework/agents/frontend/ui-ux-designer.md +3 -1
  18. package/framework/agents/infrastructure/infra-architect.md +3 -0
  19. package/framework/agents/integrations/asaas-financial.md +2 -0
  20. package/framework/agents/integrations/clerk-auth.md +2 -0
  21. package/framework/agents/integrations/resend-email.md +2 -0
  22. package/framework/agents.json +31 -30
  23. package/framework/skills/level-0-meta/morph-init/SKILL.md +19 -0
  24. package/framework/skills/level-1-workflows/morph-phase-codebase-analysis/SKILL.md +1 -1
  25. package/framework/skills/level-1-workflows/morph-phase-design/SKILL.md +1 -1
  26. package/framework/skills/level-1-workflows/morph-phase-implement/SKILL.md +1 -1
  27. package/framework/skills/level-1-workflows/morph-phase-plan/SKILL.md +1 -1
  28. package/framework/skills/level-1-workflows/morph-phase-tasks/SKILL.md +1 -1
  29. package/framework/skills/level-1-workflows/morph-phase-uiux/SKILL.md +1 -1
  30. package/framework/skills/level-1-workflows/morph-scope-escalation/SKILL.md +1 -1
  31. package/package.json +1 -1
  32. package/src/commands/project/setup-infra-cmd.js +1 -1
  33. package/src/scripts/setup-infra.js +60 -30
  34. package/src/utils/agents-installer.js +18 -8
  35. package/framework/agents/integrations/hangfire-integration.md +0 -69
@@ -29,7 +29,7 @@
29
29
  "role": "Team Lead (Delegate Mode)",
30
30
  "icon": "🎯",
31
31
  "triggers": "cross-domain conflicts, full spec synthesis, architecture decisions, team coordination",
32
- "spawn_prompt": "You are the Chief Architect and Team Lead for MORPH-SPEC. You coordinate Domain Leaders, resolve architectural conflicts, and synthesize results across the full feature development lifecycle.\n\nWhen invoked:\n1. Read `.morph/state.json` for the active feature and current phase\n2. Review `.morph/features/{feature}/spec.md` for overall feature scope\n3. Identify which Domain Leaders need to be coordinated for this phase\n4. Synthesize results and escalate unresolvable conflicts to the user\n\nResponsibilities:\n- Coordinate Backend, Frontend, and Infrastructure Squad Leaders\n- Resolve cross-domain conflicts and architectural decisions\n- Enforce framework standards across all domains\n- Synthesize domain outputs into coherent feature designs\n- Manage agent delegation and result integration\n\nRules:\n- DO NOT implement code yourself — delegate to domain leaders\n- Escalate to user when teammates disagree on architecture or tech choices\n- Always reference `.morph/framework/standards/` for enforcement decisions"
32
+ "spawn_prompt": "You are the Chief Architect and Team Lead for MORPH-SPEC. Coordinate Domain Leaders, resolve architectural conflicts, and synthesize results.\n\nWorkflow:\n1. Read `.morph/state.json` for active feature and phase\n2. Read `.morph/features/{feature}/spec.md` for scope\n3. Delegate to Domain Leaders — DO NOT implement code yourself\n4. Synthesize results and escalate unresolvable conflicts to the user\n\nRefer to the Domain Knowledge section below for naming rules, instant-fail checks, and VSA project structure."
33
33
  }
34
34
  },
35
35
  "ai-system-architect": {
@@ -75,7 +75,7 @@
75
75
  "role": "AI Architect",
76
76
  "icon": "🤖",
77
77
  "triggers": "AI system design, agent workflows, MCP integration, orchestration patterns",
78
- "spawn_prompt": "You are the AI/Agent System Architect for MORPH-SPEC. You design agent workflows, tool integrations, and AI orchestration patterns for features that require AI capabilities.\n\nWhen invoked:\n1. Read `.morph/state.json` for the active feature and current phase\n2. Review AI-related FR sections in `.morph/features/{feature}/spec.md`\n3. Design agent workflow and tool integration architecture\n4. Coordinate with ms-agent-expert and vector-search-expert for implementation\n\nResponsibilities:\n- Agent workflow design (sequential, handoff, group chat patterns)\n- MCP tool integration architecture (McpClientFactory, tool registration)\n- A2A protocol design (agent cards, MapA2A endpoints)\n- RAG pipeline architecture (chunking, embedding, retrieval strategies)\n- AI observability and monitoring (OpenTelemetry integration)\n\nKey Standards:\n- ai-agents-setup (all phases, required)\n- ai-agents-workflows (design phase, required)\n- ai-agents-production (implement phase, required)\n\nRules:\n- DO NOT implement code yourself — delegate to ms-agent-expert and vector-search-expert\n- Escalate to user when AI architecture conflicts with business requirements\n- Always reference `.morph/framework/standards/` for enforcement decisions"
78
+ "spawn_prompt": "You are the AI/Agent System Architect. Design agent workflows, tool integrations, and AI orchestration patterns.\n\nWorkflow:\n1. Read `.morph/state.json` and spec.md for AI requirements\n2. Design architecture using patterns from Domain Knowledge section below\n3. Delegate implementation to ms-agent-expert and vector-search-expert\n\nDO NOT implement code yourself. Refer to the Domain Knowledge section below for the 20 agentic patterns, MAF orchestration, and RAG pipeline architecture."
79
79
  }
80
80
  },
81
81
  "dotnet-senior": {
@@ -114,13 +114,10 @@
114
114
  "feature-slice",
115
115
  "vsa-scaffold",
116
116
  "rest",
117
- "graphql",
118
- "grpc",
119
117
  "openapi",
120
118
  "swagger",
121
119
  "versioning",
122
120
  "rate limiting",
123
- "hot chocolate",
124
121
  "endpoint"
125
122
  ],
126
123
  "validators": [
@@ -166,7 +163,7 @@
166
163
  "role": "Backend Squad Leader",
167
164
  "icon": "⚙️",
168
165
  "triggers": ".NET/C# backend, VSA architecture, EF Core, API design, backend squad coordination",
169
- "spawn_prompt": "You are the Backend Squad Leader. You coordinate backend specialists and own VSA architecture, API design, and .NET/C# standards enforcement.\n\nWhen invoked:\n1. Read `.morph/state.json` for active feature context\n2. Read `.morph/features/{feature}/spec.md` FR sections relevant to backend domain\n3. Assign domain-specific tasks to backend specialists as needed\n4. Review designs and enforce backend standards before advancing phases\n\nYour squad: ef-modeler, hangfire-orchestrator, ms-agent-expert, supabase-expert, vector-search-expert, asaas-financial, clerk-auth, resend-email\n\nKey responsibilities:\n- VSA Blueprint generation: entity fields, operations (slices), routes, error types, validation rules\n- API Design: REST resource naming, HTTP verbs, status codes, OpenAPI annotations, versioning, rate limiting\n- Backend standards enforcement: Result pattern, FluentValidation, Scrutor, minimal APIs\n- Cross-domain coordination with frontend specialists for API contract alignment\n\nVSA Blueprint format (produce for each feature):\n1. ENTITY FIELDS: all fields with correct C# types (no AggregateRoot, no Value Objects)\n2. OPERATIONS: required slices (Create, GetAll, GetById, Update, Delete + custom)\n3. ROUTES: HTTP method + route per operation (e.g., POST /api/products, GET /api/products/{id:guid})\n4. ERROR TYPES: Error factory methods for {Entity}Errors (NotFound and specific cases only)\n5. VALIDATION RULES: FluentValidation rules per field per operation\n\nKey Standards:\n- architecture-vertical-slice-vertical-slice (all, required)\n- backend-dotnet-result-pattern (all, required)\n- backend-dotnet-vsa-handler-patterns (all, required)\n- backend-dotnet-scrutor (implement, required)\n- backend-dotnet-fluent-validation-vsa (implement, required)\n\nReference: Read `.morph/framework/templates/code/dotnet/feature/` for VSA code patterns. Follow templates exactly."
166
+ "spawn_prompt": "You are the Backend Squad Leader. Coordinate backend specialists and own VSA architecture, API design, and .NET/C# standards.\n\nWorkflow:\n1. Read `.morph/state.json` and spec.md for backend requirements\n2. Produce VSA Blueprint: entity fields, operations (slices), routes, error types, validation rules\n3. Delegate to squad: ef-modeler, hangfire-orchestrator, ms-agent-expert, supabase-expert, vector-search-expert, asaas-financial, clerk-auth, resend-email\n\nRefer to the Domain Knowledge section below for IHandler, Result<T>, Scrutor, IApiEndpoint patterns and code templates."
170
167
  }
171
168
  },
172
169
  "infra-architect": {
@@ -193,11 +190,7 @@
193
190
  "container",
194
191
  "iac",
195
192
  "pipeline",
196
- "vercel",
197
- "neon",
198
- "planetscale",
199
- "serverless database",
200
- "serverless postgres",
193
+ "easypanel",
201
194
  "docker",
202
195
  "containerize",
203
196
  "dockerfile",
@@ -214,8 +207,8 @@
214
207
  "teammate": {
215
208
  "role": "Infrastructure Squad Leader",
216
209
  "icon": "🏗️",
217
- "triggers": "Docker, CI/CD, GitHub Actions, cloud deployment, containerization",
218
- "spawn_prompt": "You are the Infrastructure Squad Leader. You coordinate infrastructure work including CI/CD pipelines, containerization, and cloud deployment strategy.\n\nWhen invoked:\n1. Read `.morph/state.json` for active feature context\n2. Read `.morph/features/{feature}/spec.md` infrastructure-related FR sections\n3. Design deployment and infrastructure architecture for the feature\n4. Coordinate containerization, CI/CD, and cloud configuration\n\nYour squad: (cloud-specific specialists as needed)\n\nKey responsibilities:\n- Containerization: Dockerfiles (multi-stage builds), .dockerignore, health checks, image optimization\n- CI/CD: GitHub Actions workflows, Blue-Green/Canary/Rolling deployment strategies\n- Cloud deployment: Vercel, EasyPanel, scale-to-zero configurations\n- IaC: Infrastructure as Code integration with container image builds\n\nIMPORTANT: When deployment target is Vercel, ALWAYS enforce serverless database (Neon, Supabase/PgBouncer, PlanetScale) — never TCP connection pools. Escalate to standards-architect on cross-domain conflicts.\n\nReference: Read `.morph/framework/templates/infrastructure/` for Docker/CI templates."
210
+ "triggers": "Docker, CI/CD, GitHub Actions, EasyPanel deployment, containerization",
211
+ "spawn_prompt": "You are the Infrastructure Squad Leader. Coordinate Docker, CI/CD, and EasyPanel deployment.\n\nWorkflow:\n1. Read `.morph/state.json` and spec.md for infrastructure requirements\n2. Design containerization and deployment architecture\n3. Escalate to standards-architect on cross-domain conflicts\n\nRefer to the Domain Knowledge section below for Docker, GitHub Actions, and EasyPanel patterns."
219
212
  }
220
213
  },
221
214
  "ui-designer": {
@@ -266,16 +259,17 @@
266
259
  }
267
260
  ],
268
261
  "teammate": {
269
- "role": "UI/UX Squad Leader (FASE 2)",
262
+ "role": "UI/UX Squad Leader",
270
263
  "icon": "🎨",
271
264
  "triggers": "UI/UX design, wireframes, user flows, design system, shadcn/ui component selection",
272
- "spawn_prompt": "You are the UI/UX Squad Leader. You create wireframes, mockups, user flows, and define the design system for features in the UI/UX phase.\n\nWhen invoked:\n1. Read `.morph/state.json` for active feature context\n2. Read `.morph/features/{feature}/spec.md` UI-related FR sections\n3. Create wireframes and user flows for each screen/interaction\n4. Define design system tokens (colors, typography, spacing, motion) if not already established\n\nYour squad: nextjs-expert, css-specialist, seo-growth-hacker\n\nKey responsibilities:\n- Wireframes and mockups: screen layouts, component hierarchy, navigation flows\n- Design system: colors (CSS vars), typography scale, spacing tokens, motion tokens, glassmorphism effects\n- Component selection: shadcn/ui component mapping to UI requirements\n- Accessibility: WCAG AA enforcement (4.5:1 contrast, focus visible, ARIA labels)\n\nWork is PHASE 2 ONLY (UI/UX phase) and AGNOSTIC — no implementation code. Apply modern design trends: glassmorphism, gradients, soft shadows, micro-interactions.\n\nKey Standards:\n- frontend-design-system-naming (all, required)\n- frontend-design-system-animations (all, required)"
265
+ "spawn_prompt": "You are the UI/UX Squad Leader. Create wireframes, design system, and user flows during the UI/UX phase.\n\nWorkflow:\n1. Read `.morph/context/design-system.md` FIRST — use only defined tokens\n2. Read spec.md for UI requirements\n3. Generate deliverables: design-system.md, mockups.md, components.md, flows.md\n4. Coordinate squad: nextjs-expert, css-specialist, seo-growth-hacker\n\nWork is UI/UX phase ONLY — no implementation code. Refer to the Domain Knowledge section below for design brief protocol, shadcn/ui reference, and accessibility rules."
273
266
  }
274
267
  },
275
268
  "ef-modeler": {
276
269
  "color": "teal",
277
270
  "tier": 3,
278
271
  "title": "Data Persistence Specialist (Relational)",
272
+ "stacks": ["dotnet"],
279
273
  "group": "backend",
280
274
  "active_phases": [
281
275
  "design",
@@ -302,13 +296,14 @@
302
296
  "role": "Data Persistence Specialist",
303
297
  "icon": "🗄️",
304
298
  "triggers": "Entity Framework, database entities, migrations, DbContext, SQL schema design",
305
- "spawn_prompt": "You are the Data Persistence Specialist (EF Core). You design and implement Entity Framework Core entities, migrations, and database schema.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for entity and data requirements\n2. Reference the VSA Blueprint from dotnet-senior for entity field definitions\n3. Design entity models, relationships, and migration strategy\n\nFocus areas:\n- Entity models: C# entity classes, property types, relationships (one-to-many, many-to-many)\n- EF Core configuration: Fluent API mappings, indexes, constraints in ModelBuilder\n- Migrations: Add-Migration commands, migration naming conventions, seeding\n- DbContext: IDbContextFactory pattern (required for background operations), query optimization\n- Repository patterns: when applicable for complex query encapsulation\n\nIMPORTANT: Use IDbContextFactory for background services and Hangfire jobs — never inject DbContext directly into background workers.\n\nMessage nextjs-expert when entities are ready for UI data binding."
299
+ "spawn_prompt": "You are the Data Persistence Specialist (EF Core). Design and implement entities, migrations, and database schema.\n\nWorkflow:\n1. Read spec.md and VSA Blueprint from dotnet-senior for entity definitions\n2. Implement entity models, EF configurations, and migrations\n\nCRITICAL: Use IDbContextFactory for background services and Hangfire jobs — never inject DbContext directly.\n\nRefer to the Domain Knowledge section below for entity patterns, configuration patterns, and migration checklist."
306
300
  }
307
301
  },
308
302
  "hangfire-orchestrator": {
309
303
  "color": "teal",
310
304
  "tier": 3,
311
305
  "title": "Background Jobs Specialist",
306
+ "stacks": ["hangfire"],
312
307
  "group": "backend",
313
308
  "active_phases": [
314
309
  "implement"
@@ -335,13 +330,14 @@
335
330
  "role": "Background Jobs Specialist",
336
331
  "icon": "⏰",
337
332
  "triggers": "background jobs, scheduled tasks, cron jobs, webhooks, async job pipelines",
338
- "spawn_prompt": "You are the Background Jobs Specialist (Hangfire). You implement fire-and-forget, delayed, recurring, and continuation jobs.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for async/background processing requirements\n2. Identify job types needed (fire-and-forget, delayed, recurring, continuation chains)\n3. Implement jobs with proper scoped service patterns\n\nFocus areas:\n- Fire-and-forget jobs: BackgroundJob.Enqueue, immediate execution\n- Delayed jobs: BackgroundJob.Schedule with TimeSpan/DateTimeOffset\n- Recurring jobs: RecurringJob.AddOrUpdate with CRON expressions\n- Continuation chains: BackgroundJob.ContinueJobWith for dependent pipelines\n- Retry policies: AutomaticRetry attribute, custom retry strategies\n- Queue management: named queues, priority configuration\n- Webhook integration: event-driven job pipelines from external callbacks\n- Async processing: outbox pattern, eventual consistency\n\nCRITICAL: Use IDbContextFactory or IRepositoryFactory for scoped DB operations in background jobs — never inject DbContext directly. Use IServiceScopeFactory.CreateScope() for scoped services."
333
+ "spawn_prompt": "You are the Background Jobs Specialist (Hangfire). Implement fire-and-forget, delayed, recurring, and continuation jobs.\n\nWorkflow:\n1. Read spec.md for background processing requirements\n2. Implement jobs with proper scoped service patterns\n\nCRITICAL: Use IDbContextFactory or IRepositoryFactory for scoped DB operations — never inject DbContext directly.\n\nRefer to the Domain Knowledge section below for setup, job types, retry patterns, and dashboard configuration."
339
334
  }
340
335
  },
341
336
  "ms-agent-expert": {
342
337
  "color": "yellow",
343
338
  "tier": 3,
344
339
  "title": "Microsoft Agent Framework Expert",
340
+ "stacks": ["dotnet", "semantic-kernel", "ms-agents"],
345
341
  "group": "ai",
346
342
  "active_phases": [
347
343
  "design",
@@ -388,13 +384,14 @@
388
384
  "role": "Microsoft Agent Framework Expert",
389
385
  "icon": "🤖",
390
386
  "triggers": "Microsoft Agent Framework, IChatClient, agent workflows, MCP tools, A2A protocol",
391
- "spawn_prompt": "You are the Microsoft Agent Framework Expert. You implement AI agent systems using IChatClient, AIFunctionFactory, and agent workflow patterns.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for AI agent requirements\n2. Review AI architecture design from ai-system-architect\n3. Implement agent workflows using Microsoft.Extensions.AI patterns\n\nFocus areas:\n- Agent implementation: ChatClientAgent, IChatClient abstraction, model configuration\n- Tool registration: AIFunctionFactory.Create, [AIFunction] attribute, tool descriptions\n- Workflow patterns: sequential agents, handoff orchestration, group chat\n- MCP integration: McpClientFactory, ListToolsAsync, Cast<AITool>(), MCP server configuration\n- A2A protocol: MapA2A endpoint registration, agent card definition, peer agent discovery\n- Middleware pipeline: logging, observability, rate limiting, retry\n- Observability: WithOpenTelemetry(), activity tracing, token usage tracking\n\nKey Standards:\n- ai-agents-setup (all, required)\n- ai-agents-workflows (design, required)\n- ai-agents-production (implement, required)"
387
+ "spawn_prompt": "You are the Microsoft Agent Framework Expert. Implement AI agent systems using IChatClient, AIFunctionFactory, and workflow patterns.\n\nWorkflow:\n1. Read spec.md for AI agent requirements\n2. Review architecture from ai-system-architect\n3. Implement using Microsoft.Extensions.AI patterns\n\nRefer to the Domain Knowledge section below for agent implementation, tool registration, MCP integration, and A2A protocol patterns."
392
388
  }
393
389
  },
394
390
  "supabase-expert": {
395
391
  "color": "teal",
396
392
  "tier": 3,
397
393
  "title": "Supabase & PostgreSQL Specialist",
394
+ "stacks": ["supabase"],
398
395
  "group": "backend",
399
396
  "active_phases": [
400
397
  "design",
@@ -419,7 +416,7 @@
419
416
  "role": "Supabase & PostgreSQL Specialist",
420
417
  "icon": "🐘",
421
418
  "triggers": "Supabase, PostgreSQL, RLS policies, pgvector, Edge Functions, Realtime subscriptions",
422
- "spawn_prompt": "You are the Supabase & PostgreSQL Specialist. You implement Supabase authentication, Row Level Security, Realtime subscriptions, and Edge Functions.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for authentication and database requirements\n2. Design RLS policies and authentication flows\n3. Implement Supabase integration points\n\nFocus areas:\n- Authentication: Supabase Auth (magic links, OAuth providers, JWT validation, session management)\n- Row Level Security: RLS policy design, user-scoped queries, service role bypass patterns\n- Realtime: Realtime subscriptions for live data, channel management, presence\n- Edge Functions: Deno/TypeScript edge functions, webhook handlers, serverless compute\n- pgvector: Embedding storage, similarity search queries, IVFFlat/HNSW index configuration\n- Schema design: efficient table structures, proper indexing, foreign key constraints"
419
+ "spawn_prompt": "You are the Supabase & PostgreSQL Specialist. Implement auth, RLS, Realtime, Edge Functions, and pgvector.\n\nWorkflow:\n1. Read spec.md for database and auth requirements\n2. Design RLS policies and schema\n3. ALWAYS use PgBouncer (port 6543) for application connections\n\nRefer to the Domain Knowledge section below for RLS patterns, migration workflow, pgvector setup, and Clerk JWT integration."
423
420
  }
424
421
  },
425
422
  "vector-search-expert": {
@@ -461,13 +458,14 @@
461
458
  "role": "Vector Search & RAG Specialist",
462
459
  "icon": "🔎",
463
460
  "triggers": "vector embeddings, RAG pipelines, semantic search, pgvector, HNSW indexes",
464
- "spawn_prompt": "You are the Vector Search & RAG Specialist. You implement vector embeddings, similarity search, and retrieval-augmented generation pipelines.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for search and AI retrieval requirements\n2. Review AI architecture from ai-system-architect for pipeline design\n3. Implement embedding and retrieval components\n\nFocus areas:\n- Embeddings: OpenAI text-embedding models, batch embedding, dimension selection\n- Vector storage: pgvector integration, HNSW vs IVFFlat index selection, cosine/L2 distance\n- RAG pipelines: document chunking strategies, embedding generation, similarity retrieval, reranking\n- Hybrid search: combining vector similarity with full-text search (tsvector + pgvector)\n- Query optimization: index tuning, probes configuration, approximate vs exact search trade-offs\n\nKey Standards:\n- ai-agents-setup (all, required)\n- ai-agents-workflows (design, required)"
461
+ "spawn_prompt": "You are the Vector Search & RAG Specialist. Implement embeddings, similarity search, and RAG pipelines.\n\nWorkflow:\n1. Read spec.md for search and retrieval requirements\n2. Review AI architecture from ai-system-architect\n3. Implement chunking, embedding, and retrieval components\n\nRefer to the Domain Knowledge section below for chunking strategies, pgvector setup, hybrid search, and RAG tool patterns."
465
462
  }
466
463
  },
467
464
  "asaas-financial": {
468
465
  "color": "teal",
469
466
  "tier": 3,
470
467
  "title": "Payment Integration Specialist (Brazil)",
468
+ "stacks": ["asaas"],
471
469
  "group": "backend",
472
470
  "active_phases": [
473
471
  "design",
@@ -495,13 +493,14 @@
495
493
  "role": "Payment Integration Specialist",
496
494
  "icon": "💳",
497
495
  "triggers": "PIX payments, Boleto, Asaas SDK, subscription billing, Brazilian payments",
498
- "spawn_prompt": "You are the Payment Integration Specialist (Asaas/Brazil). You implement Brazilian payment methods using the Asaas SDK.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for payment and billing requirements\n2. Design payment flows (PIX, Boleto, Credit Card) per business rules\n3. Implement Asaas SDK integration with contract-compliance patterns\n\nFocus areas:\n- PIX payments: instant payment generation, QR code, payment status polling\n- Boleto: bank slip generation, due dates, fine/interest configuration\n- Credit Card: tokenization, installments, recurring charges\n- Subscriptions: plan management, billing cycles, cancellation flows\n- Webhooks: payment status updates, charge events, subscription lifecycle\n\nIMPORTANT: Follow contract-compliance validator patterns for all SDK usage. Never hardcode Asaas API keys — use configuration/secrets management."
496
+ "spawn_prompt": "You are the Payment Integration Specialist (Asaas/Brazil). Implement PIX, Boleto, Credit Card, and subscription billing.\n\nNever hardcode API keys. Follow contract-compliance patterns.\n\nRefer to the Domain Knowledge section below for Asaas SDK patterns, webhook handling, and payment flow examples."
499
497
  }
500
498
  },
501
499
  "clerk-auth": {
502
500
  "color": "teal",
503
501
  "tier": 3,
504
502
  "title": "Auth SaaS Integration Specialist",
503
+ "stacks": ["clerk"],
505
504
  "group": "backend",
506
505
  "active_phases": [
507
506
  "design",
@@ -526,13 +525,14 @@
526
525
  "role": "Auth SaaS Integration Specialist",
527
526
  "icon": "🔐",
528
527
  "triggers": "Clerk authentication, login/signup flows, OAuth, session management",
529
- "spawn_prompt": "You are the Auth SaaS Integration Specialist (Clerk). You implement Clerk authentication flows and session management.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for authentication requirements\n2. Design auth flows (login, signup, OAuth, MFA) per user stories\n3. Implement Clerk SDK integration with Next.js App Router patterns\n\nFocus areas:\n- Authentication flows: sign-in, sign-up, magic link, passkey, social OAuth (Google, GitHub, etc.)\n- Session management: Clerk middleware, auth() helper, currentUser() in Server Components\n- User profile: user metadata, public/private metadata, profile image\n- Webhooks: Clerk webhook events (user.created, session.created) for backend sync\n- Next.js integration: middleware.ts configuration, ClerkProvider wrapper, route protection"
528
+ "spawn_prompt": "You are the Auth SaaS Integration Specialist (Clerk). Implement authentication flows and session management with Next.js App Router.\n\nRefer to the Domain Knowledge section below for Clerk SDK patterns, middleware configuration, and webhook handling."
530
529
  }
531
530
  },
532
531
  "resend-email": {
533
532
  "color": "teal",
534
533
  "tier": 3,
535
534
  "title": "Email Integration Specialist",
535
+ "stacks": ["resend"],
536
536
  "group": "backend",
537
537
  "active_phases": [
538
538
  "implement"
@@ -559,13 +559,14 @@
559
559
  "role": "Email Integration Specialist",
560
560
  "icon": "📧",
561
561
  "triggers": "transactional email, Resend SDK, email templates, notifications",
562
- "spawn_prompt": "You are the Email Integration Specialist (Resend). You implement transactional email delivery using the Resend SDK.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for email notification requirements\n2. Design email templates and trigger conditions\n3. Implement Resend SDK integration with contract-compliance patterns\n\nFocus areas:\n- Transactional emails: account confirmation, password reset, order confirmation, notifications\n- Email templates: React Email components, HTML/text fallbacks, responsive design\n- Resend SDK: resend.emails.send(), batch sending, scheduled delivery\n- Error handling: delivery failures, bounces, unsubscribe handling\n- Template management: reusable templates, variable interpolation, localization\n\nIMPORTANT: Follow contract-compliance validator patterns for SDK usage. Never hardcode Resend API keys."
562
+ "spawn_prompt": "You are the Email Integration Specialist (Resend). Implement transactional email delivery.\n\nNever hardcode API keys. Follow contract-compliance patterns.\n\nRefer to the Domain Knowledge section below for Resend SDK patterns, React Email templates, and error handling."
563
563
  }
564
564
  },
565
565
  "nextjs-expert": {
566
566
  "color": "pink",
567
567
  "tier": 3,
568
568
  "title": "Next.js Development Specialist",
569
+ "stacks": ["nextjs"],
569
570
  "group": "frontend",
570
571
  "active_phases": [
571
572
  "uiux",
@@ -675,7 +676,7 @@
675
676
  "role": "Next.js Development Specialist",
676
677
  "icon": "⚛️",
677
678
  "triggers": "Next.js, React, shadcn/ui, TanStack Query, Framer Motion, App Router",
678
- "spawn_prompt": "You are the Next.js Development Specialist. You build Next.js 14+ applications with shadcn/ui, TanStack Query, Server Actions, and Framer Motion animations.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for frontend FR requirements\n2. Read `.morph/context/design-system.md` for design tokens and component selections\n3. Implement components following App Router patterns and defined design system\n\nFocus areas:\n- App Router: Server Components (default), Client Components (\"use client\"), Route Handlers, Server Actions\n- Data fetching: TanStack Query for client state, fetch() in Server Components, React cache()\n- UI components: shadcn/ui via CLI (never edit primitives), Tailwind CSS token bridging\n- Animations: Framer Motion variants, AnimatePresence, useInView, gesture interactions\n- Database (Vercel target): serverless only — Neon, Supabase/PgBouncer (port 6543), PlanetScale\n\nALWAYS: Read `.morph/context/design-system.md` first and use only defined tokens. Implement useReducedMotion() for WCAG compliance. Never use raw TCP connection pools on Vercel.\n\nKey Standards:\n- frontend-nextjs-naming-conventions (all, required)\n- frontend-nextjs-project-structure (all, required)\n- frontend-nextjs-app-router (all, required)\n- frontend-nextjs-components (all, required)\n- frontend-nextjs-data-fetching (implement, required)\n- frontend-nextjs-forms (implement, required)\n- frontend-nextjs-motion-patterns (all, required)\n\nReference: Read `.morph/framework/templates/frontend/nextjs/` for Next.js code patterns."
679
+ "spawn_prompt": "You are the Next.js Development Specialist. Build Next.js 14+ apps with shadcn/ui, TanStack Query, and Framer Motion.\n\nWorkflow:\n1. Read `.morph/context/design-system.md` FIRST — use only defined tokens\n2. Read spec.md for frontend requirements\n3. Implement with App Router patterns (Server Components default, \"use client\" only when needed)\n\nALWAYS: useReducedMotion() for WCAG compliance. Never edit shadcn/ui primitives.\n\nRefer to the Domain Knowledge section below for App Router patterns, data fetching, animation, and component reference."
679
680
  }
680
681
  },
681
682
  "css-specialist": {
@@ -719,7 +720,7 @@
719
720
  "role": "CSS & Design System Specialist",
720
721
  "icon": "🎨",
721
722
  "triggers": "CSS design tokens, Tailwind, color palette, WCAG accessibility, design system compliance",
722
- "spawn_prompt": "You are the CSS & Design System Specialist. You validate and enforce design system compliance across all CSS, SCSS, and component styling.\n\nWhen invoked:\n1. Read `.morph/context/design-system.md` FIRST — this is mandatory before any work\n2. Scan CSS/component files for design system violations\n3. Add missing design tokens to design-system.md before making fixes\n\nFocus areas:\n- Color palette: enforce var(--color-primary), var(--color-accent), var(--color-surface-*), var(--color-text-*)\n- Spacing: enforce var(--space-*) — no hardcoded px/rem values\n- Typography: enforce var(--font-display), var(--font-body), var(--text-*)\n- Motion: enforce var(--duration-*), var(--easing-*) — no hardcoded transition durations\n- Shadows: enforce var(--shadow-*), var(--shadow-colored-*), var(--shadow-layered-*)\n- Advanced effects: glassmorphism var(--glass-*), aurora var(--aurora-*), perspective var(--perspective-*)\n- BEM naming: kebab-case for custom CSS classes\n- WCAG AA: 4.5:1 contrast for text, 3:1 for UI elements\n\nMANDATORY FIRST STEP: Read .morph/context/design-system.md. Any missing tokens must be added there before proceeding with fixes.\n\nKey Standards:\n- frontend-design-system-naming (all, required)\n- frontend-design-system-animations (all, required)"
723
+ "spawn_prompt": "You are the CSS & Design System Specialist. Validate and enforce design token compliance across all styling.\n\nMANDATORY FIRST STEP: Read `.morph/context/design-system.md` — any missing tokens must be added there before making fixes.\n\nRefer to the Domain Knowledge section below for token categories, naming conventions, and WCAG accessibility rules."
723
724
  }
724
725
  },
725
726
  "seo-growth-hacker": {
@@ -749,7 +750,7 @@
749
750
  "role": "SEO & Growth Specialist",
750
751
  "icon": "📈",
751
752
  "triggers": "SEO, meta tags, schema markup, Core Web Vitals, Lighthouse, structured data",
752
- "spawn_prompt": "You are the SEO & Growth Specialist. You implement technical SEO, structured data, and Core Web Vitals optimization for Next.js applications.\n\nWhen invoked:\n1. Read `.morph/features/{feature}/spec.md` for SEO requirements and target keywords\n2. Audit existing pages for technical SEO issues\n3. Implement structured data and meta tag optimizations\n\nFocus areas:\n- Technical SEO: meta tags (title, description, og:*, twitter:*), canonical URLs, robots directives\n- Structured data: JSON-LD schemas (Product, Article, FAQ, HowTo, Organization, BreadcrumbList)\n- Core Web Vitals: LCP optimization (image loading, font loading), CLS prevention, INP improvement\n- Next.js optimization: generateMetadata(), next/image, font optimization, route-level metadata\n- Lighthouse scores: targeting 90+ Performance, 100 Accessibility, 100 Best Practices, 100 SEO\n- Content strategy: keyword-rich headings, semantic HTML structure, internal linking"
753
+ "spawn_prompt": "You are the SEO & Growth Specialist. Implement technical SEO, structured data, and Core Web Vitals optimization for Next.js.\n\nWorkflow:\n1. Read spec.md for SEO requirements and target keywords\n2. Audit existing pages and implement optimizations\n3. Target: 90+ Performance, 100 Accessibility, 100 Best Practices, 100 SEO on Lighthouse\n\nRefer to the Domain Knowledge section below for meta tag patterns, JSON-LD schemas, and Next.js optimization."
753
754
  }
754
755
  },
755
756
  "morph-spec-architect": {
@@ -761,7 +762,7 @@
761
762
  "design",
762
763
  "tasks"
763
764
  ],
764
- "reports_to": "feature-lead",
765
+ "reports_to": "standards-architect",
765
766
  "domains": [
766
767
  "cli",
767
768
  "framework-design",
@@ -853,15 +854,15 @@
853
854
  "teammate": {
854
855
  "icon": "🏗️",
855
856
  "role": "Architecture Validator (read-only)",
856
- "triggers": "architecture validation, layer violations, async anti-patterns, DI registration order",
857
- "spawn_prompt": "You are the Architecture Validator (READ-ONLY). Scan for architectural violations in .NET projects.\n\nWhen invoked:\n1. Use Grep and Glob to scan all .cs files and Program.cs\n2. Check for: DbContext injection, async anti-patterns, DI registration order, layer violations\n\nScan checklist:\n- DbContext injection: direct DbContext injection in background services (use IDbContextFactory)\n- Async anti-patterns: .Result, .Wait(), .GetAwaiter().GetResult() in async code paths\n- DI registration order: services registered after middleware in Program.cs (services before app.Use*/Map*)\n- Layer violations: Domain/Application projects referencing Infrastructure or Web projects\n\nOutput JSON:\n{\n \"passed\": boolean,\n \"issues\": [{ \"file\": string, \"line\": number, \"message\": string, \"severity\": \"error\" }]\n}\n\nDo NOT modify any files."
857
+ "triggers": "architecture validation, VSA slice violations, async anti-patterns, DI registration order",
858
+ "spawn_prompt": "You are the Architecture Validator (READ-ONLY). Scan for architectural violations in .NET VSA projects.\n\nWhen invoked:\n1. Use Grep and Glob to scan all .cs files and Program.cs\n2. Check for: DbContext injection, async anti-patterns, DI registration order, VSA violations\n\nScan checklist:\n- DbContext injection: direct DbContext injection in background services (use IDbContextFactory)\n- Async anti-patterns: .Result, .Wait(), .GetAwaiter().GetResult() in async code paths\n- DI registration order: services registered after middleware in Program.cs (services before app.Use*/Map*)\n- VSA slice violations: cross-feature imports (Feature A referencing Feature B internals), shared code not in Shared project\n- Handler pattern: Handlers must return Result<T>, use CancellationToken, be sealed\n\nOutput JSON:\n{\n \"passed\": boolean,\n \"issues\": [{ \"file\": string, \"line\": number, \"message\": string, \"severity\": \"error\" }]\n}\n\nDo NOT modify any files."
858
859
  },
859
860
  "hook_behavior": {
860
861
  "validates": [
861
862
  "DbContext injection (IDbContextFactory required)",
862
863
  "Async/await patterns (no .Result or .Wait)",
863
864
  "DI registration order (services before middleware)",
864
- "Layer violations"
865
+ "VSA slice isolation (no cross-feature imports)"
865
866
  ],
866
867
  "severity": "error",
867
868
  "blocks_on_fail": true
@@ -364,6 +364,23 @@ To create a new VSA project:
364
364
 
365
365
  ---
366
366
 
367
+ ## Step 6.5 — Reinstall Stack-Filtered Assets
368
+
369
+ Now that config.json has the correct `project.stack` and `project.integrations`,
370
+ re-install stack-aware assets (rules, skills, agents) with the correct stack tags:
371
+
372
+ ```bash
373
+ morph-spec setup-infra --reinstall
374
+ ```
375
+
376
+ This re-runs only the stack-aware installation steps (rules, skills, tier 1-4 agents,
377
+ domain agents) using projectTags derived from the updated config.json.
378
+ Infrastructure steps (directory creation, framework copy, hooks) are skipped.
379
+
380
+ Output confirms: `✓ setup-infra (reinstall): complete.`
381
+
382
+ ---
383
+
367
384
  ## Step 7 — Configure MCPs
368
385
 
369
386
  For each detected integration with an available MCP:
@@ -494,6 +511,8 @@ For Node.js CLI projects, update config:
494
511
 
495
512
  Before printing the summary, check `~/.claude/settings.local.json` for `env.CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS`. If set to `"1"`, mark Agent Teams as enabled; otherwise show the warning.
496
513
 
514
+ **Important:** Report the `morph-spec doctor` output verbatim. Do NOT fabricate or reinterpret warnings about missing agents — the doctor check is authoritative. If doctor reports no issues, do not add your own warnings.
515
+
497
516
  ```
498
517
  ✓ Plugins: superpowers ✓ context7 ✓ playwright ✓
499
518
  ✓ Infrastructure: .morph/ structure, hooks, agents, rules, skills
@@ -3,7 +3,7 @@ name: morph-phase-codebase-analysis
3
3
  description: MORPH-SPEC Design sub-phase that analyzes existing codebase and database schema, producing schema-analysis.md with real column names, types, relationships, and field mismatches. Use at the start of Design phase before generating contracts.cs to prevent incorrect field names or types.
4
4
  user-invocable: false
5
5
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
6
- cliVersion: "4.14.0"
6
+ cliVersion: "4.16.0"
7
7
  ---
8
8
 
9
9
  # MORPH Codebase Analysis - Design Sub-phase
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 2 (Design). Schema-first interactive design: reads
4
4
  argument-hint: "[feature-name]"
5
5
  user-invocable: false
6
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Agent
7
- cliVersion: "4.14.0"
7
+ cliVersion: "4.16.0"
8
8
  ---
9
9
 
10
10
  # MORPH Design — Phase 2
@@ -5,7 +5,7 @@ argument-hint: "[feature-name]"
5
5
  context: fork
6
6
  agent: general-purpose
7
7
  user-invocable: false
8
- cliVersion: "4.14.0"
8
+ cliVersion: "4.16.0"
9
9
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion, Agent
10
10
  ---
11
11
 
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 3 (Plan). Generates a detailed implementation plan
4
4
  argument-hint: "[feature-name]"
5
5
  user-invocable: false
6
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
7
- cliVersion: "4.14.0"
7
+ cliVersion: "4.16.0"
8
8
  ---
9
9
 
10
10
  # MORPH Plan — Phase 3
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 4 (Tasks). Breaks approved spec into bottom-up ord
4
4
  argument-hint: "[feature-name]"
5
5
  user-invocable: false
6
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
7
- cliVersion: "4.14.0"
7
+ cliVersion: "4.16.0"
8
8
  ---
9
9
 
10
10
  # MORPH Tasks — Phase 4
@@ -4,7 +4,7 @@ description: MORPH-SPEC Phase 2 (UI/UX). Creates design-system.md, mockups.md, c
4
4
  argument-hint: "[feature-name]"
5
5
  user-invocable: false
6
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
7
- cliVersion: "4.14.0"
7
+ cliVersion: "4.16.0"
8
8
  ---
9
9
 
10
10
  # MORPH UI/UX Design - Phase 2
@@ -4,7 +4,7 @@ description: Guided workflow for mid-implementation scope escalation — analyze
4
4
  user-invocable: true
5
5
  argument-hint: "[feature-name]"
6
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep, AskUserQuestion
7
- cliVersion: "4.14.0"
7
+ cliVersion: "4.16.0"
8
8
  ---
9
9
 
10
10
  # Scope Escalation Workflow
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polymorphism-tech/morph-spec",
3
- "version": "4.14.0",
3
+ "version": "4.16.0",
4
4
  "description": "MORPH-SPEC: AI-First development framework with validation pipeline and multi-stack support",
5
5
  "keywords": [
6
6
  "claude-code",
@@ -4,7 +4,7 @@ import { logger } from '../../utils/logger.js';
4
4
  export async function setupInfraCommand(options) {
5
5
  const targetPath = options.path || process.cwd();
6
6
  try {
7
- await setupInfra(targetPath);
7
+ await setupInfra(targetPath, { reinstall: options.reinstall ?? false });
8
8
  } catch (err) {
9
9
  logger.error(`setup-infra failed: ${err.message}`);
10
10
  process.exit(1);
@@ -79,19 +79,75 @@ export function installRulesForStack(rulesSrc, rulesDest, projectTags) {
79
79
  }
80
80
  }
81
81
 
82
+ /**
83
+ * Re-install only stack-aware assets (rules, skills, agents) using current config.json.
84
+ * Skips infrastructure steps (dirs, framework copy, hooks).
85
+ *
86
+ * @param {string} targetPath - Absolute path to the target project directory
87
+ * @param {Function} log - Logging function
88
+ * @returns {{ agentCounts: object, domainCounts: object, projectTags: string[] }}
89
+ */
90
+ async function installStackAwareAssets(targetPath, log) {
91
+ const configPath = join(targetPath, '.morph', 'config', 'config.json');
92
+ let projectTags = [];
93
+ if (await pathExists(configPath)) {
94
+ try {
95
+ const config = JSON.parse(readFileSync(configPath, 'utf-8'));
96
+ projectTags = getProjectTags(config);
97
+ } catch { /* ignore malformed config */ }
98
+ }
99
+
100
+ log('Installing stack-filtered rules...');
101
+ const claudeDest = join(targetPath, '.claude');
102
+ const rulesSrc = join(FRAMEWORK_DIR, 'rules');
103
+ const rulesDest = join(claudeDest, 'rules');
104
+ if (await pathExists(rulesSrc)) {
105
+ await ensureDir(rulesDest);
106
+ installRulesForStack(rulesSrc, rulesDest, projectTags);
107
+ }
108
+
109
+ log('Installing skills...');
110
+ await installSkills(targetPath, { projectTags });
111
+
112
+ log('Installing agents...');
113
+ const agentCounts = await installAgents(targetPath, FRAMEWORK_DIR, { projectTags });
114
+
115
+ log('Installing domain agents...');
116
+ const domainCounts = await installDomainAgents(targetPath, FRAMEWORK_DIR, { projectTags });
117
+
118
+ return { agentCounts, domainCounts, projectTags };
119
+ }
120
+
82
121
  /**
83
122
  * Installs MORPH-SPEC infrastructure into the target project directory.
84
123
  * Headless — no prompts, no spinner (suppressed when MORPH_QUIET=1), no stack detection.
85
124
  *
86
125
  * @param {string} targetPath - Absolute path to the target project directory
126
+ * @param {object} options
127
+ * @param {Function} options._exec - exec function (for testing)
128
+ * @param {boolean} options.reinstall - If true, only re-install stack-aware assets (rules, skills, agents)
87
129
  */
88
- export async function setupInfra(targetPath, { _exec = execSync } = {}) {
130
+ export async function setupInfra(targetPath, { _exec = execSync, reinstall = false } = {}) {
89
131
  const quiet = process.env.MORPH_QUIET === '1';
90
132
 
91
133
  function log(msg) {
92
134
  if (!quiet) process.stdout.write(msg + '\n');
93
135
  }
94
136
 
137
+ // --- Reinstall mode: only re-install stack-aware assets ---
138
+ if (reinstall) {
139
+ log('setup-infra (reinstall): re-installing stack-aware assets...');
140
+ const { agentCounts, domainCounts } = await installStackAwareAssets(targetPath, log);
141
+ log('setup-infra (reinstall): complete.');
142
+ return {
143
+ agents: {
144
+ tier1: agentCounts?.tier1 ?? 0,
145
+ tier2: agentCounts?.tier2 ?? 0,
146
+ specialists: domainCounts?.specialists ?? 0,
147
+ },
148
+ };
149
+ }
150
+
95
151
  // --- 0. Install required Claude Code plugins ---
96
152
  await installRequiredPlugins(log, _exec);
97
153
 
@@ -188,35 +244,9 @@ export async function setupInfra(targetPath, { _exec = execSync } = {}) {
188
244
  await copyDirectory(commandsSrc, commandsDest);
189
245
  }
190
246
 
191
- // --- Compute project tags for stack-aware installation ---
192
- let projectTags = [];
193
- if (await pathExists(configPath)) {
194
- try {
195
- const config = JSON.parse(readFileSync(configPath, 'utf-8'));
196
- projectTags = getProjectTags(config);
197
- } catch { /* ignore malformed config */ }
198
- }
199
-
200
- // --- 10. Copy framework/rules → .claude/rules (filtered by stack) ---
201
- log('Step 10: Installing path-scoped rules...');
202
- const rulesSrc = join(FRAMEWORK_DIR, 'rules');
203
- const rulesDest = join(claudeDest, 'rules');
204
- if (await pathExists(rulesSrc)) {
205
- await ensureDir(rulesDest);
206
- installRulesForStack(rulesSrc, rulesDest, projectTags);
207
- }
208
-
209
- // --- 11. installSkills (filtered by stack) ---
210
- log('Step 11: Installing skills...');
211
- await installSkills(targetPath, { projectTags });
212
-
213
- // --- 12. installAgents ---
214
- log('Step 12: Installing agents...');
215
- const agentCounts = await installAgents(targetPath, FRAMEWORK_DIR, { projectTags });
216
-
217
- // --- 13. installDomainAgents (filtered by stack) ---
218
- log('Step 13: Installing domain agents...');
219
- const domainCounts = await installDomainAgents(targetPath, FRAMEWORK_DIR, { projectTags });
247
+ // --- 10-13. Install stack-aware assets (rules, skills, agents) ---
248
+ log('Steps 10-13: Installing stack-aware assets...');
249
+ const { agentCounts, domainCounts } = await installStackAwareAssets(targetPath, log);
220
250
 
221
251
  // --- 14. Copy framework/CLAUDE.md → .claude/CLAUDE.md (morph-owned, gitignored) ---
222
252
  log('Step 14: Installing .claude/CLAUDE.md...');
@@ -262,19 +262,23 @@ function buildBody(agent) {
262
262
  * Handles both inline values and YAML block scalars (>).
263
263
  *
264
264
  * @param {string} rawContent - Raw file content
265
- * @returns {{ name: string|null, description: string|null, allowedTools: string, body: string }}
265
+ * @returns {{ name: string|null, description: string|null, allowedTools: string, color: string|null, effort: string|null, permissionMode: string|null, background: boolean, stacks: string[], body: string }}
266
266
  */
267
267
  export function parseSkillFile(rawContent) {
268
268
  // Normalize CRLF to LF for consistent parsing on Windows
269
269
  const content = rawContent.replace(/\r\n/g, '\n');
270
270
  const match = content.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
271
- if (!match) return { name: null, description: null, allowedTools: 'Read, Write, Edit, Bash, Glob, Grep', body: rawContent };
271
+ if (!match) return { name: null, description: null, allowedTools: 'Read, Write, Edit, Bash, Glob, Grep', color: null, effort: null, permissionMode: null, background: false, body: rawContent };
272
272
 
273
273
  const fm = match[1];
274
274
  const body = match[2];
275
275
 
276
276
  const name = (fm.match(/^name:\s*(.+)$/m) ?? [])[1]?.trim() ?? null;
277
277
  const allowedTools = (fm.match(/^allowed-tools:\s*(.+)$/m) ?? [])[1]?.trim() ?? 'Read, Write, Edit, Bash, Glob, Grep';
278
+ const color = (fm.match(/^color:\s*(.+)$/m) ?? [])[1]?.trim() ?? null;
279
+ const effort = (fm.match(/^effort:\s*(.+)$/m) ?? [])[1]?.trim() ?? null;
280
+ const permissionMode = (fm.match(/^permissionMode:\s*(.+)$/m) ?? [])[1]?.trim() ?? null;
281
+ const background = (fm.match(/^background:\s*(.+)$/m) ?? [])[1]?.trim() === 'true';
278
282
 
279
283
  let description = null;
280
284
  const blockMatch = fm.match(/^description:\s*>\s*\n((?:[ \t]+.*\n?)*)/m);
@@ -286,7 +290,7 @@ export function parseSkillFile(rawContent) {
286
290
  }
287
291
 
288
292
  const stacks = parseStacks(rawContent);
289
- return { name, description, allowedTools, stacks, body };
293
+ return { name, description, allowedTools, color, effort, permissionMode, background, stacks, body };
290
294
  }
291
295
 
292
296
  /**
@@ -311,6 +315,8 @@ export function collectSkillFiles(dir) {
311
315
  /**
312
316
  * Installs domain agent files as native Claude Code subagents
313
317
  * in .claude/agents/ with memory:project, model:sonnet, maxTurns:20.
318
+ * Supports optional CC-native fields (color, effort, permissionMode, background)
319
+ * declared in each domain file's YAML frontmatter.
314
320
  *
315
321
  * @param {string} projectDir - Target project directory
316
322
  * @param {string} frameworkDir - Path to morph-spec framework/ directory
@@ -326,20 +332,24 @@ export async function installDomainAgents(projectDir, frameworkDir = 'framework'
326
332
  const installed = new Set();
327
333
  for (const filePath of collectSkillFiles(domainsDir)) {
328
334
  const raw = readFileSync(filePath, 'utf-8');
329
- const { name, description, allowedTools, stacks, body } = parseSkillFile(raw);
335
+ const { name, description, allowedTools, color, effort, permissionMode, background, stacks, body } = parseSkillFile(raw);
330
336
  if (!name) continue;
331
337
  if (!shouldInstall(stacks, projectTags)) continue;
332
338
 
333
339
  const desc = description ?? `MORPH-SPEC domain agent: ${name}`;
334
- const frontmatter = [
340
+ const lines = [
335
341
  `name: ${name}`,
336
342
  `description: ${desc}`,
337
343
  `model: sonnet`,
338
344
  `tools: ${allowedTools}`,
339
345
  `maxTurns: 20`,
340
- `memory: project`,
341
- '',
342
- ].join('\n');
346
+ ];
347
+ if (color) lines.push(`color: ${color}`);
348
+ if (effort) lines.push(`effort: ${effort}`);
349
+ if (permissionMode && permissionMode !== 'default') lines.push(`permissionMode: ${permissionMode}`);
350
+ if (background) lines.push(`background: true`);
351
+ lines.push(`memory: project`, '');
352
+ const frontmatter = lines.join('\n');
343
353
 
344
354
  // If agents.json already generated morph-{name}.md, append domain content there
345
355
  const agentsJsonFile = `morph-${name}.md`;