s9n-devops-agent 1.7.4 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,692 @@
1
+ # Multi-Agent Workflows Guide
2
+
3
+ **DevOps Agent v2.0**
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ Run multiple AI agents simultaneously on the same project without conflicts, leveraging isolated sessions and file coordination.
10
+
11
+ ### Quick Facts
12
+
13
+ - **Multiple agents:** Claude, Cursor, Copilot, Cline, etc.
14
+ - **Isolated workspaces:** Each agent gets own worktree
15
+ - **File coordination:** Prevents conflicting edits
16
+ - **Automatic merging:** All changes converge to main branch
17
+
18
+ ---
19
+
20
+ ## Why Use Multiple Agents?
21
+
22
+ ### Parallel Development
23
+
24
+ ```
25
+ Agent 1 (Claude): Implements authentication
26
+ Agent 2 (Cursor): Builds API endpoints
27
+ Agent 3 (Copilot): Writes unit tests
28
+
29
+ All working simultaneously, no conflicts!
30
+ ```
31
+
32
+ ### Specialized Tasks
33
+
34
+ ```
35
+ Frontend specialist: Claude works on React components
36
+ Backend specialist: Cursor works on Node.js API
37
+ DevOps specialist: Copilot writes Docker config
38
+ ```
39
+
40
+ ### Faster Delivery
41
+
42
+ - **3 agents = 3x throughput** (when properly coordinated)
43
+ - **No waiting:** Agents work in parallel
44
+ - **Clean merges:** Automated daily branch consolidation
45
+
46
+ ---
47
+
48
+ ## How It Works
49
+
50
+ ### Architecture
51
+
52
+ ```
53
+ Main Branch (main)
54
+
55
+ Daily Branch (dev_abc_2025-10-31)
56
+
57
+ Session Branches
58
+ ├── session/implement-auth_abc1 (Agent 1: Claude)
59
+ ├── session/build-api_xyz2 (Agent 2: Cursor)
60
+ └── session/add-tests_def3 (Agent 3: Copilot)
61
+ ```
62
+
63
+ ### Workflow
64
+
65
+ 1. **Create sessions** for each agent
66
+ 2. **Assign tasks** (non-overlapping files ideal)
67
+ 3. **Agents work** in isolated worktrees
68
+ 4. **Automatic commits** and pushes
69
+ 5. **Close sessions** when done
70
+ 6. **Merge to daily branch** automatically
71
+ 7. **Daily rollover** merges to main
72
+
73
+ ---
74
+
75
+ ## Basic Multi-Agent Workflow
76
+
77
+ ### Step 1: Plan Task Distribution
78
+
79
+ **Before starting, decide:**
80
+ - Who works on which files?
81
+ - Any dependencies?
82
+ - Coordination points?
83
+
84
+ **Example plan:**
85
+ ```
86
+ Task: Build authentication system
87
+
88
+ Agent 1 (Claude):
89
+ - src/auth/login.js
90
+ - src/auth/token.js
91
+
92
+ Agent 2 (Cursor):
93
+ - src/api/auth-routes.js
94
+ - src/middleware/auth.js
95
+
96
+ Agent 3 (Copilot):
97
+ - tests/auth.test.js
98
+ - docs/auth-api.md
99
+ ```
100
+
101
+ ### Step 2: Create Sessions
102
+
103
+ **Terminal 1 (Agent 1 - Claude):**
104
+ ```bash
105
+ s9n-devops-agent start
106
+ # Choose: N) Create new session
107
+ # Task: implement-auth-core
108
+ # Agent: Claude
109
+ ```
110
+
111
+ **Terminal 2 (Agent 2 - Cursor):**
112
+ ```bash
113
+ s9n-devops-agent start
114
+ # Choose: N) Create new session
115
+ # Task: build-auth-api
116
+ # Agent: Cursor
117
+ ```
118
+
119
+ **Terminal 3 (Agent 3 - Copilot):**
120
+ ```bash
121
+ s9n-devops-agent start
122
+ # Choose: N) Create new session
123
+ # Task: write-auth-tests
124
+ # Agent: Copilot
125
+ ```
126
+
127
+ ### Step 3: Provide Instructions
128
+
129
+ **Each agent receives:**
130
+ - Session ID (e.g., `abc1-23d4`)
131
+ - Worktree path
132
+ - House rules
133
+ - **File declarations** (critical!)
134
+
135
+ ### Step 4: Agents Work in Parallel
136
+
137
+ **Agent 1 workspace:**
138
+ ```
139
+ local_deploy/worktrees/abc1-23d4/
140
+ ├── src/auth/login.js ← Working here
141
+ └── src/auth/token.js ← And here
142
+ ```
143
+
144
+ **Agent 2 workspace:**
145
+ ```
146
+ local_deploy/worktrees/xyz5-67d8/
147
+ ├── src/api/auth-routes.js ← Working here
148
+ └── src/middleware/auth.js ← And here
149
+ ```
150
+
151
+ **Agent 3 workspace:**
152
+ ```
153
+ local_deploy/worktrees/def9-01gh/
154
+ ├── tests/auth.test.js ← Working here
155
+ └── docs/auth-api.md ← And here
156
+ ```
157
+
158
+ **No conflicts!** Each agent in own workspace.
159
+
160
+ ### Step 5: Close Sessions
161
+
162
+ **When each agent finishes:**
163
+ ```bash
164
+ s9n-devops-agent close abc1-23d4 # Agent 1
165
+ s9n-devops-agent close xyz5-67d8 # Agent 2
166
+ s9n-devops-agent close def9-01gh # Agent 3
167
+ ```
168
+
169
+ **Automatic merge flow:**
170
+ ```
171
+ session/implement-auth_abc1 → dev_abc_2025-10-31
172
+ session/build-auth-api_xyz5 → dev_abc_2025-10-31
173
+ session/write-auth-tests_def9 → dev_abc_2025-10-31
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Advanced Patterns
179
+
180
+ ### Pattern 1: Sequential Handoff
181
+
182
+ **Use when:** Agent 2 depends on Agent 1's work
183
+
184
+ **Flow:**
185
+ ```
186
+ 1. Agent 1: Implements core auth logic → closes session
187
+ ↓ (merges to daily branch)
188
+ 2. Agent 2: Pulls daily branch → starts session → builds API
189
+
190
+ 3. Agent 3: Pulls daily branch → starts session → writes tests
191
+ ```
192
+
193
+ **Commands:**
194
+ ```bash
195
+ # Agent 1 finishes
196
+ s9n-devops-agent close abc1
197
+
198
+ # Agent 2 starts (on daily branch with Agent 1's work)
199
+ git checkout dev_abc_2025-10-31
200
+ s9n-devops-agent start
201
+ ```
202
+
203
+ ### Pattern 2: Concurrent + Coordination
204
+
205
+ **Use when:** Some files overlap, need coordination
206
+
207
+ **Setup:**
208
+ ```
209
+ Agent 1: Works on src/auth/login.js
210
+ Agent 2: Wants to edit src/auth/login.js too
211
+
212
+ Coordination:
213
+ 1. Agent 1 declares and locks login.js
214
+ 2. Agent 2 sees lock, works on different file first
215
+ 3. Agent 1 finishes, commits, closes → releases lock
216
+ 4. Agent 2 declares login.js, continues work
217
+ ```
218
+
219
+ **Commands:**
220
+ ```bash
221
+ # Agent 1
222
+ cat .file-coordination/active-edits/claude-abc1.json
223
+ # Shows: "files": ["src/auth/login.js"]
224
+
225
+ # Agent 2 checks
226
+ ls .file-coordination/active-edits/
227
+ # Sees claude-abc1.json → knows login.js is locked
228
+
229
+ # Agent 2 works on different file, waits for Agent 1
230
+ ```
231
+
232
+ ### Pattern 3: Fan-Out / Fan-In
233
+
234
+ **Use when:** One agent creates foundation, many extend it
235
+
236
+ **Flow:**
237
+ ```
238
+ Agent 1 (Foundation):
239
+ Creates auth framework → closes session
240
+
241
+ Agent 2, 3, 4 (Extensions):
242
+ All pull foundation → create parallel sessions
243
+ Agent 2: Add OAuth
244
+ Agent 3: Add JWT
245
+ Agent 4: Add 2FA
246
+
247
+ All close → merge to daily branch
248
+ ```
249
+
250
+ ### Pattern 4: Review & Iterate
251
+
252
+ **Use when:** One agent reviews another's work
253
+
254
+ **Flow:**
255
+ ```
256
+ 1. Agent 1: Implements feature → commits → pauses (don't close!)
257
+ 2. Agent 2 (Reviewer): Creates new session → reviews code
258
+ 3. Agent 2: Adds comments, suggestions → closes session
259
+ 4. Agent 1 (Resumes): Reviews feedback → makes changes → closes
260
+ ```
261
+
262
+ **Commands:**
263
+ ```bash
264
+ # Agent 1 pauses (session stays open)
265
+ # Just stops working, doesn't close
266
+
267
+ # Agent 2 reviews
268
+ s9n-devops-agent start
269
+ # Create new session
270
+ # Review Agent 1's worktree files
271
+ # Add review comments
272
+ s9n-devops-agent close xyz5
273
+
274
+ # Agent 1 resumes
275
+ cd local_deploy/worktrees/abc1-23d4
276
+ # Address feedback
277
+ # Commit changes
278
+ s9n-devops-agent close abc1
279
+ ```
280
+
281
+ ---
282
+
283
+ ## File Coordination Strategies
284
+
285
+ ### Strategy 1: File-Level Separation
286
+
287
+ **Best for:** Independent modules
288
+
289
+ **Example:**
290
+ ```
291
+ Agent 1: src/auth/*
292
+ Agent 2: src/api/*
293
+ Agent 3: src/utils/*
294
+
295
+ Zero overlap → no coordination needed!
296
+ ```
297
+
298
+ ### Strategy 2: Feature-Level Separation
299
+
300
+ **Best for:** Full-stack features
301
+
302
+ **Example:**
303
+ ```
304
+ Feature: User Profile
305
+
306
+ Agent 1 (Frontend):
307
+ - src/components/UserProfile.jsx
308
+ - src/styles/profile.css
309
+
310
+ Agent 2 (Backend):
311
+ - src/api/user-routes.js
312
+ - src/models/user.js
313
+
314
+ Agent 3 (Tests):
315
+ - tests/profile.test.js
316
+ - tests/user-api.test.js
317
+ ```
318
+
319
+ ### Strategy 3: Layer-Level Separation
320
+
321
+ **Best for:** Architectural layers
322
+
323
+ **Example:**
324
+ ```
325
+ Agent 1 (Data layer): src/models/*
326
+ Agent 2 (Business logic): src/services/*
327
+ Agent 3 (API layer): src/api/*
328
+ Agent 4 (UI layer): src/components/*
329
+ ```
330
+
331
+ ### Strategy 4: Time-Boxed Rotation
332
+
333
+ **Best for:** Overlapping needs
334
+
335
+ **Example:**
336
+ ```
337
+ Time Block 1 (9am-11am): Agent 1 works on shared file
338
+ Time Block 2 (11am-1pm): Agent 2 works on shared file
339
+ Time Block 3 (1pm-3pm): Agent 3 works on shared file
340
+
341
+ Coordination via time slots!
342
+ ```
343
+
344
+ ---
345
+
346
+ ## Communication Between Agents
347
+
348
+ ### Method 1: Commit Messages
349
+
350
+ **Agent 1 commits:**
351
+ ```
352
+ feat(auth): implement login flow
353
+
354
+ - Added login.js with JWT token generation
355
+ - TODO: Agent 2, please add API endpoint at /api/login
356
+ - Auth logic returns { token, user }
357
+ ```
358
+
359
+ **Agent 2 sees commit in daily branch:**
360
+ ```bash
361
+ git log --oneline dev_abc_2025-10-31
362
+ # Reads Agent 1's TODO
363
+ # Implements /api/login endpoint
364
+ ```
365
+
366
+ ### Method 2: Code Comments
367
+
368
+ **Agent 1 leaves comment:**
369
+ ```javascript
370
+ // src/auth/login.js
371
+
372
+ // @AGENT2: Please create API route handler that:
373
+ // 1. Accepts email + password
374
+ // 2. Calls this validateCredentials() function
375
+ // 3. Returns JWT token on success
376
+ export function validateCredentials(email, password) {
377
+ // ...
378
+ }
379
+ ```
380
+
381
+ **Agent 2 reads and implements:**
382
+ ```javascript
383
+ // src/api/auth-routes.js
384
+
385
+ // @AGENT1: API route implemented as requested
386
+ app.post('/api/login', async (req, res) => {
387
+ const { email, password } = req.body;
388
+ const valid = await validateCredentials(email, password);
389
+ // ...
390
+ });
391
+ ```
392
+
393
+ ### Method 3: Shared Documentation
394
+
395
+ **Create a coordination doc:**
396
+ ```bash
397
+ # AGENT_COORDINATION.md
398
+
399
+ ## Auth Feature - Agent Assignments
400
+
401
+ ### Agent 1 (Claude) - Core Logic
402
+ Status: ✅ Complete
403
+ Files: src/auth/login.js, src/auth/token.js
404
+ Notes: JWT token generation ready
405
+
406
+ ### Agent 2 (Cursor) - API Routes
407
+ Status: 🚧 In Progress
408
+ Files: src/api/auth-routes.js
409
+ Dependencies: Needs Agent 1's work (complete)
410
+ Next: Add /api/refresh endpoint
411
+
412
+ ### Agent 3 (Copilot) - Tests
413
+ Status: ⏳ Waiting
414
+ Dependencies: Needs Agent 1 and 2 complete
415
+ Files: tests/auth.test.js
416
+ ```
417
+
418
+ ---
419
+
420
+ ## Handling Conflicts
421
+
422
+ ### Scenario: Unintended File Overlap
423
+
424
+ **What happened:**
425
+ ```
426
+ Agent 1: Edited src/config.js (forgot to declare)
427
+ Agent 2: Edited src/config.js (declared properly)
428
+ Result: Conflict when merging!
429
+ ```
430
+
431
+ **Resolution:**
432
+ ```bash
433
+ # 1. Identify conflicting commits
434
+ git log --all --oneline --graph
435
+
436
+ # 2. Manual merge
437
+ git checkout dev_abc_2025-10-31
438
+ git merge session/task1_abc1
439
+ git merge session/task2_xyz5
440
+ # Resolve conflicts in src/config.js
441
+
442
+ # 3. Commit merge
443
+ git commit -m "fix: resolve config.js conflict between agents"
444
+ ```
445
+
446
+ ### Scenario: Race Condition
447
+
448
+ **What happened:**
449
+ ```
450
+ Agent 1: Declares src/auth.js at 10:00:00
451
+ Agent 2: Declares src/auth.js at 10:00:01
452
+ Result: Conflict warning!
453
+ ```
454
+
455
+ **Resolution:**
456
+ ```bash
457
+ # System detects, warns Agent 2
458
+ # Agent 2 chooses:
459
+ # Option A: Work on different file
460
+ # Option B: Wait for Agent 1 to finish
461
+ # Option C: Coordinate to split the file
462
+ ```
463
+
464
+ ---
465
+
466
+ ## Monitoring Multiple Agents
467
+
468
+ ### Check Active Sessions
469
+
470
+ ```bash
471
+ s9n-devops-agent list
472
+ ```
473
+
474
+ **Output:**
475
+ ```
476
+ Active Sessions:
477
+ 1. abc1-23d4 (claude, implement-auth-core)
478
+ Files: 2 locked
479
+ Last activity: 2 minutes ago
480
+
481
+ 2. xyz5-67d8 (cursor, build-auth-api)
482
+ Files: 3 locked
483
+ Last activity: 1 minute ago
484
+
485
+ 3. def9-01gh (copilot, write-auth-tests)
486
+ Files: 1 locked
487
+ Last activity: 30 seconds ago
488
+ ```
489
+
490
+ ### Check File Locks
491
+
492
+ ```bash
493
+ ls -la .file-coordination/active-edits/
494
+ ```
495
+
496
+ **Output:**
497
+ ```
498
+ claude-abc1-23d4.json
499
+ cursor-xyz5-67d8.json
500
+ copilot-def9-01gh.json
501
+ ```
502
+
503
+ ### Check Who's Editing What
504
+
505
+ ```bash
506
+ cat .file-coordination/active-edits/*.json | jq '.files[]'
507
+ ```
508
+
509
+ **Output:**
510
+ ```
511
+ "src/auth/login.js"
512
+ "src/auth/token.js"
513
+ "src/api/auth-routes.js"
514
+ "src/middleware/auth.js"
515
+ "tests/auth.test.js"
516
+ ```
517
+
518
+ ---
519
+
520
+ ## Best Practices
521
+
522
+ ### 1. Plan Before Starting
523
+
524
+ - Map out file/feature assignments
525
+ - Identify dependencies
526
+ - Schedule coordination points
527
+
528
+ ### 2. Clear Communication
529
+
530
+ - Use commit messages
531
+ - Leave code comments
532
+ - Update coordination docs
533
+
534
+ ### 3. Declare Files Early
535
+
536
+ - Always declare before editing
537
+ - Update declarations when adding files
538
+ - Check for conflicts proactively
539
+
540
+ ### 4. Close Sessions Promptly
541
+
542
+ - Don't leave sessions open overnight
543
+ - Release locks when done
544
+ - Merge work to daily branch regularly
545
+
546
+ ### 5. Test Integrations
547
+
548
+ - When multiple agents finish, test together
549
+ - Run full test suite
550
+ - Verify no integration issues
551
+
552
+ ---
553
+
554
+ ## Troubleshooting
555
+
556
+ ### Problem: Agents stepping on each other
557
+
558
+ **Solution:** Better file coordination
559
+ ```bash
560
+ # Review declarations
561
+ cat .file-coordination/active-edits/*.json
562
+
563
+ # Ensure no overlaps
564
+ # Reassign files if needed
565
+ ```
566
+
567
+ ### Problem: Merge conflicts on close
568
+
569
+ **Solution:** Smaller, frequent merges
570
+ ```bash
571
+ # Close sessions more frequently
572
+ # Merge to daily branch regularly
573
+ # Reduces conflict surface area
574
+ ```
575
+
576
+ ### Problem: Lost track of who's doing what
577
+
578
+ **Solution:** Session monitoring
579
+ ```bash
580
+ # Check active sessions
581
+ s9n-devops-agent list
582
+
583
+ # Review coordination doc
584
+ cat AGENT_COORDINATION.md
585
+ ```
586
+
587
+ ---
588
+
589
+ ## Example: 3-Agent Authentication Feature
590
+
591
+ ### Setup
592
+
593
+ **Feature:** Complete authentication system
594
+ **Agents:** Claude, Cursor, Copilot
595
+ **Timeline:** 2 hours
596
+
597
+ ### Distribution
598
+
599
+ ```
600
+ Agent 1 (Claude) - Core Logic (45 min)
601
+ ├── src/auth/login.js
602
+ ├── src/auth/token.js
603
+ └── src/auth/validation.js
604
+
605
+ Agent 2 (Cursor) - API Layer (45 min)
606
+ ├── src/api/auth-routes.js
607
+ ├── src/middleware/auth.js
608
+ └── src/api/user-routes.js
609
+
610
+ Agent 3 (Copilot) - Tests & Docs (45 min)
611
+ ├── tests/auth.test.js
612
+ ├── tests/api.test.js
613
+ └── docs/AUTH_API.md
614
+ ```
615
+
616
+ ### Execution
617
+
618
+ **10:00 AM - All agents start**
619
+ ```bash
620
+ # Terminal 1
621
+ s9n-devops-agent start # Claude: implement-auth-core
622
+
623
+ # Terminal 2
624
+ s9n-devops-agent start # Cursor: build-auth-api
625
+
626
+ # Terminal 3
627
+ s9n-devops-agent start # Copilot: write-auth-tests
628
+ ```
629
+
630
+ **10:45 AM - Agent 1 (Claude) finishes**
631
+ ```bash
632
+ s9n-devops-agent close abc1-23d4
633
+ # Merges to: dev_abc_2025-10-31
634
+ ```
635
+
636
+ **10:50 AM - Agent 2 (Cursor) finishes**
637
+ ```bash
638
+ s9n-devops-agent close xyz5-67d8
639
+ # Merges to: dev_abc_2025-10-31
640
+ ```
641
+
642
+ **11:00 AM - Agent 3 (Copilot) finishes**
643
+ ```bash
644
+ s9n-devops-agent close def9-01gh
645
+ # Merges to: dev_abc_2025-10-31
646
+ ```
647
+
648
+ **11:05 AM - Integration test**
649
+ ```bash
650
+ git checkout dev_abc_2025-10-31
651
+ npm test
652
+ # All tests pass! ✅
653
+ ```
654
+
655
+ **Result:** Complete auth system in 1 hour, 3 agents working in parallel!
656
+
657
+ ---
658
+
659
+ ## Summary
660
+
661
+ ### Key Takeaways
662
+
663
+ 1. **Multiple agents = parallel work** (when coordinated)
664
+ 2. **File coordination prevents conflicts**
665
+ 3. **Clear communication is critical**
666
+ 4. **Plan distribution before starting**
667
+ 5. **Close sessions promptly**
668
+
669
+ ### Multi-Agent Flow
670
+
671
+ ```
672
+ 1. Plan task distribution (who does what?)
673
+
674
+ 2. Create sessions (one per agent)
675
+
676
+ 3. Agents work in parallel (isolated worktrees)
677
+
678
+ 4. Coordinate overlaps (file locks + communication)
679
+
680
+ 5. Close sessions (merge to daily branch)
681
+
682
+ 6. Integration test (verify all works together)
683
+ ```
684
+
685
+ ---
686
+
687
+ **Need Help?** Run `s9n-devops-agent help-topics` and select "Workflows"
688
+
689
+ **Related Guides:**
690
+ - File Coordination Guide
691
+ - Session Management Guide
692
+ - House Rules Guide