Skip to content
John SchibelliSoftware Engineer
← ALL ARTICLES

How I Built a 3-Agent AI System to Manage 29 Pull Requests in Parallel

How I divided 29 open pull requests across three specialized agents, then designed the coordination and conflict-prevention rules around them.


Three suited figures interact with holographic panels labeled Agent 1, Agent 2, and Agent 3 above a glowing circuit table.

The 29-PR Problem

Picture this: It's launch week for your portfolio project. Everything is live, users are engaging, and your GitHub notifications are exploding. Twenty-nine open pull requests stare back at you from the project board—each one important, each one blocking something else.

Four PRs focused on performance optimizations. Sixteen dealing with testing infrastructure and TypeScript compilation errors. Nine implementing a complete AI chatbot enhancement epic. All requiring different expertise: frontend specialists for UI work, infrastructure engineers for testing frameworks, and AI developers for the chatbot features.

The traditional approach? Pick one, context switch, implement, review, merge, repeat. At that pace, you're looking at weeks—maybe months—of serial development. Even with two developers working in parallel, the bottlenecks remain: shared files, merge conflicts, coordination overhead.

This is a problem every developer faces as projects scale. The more successful your project, the more features users want, the more issues pile up, and the more you become the bottleneck.

I needed a different approach. Not just automation—intelligent, parallel automation with specialized expertise. That's when I built what I call the "3-Agent Multi-Development System."

The Journey: From Manual to Multi-Agent

The Evolution

My automation journey didn't start with AI agents. Like most developers, it began with simple scripts:

Stage 1: Basic Scripts (The "I'm tired of typing this" phase)

Stage 2: GitHub Actions (The "Let's automate CI/CD" phase)

Stage 3: PowerShell Orchestration (The "This is getting complex" phase)

Stage 4: The Multi-Agent Breakthrough (The "Wait, what if..." phase)

The breakthrough came when I realized: AI assistants don't just write code—they can specialize.

Just like a real development team, you don't hire generalists for everything. You have:

What if AI agents could work the same way? Each with their own expertise, their own workspace, all working in parallel without conflicts.

The "Aha" Moment

It hit me while reviewing my 29 open PRs. They naturally clustered into three categories:

  1. Frontend/UI work - Performance, accessibility, dashboard enhancements
  2. Infrastructure/Testing - TypeScript fixes, test framework, CI/CD
  3. AI Features - Chatbot enhancements, streaming responses, analytics

Each category needed different skills. More importantly, they rarely touched the same files. They could be developed in complete isolation.

That's when I designed the 3-agent architecture.

The Solution: 3-Agent Architecture

Agent Distribution Strategy

I divided the 29 PRs across three specialized agents based on expertise and file ownership:

PLAINTEXT

| Agent   | Focus                     | PRs | Priority  | Timeline  |
|---------|---------------------------|-----|-----------|-----------|
| Agent 1 | Frontend/UI Specialist    | 4   | P1        | Weeks 2-3 |
| Agent 2 | Infrastructure/SEO        | 16  | P0, P1    | Weeks 1-3 |
| Agent 3 | Chatbot Features          | 9   | P0, P1,P2 | Weeks 1-2 |
| Total   | -                         | 29  | -         | 3 weeks   |

Why This Distribution Works

Agent 1: Frontend/UI Specialist (4 PRs)

Agent 2: Infrastructure/SEO Specialist (16 PRs)

Agent 3: Chatbot Features Specialist (9 PRs)

The Key Insight: Exclusive File Ownership

The magic of this system is conflict prevention through exclusive ownership:

PLAINTEXT

Agent 1 owns:
  - apps/site/components/ui/*
  - apps/dashboard/components/*
  - Performance-related files

Agent 2 owns:
  - **/*.test.tsx
  - jest.config.js
  - tsconfig.json
  - CI/CD workflows

Agent 3 owns:
  - apps/site/components/features/chatbot/Chatbot.tsx
  - apps/site/app/api/chat/route.ts
  - apps/site/app/api/tts/route.ts

Zero overlap = Zero conflicts = Maximum parallelization

Automation Pipeline: The 5-Phase Workflow

Here's where the real magic happens. Each agent follows a complete end-to-end workflow:

Phase 1: Issue Analysis & Configuration

When an issue is created, the system automatically:

POWERSHELL

# Analyzes issue requirements
.\scripts\issue-config-unified.ps1 -IssueNumber 333 -Preset chatbot -AddToProject

# This automatically:
# - Analyzes issue complexity and requirements
# - Sets project fields (Status=In progress, Priority, Size, App, Area)
# - Assigns to appropriate agent
# - Creates detailed implementation plan

Real example from the system:

Issue #333: Implement streaming responses with OpenAI
├── Analyzed: High complexity, AI/Frontend hybrid
├── Priority: P0 (Critical)
├── Size: M (Medium, 1-1.5 hours)
├── Area: Chatbot
└── Assigned to: Agent 3 (Chatbot Specialist)

Phase 2: Branch Creation & Environment Setup

Each agent works in isolated worktrees:

POWERSHELL

# Create branch from develop
.\scripts\create-branch-from-release.ps1 -IssueNumber 333 -BaseBranch "develop"

# This automatically:
# - Creates feature/chatbot-streaming-responses-333 branch
# - Sets up agent's worktree environment
# - Syncs with latest changes
# - Validates environment

Worktree structure:

portfolio-os/                  # Main repo
├── worktrees/
│   ├── agent-1-chris/        # Frontend agent workspace
│   ├── agent-2-jason/        # Infrastructure agent workspace
│   └── agent-3-chatbot/      # Chatbot agent workspace
├── worktree-state.json       # Central coordination
└── scripts/                  # Automation scripts

Each worktree is a complete, isolated clone of the repository on a different branch. No conflicts, no interference.

Phase 3: Implementation & Testing

The implementation phase is fully automated:

POWERSHELL

# Implement the issue with AI assistance
.\scripts\issue-implementation.ps1 -IssueNumber 333 -Agent Agent3

# This automatically:
# - Generates implementation code
# - Runs linters and type checkers
# - Executes test suites
# - Validates accessibility and performance
# - Updates documentation

Phase 4: PR Creation & Review

PR creation is streamlined and intelligent:

POWERSHELL

# Create PR with auto-generated description and metadata
.\scripts\pr-automation-unified.ps1 -IssueNumber 333 -Action create -BaseBranch "develop"

# This automatically:
# - Creates PR with comprehensive description
# - Links to issue and epic
# - Adds appropriate labels (agent-3, chatbot, P0)
# - Assigns reviewers
# - Updates project status to "Ready"
# - Triggers CI/CD pipeline

Phase 5: Review Automation & Merge

The most powerful part—automated review handling:

POWERSHELL

# Monitor PR and automate review responses
.\scripts\pr-automation-unified.ps1 -PRNumber 333 -Action all -AutoFix

# This automatically:
# - Monitors CR-GPT bot comments
# - Categorizes feedback by priority
# - Generates threaded responses to comments
# - Implements fixes for critical issues
# - Runs quality checks (lint, test, build)
# - Updates project status
# - Merges when all checks pass

The result? A complete hands-off workflow from issue creation to merge.

The Agent Assignment System

One of the most critical pieces is intelligent agent assignment. Here's the actual script that assigns all chatbot PRs to Agent 3:

POWERSHELL

# Define all 9 chatbot PRs with metadata
$chatbotPRs = @(
    @{
        Number = 333
        Issue = 322
        Title = "feat(chatbot): implement streaming responses"
        Priority = "P0"
        Phase = 1
    },
    @{
        Number = 337
        Issue = 324
        Title = "fix(chatbot): improve error handling"
        Priority = "P0"
        Phase = 1
    },
    # ... 7 more PRs
)

# Verify all PRs exist and are open
foreach ($pr in $chatbotPRs) {
    $prInfo = gh pr view $($pr.Number) --json number,title,state
    if ($prData.state -eq "OPEN") {
        # Assign to Agent 3
        gh pr edit $($pr.Number) --add-assignee "@me"
        # Add tracking labels
        gh pr edit $($pr.Number) --add-label "agent-3,chatbot,$($pr.Priority)"
    }
}

The script provides phase-based guidance:

Phase 1: Critical Features (P0)
  - PR #333 - Streaming responses (HIGHEST PRIORITY)
  - PR #337 - Error handling
  - PR #336 - Analytics tracking

Phase 2: UX Enhancements (P1)
  - PR #340 - Typing indicators (depends on #333)
  - PR #334 - Conversation persistence
  - PR #335 - Quick reply suggestions
  - PR #332 - Context window expansion

Phase 3: Quality (P2 - Optional)
  - PR #338 - Component modularization
  - PR #339 - TypeScript types & documentation

This creates a dependency-aware workflow where Phase 1 must complete before Phase 2 begins.

Real-World Results

The Numbers

Before Multi-Agent System:

After Multi-Agent System:

Specific wins:

Quality Improvements

The system didn't just make things faster—it made them better:

Automated Quality Gates:

CR-GPT Integration: Every PR gets AI-powered code review with:

Developer Experience

The most surprising benefit? Mental clarity.

Instead of juggling 29 different contexts, I focus on:

  1. Orchestration - Ensuring agents have clear tasks
  2. Quality review - Final approval on completed work
  3. Strategy - Planning the next phase

The agents handle:

Conflict Prevention & Coordination

The Central State System

Conflict prevention starts with state management:

JSON

// worktree-state.json
{
  "version": "1.0.0",
  "agents": {
    "agent-3-chatbot": {
      "name": "Chatbot Specialist",
      "worktree": "worktrees/agent-3-chatbot",
      "branch": "feature/chatbot-streaming-responses-333",
      "assignedIssues": [322, 323, 324, 325, 326, 327, 328, 329, 330, 331],
      "status": "active",
      "lastSync": "2025-10-13T10:30:00Z"
    }
  },
  "fileOwnership": {
    "apps/site/components/features/chatbot/Chatbot.tsx": "agent-3-chatbot",
    "apps/site/app/api/chat/route.ts": "agent-3-chatbot",
    "apps/dashboard/tsconfig.json": "agent-2-jason"
  }
}

Before any work begins:

  1. Check if file is owned by another agent
  2. If owned, coordinate the change
  3. If not owned, claim ownership
  4. Proceed with implementation

Automatic Conflict Detection

POWERSHELL

# Check for conflicts before starting work
.\scripts\check-agent-conflicts.ps1 `
  -Agents "Agent1,Agent2,Agent3" `
  -PRs "262,320,333"

# Output:
# ✅ No conflicts detected
# ✅ All agents have exclusive file ownership
# ✅ Safe to proceed with parallel development

Coordination for Shared Changes

When agents must touch shared files (rare, but happens):

POWERSHELL

# Coordinate changes to shared file
.\scripts\coordinate-shared-changes.ps1 `
  -File "apps/site/components/features/chatbot/Chatbot.tsx" `
  -Agents "Agent3" `
  -Exclusive $true

# This:
# - Locks the file for Agent3
# - Notifies other agents
# - Prevents concurrent modifications
# - Releases lock after merge

How You Can Apply This

When Multi-Agent Makes Sense

This approach works best when:

✅ You have 15+ PRs/issues in your backlog ✅ Work naturally clusters into 2-3 domains ✅ File ownership can be divided (minimal overlap) ✅ You want to reduce context switching ✅ Parallel work is possible (independent features)

It's probably overkill if: ❌ You have < 10 issues ❌ All work touches the same core files ❌ You're a solo developer working sequentially ❌ Issues are highly interdependent

Starting Small: 2-Agent Approach

Don't start with three agents. Start with two:

Agent 1: Frontend Specialist

Agent 2: Backend/Infrastructure Specialist

Key scripts to build first:

  1. Agent Assignment Script (assign-agents.ps1)

    • Analyzes issues
    • Routes to appropriate agent
    • Updates project board
  2. Worktree Manager (manage-worktrees.ps1)

    • Creates isolated workspaces
    • Syncs with main branch
    • Cleans up after merge
  3. PR Automation (automate-pr.ps1)

    • Creates PRs with metadata
    • Monitors review comments
    • Handles automated responses
  4. Conflict Checker (check-conflicts.ps1)

    • Validates file ownership
    • Detects potential conflicts
    • Coordinates shared changes

Tools & Technologies

My stack:

Why PowerShell?

The core automation pattern:

POWERSHELL

# 1. Detect event (new issue, PR update, etc.)
# 2. Analyze context (what changed, what's needed)
# 3. Determine action (which agent, what workflow)
# 4. Execute with retry logic
# 5. Update state and notify
# 6. Monitor for completion

Implementation Roadmap

Week 1: Foundation

Week 2: PR Automation

Week 3: Intelligence

Week 4: Scale

Lessons Learned

What Worked

  1. Exclusive File Ownership is Key

    • The single biggest factor in preventing conflicts
    • Worth spending time to analyze and divide files upfront
  2. Start with Manual, Then Automate

    • Don't automate until you've done it manually 3+ times
    • Understand the edge cases before coding them
  3. State Management is Critical

    • Central state file (worktree-state.json) prevents races
    • File locking mechanisms are essential
    • Always validate state before actions
  4. Phase-Based Execution

    • Dependencies matter (Phase 1 before Phase 2)
    • Clear phases reduce complexity
    • Easy to track progress
  5. AI Agents Love Clear Constraints

    • Narrow focus = Better results
    • Exclusive file lists prevent confusion
    • Clear acceptance criteria guide implementation

What Didn't Work (At First)

  1. Dynamic Agent Assignment

    • Initially tried to auto-assign based on AI analysis
    • Too complex, too many edge cases
    • Manual categorization with automated routing works better
  2. Full Automation From Day 1

    • Tried to automate everything immediately
    • Hit edge cases constantly
    • Better to automate incrementally
  3. Shared File Coordination

    • First attempt at real-time locking failed
    • File system locks aren't reliable across worktrees
    • Moved to state-based ownership tracking
  4. Too Many Agents

    • Tried 5 agents initially
    • Coordination overhead was too high
    • 3 agents is the sweet spot for this project size

Best Practices

For Agent Design:

For Automation:

For Coordination:

For Scaling:

The Future: What's Next

Planned Enhancements

Machine Learning-Based Assignment

Advanced Conflict Resolution

Cross-Project Agents

Visual Dashboard

Applying to Other Domains

This pattern works beyond web development:

Mobile App Development

Data Science

DevOps

Content Creation

Conclusion

Building a multi-agent development system transformed how I work. What started as a crisis—29 overwhelming PRs—became an opportunity to rethink development workflows.

The key insights:

  1. Specialization beats generalization when work can be divided
  2. Parallel execution is possible with proper isolation
  3. Automation enables scale but requires thoughtful design
  4. AI agents work best with clear constraints and exclusive ownership
  5. Incremental automation beats big-bang approaches

The results speak for themselves:

This isn't just about automation—it's about sustainable development at scale.

Whether you're a solo developer drowning in issues or a team looking to optimize workflows, the multi-agent approach offers a path forward. Start small, focus on file ownership, automate incrementally, and watch your productivity soar.

The future of development isn't just AI-assisted—it's AI-orchestrated with specialized agents working in harmony. And that future is available today.


Resources & Next Steps

Want to implement this yourself?

  1. Explore the code: Check out my portfolio-os repository (scripts in /scripts/agent-management/)

  2. Start with basics:

    • Set up git worktrees
    • Create simple agent assignment logic
    • Automate one workflow end-to-end
  3. Join the conversation:

    • Share your multi-agent experiments
    • Discuss challenges and solutions
    • Build the future of development together
  4. Follow along: I'll be sharing more automation patterns, lessons learned, and advanced techniques.

Questions? Ideas? Drop them in the comments below. I'd love to hear about your automation journey and help you build your own multi-agent system.


This blog post is part of my ongoing series on development automation and AI-assisted workflows. Subscribe to get notified when new posts drop!