Agent skill
git-worktree-clone
Clone a Git repository as bare repo and set it up for git worktrees workflow. Use when the user says "clone as bare repo", "setup git worktrees", "worktree clone", or asks to clone a repo for worktree usage.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/git-worktree-clone
SKILL.md
Git Worktree Clone
Clone a Git repository as a bare repository and configure it for git worktrees workflow.
Arguments
The skill accepts optional arguments in the format:
/git-worktree-clone <repo-url>- Clone with auto-detected directory name/git-worktree-clone <repo-url> <directory-name>- Clone with custom directory name
Instructions
- Parse arguments:
- If args provided: extract repo URL (first arg) and optional directory name (second arg)
- If no args: ask for repository URL
- Directory name: use provided name, or derive from repo URL (last part without .git)
- Determine directory name if not provided (default: derive from repo URL)
- Create directory structure (use absolute path for
<repo-path>):bashmkdir -p <repo-path> git clone --bare <repo-url> <repo-path>/.git - Configure remote tracking (use
-Cto target the repo):bashgit -C <repo-path> config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*' - Delete local branches created during clone:
bash
git -C <repo-path> branch | sed 's/^[* ]*//' | xargs -r git -C <repo-path> branch -D - Fetch remote branches:
bash
git -C <repo-path> fetch - Verify setup:
bash
git -C <repo-path> branch -a # Should show only remotes/origin/* branches git -C <repo-path> worktree list # Should show only bare repo - Create main worktree with tracking:
bash
git -C <repo-path> worktree add -b main main origin/main - Ask user if they want to create additional worktree(s)
- If yes, create with:
git worktree add -b <branch> <path> origin/<branch>
- If yes, create with:
Workflow explanation
This setup creates:
- Bare repo in
<directory-name>/.git- central git database - Worktrees as subdirectories - actual working copies of branches
- Benefits:
- Multiple branches checked out simultaneously
- Each branch in its own directory
- No need to stash changes when switching branches
- Shared git database saves space
Example usage
# Clone with auto-detected name
/git-worktree-clone [email protected]:rmd-devops/infrastructure/rmd-devops-networking.git
# Clone with custom directory name
/git-worktree-clone [email protected]:rmd-devops/infrastructure/rmd-devops-networking.git my-network-repo
Example structure
rmd-devops-networking/
├── .git/ # Bare repository
├── main/ # Worktree for main branch
└── feat/ # Worktree for feature branch
Rules
- MUST use absolute paths and
git -C <repo-path>instead ofcd - MUST delete all local branches after clone (keep only remotes)
- MUST configure remote fetch before fetching
- MUST use
-bflag when creating worktrees to create tracking branches - MUST always create a main worktree tracking origin/main
- Ask before creating additional worktrees beyond main
- Verify the setup shows
(bare)ingit worktree list
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?