Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Domain-Driven Design architecture for claude-flow v3. Implements modular, bounded context architecture with clean separation of concerns and microkernel pattern.
.claude/skills/ruvnet-v3-ddd-architecture/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-04 | ✗→✓ | ▲ Improved | 89% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 89% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 57% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 70% | 0% |
| case-11 | ✗→✓ | ▲ Improved | 61% | 0% |
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.
bash# Initialize DDD architecture analysis Task("Architecture analysis", "Analyze current architecture and design DDD boundaries", "core-architect") # Domain modeling (parallel) Task("Domain decomposition", "Break down orchestrator god object into domains", "core-architect") Task("Context mapping", "Map bounded contexts and relationships", "core-architect") Task("Interface design", "Design clean domain interfaces", "core-architect")
├── PROBLEMATIC: core$orchestrator.ts (1,440 lines - GOD OBJECT)
│ ├── Task management responsibilities
│ ├── Session management responsibilities
│ ├── Health monitoring responsibilities
│ ├── Lifecycle management responsibilities
│ └── Event coordination responsibilities
│
└── TARGET: Modular DDD Architecture
├── core$domains/
│ ├── task-management/
│ ├── session-management/
│ ├── health-monitoring/
│ ├── lifecycle-management/
│ └── event-coordination/
└── core$shared/
├── interfaces/
├── value-objects/
└── domain-events/typescript// core$domains$task-management/ interface TaskManagementDomain { // Entities Task: TaskEntity; TaskQueue: TaskQueueEntity; // Value Objects TaskId: TaskIdVO; TaskStatus: TaskStatusVO; Priority: PriorityVO; // Services TaskScheduler: TaskSchedulingService; TaskValidator: TaskValidationService; // Repository TaskRepository: ITaskRepository; }
typescript// core$domains$session-management/ interface SessionManagementDomain { // Entities Session: SessionEntity; SessionState: SessionStateEntity; // Value Objects SessionId: SessionIdVO; SessionStatus: SessionStatusVO; // Services SessionLifecycle: SessionLifecycleService; SessionPersistence: SessionPersistenceService; // Repository SessionRepository: ISessionRepository; }
typescript// core$domains$health-monitoring/ interface HealthMonitoringDomain { // Entities HealthCheck: HealthCheckEntity; Metric: MetricEntity; // Value Objects HealthStatus: HealthStatusVO; Threshold: ThresholdVO; // Services HealthCollector: HealthCollectionService; AlertManager: AlertManagementService; // Repository MetricsRepository: IMetricsRepository; }
typescript// core$kernel$claude-flow-kernel.ts export class ClaudeFlowKernel { private domains: Map<string, Domain> = new Map(); private eventBus: DomainEventBus; private dependencyContainer: Container; async initialize(): Promise<void> { // Load core domains await this.loadDomain('task-management', new TaskManagementDomain()); await this.loadDomain('session-management', new SessionManagementDomain()); await this.loadDomain('health-monitoring', new HealthMonitoringDomain()); // Wire up domain events this.setupDomainEventHandlers(); } async loadDomain(name: string, domain: Domain): Promise<void> { await domain.initialize(this.dependencyContainer); this.domains.set(name, domain); } getDomain<T extends Domain>(name: string): T { const domain = this.domains.get(name); if (!domain) { throw new DomainNotLoadedError(name); } return domain as T; } }
typescript// core$plugins/ interface DomainPlugin { name: string; version: string; dependencies: string[]; initialize(kernel: ClaudeFlowKernel): Promise<void>; shutdown(): Promise<void>; } // Example: Swarm Coordination Plugin export class SwarmCoordinationPlugin implements DomainPlugin { name = 'swarm-coordination'; version = '3.0.0'; dependencies = ['task-management', 'session-management']; async initialize(kernel: ClaudeFlowKernel): Promise<void> { const taskDomain = kernel.getDomain<TaskManagementDomain>('task-management'); const sessionDomain = kernel.getDomain<SessionManagementDomain>('session-management'); // Register swarm coordination services this.swarmCoordinator = new UnifiedSwarmCoordinator(taskDomain, sessionDomain); kernel.registerService('swarm-coordinator', this.swarmCoordinator); } }
typescript// core$shared$domain-events/ abstract class DomainEvent { public readonly eventId: string; public readonly aggregateId: string; public readonly occurredOn: Date; public readonly eventVersion: number; constructor(aggregateId: string) { this.eventId = crypto.randomUUID(); this.aggregateId = aggregateId; this.occurredOn = new Date(); this.eventVersion = 1; } } // Task domain events export class TaskAssignedEvent extends DomainEvent { constructor( taskId: string, public readonly agentId: string, public readonly priority: Priority ) { super(taskId); } } export class TaskCompletedEvent extends DomainEvent { constructor( taskId: string, public readonly result: TaskResult, public readonly duration: number ) { super(taskId); } } // Event handlers @EventHandler(TaskCompletedEvent) export class TaskCompletedHandler { constructor( private metricsRepository: IMetricsRepository, private sessionService: SessionLifecycleService ) {} async handle(event: TaskCompletedEvent): Promise<void> { // Update metrics await this.metricsRepository.recordTaskCompletion( event.aggregateId, event.duration ); // Update session state await this.sessionService.markTaskCompleted( event.aggregateId, event.result ); } }
typescript// Architecture layers ┌─────────────────────────────────────────┐ │ Presentation │ ← CLI, API, UI ├─────────────────────────────────────────┤ │ Application │ ← Use Cases, Commands ├─────────────────────────────────────────┤ │ Domain │ ← Entities, Services, Events ├─────────────────────────────────────────┤ │ Infrastructure │ ← DB, MCP, External APIs └─────────────────────────────────────────┘ // Dependency direction: Outside → Inside // Domain layer has NO external dependencies
typescript// core$application$use-cases/ export class AssignTaskUseCase { constructor( private taskRepository: ITaskRepository, private agentRepository: IAgentRepository, private eventBus: DomainEventBus ) {} async execute(command: AssignTaskCommand): Promise<TaskResult> { // 1. Validate command await this.validateCommand(command); // 2. Load aggregates const task = await this.taskRepository.findById(command.taskId); const agent = await this.agentRepository.findById(command.agentId); // 3. Business logic (in domain) task.assignTo(agent); // 4. Persist changes await this.taskRepository.save(task); // 5. Publish domain events task.getUncommittedEvents().forEach(event => this.eventBus.publish(event) ); // 6. Return result return TaskResult.success(task); } }
typescript// core$domains$task-management$module.ts export const taskManagementModule = { name: 'task-management', entities: [ TaskEntity, TaskQueueEntity ], valueObjects: [ TaskIdVO, TaskStatusVO, PriorityVO ], services: [ TaskSchedulingService, TaskValidationService ], repositories: [ { provide: ITaskRepository, useClass: SqliteTaskRepository } ], eventHandlers: [ TaskAssignedHandler, TaskCompletedHandler ] };
typescript// Extract services from orchestrator.ts const extractionPlan = { week1: [ 'TaskManager → task-management domain', 'SessionManager → session-management domain' ], week2: [ 'HealthMonitor → health-monitoring domain', 'LifecycleManager → lifecycle-management domain' ], week3: [ 'EventCoordinator → event-coordination domain', 'Wire up domain events' ] };
typescript// Clean separation with dependency injection export class TaskController { constructor( @Inject('AssignTaskUseCase') private assignTask: AssignTaskUseCase, @Inject('CompleteTaskUseCase') private completeTask: CompleteTaskUseCase ) {} async assign(request: AssignTaskRequest): Promise<TaskResponse> { const command = AssignTaskCommand.fromRequest(request); const result = await this.assignTask.execute(command); return TaskResponse.fromResult(result); } }
typescript// Enable plugin-based extensions const pluginSystem = { core: ['task-management', 'session-management', 'health-monitoring'], optional: ['swarm-coordination', 'learning-integration', 'performance-monitoring'] };
typescript// Pure domain logic testing describe('Task Entity', () => { let task: TaskEntity; let mockAgent: jest.Mocked<AgentEntity>; beforeEach(() => { task = new TaskEntity(TaskId.create(), 'Test task'); mockAgent = createMock<AgentEntity>(); }); it('should assign to agent when valid', () => { mockAgent.canAcceptTask.mockReturnValue(true); task.assignTo(mockAgent); expect(task.assignedAgent).toBe(mockAgent); expect(task.status.value).toBe('assigned'); }); it('should emit TaskAssignedEvent when assigned', () => { mockAgent.canAcceptTask.mockReturnValue(true); task.assignTo(mockAgent); const events = task.getUncommittedEvents(); expect(events).toHaveLength(1); expect(events[0]).toBeInstanceOf(TaskAssignedEvent); }); });
v3-core-implementation - Implementation of DDD domainsv3-memory-unification - AgentDB integration within bounded contextsv3-swarm-coordination - Swarm coordination as domain pluginv3-performance-optimization - Performance optimization across domainsbash# Full DDD architecture implementation Task("DDD architecture implementation", "Extract orchestrator into DDD domains with clean architecture", "core-architect")
bash# Create domain plugin npm run create:plugin -- --name swarm-coordination --template domain
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-03 | pass→pass | 19,331 | 13,906 | -28% | 1 | 1 | 0% | 4,179 | 6,137 | +47% | 0 | 0 | — |
case-01 | fail→fail | 17,174 | 17,903 | +4% | 1 | 1 | 0% | 3,800 | 6,931 | +82% | 0 | 0 | — |
case-02 | fail→fail | 20,478 | 19,906 | -3% | 1 | 1 | 0% | 4,464 | 7,700 | +72% | 0 | 0 | — |
case-04 | fail→pass | 15,109 | 10,951 | -28% | 1 | 1 | 0% | 2,645 | 4,986 | +89% | 0 | 0 | — |
case-05 | fail→fail | 14,665 | 16,292 | +11% | 1 | 1 | 0% | 2,914 | 6,172 | +112% | 0 | 0 | — |
case-06 | fail→fail | 18,995 | 13,210 | -30% | 1 | 1 | 0% | 3,919 | 5,455 | +39% | 0 | 0 | — |
case-07 | fail→fail | 29,679 | 13,582 | -54% | 1 | 1 | 0% | 3,233 | 5,875 | +82% | 0 | 0 | — |
case-08 | fail→pass | 13,283 | 8,745 | -34% | 1 | 1 | 0% | 2,412 | 4,563 | +89% | 0 | 0 | — |
case-09 | fail→pass | 15,880 | 9,336 | -41% | 1 | 1 | 0% | 2,978 | 4,661 | +57% | 0 | 0 | — |
case-10 | fail→pass | 13,008 | 7,083 | -46% | 1 | 1 | 0% | 2,513 | 4,273 | +70% | 0 | 0 | — |
case-11 | fail→pass | 14,799 | 9,308 | -37% | 1 | 1 | 0% | 2,987 | 4,806 | +61% | 0 | 0 | — |
case-12 | pass→pass | 7,494 | 5,990 | -20% | 1 | 1 | 0% | 1,333 | 3,880 | +191% | 0 | 0 | — |
case-13 | fail→pass | 13,044 | 10,271 | -21% | 1 | 1 | 0% | 2,417 | 4,748 | +96% | 0 | 0 | — |
case-14 | fail→pass | 16,793 | 10,256 | -39% | 1 | 1 | 0% | 3,084 | 5,381 | +74% | 0 | 0 | — |
case-15 | fail→pass | 14,467 | 3,922 | -73% | 1 | 1 | 0% | 2,545 | 3,624 | +42% | 0 | 0 | — |
case-16 | fail→pass | 12,385 | 7,957 | -36% | 1 | 1 | 0% | 2,182 | 4,411 | +102% | 0 | 0 | — |
case-17 | fail→pass | 13,757 | 7,024 | -49% | 1 | 1 | 0% | 2,357 | 4,030 | +71% | 0 | 0 | — |
case-18 | fail→pass | 15,983 | 10,695 | -33% | 1 | 1 | 0% | 2,943 | 5,007 | +70% | 0 | 0 | — |
case-19 | fail→pass | 13,303 | 6,328 | -52% | 1 | 1 | 0% | 2,478 | 3,910 | +58% | 0 | 0 | — |
case-20 | pass→pass | 13,759 | 10,426 | -24% | 1 | 1 | 0% | 2,513 | 4,569 | +82% | 0 | 0 | — |
case-21 | pass→pass | 9,611 | 6,772 | -30% | 1 | 1 | 0% | 1,732 | 4,002 | +131% | 0 | 0 | — |
case-22 | pass→pass | 17,382 | 11,175 | -36% | 1 | 1 | 0% | 3,224 | 5,044 | +56% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +55 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.