using-git-worktrees
使用 git worktree 创建隔离工作空间,避免切换分支时丢失工作上下文。触发短语:"worktree"、"隔离工作空间"、"隔离分支"。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
使用 git worktree 创建隔离工作空间,避免切换分支时丢失工作上下文。触发短语:"worktree"、"隔离工作空间"、"隔离分支"。
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
协作式需求探索与设计。用苏格拉底式对话将模糊想法转化为结构化的设计规格文档(spec.md)。触发短语:"探索需求"、"讨论设计"、"头脑风暴"、"brainstorm"。
生成今日工作日报。仅在用户显式触发 /daily 时执行,不自动运行。
将多个独立问题域分配给并行子代理同时处理。每个独立问题域一个代理。触发短语:"并行"、"parallel"、"同时处理"。
会话结束时整理知识,生成中文 Markdown 摘要文档并保存到本地。仅在用户显式触发 /done 时执行,不自动运行。
按 plan.md 逐任务执行实现。通过 Todo checkbox 追踪进度,每批改动后运行编译检查。触发短语:"执行计划"、"按计划实现"、"开始实现"。
完成开发分支的收尾工作。四选项决策树:合并、创建 PR、保留、丢弃。触发短语:"完成分支"、"合并"、"提交 PR"。
| name | using-git-worktrees |
| description | 使用 git worktree 创建隔离工作空间,避免切换分支时丢失工作上下文。触发短语:"worktree"、"隔离工作空间"、"隔离分支"。 |
| allowed-tools | Read, Bash, Glob |
使用 git worktree 在同一仓库中创建多个独立的工作目录,每个目录对应一个分支。
.worktrees/ 目录git worktree list
如果目标分支已有 worktree,告知用户路径。
# 基于当前分支创建新分支和 worktree
git worktree add .worktrees/{branch-name} -b {branch-name}
# 基于已有分支创建 worktree
git worktree add .worktrees/{branch-name} {branch-name}
确认 worktree 目录被 git 忽略:
git check-ignore .worktrees/{branch-name}
如果未被忽略,在 .gitignore 中添加 .worktrees/。
自动检测并执行项目的初始化命令:
# 检查项目类型并安装依赖
if [ -f package.json ]; then npm install; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
if [ -f Cargo.toml ]; then cargo build; fi
if [ -f go.mod ]; then go mod download; fi
if [ -f pom.xml ]; then mvn dependency:resolve; fi
if [ -f build.gradle ]; then ./gradlew dependencies; fi
告知用户 worktree 的路径和切换方式:
Worktree 已创建:.worktrees/{branch-name}
切换到该目录:cd .worktrees/{branch-name}
完成工作后(使用 /finishing-a-development-branch),清理 worktree:
git worktree remove .worktrees/{branch-name}
git worktree remove 清理引用