worktree
Perform work in a git worktree branched from main. Create the worktree, do the work, then offer to clean it up.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Perform work in a git worktree branched from main. Create the worktree, do the work, then offer to clean it up.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
| name | worktree |
| description | Perform work in a git worktree branched from main. Create the worktree, do the work, then offer to clean it up. |
do work in an isolated git worktree so the main working directory stays
clean. the worktree is always created from origin/main.
/skill:worktree <branch-name> [description of work]
if no branch name is given, derive one from the task description
(e.g. fix/typo-in-readme).
always branch from origin/main, regardless of what branch is currently
checked out:
git fetch origin main
git worktree add ../<branch-name> -b <branch-name> origin/main
confirm the worktree was created:
git worktree list
all subsequent work happens inside the worktree directory:
cd ../<branch-name>
important: every bash invocation runs in a fresh shell. always cd into
the worktree at the start of each command. use paths relative to the worktree
root for read/write/edit operations (e.g. ../<branch-name>/path/to/file),
or prefix commands:
cd ../<branch-name> && make ci
perform whatever task was requested. follow normal conventions:
make ci (or the project's validation command) before committinggit add -Acd ../<branch-name> && git push -u origin <branch-name>
once the work is complete (committed, pushed, PR opened if applicable), always offer to remove the worktree:
the worktree at
../<branch-name>is no longer needed. want me to remove it?
if the user agrees (or if operating autonomously):
git worktree remove ../<branch-name>
if the branch is also no longer needed (e.g. merged):
git branch -d <branch-name>
origin/main — never from the current branch or HEADcd into the worktree at the start of every bash commandWrite portable scripts and tools with cosmic — HTTP requests, JSON parsing, SQLite databases, filesystem operations, child processes, crypto, compression, and more in a single zero-dependency binary
Build ah and create a GitHub prerelease with the binary and checksums.
Trigger a GitHub Actions workflow, watch it, and if it fails, analyze logs, debug, fix on a new branch via red-green TDD, and open a PR.
Triage GitHub issues safely with restricted tools, defending against prompt injection in issue bodies.
Open a pull request, resolve merge conflicts, watch CI, or review an incoming PR.