Dev.Worktrees logo

Dev.Worktrees

Community
kevinslin
dev.worktrees

Create, inspect, remove, or transactionally clean landed Git worktrees.

Overview

Publisherkevinslin
Repositoryagstack
Skill namedev.worktrees
Stars
26
Forks
1
Bundled files
2
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.

  • 2 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by kevinslin 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/kevinslin/agstack/tree/main/active/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/kevinslin/agstack.git /tmp/agstack
mkdir -p .claude/skills
cp -r /tmp/agstack/active/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

Create and manage Git worktrees under ~/.worktrees. Use cleanup-landed only after a caller has independently proved that the work landed and may be discarded.

Conventions

  • Resolve the repo name from the main repo directory basename (folder containing .git), unless the user provides an override.
  • Always store worktrees under ~/.worktrees/<repo>/<branch-name>.
  • Keep the branch name as-is; if it contains /, it naturally becomes nested folders.
  • Run worktree commands from the main repo unless the user specifies a different worktree.
  • If the user requests a different location, confirm the deviation before proceeding.
  • Use absolute paths for removal and cleanup targets.
  • Never remove the current, primary, locked, or dirty worktree through the ordinary removal path.

Quick Tasks

Create worktree for an existing branch

bash
mkdir -p ~/.worktrees/<repo>
git worktree add ~/.worktrees/<repo>/<branch-name> <branch-name>

Create worktree for a new branch

bash
mkdir -p ~/.worktrees/<repo>
git worktree add -b <branch-name> ~/.worktrees/<repo>/<branch-name> [start-point]

List worktrees

bash
git worktree list --porcelain

Ordinary Removal

Use ordinary removal only when the worktree is already clean and unlocked. Inspect tracked and untracked state immediately before removal. If it is dirty, stop and preserve it; do not force removal or infer that its contents landed.

bash
git -C <worktree> status --short
git -C <repo> worktree remove <absolute-worktree-path>

Delete the local branch only when the caller separately established that it is no longer needed:

bash
git -C <repo> branch -d -- <branch-name>

cleanup-landed

Use ./scripts/cleanup_worktree.py to remove one exact worktree and its local branch after the caller has proved the change landed. This path is destructive: it resets tracked changes and deletes untracked and ignored files before removing the worktree.

Before invoking it, record:

  • a retained repository checkout outside the target worktree;
  • the exact absolute target path, or --no-worktree for a branch checked out nowhere;
  • the expected local branch or detached state;
  • the full expected HEAD object ID;
  • a refreshed local base branch;
  • the full landed commit object ID contained by that base; and
  • the actual merge mode: merge, squash, or rebase.

Run a dry run first and require JSON status ready or noop:

bash
python3 ./scripts/cleanup_worktree.py \
  --repo <retained-checkout> \
  --worktree <absolute-worktree-path> \
  --expected-branch <branch> \
  --expected-head <full-object-id> \
  --base-ref <refreshed-local-base-branch> \
  --landed-commit <full-landed-object-id> \
  --merge-mode <merge|squash|rebase>

Rerun the exact command with --execute. Require final JSON status complete or noop, with the path, registration, and local branch absent and the base still containing the landed commit.

  • Replace --expected-branch <branch> with --detached for a detached target.
  • Replace --worktree <path> with --no-worktree for branch-only cleanup; detached cleanup is invalid in that mode.
  • Treat blocked, partial, a nonzero exit, identity drift, or failed postconditions as a cleanup blocker.
  • Preserve the reported journal after partial execution and rerun the exact command after resolving the blocker.
  • If matching legacy and current journals both exist, stop and reconcile them; the executor fails closed rather than choosing one.
  • Do not reproduce the reset, clean, removal, orphan recovery, or branch deletion steps manually.

The script serializes each target, revalidates identity under the lock, and journals new transactions under the Git common directory's worktree-cleanup/ directory. It resumes matching legacy fin-cleanup/ journals in place. It never refreshes the base, proves external finalization, runs repository hooks, prunes unrelated registrations, or mutates remote branches; callers own those policies.

Prune Stale Metadata

Prune only when the user explicitly requests repository-wide stale metadata cleanup. Preview first and do not use pruning as a substitute for targeted removal or journal recovery.

bash
git -C <repo> worktree prune --dry-run
git -C <repo> worktree prune

Notes

  • Never place worktrees inside the main repo or other worktrees.
  • Prefer explicit paths and branch names in responses to avoid ambiguity.
  • Keep bulk Codex worktree garbage collection in codex-clean-worktrees; cleanup-landed owns one exact, proof-locked transaction.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Dev.Worktrees AI skill do?

Create, inspect, remove, or transactionally clean landed Git worktrees.

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/kevinslin/agstack/tree/main/active/dev.worktrees. TypingMind reads its SKILL.md and bundles its files 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 kevinslin. 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 👇