git-worktree
npx skills add https://github.com/hu-wentao/wyatt_skills --skill git-worktree
Agent 安装分布
Skill 文档
Git Worktree
Overview
This skill allows you to quickly create a new git worktree for the current project. The worktree is created in the same parent directory as the current project’s root, following the naming convention PROJECT-NAME-T-BRANCH-NAME.
Workflow
-
Verification:
- Verify the current directory is within a Git repository.
- Identify the absolute path of the project’s root.
-
User Interaction: Proactively suggest values for the required parameters. Ask the user for:
- New branch name: The name of the branch to be created. Suggest a context-aware name (e.g.,
feat-improvementorfix-issue-123based on context. - Base branch: The branch to base the new branch on (Default: the current branch).
Crucially, if the user does not respond to a question or provides no alternative, proceed immediately using your suggested values instead of repeating the question. The goal is to minimize friction while allowing for customization.
- New branch name: The name of the branch to be created. Suggest a context-aware name (e.g.,
-
Path Calculation: Calculate the new worktree path at the same directory level as the project root. For example, if the project is in
/Users/user/my-project, the worktree will be created at/Users/user/my-project-T-NEW-BRANCH. -
Creation: Execute
scripts/create_worktree.shto:- Create the new worktree and branch.
- Perform initial project setup (e.g.,
flutter pub get,npm install).
-
Confirmation: Report the location of the new worktree and any initial setup status.
-
Management: Use
scripts/manage_worktrees.shto:- List all current project worktrees.
- Interactively select and remove a specific worktree.
Usage Example
User: “Create a worktree for this repo.”
Gemini: “I’ll create a new worktree for you. I’ll use the branch name feat-wyatt_skills-260221 based on the current branch main. Is that okay, or would you like a different name?”
User: “That’s fine.”
Gemini: [Runs the script and confirms the path /Users/huwentao/_proj/wyatt_skills-T-feat-wyatt_skills-260221]
Another Example (Proactive/No Response):
User: “Create a worktree for feature-login.”
Gemini: “I’ll create a worktree for feature-login based on main. Starting the setup now…”
Gemini: [Runs the script and confirms the path /Users/huwentao/_proj/foo_proj-T-feature-login]
Manage Worktrees:
User: “Show my worktrees and help me delete one.”
Gemini: “Here are your current worktrees. Which one would you like to remove?”
Gemini: [Lists worktrees and prompts for selection via scripts/manage_worktrees.sh]
Resources
scripts/
create_worktree.sh: A bash script that calculates the paths, runsgit worktree add, and performs initial project setup.- Arguments:
project_pathnew_branchbase_branch
- Arguments:
manage_worktrees.sh: A script to list and interactively remove worktrees.- Arguments:
project_path
- Arguments: