dmux-workflows
affaan-m/ECC
使用 dmux(一款适用于 Claude Code 和 Codex 等 AI 代理框架的 tmux 面板管理器)来协调并行 AI 代理会话。
...展开全部dmux 工作流
使用 dmux(一款专为代理测试框架设计的 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:“创建计费仪表盘的 UI 组件”
# 合并所有内容,然后在主面板中进行集成
模式 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 会话,为每个工作者分配一个独立的面板
- 在各自的面板中启动每个工作进程的命令
- 将主分屏留给调度器使用
当 worker 需要访问尚未纳入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
复制





首页
