using-git-worktrees
Reuses or creates a git worktree when a development task that the human user's instructions authorize must run separately from the current checkout.
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-15
- Stars
- ★ 15
- Forks
- 4
01 前言 Front Matter
- name
- using-git-worktrees
- description
- Reuses or creates a git worktree when a development task that the human user's instructions authorize must run separately from the current checkout.
- compatibility
- [ "Python 3.11+ standard library" ]
03 SKILL.md 正文
Using Git Worktrees
The response model selects an isolated checkout when the development task that the human user's instructions authorize requires isolation. Reuse a suitable attached or existing checkout before creating another. Prefer the host's managed-worktree API; use the shell procedure only when that API is unavailable or unsuitable.
Select the checkout
Inspect the repository identity, current branch and existing worktrees. Check whether an existing checkout satisfies the task's branch, file ownership and isolation requirements. Preserve its uncommitted work.
For a new shell-managed worktree, use a location that the project instructions or the human user name explicitly. Otherwise prefer an existing .worktrees/ directory, then worktrees/. If neither exists and no project preference settles the choice, ask the human user whether to use a project-local directory or ~/.config/coding-convention/worktrees/<project-name>/.
Before creating inside the repository, check the exact selected directory with git check-ignore. Do not accept a result for a different directory. If it is not ignored, add an ignore rule only within what the human user's instructions already authorize and verify it, or use an external directory that the human user authorized. An external directory needs no repository ignore rule.
Create and prepare
Resolve the absolute target path, repository and starting ref that the human user agreed to before issuing a command. For a new branch, use the host/project naming convention. For continuing work, use the existing ref that the human user requested rather than silently starting from a default branch.
The shell operation is git worktree add <absolute-target> -b <new-branch> <starting-ref> for a new branch that the human user authorized. Existing branches require the corresponding existing-branch form. Replace the arguments from inspected state; do not execute the angle-bracket notation.
Follow the project's declared package manager and setup instructions. Do not run every example package manager or install dependencies merely because a file exists. A task prohibition on network, installation or setup overrides the default preparation.
Apply verification-before-completion to the selected checkout's relevant baseline. Distinguish a pre-existing failure from the proposed change and correct it only within the task that the human user's instructions authorize.
Result and cleanup
Report the absolute checkout, branch/ref and actual baseline result or remaining gap. Finish branch integration and cleanup through finishing-a-development-branch.
For managed worktrees, use the host's attach/archive lifecycle. Never delete an active task's checkout or discard uncommitted work. A successful PR does not by itself authorize cleanup.
Failure modes
Do not create duplicate isolation merely because the skill was invoked. Do not guess a branch or target path, use an ignore result for the wrong directory, attribute an old failure to new work, or claim host adoption from creating a checkout.
04 同仓库更多 Skills
skill-evolution
Recommends skill changes from recorded tool-call patterns and conduct corrections asserted by the human user or observed by the response model, when the human user asks for such recommendations or their pending backlog, or authorizes that analysis.
session-intent-analyzer
Records the response model's new or changed interpretation of the input the response model is answering as its `interpreted-as` record before the first tool call of work, and reads that record when it can change the objective, constraints, work choice or whether earlier work continues.
necessity-gate
Judges whether proposed work is justified, needs a narrower scope or is unjustified, when the response model proposes new work or the human user asks whether to do it.
merge-companion
Reviews the installer's backups of external changes to installed skills and merges each into the new skill version, discards or defers it as the human user chooses, before a task changes or reinstalls an installed skill, or when the human user asks for that review.
compact-handoff
Writes a handoff of the task's objective, scope, evidence and next action when a long conversation, compaction or handover to another session or agent could lose them, and resumes the task from it afterwards.
writing-skills
Writes a new skill or changes an existing one in its folder (SKILL.md, references and scripts) and tests it.