dmux-workflows
affaan-m/ECC
使用 dmux(一款專為 Claude Code 和 Codex 等 AI 代理框架設計的 tmux 面板管理器)來協調並行 AI 代理會話。
...展開全部dmux 工作流程
使用 dmux(一款專為 AI 代理程式框架設計的 tmux 面板管理工具)來協調並行 AI 代理程式工作階段。
何時啟用
- 並行執行多個代理程式工作階段
- 在 Claude Code、Codex 及其他代理框架之間協調工作
- 適合採用「分而治之」並行處理的複雜任務
- 使用者說「並行執行」、「將這項工作拆分」、「使用 dmux」或「多代理」
什麼是 dmux
dmux 是一款基於 tmux 的協調工具,用於管理 AI 代理程式分窗:
- 按下
n 鍵可建立一個帶有提示字元的全新分窗 - 按下
m將分區輸出合併回主會話 - 支援:Claude Code、Codex、OpenCode、Cline、Gemini、Qwen
安裝:請先詳閱套件說明,再從其儲存庫安裝 dmux。請參閱 github.com/standardagents/dmux
快速入門
# 啟動 dmux 工作階段
dmux
# 建立代理程式分窗格(在 dmux 中按下 'n',然後輸入提示字元)
# 分窗 1:「在 src/auth/ 中實作認證中介軟體」
# 分窗 2:「為使用者服務撰寫測試」
# 分窗 3:「更新 API 文件」
# 每個分窗皆運行其專屬的代理程式工作階段
# 按下 'm' 將結果合併回主工作階段
工作流程模式
模式 1:研究 + 實作
將研究與實作拆分為並行流程:
窗格 1(研究):「研究 Node.js 中速率限制的最佳實踐。
檢視現有函式庫、比較各種方法,並將研究結果寫入
/tmp/rate-limit-research.md」
窗格 2(實作):「為我們的 Express API 實作速率限制中介軟體。
先從基本的代幣桶開始,待研究完成後再進行優化。」
# 窗格 1 完成後,將研究結果合併至窗格 2 的上下文中
模式 2:多檔案功能
將工作並行化至獨立檔案中:
工作區 1:「為計費功能建立資料庫結構與遷移腳本」
工作區 2:「在 src/api/billing/ 中建置計費 API 端點」
工作區 3:「建立計費儀表板的使用者介面元件」
# 合併所有內容,然後在主工作區進行整合
模式 3:測試 + 修正循環
在一個窗格中執行測試,在另一個窗格中修復:
窗格 1(監控器):「以監控模式執行測試套件。當測試失敗時,
彙整失敗結果。」
窗格 2(修正器):「根據窗格 1 的錯誤輸出,修正失敗的測試」
模式 4:跨測試框架
針對不同任務使用不同的 AI 工具:
窗格 1(Claude Code):「審查認證模組的安全性」
窗格 2(Codex):「為提升效能而重構輔助函式」
窗格 3(Claude Code):「為結帳流程撰寫端到端測試」
模式 5:程式碼審查流程
並行審查視角:
窗格 1:「審查 src/api/ 是否存在安全漏洞」
窗格 2:「審查 src/api/ 是否存在效能問題」
窗格 3:「審查 src/api/ 是否存在測試覆蓋率缺口」
# 將所有審查結果整合為單一報告
最佳實務
- 僅限獨立任務。請勿將相互依賴彼此輸出結果的任務並行處理。
- 界線清晰。每個檢視窗應處理不同的檔案或關注點。
- 策略性地合併。合併前請先審閱各檢視窗格的輸出結果,以避免衝突。
- 使用 Git 工作樹。對於容易發生檔案衝突的工作,請為每個面板使用獨立的工作樹。
- 注意資源使用。每個面板皆會使用 API 憑證——請將面板總數控制在 5 至 6 個以內。
Git 工作樹整合
針對涉及重疊檔案的任務:
# 建立工作樹以進行隔離
git worktree add -b feat/auth ../feature-auth HEAD
git worktree add -b feat/billing ../feature-billing HEAD
# 在獨立的工作樹中執行代理程式
# 工作區 1:cd ../feature-auth && claude
# 工作區 2:cd ../feature-billing && claude
# 完成後合併分支
git merge feat/auth
git merge feat/billing
輔助工具
| 工具 | 功能說明 | 何時使用 |
|---|---|---|
| dmux | 適用於代理程式的 tmux 窗格管理 | 並行代理程式工作階段 |
| 超集 | 適用於 10 個以上並行代理程式的終端機 IDE | 大規模協調 |
| Claude 程式碼任務工具 | 進程內子代理生成 | 單一會話內的程式化並行處理 |
| Codex 多代理 | 內建代理角色 | Codex 專屬的並行處理 |
ECC 輔助程式
ECC 現已包含一個輔助程式,用於協調具有獨立 git 工作樹的外部 tmux 面板:
node scripts/orchestrate-worktrees.js plan.json --execute
plan.json 範例:
{
"sessionName": "skill-audit",
"baseRef": "HEAD",
"launcherCommand": "codex exec --cwd {worktree_path} --task-file {task_file}",
"workers": [
{ "name": "docs-a", "task": "修正技能 1-4 並撰寫交接備註。" },
{ "name": "docs-b", "task": "修正技能 5-8 並撰寫交接備註。" }
]
}
輔助程式:
- 為每個工作節點建立一個由分支支援的 Git 工作樹
- 可選地將主檢查點中的選定
seedPaths疊加至每個工作節點的工作樹中 - 在
.orchestration/目錄下,為每位工作者寫入/ task.md、handoff.md及status.md檔案 - 啟動一個 tmux 工作階段,並為每個工作節點分配一個獨立分區
- 在各自的分區中執行每個工作節點的指令
- 將主分隔窗保留給協調器使用
當工作節點需要存取尚未納入HEAD 的「已修改」或「未追蹤」的本地檔案時(例如本地協調腳本、草稿計畫或文件),請使用seedPaths:
{
"sessionName": "workflow-e2e",
"seedPaths": [
"scripts/orchestrate-worktrees.js",
"scripts/lib/tmux-worktree-orchestrator.js",
".claude/plan/workflow-e2e-test.json"
],
"launcherCommand": "bash {repo_root}/scripts/orchestrate-codex-worker.sh {task_file} {handoff_file} {status_file}",
"workers": [
{ "name": "seed-check", "task": "在開始工作前,驗證是否存在預先準備的檔案。" }
]
}
疑難排解
- 面板無回應:請直接切換至該面板,或使用
tmux 指令 `capture-pane -pt檢視該面板:0` 。。 - 合併衝突:使用 git worktrees 將每個窗格的檔案變更隔離。
- 代幣使用量過高:減少並行工作窗格的數量。每個工作窗格都是一個完整的代理程式工作階段。
- 找不到 tmux:請使用
brew install tmux(macOS)或apt install tmux(Linux)進行安裝。
---
name: dmux-workflows
description: Orchestrate parallel AI agent sessions using dmux, a tmux pane manager for agent harnesses like Claude Code and Codex.
---
# dmux Workflows
Orchestrate parallel AI agent sessions using dmux, a tmux pane manager for agent harnesses.
## When to Activate
- Running multiple agent sessions in parallel
- Coordinating work across Claude Code, Codex, and other harnesses
- Complex tasks that benefit from divide-and-conquer parallelism
- User says "run in parallel", "split this work", "use dmux", or "multi-agent"
## What is dmux
dmux is a tmux-based orchestration tool that manages AI agent panes:
- Press `n` to create a new pane with a prompt
- Press `m` to merge pane output back to the main session
- Supports: Claude Code, Codex, OpenCode, Cline, Gemini, Qwen
**Install:** Install dmux from its repository after reviewing the package. See [github.com/standardagents/dmux](https://github.com/standardagents/dmux)
## Quick Start
```bash
# Start dmux session
dmux
# Create agent panes (press 'n' in dmux, then type prompt)
# Pane 1: "Implement the auth middleware in src/auth/"
# Pane 2: "Write tests for the user service"
# Pane 3: "Update API documentation"
# Each pane runs its own agent session
# Press 'm' to merge results back
```
## Workflow Patterns
### Pattern 1: Research + Implement
Split research and implementation into parallel tracks:
```
Pane 1 (Research): "Research best practices for rate limiting in Node.js.
Check current libraries, compare approaches, and write findings to
/tmp/rate-limit-research.md"
Pane 2 (Implement): "Implement rate limiting middleware for our Express API.
Start with a basic token bucket, we'll refine after research completes."
# After Pane 1 completes, merge findings into Pane 2's context
```
### Pattern 2: Multi-File Feature
Parallelize work across independent files:
```
Pane 1: "Create the database schema and migrations for the billing feature"
Pane 2: "Build the billing API endpoints in src/api/billing/"
Pane 3: "Create the billing dashboard UI components"
# Merge all, then do integration in main pane
```
### Pattern 3: Test + Fix Loop
Run tests in one pane, fix in another:
```
Pane 1 (Watcher): "Run the test suite in watch mode. When tests fail,
summarize the failures."
Pane 2 (Fixer): "Fix failing tests based on the error output from pane 1"
```
### Pattern 4: Cross-Harness
Use different AI tools for different tasks:
```
Pane 1 (Claude Code): "Review the security of the auth module"
Pane 2 (Codex): "Refactor the utility functions for performance"
Pane 3 (Claude Code): "Write E2E tests for the checkout flow"
```
### Pattern 5: Code Review Pipeline
Parallel review perspectives:
```
Pane 1: "Review src/api/ for security vulnerabilities"
Pane 2: "Review src/api/ for performance issues"
Pane 3: "Review src/api/ for test coverage gaps"
# Merge all reviews into a single report
```
## Best Practices
1. **Independent tasks only.** Don't parallelize tasks that depend on each other's output.
2. **Clear boundaries.** Each pane should work on distinct files or concerns.
3. **Merge strategically.** Review pane output before merging to avoid conflicts.
4. **Use git worktrees.** For file-conflict-prone work, use separate worktrees per pane.
5. **Resource awareness.** Each pane uses API tokens — keep total panes under 5-6.
## Git Worktree Integration
For tasks that touch overlapping files:
```bash
# Create worktrees for isolation
git worktree add -b feat/auth ../feature-auth HEAD
git worktree add -b feat/billing ../feature-billing HEAD
# Run agents in separate worktrees
# Pane 1: cd ../feature-auth && claude
# Pane 2: cd ../feature-billing && claude
# Merge branches when done
git merge feat/auth
git merge feat/billing
```
## Complementary Tools
| Tool | What It Does | When to Use |
|------|-------------|-------------|
| **dmux** | tmux pane management for agents | Parallel agent sessions |
| **Superset** | Terminal IDE for 10+ parallel agents | Large-scale orchestration |
| **Claude Code Task tool** | In-process subagent spawning | Programmatic parallelism within a session |
| **Codex multi-agent** | Built-in agent roles | Codex-specific parallel work |
## ECC Helper
ECC now includes a helper for external tmux-pane orchestration with separate git worktrees:
```bash
node scripts/orchestrate-worktrees.js plan.json --execute
```
Example `plan.json`:
```json
{
"sessionName": "skill-audit",
"baseRef": "HEAD",
"launcherCommand": "codex exec --cwd {worktree_path} --task-file {task_file}",
"workers": [
{ "name": "docs-a", "task": "Fix skills 1-4 and write handoff notes." },
{ "name": "docs-b", "task": "Fix skills 5-8 and write handoff notes." }
]
}
```
The helper:
- Creates one branch-backed git worktree per worker
- Optionally overlays selected `seedPaths` from the main checkout into each worker worktree
- Writes per-worker `task.md`, `handoff.md`, and `status.md` files under `.orchestration/<session>/`
- Starts a tmux session with one pane per worker
- Launches each worker command in its own pane
- Leaves the main pane free for the orchestrator
Use `seedPaths` when workers need access to dirty or untracked local files that are not yet part of `HEAD`, such as local orchestration scripts, draft plans, or docs:
```json
{
"sessionName": "workflow-e2e",
"seedPaths": [
"scripts/orchestrate-worktrees.js",
"scripts/lib/tmux-worktree-orchestrator.js",
".claude/plan/workflow-e2e-test.json"
],
"launcherCommand": "bash {repo_root}/scripts/orchestrate-codex-worker.sh {task_file} {handoff_file} {status_file}",
"workers": [
{ "name": "seed-check", "task": "Verify seeded files are present before starting work." }
]
}
```
## Troubleshooting
- **Pane not responding:** Switch to the pane directly or inspect it with `tmux capture-pane -pt <session>:0.<pane-index>`.
- **Merge conflicts:** Use git worktrees to isolate file changes per pane.
- **High token usage:** Reduce number of parallel panes. Each pane is a full agent session.
- **tmux not found:** Install with `brew install tmux` (macOS) or `apt install tmux` (Linux).
所有檔案
1 個檔案安裝 dmux-workflows
請下載並將技能檔案解壓縮至您的 .claude/skills/ 目錄中。
下載 ZIP複製儲存庫並將技能檔案複製到您的專案中。
git clone https://github.com/affaan-m/ECC/tree/main/skills/dmux-workflows # Copy SKILL.md to your .claude/skills/ directory
複製





首頁
