Worktree logo

Worktree

OrganizationPopular
mistralai
worktree

Create, reuse, and clean up git worktrees under $VIBE_HOME/worktrees. Use when the user wants to work in an isolated git worktree, create a worktree for a task, or list/remove existing worktrees.

Overview

Publishermistralai
Repositorymistral-vibe
Skill nameworktree
Stars
5K
Forks
700
Bundled files
Instructions only
LicenseApache-2.0
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 mistralai on GitHub. Read the source before you install it.

Installation

Install the Worktree 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.
  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/mistralai/mistral-vibe.git /tmp/mistral-vibe
mkdir -p .claude/skills
cp -r /tmp/mistral-vibe/vibe/plugins/builtins/vibe/skills/worktree .claude/skills/worktree
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Worktree 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 Worktree 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 Worktree 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.

Worktree Management

Git worktrees live under $VIBE_HOME/worktrees/ (default ~/.vibe/worktrees/), each in a per-repository bucket named <repo_root.name>-<sha256(common_git_dir)[:12]> so worktrees from different repos never collide.

$VIBE_HOME/worktrees/
  .claims/<bucket>/<name>/          # claim records and holder markers
    record.json                     # metadata: branch, base_commit, branch_created, claimed_at
    recovery.json                   # snapshot metadata for a retained chat
    holders/                        # one empty file per live session
  <bucket>/<name>/                  # the actual git worktree checkout

Creating a worktree

  1. Compute the bucket from the repo root and common git dir.
  2. Validate the name (single portable path segment; no <>:"/\|?*, no trailing space or dot, no Windows reserved names like CON/PRN/NUL/ COM1-COM9/LPT1-LPT9, not . or ..).
  3. Reserve the directory with mkdir (atomic claim — fails if taken).
  4. For a new branch, start from the remote's default branch (fetch first, best-effort). For an existing branch, check it out into the worktree.
  5. git worktree add -b <name> <path> <start_point> (or without -b for reuse).
  6. Record the worktree's own HEAD as base_commit — this is the baseline for cleanup, not the invoking checkout's HEAD.
  7. Write record.json under .claims/<bucket>/<name>/.

When no name is given, derive one by slugifying the prompt: NFKD-normalize, lowercase, replace non-[a-z0-9]+ with -, take the first 6 words, trim to 40 chars, drop trailing stop words. Branch gets a vibe/ prefix. Append -2, -3, etc. on collision (up to 100). Fall back to a random slug if empty.

Reuse an existing worktree only after validating: no symlinks in the path, .git is a file (not a directory), same common git dir, matching branch.

Holding

A session using a worktree must register as a holder to prevent the background cleanup from removing it. Holder files are locked for the lifetime of the session; an unlocked marker left by a crashed process is stale and may be removed. A temporary holder protects a worktree while a session attaches.

Cleaning up

Before removal, inspect the worktree state:

  • Uncommitted changes or untracked files: git -c core.fsmonitor= status --porcelain --untracked-files=all
  • New commits since start: git rev-list --count <base_commit>..HEAD

The worktree is clean only if all three are absent. If dirty, confirm with the user before proceeding — removal discards uncommitted work, untracked files, and new commits.

If the branch pre-existed (not created by this session), confirm separately before deleting it. Re-check holders — if another session still holds the worktree, keep it. cd out of the worktree before removing (Windows refuses to delete a process's cwd).

Remove: git worktree remove --force <path>, then git branch -D <name> if the branch was created this session or the user confirmed. Delete the claim record and rmdir empty directories (never rmtree — a surviving holder must not be lost).

Snapshotting

Before retention removes an inactive worktree, save its state to a ref: stage all files (including untracked, excluding ignored) and commit to refs/vibe/reaped/<name>. Use a separate index file so the worktree's own index is untouched. Keep recovery.json after removing the active claim so reopening a chat can recreate the checkout automatically.

Retention

Keep the newest configured number of managed worktrees across repositories. Skip active worktrees. Snapshot each inactive excess worktree before removal; if snapshotting fails, keep it. Reservations without a base_commit are discarded only if empty and no creation process still holds their marker.

Creation, attachment, and retention transitions use a cross-process lock so a worktree cannot be removed while another process is claiming or attaching it.

Gotchas

  • Disable core.fsmonitor when reading someone else's working tree: git -c core.fsmonitor= status.
  • New branches start from the remote default branch, not the current checkout's HEAD.
  • Symlink paths are rejected — not a stable worktree path.
  • git worktree add cannot distinguish a taken path from an invalid ref (both exit 128), so mkdir reserves the path first.
  • Worktrees are implicitly trusted for the session only, not persisted.

Frequently asked questions

What does the Worktree AI skill do?

Create, reuse, and clean up git worktrees under $VIBE_HOME/worktrees. Use when the user wants to work in an isolated git worktree, create a worktree for a task, or list/remove existing worktrees.

Why use Worktree on TypingMind?

Because you install it once and use it with any model. Worktree 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 Worktree in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/mistralai/mistral-vibe/tree/main/vibe/plugins/builtins/vibe/skills/worktree. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Worktree?

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 Worktree?

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

Is the Worktree AI skill free?

Yes. It is published on GitHub by mistralai under the Apache-2.0 license. 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 👇