switch-worktree

Switch the current session to work in an existing git worktree

5,182 stars

Best use case

switch-worktree is best used when you need a repeatable AI agent workflow instead of a one-off prompt.

Switch the current session to work in an existing git worktree

Teams using switch-worktree should expect a more consistent output, faster repeated execution, less prompt rewriting.

When to use this skill

  • You want a reusable workflow that can be run more than once with consistent structure.

When not to use this skill

  • You only need a quick one-off answer and do not need a reusable workflow.
  • You cannot install or maintain the underlying files, dependencies, or repository context.

Installation

Claude Code / Cursor / Codex

$curl -o ~/.claude/skills/switch-worktree/SKILL.md --create-dirs "https://raw.githubusercontent.com/dlt-hub/dlt/main/.claude/skills/switch-worktree/SKILL.md"

Manual Installation

  1. Download SKILL.md from GitHub
  2. Place it in .claude/skills/switch-worktree/SKILL.md inside your project
  3. Restart your AI agent — it will auto-discover the skill

How switch-worktree Compares

Feature / Agentswitch-worktreeStandard Approach
Platform SupportNot specifiedLimited / Varies
Context Awareness High Baseline
Installation ComplexityUnknownN/A

Frequently Asked Questions

What does this skill do?

Switch the current session to work in an existing git worktree

Where can I find the source code?

You can find the source code on GitHub using the link provided at the top of the page.

Related Guides

SKILL.md Source

# Switch to worktree

Switch the current session to an existing worktree.

## Steps

### 1. Resolve the worktree

If `$ARGUMENTS` is empty, list available worktrees and ask the user to pick one:

```
git worktree list
```

Otherwise, let `NAME` = `$ARGUMENTS`. The worktree path is `<repo-root>/.worktrees/<NAME>`.

Verify the worktree exists in `git worktree list` output. If not, stop with an error.

Let `WORKTREE` = the absolute path to the worktree.

### 2. Switch cwd

```
cd WORKTREE
```

Then verify the switch took effect:

```
pwd
```

If `pwd` does not show `WORKTREE`, stop with an error — the cwd did not persist.

### 3. Report

```
Switched to worktree: WORKTREE
Branch: <current branch from git branch --show-current>
```