$npx -y skills add spencermarx/open-code-review --skill v3-ddd-architectureDomain-Driven Design architecture for claude-flow v3. Implements modular, bounded context architecture with clean separation of concerns and microkernel pattern.
| 1 | # V3 DDD Architecture |
| 2 | |
| 3 | ## What This Skill Does |
| 4 | |
| 5 | Designs and implements Domain-Driven Design (DDD) architecture for claude-flow v3, decomposing god objects into bounded contexts, implementing clean architecture patterns, and enabling modular, testable code structure. |
| 6 | |
| 7 | ## Quick Start |
| 8 | |
| 9 | ```bash |
| 10 | # Initialize DDD architecture analysis |
| 11 | Task("Architecture analysis", "Analyze current architecture and design DDD boundaries", "core-architect") |
| 12 | |
| 13 | # Domain modeling (parallel) |
| 14 | Task("Domain decomposition", "Break down orchestrator god object into domains", "core-architect") |
| 15 | Task("Context mapping", "Map bounded contexts and relationships", "core-architect") |
| 16 | Task("Interface design", "Design clean domain interfaces", "core-architect") |
| 17 | ``` |
| 18 | |
| 19 | ## DDD Implementation Strategy |
| 20 | |
| 21 | ### Current Architecture Analysis |
| 22 | ``` |
| 23 | ├── PROBLEMATIC: core/orchestrator.ts (1,440 lines - GOD OBJECT) |
| 24 | │ ├── Task management responsibilities |
| 25 | │ ├── Session management responsibilities |
| 26 | │ ├── Health monitoring responsibilities |
| 27 | │ ├── Lifecycle management responsibilities |
| 28 | │ └── Event coordination responsibilities |
| 29 | │ |
| 30 | └── TARGET: Modular DDD Architecture |
| 31 | ├── core/domains/ |
| 32 | │ ├── task-management/ |
| 33 | │ ├── session-management/ |
| 34 | │ ├── health-monitoring/ |
| 35 | │ ├── lifecycle-management/ |
| 36 | │ └── event-coordination/ |
| 37 | └── core/shared/ |
| 38 | ├── interfaces/ |
| 39 | ├── value-objects/ |
| 40 | └── domain-events/ |
| 41 | ``` |
| 42 | |
| 43 | ### Domain Boundaries |
| 44 | |
| 45 | #### 1. Task Management Domain |
| 46 | ```typescript |
| 47 | // core/domains/task-management/ |
| 48 | interface TaskManagementDomain { |
| 49 | // Entities |
| 50 | Task: TaskEntity; |
| 51 | TaskQueue: TaskQueueEntity; |
| 52 | |
| 53 | // Value Objects |
| 54 | TaskId: TaskIdVO; |
| 55 | TaskStatus: TaskStatusVO; |
| 56 | Priority: PriorityVO; |
| 57 | |
| 58 | // Services |
| 59 | TaskScheduler: TaskSchedulingService; |
| 60 | TaskValidator: TaskValidationService; |
| 61 | |
| 62 | // Repository |
| 63 | TaskRepository: ITaskRepository; |
| 64 | } |
| 65 | ``` |
| 66 | |
| 67 | #### 2. Session Management Domain |
| 68 | ```typescript |
| 69 | // core/domains/session-management/ |
| 70 | interface SessionManagementDomain { |
| 71 | // Entities |
| 72 | Session: SessionEntity; |
| 73 | SessionState: SessionStateEntity; |
| 74 | |
| 75 | // Value Objects |
| 76 | SessionId: SessionIdVO; |
| 77 | SessionStatus: SessionStatusVO; |
| 78 | |
| 79 | // Services |
| 80 | SessionLifecycle: SessionLifecycleService; |
| 81 | SessionPersistence: SessionPersistenceService; |
| 82 | |
| 83 | // Repository |
| 84 | SessionRepository: ISessionRepository; |
| 85 | } |
| 86 | ``` |
| 87 | |
| 88 | #### 3. Health Monitoring Domain |
| 89 | ```typescript |
| 90 | // core/domains/health-monitoring/ |
| 91 | interface HealthMonitoringDomain { |
| 92 | // Entities |
| 93 | HealthCheck: HealthCheckEntity; |
| 94 | Metric: MetricEntity; |
| 95 | |
| 96 | // Value Objects |
| 97 | HealthStatus: HealthStatusVO; |
| 98 | Threshold: ThresholdVO; |
| 99 | |
| 100 | // Services |
| 101 | HealthCollector: HealthCollectionService; |
| 102 | AlertManager: AlertManagementService; |
| 103 | |
| 104 | // Repository |
| 105 | MetricsRepository: IMetricsRepository; |
| 106 | } |
| 107 | ``` |
| 108 | |
| 109 | ## Microkernel Architecture Pattern |
| 110 | |
| 111 | ### Core Kernel |
| 112 | ```typescript |
| 113 | // core/kernel/claude-flow-kernel.ts |
| 114 | export class ClaudeFlowKernel { |
| 115 | private domains: Map<string, Domain> = new Map(); |
| 116 | private eventBus: DomainEventBus; |
| 117 | private dependencyContainer: Container; |
| 118 | |
| 119 | async initialize(): Promise<void> { |
| 120 | // Load core domains |
| 121 | await this.loadDomain('task-management', new TaskManagementDomain()); |
| 122 | await this.loadDomain('session-management', new SessionManagementDomain()); |
| 123 | await this.loadDomain('health-monitoring', new HealthMonitoringDomain()); |
| 124 | |
| 125 | // Wire up domain events |
| 126 | this.setupDomainEventHandlers(); |
| 127 | } |
| 128 | |
| 129 | async loadDomain(name: string, domain: Domain): Promise<void> { |
| 130 | await domain.initialize(this.dependencyContainer); |
| 131 | this.domains.set(name, domain); |
| 132 | } |
| 133 | |
| 134 | getDomain<T extends Domain>(name: string): T { |
| 135 | const domain = this.domains.get(name); |
| 136 | if (!domain) { |
| 137 | throw new DomainNotLoadedError(name); |
| 138 | } |
| 139 | return domain as T; |
| 140 | } |
| 141 | } |
| 142 | ``` |
| 143 | |
| 144 | ### Plugin Architecture |
| 145 | ```typescript |
| 146 | // core/plugins/ |
| 147 | interface DomainPlugin { |
| 148 | name: string; |
| 149 | version: string; |
| 150 | dependencies: string[]; |
| 151 | |
| 152 | initialize(kernel: ClaudeFlowKernel): Promise<void>; |
| 153 | shutdown(): Promise<void>; |
| 154 | } |
| 155 | |
| 156 | // Example: Swarm Coordination Plugin |
| 157 | export class SwarmCoordinationPlugin implements DomainPlugin { |
| 158 | name = 'swarm-coordination'; |
| 159 | version = '3.0.0'; |
| 160 | dependencies = ['task-management', 'session-management']; |
| 161 | |
| 162 | async initialize(kernel: ClaudeFlowKernel): Promise<void> { |
| 163 | const taskDomain = kernel.getDomain<TaskManagementDomain>('task-management'); |
| 164 | const sessionDomain = kernel.getDomain<SessionManagementDomain>('session-management'); |
| 165 | |
| 166 | // Register swarm coordination services |
| 167 | this.swarmCoordinator = new UnifiedSwarmCoordinator(taskDomain, sessionDomain); |
| 168 | kernel.registerService('swarm-coordinator', this.swarmCoordinator); |
| 169 | } |
| 170 | } |
| 171 | ``` |
| 172 | |
| 173 | ## Domain Events & Integration |
| 174 | |
| 175 | ### Event-Driven Communication |
| 176 | ```typescript |
| 177 | // core/shared/domain-events/ |
| 178 | abstract class DomainEvent { |
| 179 | public readonly eventId: string; |