mimukit/skills/gitkit

Claude Code and agent skill by mimukit/skills

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

The shared git layer other skills borrow: the worktree path, name, and lifecycle, a worktree's declared setup and teardown, the base branch, rebase versus merge, branch sync, hotfix branches, merged-branch cleanup, lost-work recovery, and stacked branches. Use when the user says "make me a worktree for #42", "where's the worktree for this branch", "tear down this worktree", "set up this worktree", "make this worktree's dev database", "what's the base branch here", "should I rebase or merge", "sync this branch with main", "start a hotfix for the login crash", "backport this hotfix", "clean up my merged worktrees", "I lost a commit", "stack this on #43", or runs "/gitkit", and whenever another skill needs any of those answers.

Install

npx vskill@latest install mimukit/skills/gitkit

SKILL.md

The same SKILL.md was published earlier as mimukit/skills/gitkit.

gitkit

The core is native git worktree, with no vendor CLI and no state outside git, so every machine runs the same commands. Two branches go further. Stacked branches need gh and a GitHub remote, and degrade to plain git without them. `prepare` runs only the commands the repository declares, or the install its lockfile implies when it declares none.

Not this skill: committing, opening a PR, reviewing a diff, judging code. gitkit answers where and how, never what the change should be.

Modes

modedoeslives
worktreecreate, adopt, look up, list, and remove a worktreebelow
synccatch a feature branch up with its own remote, bring it onto the latest base, and force-push it with a leasebelow
preparerun the repository's declared setup in a worktree, and its teardown before removalprepare.md, and below
hotfixcut a fix or a quick change from the branch production deploys from, with no issue, and backport it after the mergehotfix.md, and below
cleansweep the merged worktrees and branches away, one confirmation eachclean.md
rescuefind work that looks lost and restore it onto a new branchrescue.md
stackbuild and restack a chain of branches through gh stackstacks.md, and Stacked branches

When the mode is not clear from the ask, pick it from the verb and name it in the first line. "Tidy this up" after a merge is clean; "tidy this up" on a branch behind its base is sync.

Running inside a container with a bind-mounted repo, or a GUI worktree tool does not show gitkit's worktrees → read container.md, then follow it.

The convention

Path
$WORKTREE_ROOT/<repo-basename>/<local-branch-name>

$WORKTREE_ROOT defaults to ~/worktrees; honor the environment variable when it is set. <repo-basename> is the main checkout's directory name.

Slashes in a branch name flatten to dashes. A branch mimukit/6-marketing-site gets the directory mimukit-6-marketing-site, not a nested mimukit/ parent. The directory name does not round-trip to the branch, so look a worktree up through git. On a collision (branches a/b and a-b both flatten to a-b), git worktree add fails on the existing path: report it and let the human pick a name rather than append a suffix.

Worktrees live outside the repository, never in a .worktrees/ directory inside it, because an in-repo worktree gets swept into docker build contexts, bind mounts, file watchers, and test globs.

The invariant: one branch, one worktree

A branch has at most one worktree, and the directory is named after it. Git enforces this: git worktree add refuses a branch that another worktree holds. A worktree is keyed to a branch, not to a workflow stage, so implementing a feature and later reviewing its pull request use the same worktree. Never name a worktree by stage (review-…, qa-…).

Look a worktree up by branch, through git, never by reading or guessing a directory path. A worktree in an older root then keeps working.

Branch naming
  • `issue-<n>-<slug>` for work that starts from a tracker issue. Slug from the issue title: if it follows a conventional type(scope): summary form, strip the prefix; kebab-case the rest, cap at roughly 50 characters on a word boundary, drop a trailing hyphen. An empty slug degrades to a bare issue-<n>.
  • `hotfix-<slug>` for an urgent fix or a quick change that goes straight to the branch production deploys from, with no issue first. Slug from the symptom for a fix, or from the change for a quick change, kebab-cased, capped at roughly 40 characters. A backport of a merged hotfix appends -to-<target>. When a hotfix traces to an issue, the branch keeps this shape and the pull request carries the Closes #<n> link. On a collision with an existing branch, add a short distinguishing word rather than a counter. The separator is a hyphen: write `hotfix-<slug>`, never `hotfix/<slug>`. The skills that read the type off the branch name (commitkit, prkit) match the hyphen form only.
  • `pr-<n>-<slug>` only for a fork pull request, where no local branch exists yet and one must be invented to hold the fetched head. Slug from the head branch name, kebab-cased, capped at roughly 40 characters.
  • Anything else takes a branch name the human or the repo's convention supplies. gitkit does not rename it.

An agent that cuts a branch on its own uses one of the three shapes above. It never invents another prefix (feature/…, fix-…, claude/…). A name the human types, or one the repo documents, is the only other kind of branch.

For a same-repo pull request there is already a local branch name: use it, never a pr-* name.

worktree

All four operations are idempotent: a second run never errors and never destroys work.

No skill may create or remove a worktree through a vendor CLI. Use native git, so every machine stays in step. A vendor's own metadata about a worktree (the issue its card links to, a status, a comment) has no git equivalent, so a companion skill may reconcile it. gitkit never calls a vendor tool, and works where none is installed.

Look up a branch's worktree
sh
git -C "$REPO" worktree list --porcelain

Each record carries a worktree <path> line and, when a branch is checked out, a branch refs/heads/<name> line. Match on the branch to get the path.

Create, or adopt

Always look first. If a worktree already exists for the branch, adopt it: report the path and stop. Never create a second one, never error.

When there is none:

sh
WT="${WORKTREE_ROOT:-$HOME/worktrees}/$(basename "$REPO")/$(printf '%s' "$BRANCH" | tr / -)" # slashes flatten to dashes
git -C "$REPO" fetch origin --prune
git -C "$REPO" worktree add -b "$BRANCH" "$WT" "$BASE"
  • Fetch first, always.
  • $BASE comes from The base ref, never a hard-coded origin/main, and never a sibling feature branch. The one exception is a stack layer, whose base is the branch below it, named deliberately by the caller.
  • Drop -b when the branch already exists locally (a same-repo PR you have fetched, a branch you made earlier); git worktree add <path> <branch> checks it out.
  • For a fork pull request, fetch the head into a local branch first with git fetch origin "pull/<n>/head:pr-<n>-<slug>", then add the worktree on that branch, no -b.

Then record what gitkit made, because a later session has no other way to tell its own worktrees from someone else's:

sh
touch "$(git -C "$WT" rev-parse --absolute-git-dir)/gitkit-created" # gitkit made this worktree
git -C "$REPO" config "branch.$BRANCH.gitkitCreated" true # only after -b: gitkit made the branch too
  • Both records live in git's own storage. The worktree marker sits in the worktree's admin directory under .git/worktrees/, and git worktree remove deletes it with the worktree. The branch key sits in the branch's config section, and git branch -d deletes it with the branch.
  • Write the branch key only when this run passed `-b`. A branch that already existed belongs to whoever made it, and an adopted worktree gets no marker.
  • No record means not gitkit's. A worktree or branch with no record reads as adopted, and Remove leaves it alone.

When the caller hands the worktree to a person or an agent to work in, run `prepare` next, on a created and an adopted worktree alike. A scratch worktree that only runs one command skips it.

Report the path and the branch. When the user asked gitkit for the worktree directly, end the reply with the workspace block. Creating a worktree does not imply doing anything in it. Ends when the worktree exists at $WT on $BRANCH and its records are written.

The workspace block

A skill that hands a worktree to a human to work in ends its reply with this block. The labels are fixed; fill the values.

Workspace ready
- repo: <absolute path of the main checkout>
- worktree: <absolute worktree path>
- branch: <branch>
- base: <base ref the branch was cut from or tracks>
- state: created | adopted
- for: issue #<n> | PR #<n> | none
  • The block names no harness and no app. A host that can open a session bound to a worktree reads it; any other host shows six plain lines.
  • It starts nothing. It carries no prompt and no command to run in the worktree. The human decides how the work begins.
  • Print it once, last, and only to a human. When another skill called gitkit, return the path and the branch to that caller, and the caller prints the block in its own hand-off. An unattended run prints no block, because it works in the worktree by path in its own session.
Remove
sh
test -e "$(git -C "$WT" rev-parse --absolute-git-dir)/gitkit-created" # gitkit made this worktree?
git -C "$REPO" config --get "branch.$BRANCH.gitkitCreated" # gitkit made this branch?
git -C "$REPO" worktree remove "$WT"
git -C "$REPO" branch -d "$BRANCH"

This is the one removal rule in the collection. Every skill that removes a worktree or deletes a branch, whether a sweep here, a workspace tool's cleanup, or an issue close-out, follows these five rules:

  • A dirty worktree stops teardown. Show exactly what would be lost (uncommitted changes, untracked files, unpushed commits) and let the human decide. Never reach for --force on their behalf.
  • Remove only a worktree whose marker says gitkit created it. A worktree without the marker was adopted, and you do not know what is open in it.
  • Delete only a branch whose `gitkitCreated` key is set, and delete it with `-d`, so git refuses an unmerged branch.
  • One confirmation per removal. A list of worktrees and branches takes one answer per row, never one answer for the set.
  • A prepared worktree runs its teardown first. When the gitkit-prepared marker exists and the worktree declares teardown:, run it after the dirty check and the confirmation, before git worktree remove. A failed teardown keeps the worktree and reports the failure. Teardown holds the procedure.

The squash exception is the only `-D` gitkit runs. A squash-merged branch never passes -d, because the squash commit has no ancestry link back to the branch. Use -D only when gh reports a merged pull request for the branch and that pull request's headRefOid equals the local branch tip:

sh
gh pr list --head "$BRANCH" --state merged --json number,headRefOid --jq '.[0]'
git -C "$REPO" rev-parse "$BRANCH" # must equal headRefOid, or -D is off the table

A tip that moved after the merge holds commits the merge never saw, so the branch stays and the report names it. Name the pull request number in that row's confirmation.

The merged-PR exception lifts the marker rule and the confirmation rule for one PR's own workspace. When a human tells a caller to merge or close one pull request, and the caller then sees it merged, that instruction is the confirmation to remove the worktree of the PR's head branch and the local head branch. They go whether gitkit created them or not, with no further prompt. The caller passes the PR number, and the exception reaches that one branch and its worktree only. These guards still hold, and each one keeps its item and names it in the report:

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

7-day trend score
0

Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/mimukit/skills/gitkit/badge)](https://verified-skill.com/skills/mimukit/skills/gitkit)

Something wrong with this skill or its page? Tell us.