Skip to content
Back to skills

Worktree

ASecurity

Create git worktrees for parallel feature development. Use when working on multiple features simultaneously.

  • 3 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
businessbashgit

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add jinyuanlu/dotfiles --skill worktree --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Worktree?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Worktree
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jinyuanlu-worktree/badge)](https://www.skillsdirectory.com/skills/jinyuanlu-worktree)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: worktree
description: Create git worktrees for parallel feature development. Use when working on multiple features simultaneously.
argument-hint: [branch-name]
---

# Worktree Management Skill

## Instructions

When the user invokes this skill:

1. **Fetch latest changes**
   ```bash
   git fetch origin
   ```

2. **Ensure .gitignore is configured**
   - Check if `.worktrees/` is in `.gitignore`
   - If not, append `.worktrees/` to `.gitignore`

3. **Determine branch type** - Check if the branch already exists:
   ```bash
   git branch -a | grep -E "(^|\s)feat/<name>$|origin/feat/<name>"
   ```

4. **Determine base branch** (only needed for new branches):
   ```bash
   git branch -r | grep -E "origin/(develop|master)$"
   ```
   - Use `origin/develop` if it exists
   - Fall back to `origin/master` if `develop` doesn't exist

5. **Create the worktree**

   **If branch does NOT exist** → create new branch from base branch:
   ```bash
   # If origin/develop exists:
   git worktree add .worktrees/<name> -b feat/<name> origin/develop

   # If origin/develop doesn't exist, use origin/master:
   git worktree add .worktrees/<name> -b feat/<name> origin/master
   ```

   **If branch EXISTS** → use existing branch:
   ```bash
   git worktree add .worktrees/<name> feat/<name>
   ```

6. **Report the result**
   - Show `git worktree list`
   - Provide the worktree path: `.worktrees/<name>`

## Examples

```
User: /worktree auth-refactor
→ Branch feat/auth-refactor doesn't exist
→ origin/develop exists
→ Creates .worktrees/auth-refactor on NEW branch feat/auth-refactor (from origin/develop)

User: /worktree new-feature
→ Branch feat/new-feature doesn't exist
→ origin/develop doesn't exist, using origin/master
→ Creates .worktrees/new-feature on NEW branch feat/new-feature (from origin/master)

User: /worktree metaknow_url_header
→ Branch feat/metaknow_url_header already exists
→ Creates .worktrees/metaknow_url_header using EXISTING branch
```

## Cleanup

```bash
git worktree remove .worktrees/<name>
git worktree list
```

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in business →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.