Dev Worktrees logo

Dev Worktrees

Community
diegomarino
dev-worktrees

This skill should be used when the user asks to "create a worktree", "set up an isolated workspace", "create a branch for a feature", "start working on a new branch", or before executing an implementation plan that needs an isolated git workspace.

Overview

Publisherdiegomarino
Repositoryclaude-toolshed
Skill namedev-worktrees
Stars
58
Forks
5
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by diegomarino on GitHub. Read the source before you install it.

Installation

Install the Dev Worktrees AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/diegomarino/claude-toolshed/tree/main/plugins/dev-setup/skills/dev-worktrees
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/diegomarino/claude-toolshed.git /tmp/claude-toolshed
mkdir -p .claude/skills
cp -r /tmp/claude-toolshed/plugins/dev-setup/skills/dev-worktrees .claude/skills/dev-worktrees
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Dev Worktrees in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Dev Worktrees on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Dev Worktrees is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

dev-worktrees

Overview

Creates an isolated git worktree with dependency install, port allocation (when dev-setup scripts are present), and baseline test verification.

Works in two modes — the steps after worktree creation are identical in both:

  • Create mode: branch does not exist yet → creates worktree + branch, then sets up
  • Setup mode: worktree already exists (created manually or by another tool) → enters it and runs setup only (deps + ports + tests)

Announce at start: "I'm using the dev-worktrees skill to set up an isolated workspace."

Branch Name

Branch: $ARGUMENTS

If the branch name above is empty: derive it from context (implementation plan, task description) or ask the user:

"What branch name should I use? (e.g. feature/auth, fix/login-bug)"

Use the branch name exactly as provided — do not sanitize or replace / with - or any other character. Branch names with slashes (e.g. feature/auth) create nested directories in the worktree folder, which is handled in the Create Worktree step with mkdir -p.

Worktree Directory Selection

Follow this priority order exactly — do NOT skip steps or invent paths:

  1. Read .claude/dev-setup.json → worktrees_dir key

    • If key present in file: use that value. Stop here. Do not ask.
  2. Check if .worktrees/ exists in project root → use it

  3. Check if worktrees/ exists in project root → use it

    • If both exist: .worktrees/ wins — use it without asking.
  4. Check CLAUDE.md for a worktree directory preference:

    bash
    grep -i "worktree.*dir" CLAUDE.md 2>/dev/null

    If a preference is found: use it. Do not ask.

  5. Ask user — recommend .worktrees/ as the default:

    • .worktrees/ — project-local, hidden (recommended)
    • ~/.config/worktrees/<project-name>/ — global (no gitignore check needed; directory auto-created by git worktree add)

Never invent a directory (e.g. sibling pattern, --branch-name suffix) without going through this priority order first.

Safety Check (project-local dirs only)

ALWAYS run before creating the worktree — do NOT skip this step:

bash
git check-ignore -q <worktrees-dir>

Do not manually read .gitignore. Use git check-ignore -q.

If NOT ignored: add to .gitignore and commit before proceeding:

bash
echo "<worktrees-dir>/" >> .gitignore
git add .gitignore
git commit -m "chore: add <worktrees-dir> to .gitignore"

Create Worktree

Before creating, check for an existing branch or worktree:

bash
git worktree list | grep "<branch>"   # non-empty → worktree already exists
git branch --list "<branch>"          # non-empty → branch exists, no worktree yet
  • Worktree already exists → setup mode: extract its path from git worktree list, EnterWorktree to it, then proceed directly to Install Dependencies. Skip the Safety Check and git worktree add entirely — the worktree is already there.
  • Branch exists, no worktree → git worktree add <full-path>/<branch> <branch> (no -b)
  • Neither exists → git worktree add <full-path>/<branch> -b <branch>
bash
project=$(basename "$(git rev-parse --show-toplevel)")
# Create intermediate directories if branch name contains slashes
mkdir -p "$(dirname "<full-path>/<branch>")"
git worktree add <full-path>/<branch> [-b] <branch>

After the worktree is created, use the EnterWorktree tool to set Claude's working directory to <full-path>/<branch>. Do NOT use cd in Bash — it does not persist between tool calls and subsequent steps (install, tests) will silently run in the wrong directory.

<full-path>/<branch> is:

  • Local: <worktrees-dir>/<branch>
  • Global: ~/.config/worktrees/<project>/<branch>

Use the branch name as-is for the folder name. Do not replace / with - or any other character.

Install Dependencies

Auto-detect and run from the new worktree directory:

ManifestCommand
package.jsondetect from lockfile (see below)
Cargo.tomlcargo build
go.modgo mod download
requirements.txtpip install -r requirements.txt
pyproject.tomlpoetry install
None foundskip — note "No dependency manifest found"

Node.js lockfile → package manager (check in this order):

LockfileManager
bun.lockbbun install
pnpm-lock.yamlpnpm install
yarn.lockyarn install
package-lock.json or nonenpm install

Remember the detected manager — use it for the baseline test command too.

Port Allocation (conditional)

Search for dev-wt-ports.sh in these dirs (relative to project root): tools/dev/, scripts/, bin/, devtools/

If NOT found:

"No dev-setup scripts found — skipping port allocation. Run /dev-setup to add port isolation support."

Continue to the next step. Do NOT stop.

If found (SCRIPT_DIR = that directory):

First check whether .wt-ports.env already exists and has content in the worktree root:

bash
[[ -s "<worktree-path>/.wt-ports.env" ]]
  • Non-empty .wt-ports.env found → skip allocation, note "ports already allocated" in report. Do NOT re-allocate — that would break any servers currently using those ports.
  • Missing or empty → allocate:
bash
bash <SCRIPT_DIR>/dev-wt-ports.sh <worktree-full-path> <branch>

Do NOT call dev-allocate-ports.sh directly — always call dev-wt-ports.sh.

Then verify .wt-ports.env exists and is non-empty in the worktree root.

Baseline Test Verification

Auto-detect and run from the new worktree directory:

ManifestCommand
package.json<package-manager> test (use same manager detected for install: npm/yarn/pnpm/bun)
Cargo.tomlcargo test
pyproject.toml / requirements.txtpytest
go.modgo test ./...
None foundskip — note "No test framework detected"
  • Pass: record test count
  • Fail: report failures, ask "Proceed anyway or investigate first?"

Do NOT skip this step. Baseline tests are always run.

Report

Worktree ready at <full-path>
Ports allocated: API_WT_PORT=<n>, WEB_WT_PORT=<n>, ...   (if ports allocated)
Tests passing (<N> tests, 0 failures)                     (if tests ran)
Ready to implement <feature-name>
When done: run /merge-checks before merging

Quick Reference

SituationAction
Config has worktrees_dirUse it — do not ask
.worktrees/ existsUse it (verify ignored)
worktrees/ existsUse it (verify ignored)
Both .worktrees/ and worktrees/ exist.worktrees/ wins
Neither existsCheck CLAUDE.md → ask user
Dir not ignoredAdd to .gitignore + commit first
Worktree already existsSetup mode: EnterWorktree → deps → ports → tests (no git worktree add)
.wt-ports.env already has contentSkip port allocation — note "already allocated"
No dev-setup scriptsSkip port allocation, continue
Tests failReport + ask before proceeding

Common Mistakes

  • Using cd instead of EnterWorktree — cd in Bash does not persist; install and tests run in the wrong directory
  • Skipping the branch existence check — git worktree add -b <branch> fails if the branch already exists
  • Inventing a directory — always follow priority order, never assume a sibling pattern
  • Reading .gitignore manually — always use git check-ignore -q <dir>
  • Calling dev-allocate-ports.sh directly — always call dev-wt-ports.sh <path> <branch>
  • Skipping baseline tests — always run, always ask if they fail
  • Replacing / in branch name — use the branch name exactly as-is for the folder

Frequently asked questions

What does the Dev Worktrees AI skill do?

This skill should be used when the user asks to "create a worktree", "set up an isolated workspace", "create a branch for a feature", "start working on a new branch", or before executing an implementation plan that needs an isolated git workspace.

Why use Dev Worktrees on TypingMind?

Because you install it once and use it with any model. Dev Worktrees is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Dev Worktrees in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/diegomarino/claude-toolshed/tree/main/plugins/dev-setup/skills/dev-worktrees. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Dev Worktrees?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Dev Worktrees?

As many as you like. As long as a model supports skills, you can use Dev Worktrees with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Dev Worktrees AI skill free?

It is published on GitHub by diegomarino. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇