Skip to content
Back to skills

Worktree

ASecurity

Create a work branch in a ready-to-use git worktree. The normal way to start a branch, so as not to cross another session in the main tree.

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 7, 2026
developmentbashgit

Works with

  • claude code

Security analysis

A100/100

Scanned November 30, 2026

npx -y skills add antoine-tena/ion-repo --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/antoine-tena-worktree-427bae1a/badge)](https://www.skillsdirectory.com/skills/antoine-tena-worktree-427bae1a)

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 a work branch in a ready-to-use git worktree. The normal way to start a branch, so as not to cross another session in the main tree.
argument-hint: "<type/branch-name>"
---

Branch asked for: `$ARGUMENTS` (`feat/…`, `fix/…`, `chore/…`, like the repo's history). Without
an argument, propose one from the task.

1. Find the root of the repo (`git rev-parse --show-toplevel` of the main tree) and its
   integration branch: the one the project's `CLAUDE.md` names, otherwise `develop` if it exists
   on `origin`, otherwise the default branch (`git symbolic-ref refs/remotes/origin/HEAD`).
2. From the root, never switching the branch of the main tree: `git fetch -q origin
   <integration>`, then `git worktree add --no-track .claude/worktrees/<name> -b <branch>
   origin/<integration>` (`<name>` = the branch with `/` replaced by `-`). Without `--no-track`,
   the branch would track `origin/<integration>`: a bare `git push` refused, a `git pull` that
   pulls the integration branch. If the branch already exists, attach it without `-b`. Check
   that `.claude/worktrees/` is ignored by git; otherwise add it to `.git/info/exclude`.
3. Prepare the worktree: `bash "${CLAUDE_PLUGIN_ROOT}/scripts/prepare-worktree.sh" <path of the
   worktree>` (copies the ignored `.env*` files of the main tree, installs the dependencies of
   each `pnpm-lock.yaml` / `package-lock.json`, then copies the main tree's `.mypy_cache` and `.ruff_cache` into the
   matching folders when their `uv.lock` and tool config are identical, `warm-caches.sh`). If the repo also provides
   `.claude/worktree-setup.sh`, run it next with the same argument.
4. Move the session into it with Claude Code's `EnterWorktree` tool (`path` = the worktree):
   the status line, the hooks and the relative paths then describe the branch being worked on,
   not the main tree's integration branch. Without that tool, or when it refuses (a subagent
   launched from the main tree: "is the repository root, not an isolated worktree"), do not
   retry it: work only in the worktree, absolute paths for files, each Bash command started with
   `cd <worktree> &&` so git and the branch guard see the branch. Give its path. Claude Code's isolation then refuses a command it cannot read
   (a variable even in a plain path, a heredoc, `cd`, a loop, `$(…)`, `git -C`, several commands chained around git): send git commands plain
   and one by one, and put the rest in a script.

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 development →

Comments

Loading comments…

Newsletter

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