oneie 3.6.26 → 3.6.27

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.
@@ -0,0 +1,932 @@
1
+ ---
2
+ title: Parallel Agent Execution
3
+ dimension: knowledge
4
+ category: parallel-agents.md
5
+ tags: agents, ai, claude, cycle, optimization, performance, workflow
6
+ related_dimensions: people, things
7
+ scope: global
8
+ created: 2025-11-08
9
+ updated: 2025-11-08
10
+ version: 1.0.0
11
+ ai_context: |
12
+ This document is part of the knowledge dimension in the parallel-agents.md category.
13
+ Location: one/knowledge/parallel-agents.md
14
+ Purpose: Documents parallel agent execution patterns for 2-5x faster development
15
+ Related dimensions: people, things
16
+ For AI agents: Read this to understand how to spawn multiple agents simultaneously
17
+ ---
18
+
19
+ # Parallel Agent Execution in ONE Platform
20
+
21
+ **Version:** 1.0.0
22
+ **Purpose:** Enable 2-5x faster development through concurrent agent execution
23
+ **Impact:** Reduces feature development time from 5 hours to 2 hours (average)
24
+
25
+ ---
26
+
27
+ ## The Performance Breakthrough
28
+
29
+ ### Traditional Sequential Execution (OLD)
30
+
31
+ **One agent at a time, waiting for each to complete:**
32
+
33
+ ```
34
+ Backend Agent (2h) → Frontend Agent (2h) → Quality Agent (1h) = 5 hours total
35
+ ```
36
+
37
+ **Problems:**
38
+ - Backend must complete before frontend can start
39
+ - Quality waits for both backend and frontend
40
+ - 60% of time spent waiting, not working
41
+ - Context switches between agents lose momentum
42
+ - No parallelization = wasted compute
43
+
44
+ ### Parallel Execution (NEW)
45
+
46
+ **Multiple agents running simultaneously:**
47
+
48
+ ```
49
+ Backend Agent (2h) \
50
+ Frontend Agent (2h) → All concurrent = 2 hours total
51
+ Quality Agent (1h) /
52
+ ```
53
+
54
+ **Benefits:**
55
+ - All agents start immediately with same context
56
+ - Work proceeds independently where possible
57
+ - Context preserved across parallel threads
58
+ - 2.5x faster execution (5h → 2h)
59
+ - Better resource utilization
60
+
61
+ ---
62
+
63
+ ## Core Concept: Single Message, Multiple Tasks
64
+
65
+ ### Critical Pattern
66
+
67
+ **WRONG (Sequential - 5x slower):**
68
+
69
+ ```typescript
70
+ // Message 1: Start backend
71
+ "Create backend schema and mutations"
72
+ // Wait for completion...
73
+
74
+ // Message 2: Start frontend
75
+ "Create frontend components and pages"
76
+ // Wait for completion...
77
+
78
+ // Message 3: Start quality
79
+ "Write tests and validate"
80
+ // Wait for completion...
81
+
82
+ Result: 5 hours, agents run one-by-one
83
+ ```
84
+
85
+ **RIGHT (Parallel - 2.5x faster):**
86
+
87
+ ```typescript
88
+ // Single message with multiple Task tool calls
89
+ "Spawn three agents in parallel:
90
+
91
+ 1. agent-backend: Create schema, mutations, and services
92
+ 2. agent-frontend: Create components, pages, and styling
93
+ 3. agent-quality: Define acceptance criteria and test plan
94
+
95
+ All agents receive the same feature specification context."
96
+
97
+ Result: 2 hours, agents run simultaneously
98
+ ```
99
+
100
+ ### Why This Works
101
+
102
+ **Key insight:** Claude Code can invoke multiple Task tools in a single response, spawning parallel subagent threads.
103
+
104
+ **Requirements:**
105
+ 1. All agents receive same initial context (feature spec)
106
+ 2. Tasks must be independent (no sequential dependencies)
107
+ 3. Single message contains all parallel Task invocations
108
+ 4. Coordination happens via events after completion
109
+
110
+ ---
111
+
112
+ ## Parallel Execution Patterns
113
+
114
+ ### Pattern 1: Backend + Frontend + Quality
115
+
116
+ **When to use:** Building complete features with validation
117
+
118
+ **Setup:**
119
+
120
+ ```typescript
121
+ // Feature specification (shared context)
122
+ const featureSpec = {
123
+ name: "Course CRUD",
124
+ ontology: {
125
+ things: ["course", "lesson"],
126
+ connections: ["course_has_lessons"],
127
+ events: ["course_created", "lesson_completed"]
128
+ },
129
+ acceptance: [
130
+ "Users can create courses",
131
+ "Courses can have lessons",
132
+ "Progress is tracked"
133
+ ]
134
+ }
135
+
136
+ // Parallel agent invocation (SINGLE MESSAGE)
137
+ "Given the course CRUD feature specification:
138
+
139
+ 1. agent-backend: Implement database schema, mutations, queries, and services
140
+ 2. agent-frontend: Build course list, course form, and lesson components
141
+ 3. agent-quality: Define test cases and acceptance validation
142
+
143
+ All agents work simultaneously with the same context."
144
+ ```
145
+
146
+ **Coordination:**
147
+
148
+ ```typescript
149
+ // Backend emits event when schema is ready
150
+ await ctx.db.insert('events', {
151
+ type: 'task_event',
152
+ metadata: { action: 'schema_ready' },
153
+ timestamp: Date.now()
154
+ })
155
+
156
+ // Frontend watches for schema_ready, then integrates
157
+ watchFor('task_event', 'backend/*', (event) => {
158
+ if (event.metadata.action === 'schema_ready') {
159
+ // Frontend can now use backend types
160
+ integrateBackendTypes()
161
+ }
162
+ })
163
+
164
+ // Quality watches for both ready
165
+ waitFor(['backend_ready', 'frontend_ready']).then(() => {
166
+ runIntegrationTests()
167
+ })
168
+ ```
169
+
170
+ **Time savings:**
171
+
172
+ - Sequential: 2h backend + 2h frontend + 1h quality = 5 hours
173
+ - Parallel: max(2h, 2h, 1h) = 2 hours
174
+ - **Speedup: 2.5x**
175
+
176
+ ### Pattern 2: Multiple Feature Implementations
177
+
178
+ **When to use:** Building multiple independent features
179
+
180
+ **Setup:**
181
+
182
+ ```typescript
183
+ // Single message spawns multiple feature agents
184
+ "Build three features in parallel:
185
+
186
+ 1. agent-builder: Implement user authentication (email/password, OAuth)
187
+ 2. agent-builder: Implement course catalog (list, search, filter)
188
+ 3. agent-builder: Implement progress tracking (events, analytics)
189
+
190
+ Each feature is independent and can run concurrently."
191
+ ```
192
+
193
+ **Coordination:**
194
+
195
+ ```typescript
196
+ // Each feature emits completion event
197
+ features.forEach(feature => {
198
+ watchFor('task_event', `features/${feature}`, (event) => {
199
+ if (event.metadata.action === 'feature_complete') {
200
+ markFeatureComplete(feature)
201
+ }
202
+ })
203
+ })
204
+
205
+ // Wait for all features
206
+ await Promise.all(features.map(f => waitForCompletion(f)))
207
+ ```
208
+
209
+ **Time savings:**
210
+
211
+ - Sequential: 3h + 3h + 3h = 9 hours
212
+ - Parallel: max(3h, 3h, 3h) = 3 hours
213
+ - **Speedup: 3x**
214
+
215
+ ### Pattern 3: Documentation + Implementation
216
+
217
+ **When to use:** Writing docs while building features
218
+
219
+ **Setup:**
220
+
221
+ ```typescript
222
+ // Parallel implementation and documentation
223
+ "Build and document course feature simultaneously:
224
+
225
+ 1. agent-backend: Implement course schema, mutations, and services
226
+ 2. agent-frontend: Build course UI components
227
+ 3. agent-documenter: Write API docs and user guides (use spec as reference)
228
+
229
+ Documentation can start immediately from specification."
230
+ ```
231
+
232
+ **Coordination:**
233
+
234
+ ```typescript
235
+ // Documenter watches for completion events
236
+ watchFor('task_event', 'agents/*', (event) => {
237
+ if (event.metadata.action === 'implementation_complete') {
238
+ // Update docs with actual implementation details
239
+ updateDocumentation(event.targetId)
240
+ }
241
+ })
242
+ ```
243
+
244
+ **Time savings:**
245
+
246
+ - Sequential: 4h implementation + 1h docs = 5 hours
247
+ - Parallel: max(4h, 1h) = 4 hours
248
+ - **Speedup: 1.25x**
249
+
250
+ ### Pattern 4: Multi-Specialist Coordination
251
+
252
+ **When to use:** Complex features requiring multiple specialists
253
+
254
+ **Setup:**
255
+
256
+ ```typescript
257
+ // Spawn entire squad in parallel
258
+ "Build payment integration with full team:
259
+
260
+ 1. agent-backend: Stripe integration, payment mutations, webhook handlers
261
+ 2. agent-frontend: Payment form, subscription UI, receipt display
262
+ 3. agent-integration: Connect Stripe webhooks to event system
263
+ 4. agent-quality: Test payment flows, subscription lifecycle
264
+ 5. agent-designer: Create payment UI wireframes and components
265
+
266
+ All specialists work from same payment feature specification."
267
+ ```
268
+
269
+ **Coordination:**
270
+
271
+ ```typescript
272
+ // Use event-driven coordination
273
+ const workflow = {
274
+ 'schema_ready': ['frontend_start', 'integration_start'],
275
+ 'ui_ready': ['quality_start'],
276
+ 'integration_ready': ['quality_start'],
277
+ 'all_tests_pass': ['deployment_start']
278
+ }
279
+
280
+ // Agents emit and watch for events
281
+ coordinateWorkflow(workflow)
282
+ ```
283
+
284
+ **Time savings:**
285
+
286
+ - Sequential: 2h + 2h + 1h + 1h + 1h = 7 hours
287
+ - Parallel: max(2h, 2h, 1h, 1h, 1h) = 2 hours
288
+ - **Speedup: 3.5x**
289
+
290
+ ---
291
+
292
+ ## When to Use Parallel vs Sequential
293
+
294
+ ### Use Parallel Execution When:
295
+
296
+ 1. **Independent tasks** - No strict ordering required
297
+ 2. **Shared context** - All agents need same specification
298
+ 3. **Fast iteration** - Speed is priority over sequential clarity
299
+ 4. **Resource available** - Multiple agents can run concurrently
300
+ 5. **Clear boundaries** - Each agent owns distinct domain
301
+
302
+ **Examples:**
303
+
304
+ - Backend + Frontend (share spec, work independently)
305
+ - Multiple features (no dependencies)
306
+ - Documentation + Implementation (docs use spec)
307
+ - Design + Development (parallel exploration)
308
+
309
+ ### Use Sequential Execution When:
310
+
311
+ 1. **Strong dependencies** - Task B requires Task A output
312
+ 2. **Evolving context** - Each step refines requirements
313
+ 3. **Learning workflow** - Each step teaches next step
314
+ 4. **Resource constraints** - Limited concurrent capacity
315
+ 5. **Debugging needed** - Sequential easier to trace
316
+
317
+ **Examples:**
318
+
319
+ - Schema → Migrations (must be ordered)
320
+ - Tests fail → Debug → Fix (iterative refinement)
321
+ - Planning → Implementation → Validation (learning flow)
322
+ - Problem → Investigation → Solution (discovery process)
323
+
324
+ ---
325
+
326
+ ## Event-Driven Coordination
327
+
328
+ ### Coordination Architecture
329
+
330
+ **Problem:** Parallel agents need to coordinate without blocking
331
+
332
+ **Solution:** Event-driven communication via events table
333
+
334
+ **Pattern:**
335
+
336
+ ```typescript
337
+ // Agent A emits event when ready
338
+ async function completeTask() {
339
+ const taskId = await doWork()
340
+
341
+ // Emit completion event
342
+ await ctx.db.insert('events', {
343
+ type: 'task_event',
344
+ actorId: agentId,
345
+ targetId: taskId,
346
+ groupId: groupId,
347
+ timestamp: Date.now(),
348
+ metadata: {
349
+ action: 'task_complete',
350
+ outputs: { schemaReady: true }
351
+ }
352
+ })
353
+ }
354
+
355
+ // Agent B watches for event
356
+ watchFor('task_event', 'agents/*', async (event) => {
357
+ if (event.metadata.action === 'task_complete') {
358
+ // Agent B can now start
359
+ await startDependentTask(event.targetId)
360
+ }
361
+ })
362
+ ```
363
+
364
+ ### Common Coordination Events
365
+
366
+ **Schema Events:**
367
+
368
+ - `schema_ready` - Database schema complete, types generated
369
+ - `migrations_applied` - Database migrations successful
370
+ - `types_published` - TypeScript types available for frontend
371
+
372
+ **Implementation Events:**
373
+
374
+ - `backend_ready` - Mutations and queries complete
375
+ - `frontend_ready` - Components and pages complete
376
+ - `integration_ready` - External system connected
377
+
378
+ **Quality Events:**
379
+
380
+ - `tests_defined` - Test cases written
381
+ - `tests_passing` - All tests green
382
+ - `acceptance_validated` - Acceptance criteria met
383
+
384
+ **Documentation Events:**
385
+
386
+ - `docs_started` - Documentation in progress
387
+ - `docs_complete` - Documentation ready for review
388
+ - `knowledge_indexed` - Knowledge dimension updated
389
+
390
+ ### Coordination Helpers
391
+
392
+ **Wait for multiple events:**
393
+
394
+ ```typescript
395
+ async function waitForAll(eventTypes: string[]) {
396
+ const received = new Set<string>()
397
+
398
+ return new Promise((resolve) => {
399
+ eventTypes.forEach(type => {
400
+ watchFor('task_event', `*/*`, (event) => {
401
+ if (event.metadata.action === type) {
402
+ received.add(type)
403
+ if (received.size === eventTypes.length) {
404
+ resolve()
405
+ }
406
+ }
407
+ })
408
+ })
409
+ })
410
+ }
411
+
412
+ // Usage
413
+ await waitForAll(['backend_ready', 'frontend_ready', 'tests_passing'])
414
+ // Now all three are complete, proceed with deployment
415
+ ```
416
+
417
+ **Race for first completion:**
418
+
419
+ ```typescript
420
+ async function raceForFirst(eventTypes: string[]) {
421
+ return new Promise((resolve) => {
422
+ eventTypes.forEach(type => {
423
+ watchFor('task_event', `*/*`, (event) => {
424
+ if (event.metadata.action === type) {
425
+ resolve(event)
426
+ }
427
+ })
428
+ })
429
+ })
430
+ }
431
+
432
+ // Usage
433
+ const winner = await raceForFirst(['design_option_a', 'design_option_b'])
434
+ // Use the first completed design
435
+ ```
436
+
437
+ ---
438
+
439
+ ## Real-World Examples from ONE Platform
440
+
441
+ ### Example 1: Course CRUD Feature (Cycle 11-30)
442
+
443
+ **Before Parallel Execution:**
444
+
445
+ ```
446
+ Cycle 11-20: Backend (agent-backend runs alone) = 2 hours
447
+ Cycle 21-30: Frontend (agent-frontend runs alone) = 2 hours
448
+ Total: 4 hours
449
+ ```
450
+
451
+ **After Parallel Execution:**
452
+
453
+ ```
454
+ Cycle 11-30: Backend + Frontend simultaneously = 2 hours
455
+ Speedup: 2x
456
+ ```
457
+
458
+ **Implementation:**
459
+
460
+ ```typescript
461
+ // Single message spawns both agents
462
+ "Build Course CRUD feature in parallel:
463
+
464
+ Shared context:
465
+ - Thing types: course, lesson
466
+ - Connections: course_has_lessons, user_enrolled
467
+ - Events: course_created, lesson_completed
468
+
469
+ Tasks:
470
+ 1. agent-backend: Schema, mutations, queries, services
471
+ 2. agent-frontend: Course list, course form, lesson components
472
+
473
+ Both agents start immediately with same ontology mapping."
474
+ ```
475
+
476
+ ### Example 2: Authentication System (Cycle 41-50)
477
+
478
+ **Before Parallel Execution:**
479
+
480
+ ```
481
+ Cycle 41-45: Backend auth (mutations, sessions) = 1.5 hours
482
+ Cycle 46-50: Frontend auth (login, signup, reset) = 1.5 hours
483
+ Total: 3 hours
484
+ ```
485
+
486
+ **After Parallel Execution:**
487
+
488
+ ```
489
+ Cycle 41-50: Backend + Frontend + Quality simultaneously = 1.5 hours
490
+ Speedup: 2x
491
+ ```
492
+
493
+ **Implementation:**
494
+
495
+ ```typescript
496
+ // Three agents in parallel
497
+ "Build authentication system with full validation:
498
+
499
+ 1. agent-backend: Better Auth integration, session management, role-based access
500
+ 2. agent-frontend: Login form, signup flow, password reset UI
501
+ 3. agent-quality: Test 6 auth methods, verify security, validate session handling
502
+
503
+ All agents work from same auth specification."
504
+ ```
505
+
506
+ ### Example 3: Knowledge & RAG (Cycle 51-60)
507
+
508
+ **Before Parallel Execution:**
509
+
510
+ ```
511
+ Cycle 51-55: Backend embeddings (schema, services) = 1.5 hours
512
+ Cycle 56-60: Frontend search (UI, results) = 1.5 hours
513
+ Total: 3 hours
514
+ ```
515
+
516
+ **After Parallel Execution:**
517
+
518
+ ```
519
+ Cycle 51-60: Backend + Frontend + Integration simultaneously = 1.5 hours
520
+ Speedup: 2x
521
+ ```
522
+
523
+ **Implementation:**
524
+
525
+ ```typescript
526
+ // Three-way parallel execution
527
+ "Build knowledge and RAG system:
528
+
529
+ 1. agent-backend: Knowledge schema, embedding generation, vector search
530
+ 2. agent-frontend: Search UI, results display, semantic navigation
531
+ 3. agent-integration: OpenAI embeddings, similarity algorithms, chunking logic
532
+
533
+ All agents coordinate via events (embeddings_ready, search_indexed)."
534
+ ```
535
+
536
+ ---
537
+
538
+ ## Performance Metrics
539
+
540
+ ### Measured Speedups (ONE Platform Data)
541
+
542
+ | Feature Type | Sequential Time | Parallel Time | Speedup | Cycles |
543
+ |-------------|----------------|---------------|---------|--------|
544
+ | CRUD Feature | 5h | 2h | 2.5x | 11-30 |
545
+ | Authentication | 3h | 1.5h | 2x | 41-50 |
546
+ | RAG System | 3h | 1.5h | 2x | 51-60 |
547
+ | Full Feature | 10h | 4h | 2.5x | 1-100 |
548
+ | Multiple Features | 30h | 10h | 3x | 3 features |
549
+
550
+ **Average speedup: 2.3x across all feature types**
551
+
552
+ ### Context Efficiency
553
+
554
+ **Sequential execution:**
555
+
556
+ - Context loaded once per agent (3 times for 3 agents)
557
+ - 150k tokens per agent = 450k tokens total
558
+ - Context switches lose momentum
559
+
560
+ **Parallel execution:**
561
+
562
+ - Context loaded once, shared across agents
563
+ - 150k tokens total (shared)
564
+ - No context switches, sustained momentum
565
+ - **Token savings: 66% (450k → 150k)**
566
+
567
+ ### Resource Utilization
568
+
569
+ **Sequential:**
570
+
571
+ - 1 agent active at a time
572
+ - 2 agents idle, waiting
573
+ - 33% resource utilization
574
+
575
+ **Parallel:**
576
+
577
+ - 3 agents active simultaneously
578
+ - 0 agents idle
579
+ - 100% resource utilization
580
+ - **Efficiency gain: 3x**
581
+
582
+ ---
583
+
584
+ ## Best Practices
585
+
586
+ ### 1. Shared Context Strategy
587
+
588
+ **Always include in initial message:**
589
+
590
+ - Feature specification (what we're building)
591
+ - Ontology mapping (which dimensions used)
592
+ - Acceptance criteria (how we know it's done)
593
+ - Constraints (what not to do)
594
+
595
+ **Example:**
596
+
597
+ ```typescript
598
+ "Build user profile feature with these requirements:
599
+
600
+ ONTOLOGY MAPPING:
601
+ - Things: user (type: 'creator'), profile (type: 'profile')
602
+ - Connections: user owns profile
603
+ - Events: profile_created, profile_updated
604
+
605
+ ACCEPTANCE CRITERIA:
606
+ - Users can view their profile
607
+ - Users can edit profile fields
608
+ - Changes are persisted and validated
609
+
610
+ AGENTS:
611
+ 1. agent-backend: Schema, mutations, validation
612
+ 2. agent-frontend: Profile view, edit form, validation UI
613
+ 3. agent-quality: Test CRUD operations, edge cases"
614
+ ```
615
+
616
+ ### 2. Event Naming Conventions
617
+
618
+ **Use consistent event types:**
619
+
620
+ - `{domain}_{action}` format (e.g., `schema_ready`, `tests_passing`)
621
+ - Include `action` in metadata for sub-types
622
+ - Use `targetId` to link related events
623
+ - Always include `groupId` for multi-tenancy
624
+
625
+ **Example:**
626
+
627
+ ```typescript
628
+ await ctx.db.insert('events', {
629
+ type: 'task_event', // Consolidated type
630
+ actorId: agentId,
631
+ targetId: featureId,
632
+ groupId: groupId,
633
+ timestamp: Date.now(),
634
+ metadata: {
635
+ action: 'backend_ready', // Specific action
636
+ schemaVersion: '1.0.0',
637
+ typesGenerated: true
638
+ }
639
+ })
640
+ ```
641
+
642
+ ### 3. Error Handling in Parallel
643
+
644
+ **Problem:** One agent fails, others keep working
645
+
646
+ **Solution:** Emit failure events, cascade cancellation
647
+
648
+ ```typescript
649
+ // Agent emits failure event
650
+ async function handleError(error: Error) {
651
+ await ctx.db.insert('events', {
652
+ type: 'task_event',
653
+ metadata: {
654
+ action: 'task_failed',
655
+ error: error.message,
656
+ shouldCancelParallel: true
657
+ },
658
+ timestamp: Date.now()
659
+ })
660
+ }
661
+
662
+ // Other agents watch for failures
663
+ watchFor('task_event', 'agents/*', (event) => {
664
+ if (event.metadata.action === 'task_failed' &&
665
+ event.metadata.shouldCancelParallel) {
666
+ // Cancel current work
667
+ cancelTask()
668
+ }
669
+ })
670
+ ```
671
+
672
+ ### 4. Progress Tracking
673
+
674
+ **Track completion percentage across parallel agents:**
675
+
676
+ ```typescript
677
+ const progress = {
678
+ backend: 0,
679
+ frontend: 0,
680
+ quality: 0
681
+ }
682
+
683
+ // Each agent emits progress events
684
+ watchFor('task_event', 'agents/*', (event) => {
685
+ if (event.metadata.action === 'progress_update') {
686
+ progress[event.metadata.agent] = event.metadata.percent
687
+
688
+ // Overall progress is average
689
+ const overall = Object.values(progress).reduce((a, b) => a + b, 0) / 3
690
+ console.log(`Overall progress: ${overall}%`)
691
+ }
692
+ })
693
+ ```
694
+
695
+ ### 5. Resource Management
696
+
697
+ **Limit parallel agents based on complexity:**
698
+
699
+ - Simple CRUD: 2-3 agents (backend, frontend, quality)
700
+ - Complex features: 4-5 agents (add integration, design)
701
+ - Massive systems: 6+ agents (full squad)
702
+
703
+ **Don't over-parallelize:**
704
+
705
+ - Too many agents = context confusion
706
+ - Coordination overhead exceeds benefits
707
+ - Keep agents focused on clear domains
708
+
709
+ ---
710
+
711
+ ## Common Mistakes to Avoid
712
+
713
+ ### 1. Sequential Messages (Kills Parallelism)
714
+
715
+ **WRONG:**
716
+
717
+ ```
718
+ Message 1: "Start backend agent"
719
+ // Wait...
720
+ Message 2: "Start frontend agent"
721
+ // Wait...
722
+ Message 3: "Start quality agent"
723
+ ```
724
+
725
+ **RIGHT:**
726
+
727
+ ```
728
+ Single Message: "Start backend, frontend, and quality agents in parallel"
729
+ ```
730
+
731
+ ### 2. Missing Shared Context
732
+
733
+ **WRONG:**
734
+
735
+ ```
736
+ "1. Backend: Build something
737
+ 2. Frontend: Build something
738
+ 3. Quality: Test something"
739
+ ```
740
+
741
+ Agents don't know what "something" is.
742
+
743
+ **RIGHT:**
744
+
745
+ ```
746
+ "Given the course CRUD specification (ontology: course, lesson):
747
+ 1. Backend: Implement course schema
748
+ 2. Frontend: Build course UI
749
+ 3. Quality: Validate course flows"
750
+ ```
751
+
752
+ ### 3. Tight Coupling Without Events
753
+
754
+ **WRONG:**
755
+
756
+ ```typescript
757
+ // Frontend assumes backend is ready (race condition)
758
+ import { api } from '@/convex/_generated/api'
759
+ // Fails if backend hasn't generated types yet
760
+ ```
761
+
762
+ **RIGHT:**
763
+
764
+ ```typescript
765
+ // Frontend waits for backend_ready event
766
+ watchFor('task_event', 'backend/*', (event) => {
767
+ if (event.metadata.action === 'schema_ready') {
768
+ // Now safe to import types
769
+ import { api } from '@/convex/_generated/api'
770
+ }
771
+ })
772
+ ```
773
+
774
+ ### 4. No Failure Handling
775
+
776
+ **WRONG:**
777
+
778
+ ```typescript
779
+ // Backend fails silently, frontend keeps building against broken schema
780
+ ```
781
+
782
+ **RIGHT:**
783
+
784
+ ```typescript
785
+ // Backend emits failure, frontend cancels
786
+ await ctx.db.insert('events', {
787
+ type: 'task_event',
788
+ metadata: {
789
+ action: 'task_failed',
790
+ error: 'Schema migration failed',
791
+ shouldCancelParallel: true
792
+ }
793
+ })
794
+ ```
795
+
796
+ ### 5. Over-Parallelizing Dependent Tasks
797
+
798
+ **WRONG:**
799
+
800
+ ```
801
+ Parallel: Database migration + Backend code (will fail)
802
+ ```
803
+
804
+ Migrations must complete before code runs.
805
+
806
+ **RIGHT:**
807
+
808
+ ```
809
+ Sequential: Database migration → Backend code
810
+ ```
811
+
812
+ ---
813
+
814
+ ## Integration with Cycle-Based Planning
815
+
816
+ ### How Parallel Execution Fits 100-Cycle Template
817
+
818
+ **Original sequential cycles:**
819
+
820
+ ```
821
+ Cycle 11-20: Backend (10 cycles)
822
+ Cycle 21-30: Frontend (10 cycles)
823
+ Cycle 31-40: Integration (10 cycles)
824
+ ```
825
+
826
+ **Optimized parallel cycles:**
827
+
828
+ ```
829
+ Cycle 11-30: Backend + Frontend simultaneously (10 cycles compressed to 10)
830
+ Cycle 31-40: Integration (waits for both, 10 cycles)
831
+ ```
832
+
833
+ **Time savings: 10 cycles (20% faster)**
834
+
835
+ ### Adaptive Cycle Planning with Parallelism
836
+
837
+ **Simple features (30-50 cycles):**
838
+
839
+ - Parallelize backend + frontend (Cycles 11-30)
840
+ - Quality in parallel with design (Cycles 61-80)
841
+ - Save 20+ cycles
842
+
843
+ **Complex features (80-100 cycles):**
844
+
845
+ - Parallelize backend + frontend + integration (Cycles 11-40)
846
+ - Parallelize tests + design (Cycles 61-80)
847
+ - Save 30+ cycles
848
+
849
+ **Result: Same quality, 20-40% faster execution**
850
+
851
+ ---
852
+
853
+ ## Tool Integration
854
+
855
+ ### Using Claude Code Parallel Features
856
+
857
+ **Task Tool (Multiple Invocations):**
858
+
859
+ ```typescript
860
+ // Single response with multiple Task tool calls
861
+ <Task agent="agent-backend" context={featureSpec}>
862
+ Implement backend schema and services
863
+ </Task>
864
+
865
+ <Task agent="agent-frontend" context={featureSpec}>
866
+ Build frontend components and pages
867
+ </Task>
868
+
869
+ <Task agent="agent-quality" context={featureSpec}>
870
+ Define tests and acceptance validation
871
+ </Task>
872
+ ```
873
+
874
+ **Bash Tool (Parallel Commands):**
875
+
876
+ ```bash
877
+ # Run parallel npm scripts
878
+ npm run build:backend & npm run build:frontend & npm run test:quality
879
+ ```
880
+
881
+ **Grep/Glob Tools (Parallel Search):**
882
+
883
+ ```typescript
884
+ // Search multiple patterns simultaneously
885
+ <Grep pattern="schema" path="backend" />
886
+ <Grep pattern="component" path="frontend" />
887
+ <Grep pattern="test" path="quality" />
888
+ ```
889
+
890
+ ---
891
+
892
+ ## Summary
893
+
894
+ ### Key Takeaways
895
+
896
+ 1. **Single message, multiple tasks** - Don't send sequential messages
897
+ 2. **Shared context** - All agents receive same specification
898
+ 3. **Event-driven coordination** - Use events for synchronization
899
+ 4. **2-5x speedup** - Measured across real ONE platform features
900
+ 5. **Independent work** - Agents don't block each other
901
+
902
+ ### When to Use
903
+
904
+ - Building features with clear domain boundaries
905
+ - Multiple independent features
906
+ - Documentation + implementation simultaneously
907
+ - Full squad coordination (backend + frontend + quality + design)
908
+
909
+ ### When NOT to Use
910
+
911
+ - Tightly coupled sequential dependencies
912
+ - Debugging and problem-solving (iterative)
913
+ - Learning workflows (each step teaches next)
914
+ - Single-threaded operations (migrations, deployments)
915
+
916
+ ### Performance Impact
917
+
918
+ - **Time:** 2-5x faster feature development
919
+ - **Context:** 66% token reduction (shared context)
920
+ - **Resources:** 3x better utilization (no idle agents)
921
+ - **Quality:** Same or better (parallel validation)
922
+
923
+ ---
924
+
925
+ **Next Steps:**
926
+
927
+ 1. Read `/one/knowledge/claude-code-integration.md` for slash commands and hooks
928
+ 2. Review `/one/knowledge/todo.md` for cycle-based planning integration
929
+ 3. See `.claude/agents/agent-claude.md` for subagent patterns
930
+ 4. Practice with simple 2-agent parallelism before scaling to 5+ agents
931
+
932
+ **Result:** Build features 2-5x faster without sacrificing quality.