用途
dmux-workflows 是一套使用 dmux 进行多智能体编排的工作流模式集合。dmux 是一个基于 tmux 的编排工具,用于管理 AI 智能体窗格,帮助用户并行运行多个智能体会话,协调跨不同智能体工具的工作,并对适合分而治之的复杂任务进行并行处理。
当出现以下情况时可激活该技能:需要并行运行多个智能体会话;需要在 Claude Code、Codex 等不同工具之间协调工作;任务复杂且适合分而治之的并行处理;用户说出“并行运行”“拆分这项工作”“使用 dmux”或“多智能体”等表述。
什么是 dmux
dmux 是一个基于 tmux 的编排工具,用于管理 AI 智能体窗格。其核心操作包括:按 n 创建一个带提示词的新窗格;按 m 将窗格输出合并回主会话。它支持 Claude Code、Codex、OpenCode、Cline、Gemini、Qwen。安装命令为 npm install -g dmux,也可参见 github.com/standardagents/dmux。
快速开始
启动 dmux 会话:
dmux
在 dmux 中按 n 创建智能体窗格,然后输入提示词。例如:窗格 1 输入“Implement the auth middleware in src/auth/”;窗格 2 输入“Write tests for the user service”;窗格 3 输入“Update API documentation”。每个窗格运行各自的智能体会话,按 m 可将结果合并回来。
工作流模式
模式 1:研究 + 实现。将研究与实现拆分为并行轨道。窗格 1(研究):“Research best practices for rate limiting in Node.js. Check current libraries, compare approaches, and write findings to /tmp/rate-limit-research.md”。窗格 2(实现):“Implement rate limiting middleware for our Express API. Start with a basic token bucket, we'll refine after research completes.”。窗格 1 完成后,将研究结果合并到窗格 2 的上下文中。
模式 2:多文件功能。在相互独立的文件之间并行工作。窗格 1:“Create the database schema and migrations for the billing feature”;窗格 2:“Build the billing API endpoints in src/api/billing/”;窗格 3:“Create the billing dashboard UI components”。全部合并后,在主窗格中进行集成。
模式 3:测试 + 修复循环。一个窗格运行测试,另一个窗格修复。窗格 1(监视者):“Run the test suite in watch mode. When tests fail, summarize the failures.”;窗格 2(修复者):“Fix failing tests based on the error output from pane 1”。
模式 4:跨工具协作。为不同任务使用不同的 AI 工具。窗格 1(Claude Code):“Review the security of the auth module”;窗格 2(Codex):“Refactor the utility functions for performance”;窗格 3(Claude Code):“Write E2E tests for the checkout flow”。
模式 5:代码审查流水线。并行采用多个审查视角。窗格 1:“Review src/api/ for security vulnerabilities”;窗格 2:“Review src/api/ for performance issues”;窗格 3:“Review src/api/ for test coverage gaps”。将所有审查结果合并为一份报告。
最佳实践
仅并行处理相互独立的任务,不要并行化彼此依赖输出的任务。保持清晰边界,每个窗格应处理不同的文件或关注点。策略性合并,在合并前先审查窗格输出以避免冲突。对于容易产生文件冲突的工作,为每个窗格使用独立的 git worktree。注意资源消耗,每个窗格都会使用 API token,总窗格数应控制在 5 到 6 个以内。
Git Worktree 集成
对于涉及重叠文件的任务,可创建 worktree 进行隔离:
git worktree add ../feature-auth feat/auth
git worktree add ../feature-billing feat/billing
在各自的 worktree 中运行智能体:窗格 1 执行 cd ../feature-auth && claude;窗格 2 执行 cd ../feature-billing && claude。完成后合并分支:git merge feat/auth、git merge feat/billing。
互补工具
dmux:面向智能体的 tmux 窗格管理,用于并行智能体会话。Superset:面向 10 个以上并行智能体的终端 IDE,用于大规模编排。Claude Code Task tool:进程内子智能体生成,用于会话内的程序化并行。Codex multi-agent:内置智能体角色,用于 Codex 特定的并行工作。
故障排查
窗格无响应:检查智能体会话是否在等待输入,使用 m 读取输出。合并冲突:使用 git worktree 为每个窗格隔离文件变更。Token 使用量过高:减少并行窗格数量,每个窗格都是一个完整的智能体会话。找不到 tmux:在 macOS 上使用 brew install tmux 安装,在 Linux 上使用 apt install tmux 安装。