worktree
Skill4 starsChanged 44 days agoMITView on GitHub
创建和删除 Git worktree,目录固定在目标项目根的 worktree/ 下并保留分支层级。add 从本地或远端基线创建新分支;remove 移除工作树并保留分支。用户要求创建、删除 worktree 时使用,不负责恢复已有分支或推送。
- Deletes or force-pushes
59 other projects use a version of this.
Adopted by
Most recently taken up by
- venhdev/skillstheir own version, first seen Nov 8, 2026
- domengabrovsek/agent-configtheir own version, first seen Nov 8, 2026
- domengabrovsek/claudetheir own version, first seen Nov 8, 2026
- kortix-ai/sunatheir own version, first seen Nov 8, 2026
- tardigrde/obsidian-agentic-chattheir own version, first seen Nov 8, 2026
- kortix-ai/CompanyOStheir own version, first seen Nov 8, 2026
Used with
Projects with it also use worktree-merge, resolve-conflicts and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
leessjuSkillworktree-merge
Squash-merge the current worktree branch into the main branch (or a specified target). Analyzes git history and source code to craft a comprehensive commit message.
Also in 3 projects that use this
ralphkraussSkillresolve-conflicts
Resolve git merge conflicts or re-apply changes from a stale branch onto current main. Use when user says "resolve conflicts", "merge conflicts", "rebase branch", "branch is behind", "re-apply changes", "port branch", or a branch is too far behind main to merge cleanly.
Also in 5 projects that use this
SentrySkille2e
Run E2E tests for Sentry JavaScript SDK test applications
Also in 5 projects that use this
hdcolaSkillpr-comments
Fetch unresolved review comments from a GitHub PR or mark comments as resolved. Use this when managing PR review feedback, checking pending comments, or marking review threads as resolved. Supports GitHub URLs or explicit owner/repo/PR-number from anywhere, or PR number auto-detection from within a git repository.
Also in 3 projects that use this
Google CloudSkillcontributing
Guides the developer workflow for contributing to Race Condition. Use when setting up pre-commit hooks, running tests before a PR, understanding code style requirements, or preparing a contribution.
Also in 3 projects that use this
PydanticSkillcoverage
Fetch coverage diff from Codecov for the current branch or a specific PR. Shows uncovered lines, patch coverage, and overall coverage change.
Also in 3 projects that use this
Other versions59 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 59
- Significant-Gravitas/AutoGPT★ 188ksame name
- kortix-ai/suna★ 21ksame name
- kortix-ai/CompanyOS★ 21ksame name
- gitkraken/vscode-gitlens★ 10ksame name
- Zipstack/unstract★ 7.4ksame name
- mistralai/mistral-vibe★ 5.3ksame name
- nubjs/nub★ 4.4ksame name
- raine/workmux★ 3ksame name
- astashov/liftosaur★ 775same name
- nudgebee/nudgebee★ 520same name
49 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- architecture-designSkill
- architecture-scoutSkill
- bug-debuggingSkill
- complexity-auditSkill
- diff-reviewSkill
- implementation-workflowSkill
- mutation-testingSkill
- pmSkill
- prototypeSkill
- researchSkill
- test-designSkill
- wikiSkill
The file
Files
Worktree 管理
/agentforge:worktree add dev feature/login
/agentforge:worktree remove feature/loginadd 接受 from、新分支两个参数;remove 接受一个分支参数,动作不可省略。不接受目录参数,目标固定为 <项目主工作树根>/worktree/<分支>/,如 worktree/feature/login/。
公共规则
- 用
git -C "<目标项目目录>" worktree list --porcelain确定主工作树根$root;在 linked worktree 中调用也使用该根,不使用技能安装目录或当前 shell 目录。裸仓库不支持。之后所有仓库命令都显式写git -C "$root"或git -C "$target",不依赖当前工作目录。 - 校验动作、参数数量及分支名:用
git check-ref-format "refs/heads/$branch",拒绝以-开头的名称,不展开 checkout 简写。远端名来自仓库配置,同样视为不可信:必须精确出现在git -C "$root" remote的输出中,且不能以-开头、不能含空白或控制字符,否则停止并报告。命令参数安全传递,shell 变量始终引用,远端名放在--之后,防止被 Git 解析为选项。 - 目标必须在根
worktree/内,目标和父路径不能经过符号链接、嵌入另一工作树或独立仓库。 - 旧
.worktree/中的工作树不自动迁移或删除;remove仅核对新约定路径,旧路径另有登记时报告实际位置,不把同名目录当作目标。 - 使用原生 Git,不要求当前分支为 dev。不切换分支、不自动暂存、提交、stash、推送、删除分支或安装依赖。
- 检查失败就停止并报告实际状态;不把查询失败当作不存在,不自动覆盖、解锁、prune 或清理残留。强制删除必须先说明具体数据风险并获得用户对本次丢弃的明确同意。
add
- 选择来源:询问 from 使用本地还是远端;对话已明确时不重复询问。默认远端为 origin,没有 origin 时使用唯一远端,存在多个则补问;选定后按公共规则校验远端名。无远端或无法查询就停止,即使 from 选择本地也要检查远端重名。
- 锁定基线:本地用
git -C "$root" rev-parse --verify --end-of-options "refs/heads/$from^{commit}"解析;远端先获取指定分支,再解析远端跟踪引用,记录完整 OID。例如:
来源不存在或获取失败就停止,不改写本地 from,不回退到其他来源或旧缓存。git -C "$root" fetch --no-tags -- "$remote" "+refs/heads/$from:refs/remotes/$remote/$from" - 检查冲突:本地已有
refs/heads/<new>、目标路径已存在或已登记,都停止;已挂载时报告路径。用下列命令查询所选远端的精确引用,不依赖缓存:
核对返回 ref;退出码 0 为存在,停止;2 为无匹配;其他为查询失败,停止。此检查不预留远端分支名。git -C "$root" ls-remote --exit-code --heads -- "$remote" "refs/heads/$new" - 准备目录:确认
worktree/下没有已跟踪文件,并被忽略;必要时在根.gitignore追加/worktree/,保留原内容。通过路径检查后创建缺失父目录。 - 创建并验证:
重新核对注册路径、实际分支、HEAD 等于基线 OID,以及目标被主工作树忽略。报告来源类型/远端、基线短 hash、新分支、完整路径及未提交的git -C "$root" worktree add -b "$new" -- "$target" "$base_oid".gitignore改动。
remove
remove 不查询远端,不询问 from,不修改忽略规则。
- 核对身份:按分支计算目标路径,精确匹配 worktree 登记;未登记则报告不存在,不能直接删同名目录。目录缺失、锁定、失效、detached HEAD,或登记分支与实际分支不一致时停止。记录分支提交 OID,并确认目标 HEAD 一致。
- 检查数据:
按 NUL 分隔解析;任何暂存、未暂存、未跟踪、忽略内容或子模块变化都列出路径和状态并停止,等待用户处理,不输出敏感文件内容。忽略文件也可能随正常删除丢失,保留分支不能保护这些数据。 未推送的提交仍由本地分支保留,不要求先合并或推送。git -C "$target" status --porcelain=v1 -z --untracked-files=all --ignored=matching --ignore-submodules=none - 删除:确认身份和状态未变化,在主工作树根执行:
Git 拒绝时报告原因,不自动加git -C "$root" worktree remove -- "$target"--force或改用rm -rf。 - 验证:目录和注册项均已消失,原分支仍存在且 OID 未变。报告移除路径、保留分支及短 hash;不清理空父目录或其他工作树。add 仍拒绝已有分支,不将其描述为恢复命令。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

