Dual-Mode -- Claude + Codex Hybrid Orchestration
Orchestrate Claude Code (interactive reasoning) and headless Codex workers (parallel execution) together in a single workflow. Design interactively, implement in parallel, review interactively.
Purpose
Combine the strengths of interactive Claude Code sessions with background Codex workers for maximum throughput. Claude Code handles complex reasoning, design decisions, and quality review while Codex workers execute implementation tasks in parallel.
Commands
/dual-spawn -- Spawn Headless Workers
/dual-spawn "<task>" --workers <count> [--type <worker-type>] [--wait]
| Parameter | Default | Description |
|---|---|---|
task |
required | Task description for workers |
--workers |
3 | Number of parallel workers (1-10) |
--type |
coder | Worker type: coder, tester, docs, reviewer |
--wait |
false | Block until all workers complete |
Example:
/dual-spawn "Implement user authentication" --workers 2 --type coder
/dual-spawn "Write comprehensive tests for auth module" --workers 2 --type tester
/dual-coordinate -- Full Hybrid Workflow
/dual-coordinate --workflow <workflow-name> --task "<task-description>"
| Parameter | Default | Description |
|---|---|---|
--workflow |
hybrid_development | Workflow template to use |
--task |
required | Task description |
--interactive-first |
true | Start with interactive phase |
Available workflows:
- hybrid_development -- Design interactively, implement in parallel, review interactively
- parallel_feature -- Spawn multiple Codex workers for parallel implementation
- design_and_execute -- Interactive design phase, then batch execution
/dual-collect -- Gather Worker Results
/dual-collect [--namespace <namespace>] [--format <format>] [--filter <pattern>]
| Parameter | Default | Description |
|---|---|---|
--namespace |
results | Memory namespace to search |
--format |
summary | Output format: summary, detailed, json |
--filter |
none | Filter by key pattern |
Workflow Phases
- Routing Decision -- Analyzes the task to determine the optimal platform split between Claude Code and Codex
- Interactive Phase -- Complex reasoning handled in the current Claude Code session (design, planning, architecture)
- Parallel Phase -- Spawns headless Codex workers via
claude -pfor execution tasks - Review Phase -- Returns to Claude Code for quality review and integration
- Result Collection -- Aggregates worker results from shared memory
Implementation Details
Worker Spawning
Workers are spawned using claude -p with session IDs for tracking:
# Initialize swarm coordination
npx claude-flow swarm init --topology hierarchical --max-agents <workers>
# Spawn each worker
claude -p "
You are worker-<index>.
TASK: <task>
1. Search: memory_search(query='<task_keywords>')
2. Execute your assigned work
3. Store: memory_store(key='result-<index>', namespace='results', upsert=true)
" --session-id task-<index> &
Memory Coordination
All workers share memory via claude-flow MCP tools:
memory_store-- Workers store their resultsmemory_search-- Workers search for relevant contextmemory_list-- Collect all results from a namespace
Agent Definitions
Three agents support dual-mode operations:
- dual-orchestrator -- Hybrid workflow orchestration
- codex-coordinator -- Parallel worker coordination
- codex-worker -- Headless execution worker
Output Formats
Summary (default)
Workers Completed: 4/4
-- worker-auth-core: Complete (auth.service.ts)
-- worker-auth-api: Complete (auth.controller.ts)
-- worker-tests: Complete (15 tests passing)
-- worker-docs: Complete (API.md updated)
Detailed
Shows per-worker status, duration, files modified, and result summary.
JSON
Machine-readable format with worker array and summary statistics.
Protocols
- Workers execute independently and store results in shared memory
- The coordinator monitors completion status
- If
--waitis specified, the spawning command blocks until all workers finish - Results are aggregated and presented in the requested format
- Failed workers are reported with error details