Using Git Worktrees logo

Using Git Worktrees

Community
Innei
using-git-worktrees

Use when ryugi:executing-specs or ryugi:test-driven-development sends you here before the first implementation edit, when uncommitted work has to move to or be committed on a branch other than the one checked out, or when work done in a worktree has landed

Overview

PublisherInnei
Repositoryryugi
Skill nameusing-git-worktrees
Stars
321
Forks
14
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 Innei on GitHub. Read the source before you install it.

Installation

Install the Using Git 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/Innei/ryugi/tree/main/skills/using-git-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/Innei/ryugi.git /tmp/ryugi
mkdir -p .claude/skills
cp -r /tmp/ryugi/skills/using-git-worktrees .claude/skills/using-git-worktrees
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Using Git 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 Using Git 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 Using Git 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.

Using Git Worktrees

Work in place unless the table below says otherwise. A worktree costs a dependency install, its own build caches, and a cleanup someone has to remember. Other agents may be working in the same checkout; you stay apart from them per hunk, by committing only what is yours, not per directory.

Where to work

Run once per session:

bash
git rev-parse --path-format=absolute --git-dir --git-common-dir
git rev-parse --show-superproject-working-tree
git branch --show-current
git status --porcelain
cat .ryugi/sdd/*/EXPLORING

The answer holds for the rest of the session. When another skill sends you here again (the next task, the next TDD cycle), keep working where you are; run the commands again only in a different repository.

"The work" is the files your spec or change will touch. The spec you are building, and files you created or changed in this session, are yours. Untracked caches and build output (.vitest/, .next/, dist/, coverage/) are nobody's edits.

Before changing a file that has edits you did not make, run git diff <file> to see which lines they touch.

Take the first row that matches:

The checkout showsWhere you work
--git-dir differs from --git-common-dir, and --show-superproject-working-tree printed nothing (a linked worktree, not a submodule)Stay there
Your human partner's instructions say where to workFollow them
The work must be developed, tested or built on other content: another branch or commit, a rebase, a bisectNew worktree, without asking
Your change would touch lines that already have edits you did not makeNew worktree, without asking
An EXPLORING file lists a path the work changesNew worktree, without asking
The work changes dependencies, formats the whole repo, or runs codegen, and files that step rewrites (manifest, lockfile, formatted or generated files) have edits you did not makeNew worktree, without asking
HEAD is on a branch that is neither the default branch nor one made for this workAsk whether to use a worktree
Anything else, including edits you did not make in other files or in other hunks of the files you changeIn place, no question

Commit only what is yours

Working in place, stage your own paths by name. In a file that also has someone else's edits, stage only your hunks: save git diff <file> to a patch, delete the hunks that are not yours, and git apply --cached it. Never git add -A, git add . or git commit -a. Your tests ran on the shared tree; CI checks the commit on its own.

Move your changes, never copy them

When uncommitted work has to go to another branch, either to keep developing there or just to commit it there (a PR branch off the default branch, for example), do not switch branches in the shared checkout. Move the changes:

bash
git stash push --include-untracked -- <your paths>

Stashes are shared by every worktree of a repository. Create the worktree (below), run git stash pop inside it, then check that git -C <original checkout> status --porcelain -- <your paths> prints nothing. If the pop conflicts, stop and show your human partner.

If you only need to commit there, the worktree lives for the commit: no install, no test run, then commit, push, open the PR if asked, and remove the worktree at once. The pushed branch carries any later fixes.

Create a worktree

Native tool first. If you have a tool or command that creates worktrees (EnterWorktree, WorktreeCreate, a /worktree command, a --worktree flag), use it. git worktree add beside a native tool creates a worktree your harness cannot see or clean up. A "New worktree" row or a move above is your human partner's standing instruction to work in a worktree: it is the explicit request a native tool's description asks for.

Otherwise, git worktree add:

  • Directory: the one your instructions name; else an existing .worktrees/ (it wins over worktrees/) or worktrees/; else default to .worktrees/ at the project root. Never /tmp, a sibling of the repository, or a harness's own folder (.claude/worktrees/, ~/.codex/worktrees/) by hand.
  • If git check-ignore -q <dir> fails, append the directory to $(git rev-parse --git-common-dir)/info/exclude. Never edit or commit .gitignore for this: in a shared checkout that commit lands on someone else's branch.
  • git worktree add "<dir>/<branch>" -b "<branch>" [<base>], then work from there.
  • If the sandbox refuses, say so and work in place.

Uncommitted spec. A new worktree starts from HEAD. If the spec, or another file the work needs, is untracked or modified, copy it into the worktree at the same path. Do not commit it on your human partner's behalf.

Set up

Only in a worktree you just created to develop or test in. Install with the package manager the repository uses: frozen when the lockfile is committed (pnpm install --frozen-lockfile, npm ci, …), a plain install when it is not. Never symlink or copy node_modules from another checkout: workspace packages would resolve to that checkout's source. Run the project's test command once; if it fails, report the failures and ask whether to go on.

Cleanup

When the work has landed (merged, or your human partner says it is done) or they ask you to discard it, remove every worktree you created in this session, native ones included, without asking. A worktree with an open PR stays: feedback gets fixed there. Worktrees you did not create stay.

Run removal from the main repo root, never from inside the worktree. First delete a spec you copied in at creation if it still matches the main checkout's copy (cmp); one you changed there stays.

  • Native tool: its remove action (ExitWorktree with remove, or your platform's archive tool).
  • git worktree add: git worktree remove "$WORKTREE_PATH", then git worktree prune.

If removal is refused, or status shows changes (contains modified or untracked files): those files exist nowhere else. Never --force or discard_changes on your own initiative. Show your human partner git -C "$WORKTREE_PATH" status --porcelain -uall and ask whether to commit them, move them into the main repo, or delete them.

Before you report done

Every checkout and worktree you touched holds none of your uncommitted changes, or your final message names what is left there and whether it is pushed.

Common Rationalizations

ExcuseReality
"I'm obviously not in a worktree — no need to check"Run the Where to work commands. Harness-created isolation and submodules both fool eyeballing; the commands settle it.
"Someone else has edits here, a worktree is safer"Edits in other files or other hunks never touch yours. Commit only your hunks; a worktree costs an install, a build cache and a cleanup.
"I'll re-run the checks to be safe"The answer holds for the session. Re-running is how a decided question gets reopened mid-task.
"I'll copy my files over and tidy the original later"Later never comes, and your human partner is left checking whether those edits shipped. Stash-move them.
"git worktree add is quicker than hunting for a native tool"A native tool (e.g. EnterWorktree) owns placement, branching, and cleanup. Bypassing it is the #1 mistake — it creates phantom state your harness can't see or manage.
"Removal refused — --force is just finishing the cleanup"The refusal means files exist only in that worktree. --force destroys them permanently. Show your human partner and ask.

Frequently asked questions

What does the Using Git Worktrees AI skill do?

Use when ryugi:executing-specs or ryugi:test-driven-development sends you here before the first implementation edit, when uncommitted work has to move to or be committed on a branch other than the one checked out, or when work done in a worktree has landed

Why use Using Git Worktrees on TypingMind?

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

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/Innei/ryugi/tree/main/skills/using-git-worktrees. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Using Git 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 Using Git Worktrees?

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

Is the Using Git Worktrees AI skill free?

It is published on GitHub by Innei. 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 👇