agent-fork-join
Multi-agent git workflow orchestrator with isolated worktrees, FIFO merge queue, and automated PR lifecycle management.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Multi-agent git workflow orchestrator with isolated worktrees, FIFO merge queue, and automated PR lifecycle management.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | Agent Fork-Join |
| description | Multi-agent git workflow orchestrator with isolated worktrees, FIFO merge queue, and automated PR lifecycle management. |
A sophisticated multi-agent orchestration system that enables parallel agent work with isolated git worktrees, automatic conflict resolution, and full PR lifecycle automation.
Agent Fork-Join solves the fundamental challenge of multiple AI agents working on the same codebase simultaneously. Each agent operates in an isolated git worktree, and a Rust-based merge daemon coordinates the integration of all changes through a FIFO queue with automatic conflict resolution.
┌─────────────────────────────────────────────────────────────────────────┐
│ User Prompt (makes changes) │
└─────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ UserPromptSubmit Hook │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ 1. Detect if prompt will make changes │ │
│ │ 2. Create feature branch (if not on one) │ │
│ │ 3. Start merge daemon (if not running) │ │
│ │ 4. Initialize session state │ │
│ └─────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ Orchestrator Spawns Agents │
└─────────────────────────────────────────────────────────────────────────┘
│ │ │
▼ ▼ ▼
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ AgentSpawn │ │ AgentSpawn │ │ AgentSpawn │
│ Hook │ │ Hook │ │ Hook │
│ │ │ │ │ │
│ Create worktree │ │ Create worktree │ │ Create worktree │
│ agent/agent-1 │ │ agent/agent-2 │ │ agent/agent-3 │
└──────────────────┘ └──────────────────┘ └──────────────────┘
│ │ │
▼ ▼ ▼
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Agent Works │ │ Agent Works │ │ Agent Works │
│ (isolated) │ │ (isolated) │ │ (isolated) │
└──────────────────┘ └──────────────────┘ └──────────────────┘
│ │ │
▼ ▼ ▼
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ AgentComplete │ │ AgentComplete │ │ AgentComplete │
│ Hook │ │ Hook │ │ Hook │
│ │ │ │ │ │
│ 1. Check diff │ │ 1. Check diff │ │ 1. Check diff │
│ 2. Get commit │ │ 2. Get commit │ │ 2. Get commit │
│ message │ │ message │ │ message │
│ 3. Create branch │ │ 3. Create branch │ │ 3. Create branch │
│ 4. Commit │ │ 4. Commit │ │ 4. Commit │
│ 5. Queue merge │ │ 5. Queue merge │ │ 5. Queue merge │
└──────────────────┘ └──────────────────┘ └──────────────────┘
│ │ │
└────────────────────────┼────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────────────┐
│ Merge Daemon (Rust) │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ FIFO Merge Queue │ │
│ │ ┌─────────┐ ┌─────────┐ ┌─────────┐ │ │
│ │ │ Agent-1 │→ │ Agent-2 │→ │ Agent-3 │→ ... │ │
│ │ └─────────┘ └─────────┘ └─────────┘ │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
│ For each queued merge: │
│ 1. Attempt merge into feature branch │
│ 2. If conflict → rebase agent branch → request agent fix → re-queue │
│ 3. If success → update feature branch → remove from queue │
│ 4. Track merge order and dependencies │
└─────────────────────────────────────────────────────────────────────────┘
│
▼ (all agents done, all merges complete)
┌─────────────────────────────────────────────────────────────────────────┐
│ PR Creation & Validation │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ 1. Create draft PR with: │ │
│ │ - Original user prompt as description │ │
│ │ - Aggregated commit messages │ │
│ │ - Agent contribution summary │ │
│ │ │ │
│ │ 2. Run validation suite: │ │
│ │ - Tests (configurable command) │ │
│ │ - Linting │ │
│ │ - Type checking │ │
│ │ │ │
│ │ 3. If validation fails: │ │
│ │ - Pass results to orchestrator │ │
│ │ - Spawn fix agents → cycle repeats │ │
│ │ │ │
│ │ 4. If validation passes: │ │
│ │ - Mark PR as ready for review │ │
│ │ - Request reviews from CODEOWNERS or configured reviewers │ │
│ └─────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
A lightweight, high-performance daemon that manages the merge queue.
Location: daemon/
Features:
API:
ENQUEUE <agent-id> <branch-name> <worktree-path>
DEQUEUE <agent-id>
STATUS
CONFLICTS <agent-id>
RETRY <agent-id>
SHUTDOWN
hooks/on-prompt-submit.sh)Triggered when user submits a prompt. Determines if the prompt will make changes and initializes the fork-join session.
Logic:
hooks/on-agent-spawn.sh)Triggered when an agent is spawned by the orchestrator.
Logic:
git worktree add .worktrees/agent-<id> <feature-branch>hooks/on-agent-complete.sh)Triggered when an agent finishes its work.
Logic:
git diff --stat in agent's worktreeagent/<session-id>/<agent-id>
c. Stage and commit changes
d. Enqueue branch for mergescripts/create-pr.shCreates a draft PR when all agents complete and merges succeed.
Inputs:
Output:
draft, ai-generated, needs-reviewscripts/run-validation.shRuns the configured validation suite.
Steps:
scripts/request-reviews.shRequests reviews when validation passes.
Logic:
useCodeowners: true)maxReviewers limitdefaultReviewers if configuredgh pr edit to request reviewsFiles:
daemon/
├── Cargo.toml
├── src/
│ ├── main.rs # Entry point, signal handling
│ ├── lib.rs # Library exports
│ ├── queue.rs # FIFO merge queue
│ ├── merger.rs # Git merge operations
│ ├── ipc.rs # Unix socket server
│ ├── state.rs # Persistent state management
│ ├── config.rs # Configuration loading
│ └── error.rs # Error types
└── tests/
├── queue_test.rs
└── merger_test.rs
Dependencies:
[dependencies]
tokio = { version = "1", features = ["full"] }
git2 = "0.18"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
rusqlite = "0.31"
tracing = "0.1"
tracing-subscriber = "0.3"
thiserror = "1"
Files:
hooks/
├── on-prompt-submit.sh
├── on-agent-spawn.sh
├── on-agent-complete.sh
└── lib/
├── common.sh # Shared functions
├── git-utils.sh # Git helper functions
└── daemon-client.sh # Merge daemon IPC client
gh CLI for review requests{
"agent-fork-join": {
"maxConcurrentAgents": 8,
"mergeStrategy": "rebase",
"maxMergeRetries": 3,
"testCommand": "npm test",
"validationCommands": ["npm run lint", "npm run typecheck"],
"defaultReviewers": ["@senior-dev", "@tech-lead"],
"maxReviewers": 3,
"useCodeowners": true,
"autoMergeOnSuccess": false,
"featureBranchPrefix": "feature/",
"agentBranchPrefix": "agent/",
"worktreeDir": ".worktrees",
"daemonSocket": "/tmp/merge-daemon.sock",
"sessionTimeout": 3600,
"cleanupOrphanedWorktrees": true
}
}
The plugin activates automatically when:
# Check merge daemon status
/agent-fork-join status
# View merge queue
/agent-fork-join queue
# Force cleanup of worktrees
/agent-fork-join cleanup
# View session info
/agent-fork-join session
# Retry failed merge
/agent-fork-join retry <agent-id>
# Cancel session
/agent-fork-join cancel
┌─────────────┐
│ IDLE │
└─────────────┘
│
│ UserPromptSubmit (change detected)
▼
┌─────────────┐
│ STARTED │ ← Feature branch created, daemon started
└─────────────┘
│
│ AgentSpawn
▼
┌─────────────┐
│ WORKING │ ← Agents working in worktrees
└─────────────┘
│
│ AgentComplete (last agent)
▼
┌─────────────┐
│ MERGING │ ← Processing merge queue
└─────────────┘
│
├─────────────────────────────┐
│ │
│ All merges succeed │ Conflict detected
▼ ▼
┌─────────────┐ ┌─────────────┐
│ VALIDATING │ │ RESOLVING │
└─────────────┘ └─────────────┘
│ │
├─────────────┐ │ Agent fixes conflict
│ │ │
│ Pass │ Fail └───────────┐
▼ ▼ │
┌─────────────┐ ┌─────────────┐ │
│ READY │ │ FIX_CYCLE │ ──────────────▶ │
└─────────────┘ └─────────────┘ │
│ │ │
│ │ Spawn fix agents │
│ ▼ │
│ ┌─────────────┐ │
│ │ WORKING │ ◀─────────────────┘
│ └─────────────┘
│
│ Request reviews
▼
┌─────────────┐
│ COMPLETE │
└─────────────┘
Solution: Check if socket file exists at /tmp/merge-daemon.sock. Remove stale socket and retry.
Solution: Ensure .worktrees directory exists and is writable. Check for branch name conflicts.
Solution: Ensure merge daemon has read access to all worktrees. Check daemon logs.
Solution: Verify gh CLI is authenticated. Check for branch push permissions.