ワンクリックで
git-worktree
Manage Git worktrees in project-level ../.zcf/project-name/ directory with smart defaults, IDE integration and content migration
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Manage Git worktrees in project-level ../.zcf/project-name/ directory with smart defaults, IDE integration and content migration
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Professional AI programming assistant with structured workflow (Research -> Ideate -> Plan -> Execute -> Optimize -> Review) for developers
专业AI编程助手,提供结构化六阶段开发工作流(研究→构思→计划→执行→优化→评审),适用于专业开发者
Quickly add a new corporate sponsor to ZCF — sponsor list by default, with optional API preset and documentation ad placements
Create pull request based on current branch changes
Automate version release and code commit using changeset
Automatically check code changes since last tag and update documentation in docs/ directory (en, zh-CN, ja-JP) and CLAUDE.md to ensure consistency with actual code implementation
| name | git-worktree |
| description | Manage Git worktrees in project-level ../.zcf/project-name/ directory with smart defaults, IDE integration and content migration |
| disable-model-invocation | true |
| allowed-tools | Read(**), Exec(git worktree add, git worktree list, git worktree remove, git worktree prune, git branch, git checkout, git rev-parse, git stash, git cp, detect-ide, open-ide, which, command, basename, dirname) |
Manage Git worktrees with smart defaults, IDE integration and content migration in structured ../.zcf/project-name/ paths.
Execute commands directly and provide concise results.
# Basic operations
/git-worktree add <path> # create new branch named <path> from main/master
/git-worktree add <path> -b <branch> # create new branch with specified name
/git-worktree add <path> -o # create and open directly in IDE
/git-worktree list # show all worktree status
/git-worktree remove <path> # remove specified worktree
/git-worktree prune # clean invalid worktree references
# Content migration
/git-worktree migrate <target> --from <source> # migrate uncommitted content
/git-worktree migrate <target> --stash # migrate stash content
| Option | Description |
|---|---|
add [<path>] | Add new worktree in ../.zcf/project-name/<path> |
migrate <target> | Migrate content to specified worktree |
list | List all worktrees and their status |
remove <path> | Remove worktree at specified path |
prune | Clean invalid worktree references |
-b <branch> | Create new branch and checkout to worktree |
-o, --open | Open directly in IDE after creation (skip prompt) |
--from <source> | Specify migration source path (migrate only) |
--stash | Migrate current stash content (migrate only) |
--track | Set new branch to track corresponding remote branch |
--guess-remote | Auto guess remote branch for tracking |
--detach | Create detached HEAD worktree |
--checkout | Checkout immediately after creation (default behavior) |
--lock | Lock worktree after creation |
Environment Check
git rev-parse --is-inside-work-treeSmart Path Management
../.zcf/project-name/<path> directory# Core path calculation logic for worktree detection
get_main_repo_path() {
local git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null)
local current_toplevel=$(git rev-parse --show-toplevel 2>/dev/null)
# Check if in worktree
if [[ "$git_common_dir" != "$current_toplevel/.git" ]]; then
# In worktree, derive main repo path from git-common-dir
dirname "$git_common_dir"
else
# In main repository
echo "$current_toplevel"
fi
}
MAIN_REPO_PATH=$(get_main_repo_path)
PROJECT_NAME=$(basename "$MAIN_REPO_PATH")
WORKTREE_BASE="$MAIN_REPO_PATH/../.zcf/$PROJECT_NAME"
# Always use absolute path to prevent nesting issues
ABSOLUTE_WORKTREE_PATH="$WORKTREE_BASE/<path>"
Critical Fix: Always use absolute paths when creating worktrees from within existing worktrees to prevent path nesting issues like ../.zcf/project/.zcf/project/path.
Worktree Operations
Smart Defaults
-b specified, create new branch using path nameContent Migration
Safety Features
.zcf directories when in worktreeEnvironment File Handling
.gitignore for environment variable file patterns.env and .env.* files that are listed in .gitignore.env.example and other template files# Environment file copying implementation
copy_environment_files() {
local main_repo="$MAIN_REPO_PATH"
local target_worktree="$ABSOLUTE_WORKTREE_PATH"
local gitignore_file="$main_repo/.gitignore"
# Check if .gitignore exists
if [[ ! -f "$gitignore_file" ]]; then
return 0
fi
local copied_count=0
# Detect .env file
if [[ -f "$main_repo/.env" ]] && grep -q "^\.env$" "$gitignore_file"; then
cp "$main_repo/.env" "$target_worktree/.env"
echo "✅ Copied .env"
((copied_count++))
fi
# Detect .env.* pattern files (excluding .env.example)
for env_file in "$main_repo"/.env.*; do
if [[ -f "$env_file" ]] && [[ "$(basename "$env_file")" != ".env.example" ]]; then
local filename=$(basename "$env_file")
if grep -q "^\.env\.\*$" "$gitignore_file"; then
cp "$env_file" "$target_worktree/$filename"
echo "✅ Copied $filename"
((copied_count++))
fi
fi
done
if [[ $copied_count -gt 0 ]]; then
echo "📋 Copied $copied_count environment file(s) from .gitignore"
fi
}
-o flag to skip prompt and open immediately# Migrate uncommitted changes
/git-worktree migrate feature-ui --from main
/git-worktree migrate hotfix --from ../other-worktree
# Migrate stash content
/git-worktree migrate feature-ui --stash
Migration Flow:
# Basic usage
/git-worktree add feature-ui # create new branch 'feature-ui' from main/master
/git-worktree add feature-ui -b my-feature # create new branch 'my-feature' with path 'feature-ui'
/git-worktree add feature-ui -o # create and open in IDE directly
# Content migration scenarios
/git-worktree add feature-ui -b feature/new-ui # create new feature worktree
/git-worktree migrate feature-ui --from main # migrate uncommitted changes
/git-worktree migrate hotfix --stash # migrate stash content
# Management operations
/git-worktree list # view all worktrees
/git-worktree remove feature-ui # remove unneeded worktree
/git-worktree prune # clean invalid references
Example Output:
✅ Worktree created at ../.zcf/project-name/feature-ui
✅ Copied .env
✅ Copied .env.local
📋 Copied 2 environment file(s) from .gitignore
🖥️ Open ../.zcf/project-name/feature-ui in IDE? [y/n]: y
🚀 Opening ../.zcf/project-name/feature-ui in VS Code...
parent-directory/
├── your-project/ # main project
│ ├── .git/
│ └── src/
└── .zcf/ # worktree management
└── your-project/ # project worktrees
├── feature-ui/ # feature branch
├── hotfix/ # hotfix branch
└── debug/ # debug worktree
# Configure custom IDE
git config worktree.ide.custom.sublime "subl %s"
git config worktree.ide.preferred "sublime"
# Control auto-detection
git config worktree.ide.autodetect true # default
.git directory, saving disk spacegit cherry-pick for commits.gitignore to new worktrees.env.example are preserved in main repo only