fork-terminal

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Fork Terminal Skill

Fork Terminal 技能

This skill enables forking terminal sessions to new windows using various AI coding tools or raw CLI commands.
本技能支持使用各类AI编码工具或原生CLI命令,将终端会话分叉到新窗口中。

Supported Tools

支持的工具

ToolTrigger PatternDefault Model
Claude Code"fork terminal use claude code..."opus
Codex CLI"fork terminal use codex..."gpt-5.1-codex-max
Gemini CLI"fork terminal use gemini..."gemini-3-pro-preview
Raw CLI"fork terminal run..."N/A
工具触发模式默认模型
Claude Code"fork terminal use claude code..."opus
Codex CLI"fork terminal use codex..."gpt-5.1-codex-max
Gemini CLI"fork terminal use gemini..."gemini-3-pro-preview
原生CLI"fork terminal run..."N/A

Model Modifiers

模型修饰符

  • fast: Use lighter/faster models (haiku, codex-mini, flash)
  • heavy: Use most capable models (opus, codex-max, gemini-pro)
  • fast: 使用更轻量/快速的模型(haiku、codex-mini、flash)
  • heavy: 使用能力最强的模型(opus、codex-max、gemini-pro)

How to Execute

执行方法

  1. Identify the tool from the user's request
  2. Read the appropriate cookbook for execution details
  3. Execute
    fork_terminal(command)
    using the Python tool
  1. 识别工具:根据用户请求确定要使用的工具
  2. 阅读对应手册:查看相关cookbook获取执行细节
  3. 执行
    fork_terminal(command)
    :使用Python工具执行该命令

Tool Selection

工具选择

Match the user's language against these patterns:
  • "fork terminal use claude code to..." → Use
    cookbook/claude-code.md
  • "fork terminal use codex to..." → Use
    cookbook/codex-cli.md
  • "fork terminal use gemini to..." → Use
    cookbook/gemini-cli.md
  • "fork terminal run..." → Use
    cookbook/cli-command.md
根据用户语言匹配以下模式:
  • "fork terminal use claude code to..." → 使用
    cookbook/claude-code.md
  • "fork terminal use codex to..." → 使用
    cookbook/codex-cli.md
  • "fork terminal use gemini to..." → 使用
    cookbook/gemini-cli.md
  • "fork terminal run..." → 使用
    cookbook/cli-command.md

Execution Steps

执行步骤

For AI Coding Tools (Claude Code, Codex, Gemini)

针对AI编码工具(Claude Code、Codex、Gemini)

  1. Read the corresponding cookbook file to get model variables and command format
  2. Determine model based on modifier (fast/heavy/default)
  3. If the user requests "with summary" or context handoff:
    • Use the template in
      prompts/fork_summary_user_prompt.md
    • Fill in conversation history summary
    • Include the next user request
  4. Execute via:
    python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "<full_command>"
  1. 读取对应cookbook文件,获取模型变量和命令格式
  2. 根据修饰符(fast/heavy/default)确定模型
  3. 如果用户请求“with summary”或上下文传递:
    • 使用
      prompts/fork_summary_user_prompt.md
      中的模板
    • 填入对话历史摘要
    • 包含用户的下一个请求
  4. 通过以下命令执行:
    python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "<full_command>"

For Raw CLI Commands

针对原生CLI命令

  1. Parse the command from the user's request
  2. Run
    <command> --help
    first to understand options (if needed)
  3. Execute via:
    python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "<command>"
  1. 从用户请求中解析命令
  2. 先运行
    <command> --help
    以了解选项(如有需要)
  3. 通过以下命令执行:
    python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "<command>"

Example Commands

示例命令

Security Warning: The
--dangerously-*
flags and
-y
(yolo) mode bypass safety prompts. Only use in trusted environments where you understand the risks of unattended AI agent execution.
bash
undefined
安全警告
--dangerously-*
标志和
-y
(yolo)模式会绕过安全提示。仅在受信任环境中使用,且需了解无人值守AI Agent执行的风险。
bash
undefined

Fork with Claude Code

使用Claude Code分叉终端

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "claude --model opus --dangerously-skip-permissions"
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "claude --model opus --dangerously-skip-permissions"

Fork with Codex CLI

使用Codex CLI分叉终端

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "codex --model gpt-5.1-codex-max --dangerously-bypass-approvals-and-sandbox"
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "codex --model gpt-5.1-codex-max --dangerously-bypass-approvals-and-sandbox"

Fork with Gemini CLI

使用Gemini CLI分叉终端

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "gemini --model gemini-3-pro-preview -y"
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "gemini --model gemini-3-pro-preview -y"

Fork with raw CLI

使用原生CLI分叉终端

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "npm run dev"
undefined
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/fork_terminal.py "npm run dev"
undefined

Platform Support

平台支持

  • macOS: Fully supported (AppleScript)
  • Windows: Fully supported (cmd.exe)
  • Linux: Not yet implemented
  • macOS:完全支持(基于AppleScript)
  • Windows:完全支持(基于cmd.exe)
  • Linux:暂未实现

Example Triggers

示例触发语句

  • "Fork terminal use claude code to refactor the auth module"
  • "Fork terminal use codex fast to write tests"
  • "Fork terminal run npm start"
  • "Spawn a new terminal with gemini to analyze this codebase"

  • "分叉终端,使用Claude Code重构认证模块"
  • "分叉终端,使用Codex快速编写测试"
  • "分叉终端运行npm start"
  • "启动新终端,使用Gemini分析此代码库"

Worktree Mode

Worktree模式

Worktree mode creates git-isolated workspaces for parallel development. Each worker gets its own branch and worktree directory.
Worktree模式会创建git隔离的工作区以支持并行开发。每个工作进程都有自己的分支和worktree目录。

When to Use Worktree Mode

何时使用Worktree模式

Use worktree mode when:
  • You need git isolation between parallel workers
  • Working on multiple features simultaneously
  • You want to avoid file conflicts between agents
在以下场景使用Worktree模式:
  • 你需要并行工作进程之间的git隔离
  • 同时开发多个功能
  • 你想避免Agent之间的文件冲突

Worktree Trigger Patterns

Worktree触发模式

  • "fork terminal in worktree use claude to..." → Worktree + Claude
  • "spawn worktree for..." → Create worktree with task
  • "spawn 3 worktrees to..." → Multiple workers
  • "fork in worktree from develop..." → Specify base branch
  • "fork terminal in worktree use claude to..." → Worktree + Claude
  • "spawn worktree for..." → 创建带任务的worktree
  • "spawn 3 worktrees to..." → 多个工作进程
  • "fork in worktree from develop..." → 指定基础分支

How to Execute Worktree Mode

Worktree模式执行方法

  1. Identify worktree mode from trigger patterns above
  2. Ask the user which execution mode they prefer using the
    AskUserQuestion
    tool:
    • Interactive (default): Claude stays open for follow-up questions
    • Autonomous: Claude runs the task and exits when done
  3. Read the cookbook:
    cookbook/worktree.md
  4. Execute spawn_session.py:
bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/spawn_session.py \
  --task "<task description>" \
  [--branch "<branch-name>"] \
  [--base "<base-branch>"] \
  [--count <1-4>] \
  [--model <opus|haiku>] \
  [--mode <interactive|autonomous>] \
  [--terminal <auto|tmux|window>]
  1. 识别Worktree模式:根据上述触发模式判断
  2. 询问用户偏好的执行模式:使用
    AskUserQuestion
    工具:
    • 交互式(默认):Claude保持开启以支持后续问题
    • 自主式:Claude完成任务后退出
  3. 阅读手册
    cookbook/worktree.md
  4. 执行spawn_session.py
bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/spawn_session.py \
  --task "<task description>" \
  [--branch "<branch-name>"] \
  [--base "<base-branch>"] \
  [--count <1-4>] \
  [--model <opus|haiku>] \
  [--mode <interactive|autonomous>] \
  [--terminal <auto|tmux|window>]

Worktree Examples

Worktree示例

bash
undefined
bash
undefined

Single worker

单个工作进程

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/spawn_session.py
--task "implement user authentication"
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/spawn_session.py
--task "implement user authentication"

Multiple workers

多个工作进程

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/spawn_session.py
--task "write API tests"
--count 3
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/spawn_session.py
--task "write API tests"
--count 3

From specific base branch

基于指定基础分支

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/spawn_session.py
--task "fix bug in login"
--base develop
--branch "fix/login-bug"
undefined
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/spawn_session.py
--task "fix bug in login"
--base develop
--branch "fix/login-bug"
undefined

Terminal Detection

终端检测

Worktree mode automatically detects the terminal environment:
  • Inside tmux: Creates new tmux window
  • tmux available: Creates new tmux session
  • No tmux: Falls back to new terminal window (same as regular fork)
Worktree模式会自动检测终端环境:
  • 在tmux内:创建新的tmux窗口
  • 可用tmux:创建新的tmux会话
  • 无tmux:回退到新终端窗口(与常规分叉相同)

Management Commands

管理命令

After spawning worktree workers:
  • /fork-terminal:list
    - Show active worktrees and workers
  • /fork-terminal:remove --path <path>
    - Clean up a worktree
启动Worktree工作进程后:
  • /fork-terminal:list
    - 显示活跃的worktree和工作进程
  • /fork-terminal:remove --path <path>
    - 清理worktree

Worktree Example Triggers

Worktree示例触发语句

  • "Spawn worktree to implement the search feature"
  • "Fork in worktree to refactor the database layer"
  • "Spawn 2 worktrees to work on frontend and backend"
  • "Fork terminal in worktree from develop to fix the auth bug"

  • "创建worktree以实现搜索功能"
  • "在worktree中分叉终端以重构数据库层"
  • "启动2个worktree分别处理前端和后端"
  • "从develop分支的worktree中分叉终端以修复认证bug"

Tournament Mode

锦标赛模式

Tournament mode spawns multiple AI CLIs (Claude, Gemini, Codex) to compete on the same task in separate worktrees. After all workers complete, the main session reviews solutions and creates a combined branch with the best parts.
锦标赛模式会启动多个AI CLI(Claude、Gemini、Codex),在独立的worktree中竞争完成同一任务。所有工作进程完成后,主会话会评审解决方案,并创建一个融合了各方案最佳部分的合并分支。

When to Use Tournament Mode

何时使用锦标赛模式

Use tournament mode when:
  • You want multiple approaches to the same problem
  • You want to compare how different AI tools solve a task
  • You need the best solution from multiple attempts
在以下场景使用锦标赛模式:
  • 你想针对同一问题获取多种解决思路
  • 你想对比不同AI工具解决任务的方式
  • 你需要从多次尝试中得到最佳解决方案

Tournament Trigger Patterns

锦标赛触发模式

  • "tournament mode to implement X" → All CLIs (claude, gemini, codex)
  • "tournament with claude and gemini to fix Y" → Claude + Gemini
  • "have claude vs codex compete on Z" → Claude + Codex
  • "race to solve X" → All CLIs
  • "tournament mode to implement X" → 所有CLI(Claude、Gemini、Codex)
  • "tournament with claude and gemini to fix Y" → Claude + Gemini
  • "have claude vs codex compete on Z" → Claude + Codex
  • "race to solve X" → 所有CLI

How to Execute Tournament Mode

锦标赛模式执行方法

  1. Identify tournament mode from trigger patterns above
  2. Parse CLIs to use: Default is all three, or parse from request
  3. Ask the user where to run workers using
    AskUserQuestion
    :
json
{
  "questions": [{
    "question": "Where should the tournament workers run?",
    "header": "Terminal",
    "options": [
      {"label": "tmux (Recommended)", "description": "Background sessions - more reliable, no visible windows"},
      {"label": "Warp/Terminal", "description": "Visible windows - watch workers in real-time"}
    ],
    "multiSelect": false
  }]
}
  1. Read the cookbook:
    cookbook/tournament.md
  2. Execute tournament spawning:
bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament.py spawn \
  --task "<task description>" \
  [--clis claude,gemini,codex] \
  [--base <base-branch>] \
  --terminal <tmux|window>
  1. 识别锦标赛模式:根据上述触发模式判断
  2. 解析要使用的CLI:默认使用全部三个,或从请求中解析
  3. 询问用户工作进程的运行位置:使用
    AskUserQuestion
    工具:
json
{
  "questions": [{
    "question": "锦标赛工作进程应在何处运行?",
    "header": "终端",
    "options": [
      {"label": "tmux(推荐)", "description": "后台会话 - 更可靠,无可见窗口"},
      {"label": "Warp/终端", "description": "可见窗口 - 实时查看工作进程"}
    ],
    "multiSelect": false
  }]
}
  1. 阅读手册
    cookbook/tournament.md
  2. 执行锦标赛启动
bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament.py spawn \
  --task "<task description>" \
  [--clis claude,gemini,codex] \
  [--base <base-branch>] \
  --terminal <tmux|window>

Tournament Workflow

锦标赛工作流

  1. Spawn: Creates worktrees and starts CLI sessions
  2. Compete: Workers independently solve the task
  3. Complete: Workers write DONE.md when finished
  4. Status: User checks progress with
    /fork-terminal:status
  5. Review: User triggers review with
    /fork-terminal:review
  6. Combine: Create combined branch with best parts
  1. 启动:创建worktree并启动CLI会话
  2. 竞争:工作进程独立解决任务
  3. 完成:工作进程完成后写入DONE.md
  4. 状态:用户使用
    /fork-terminal:status
    查看进度
  5. 评审:用户使用
    /fork-terminal:review
    触发评审
  6. 合并:创建融合最佳部分的合并分支

Tournament Commands

锦标赛命令

CommandDescription
/fork-terminal:status
Check tournament progress
/fork-terminal:review
Review completed solutions
/fork-terminal:list
List all worktrees
/fork-terminal:remove
Clean up worktrees
命令描述
/fork-terminal:status
查看锦标赛进度
/fork-terminal:review
评审已完成的解决方案
/fork-terminal:list
列出所有worktree
/fork-terminal:remove
清理worktree

Tournament Example

锦标赛示例

bash
undefined
bash
undefined

Spawn tournament

启动锦标赛

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament.py spawn
--task "implement user authentication"
--clis claude,gemini,codex
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament.py spawn
--task "implement user authentication"
--clis claude,gemini,codex

Check status

查看状态

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament.py status
--tournament "<tournament-id>"
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament.py status
--tournament "<tournament-id>"

Generate review report

生成评审报告

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament_review.py report
--tournament "<tournament-id>"
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament_review.py report
--tournament "<tournament-id>"

Create combined branch

创建合并分支

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament_review.py combine
--tournament "<tournament-id>"
undefined
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/tournament_review.py combine
--tournament "<tournament-id>"
undefined

Tournament Example Triggers

锦标赛示例触发语句

  • "Tournament mode to implement user authentication"
  • "Have claude, gemini, and codex compete on adding caching"
  • "Race to solve the performance issue"
  • "Tournament with claude and gemini to refactor the API"

  • "锦标赛模式实现用户认证"
  • "让Claude、Gemini和Codex竞争实现缓存功能"
  • "竞速解决性能问题"
  • "Claude和Gemini锦标赛模式重构API"

Visual Tournament Mode

可视化锦标赛模式

Visual tournament mode runs multiple AI CLIs side-by-side in tmux split panes so you can watch them all simultaneously. Unlike regular tournament mode (which uses separate worktrees), visual mode runs all CLIs in the current project.
可视化锦标赛模式会在tmux分屏窗格中并排运行多个AI CLI,让你可以同时查看所有进程。与常规锦标赛模式(使用独立worktree)不同,可视化模式在当前项目中运行所有CLI。

When to Use Visual Mode

何时使用可视化模式

Use visual mode when:
  • You want to watch all CLIs working in real-time
  • You're doing a quick comparison or code review
  • You don't need git isolation between workers
  • You want a single tmux session with all CLIs visible
在以下场景使用可视化模式:
  • 你想实时查看所有CLI的工作过程
  • 你正在进行快速对比或代码评审
  • 你不需要工作进程之间的git隔离
  • 你希望在单个tmux会话中查看所有CLI

Visual Mode Trigger Patterns

可视化模式触发模式

  • "visual tournament to review X" → All CLIs in split panes
  • "watch all clis review the code" → All CLIs visible
  • "tmux visual mode with claude and gemini" → Specific CLIs
  • "split pane tournament" → All CLIs in split panes
  • "visual tournament to review X" → 所有CLI在分屏窗格中运行
  • "watch all clis review the code" → 所有CLI可见
  • "tmux visual mode with claude and gemini" → 指定CLI
  • "split pane tournament" → 所有CLI在分屏窗格中运行

How to Execute Visual Mode

可视化模式执行方法

  1. Identify visual mode from trigger patterns above
  2. Parse CLIs to use: Default is all three, or parse from request
  3. Execute visual tournament:
bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/visual_tournament.py \
  --task "<task or prompt>" \
  [--clis claude,gemini,codex]
  1. 识别可视化模式:根据上述触发模式判断
  2. 解析要使用的CLI:默认使用全部三个,或从请求中解析
  3. 执行可视化锦标赛
bash
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/visual_tournament.py \
  --task "<task or prompt>" \
  [--clis claude,gemini,codex]

Visual Mode Workflow

可视化模式工作流

  1. Spawn: Creates tmux session with split panes
  2. Watch: All CLIs run simultaneously, visible in panes
  3. Output: Each CLI's output saved to
    ~/.fork-terminal/visual/<id>/<cli>.txt
  4. Detach: Use
    Ctrl+B then D
    to detach (CLIs continue running)
  5. Reattach: Use
    tmux attach -t <session>
    to view again
  1. 启动:创建带分屏窗格的tmux会话
  2. 查看:所有CLI同时运行,在窗格中可见
  3. 输出:每个CLI的输出会保存到
    ~/.fork-terminal/visual/<id>/<cli>.txt
  4. 分离:使用
    Ctrl+B 然后 D
    分离会话(CLI会继续运行)
  5. 重新连接:使用
    tmux attach -t <session>
    重新查看

Tmux Controls

Tmux快捷键

ShortcutAction
Ctrl+B D
Detach (CLIs continue in background)
Ctrl+B [
Scroll mode (q to exit)
Ctrl+B z
Zoom current pane (toggle)
Ctrl+B o
Switch between panes
快捷键操作
Ctrl+B D
分离会话(CLI在后台继续运行)
Ctrl+B [
滚动模式(按q退出)
Ctrl+B z
放大当前窗格(切换)
Ctrl+B o
在窗格间切换

Visual Mode Example

可视化模式示例

bash
undefined
bash
undefined

Run all CLIs to review code

运行所有CLI评审代码

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/visual_tournament.py
--task "Review this codebase for security issues"
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/visual_tournament.py
--task "Review this codebase for security issues"

Run specific CLIs

运行指定CLI

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/visual_tournament.py
--task "Analyze the authentication flow"
--clis claude,gemini
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/visual_tournament.py
--task "Analyze the authentication flow"
--clis claude,gemini

Don't auto-attach (run in background)

不自动连接(后台运行)

python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/visual_tournament.py
--task "Review the API endpoints"
--no-attach
undefined
python3 ${CLAUDE_PLUGIN_ROOT}/skills/fork-terminal/tools/visual_tournament.py
--task "Review the API endpoints"
--no-attach
undefined

Visual Mode Example Triggers

可视化模式示例触发语句

  • "Visual tournament to review the authentication code"
  • "Watch all CLIs analyze this codebase"
  • "Split pane tournament with claude and codex"
  • "Show all CLIs running on security review"
  • "可视化锦标赛评审认证代码"
  • "查看所有CLI分析此代码库"
  • "分屏锦标赛使用Claude和Codex"
  • "显示所有CLI运行安全评审"