一键导入
teardown-worktree
Tear down the current git worktree and associated branch resources.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Tear down the current git worktree and associated branch resources.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Merges completed work back to main through a protected-branch pull request workflow.
Set up a new git worktree and install dependencies.
Merges completed work back to main through a protected-branch pull request workflow.
Set up a new git worktree and install dependencies.
Prepares a Python package for PyPI release by updating the version, building, and verifying the distribution.
Prepare a release by updating the version, building, and verifying the distribution.
| name | teardown-worktree |
| description | Tear down the current git worktree and associated branch resources. |
Tears down the current git worktree by removing its virtual environment, deleting the remote branch if it exists, and removing the worktree directory and local branch. Auto-detects the branch name and worktree path from the current directory.
$ARGUMENTS
Detect the current branch name by running git branch --show-current. Remember this as <branch>. Detect the current worktree path by running pwd. Remember this as <worktree-path>.
If the project uses a tool that stores environments outside the worktree directory, remove them explicitly to prevent stale environments from accumulating. (Environments stored inside the worktree — .venv, node_modules, target/, etc. — are automatically wiped in step 3.)
Examples of tools that require explicit cleanup:
poetry env remove --allpipenv --rmCheck whether the branch exists on origin with git ls-remote origin <branch>. If the output is non-empty, the branch exists — delete it with git push origin --delete <branch>. If the output is empty, the branch is already gone — skip deletion.
Clean up by running cd ../main && git worktree remove -f <worktree-path> && rm -rf <worktree-path> && git branch -D <branch> from the ../main directory. The -f flag forces removal even if the worktree has modifications. The rm -rf ensures any leftover files are fully removed. Do NOT run this from the worktree directory itself.
If this command succeeds, you will start getting errors such as Error: Path "/path/to/old/branch" does not exist. This means that the worktree directory you started in no longer exists, and all commands you continue to run will fail. This is a sign for you to stop. The script is complete.
../main. Only step 3 switches to ../main for the final removal.