Index of every page on this site: llms.txt
All skills
webpro avatar

/using-git-worktrees

@30e66c9
by Lars Kappertwebpro/skills18 stars
Run it yourself

Discover and select Git worktree layouts from the starting directory. Use when asked to find, choose, reuse, or create a checkout or worktree; when cwd is above checkouts, a worktree container, or not a Git repo; or when deciding where shared .agents state belongs. Do not use for ordinary Git history, commit, or pull request work, or for bulk cleanup.

Use this Skill: https://skilld.dev/gh/webpro/skills/using-git-worktrees

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈94 tokens for metadata: the name and description. ≈536 when used: this file.

Description uses 4.7% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈375 characters, or 4.7%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

Using Git Worktrees

Discover the layout

Run scripts/discover-worktree-layout.sh once from the initial cwd to discover the layout:

  • worktree: use the reported worktree; starting there means the user already selected that checkout, so do not create another for the same target. Create another only when the task requires a different revision and no suitable checkout exists.
  • single-container: use the sole reported repository.
  • mixed-container: select the reported repository that matches the task.
  • Nonzero exit: the target is not a recognized Git workspace. Stop, unless the task is to set up a new container there.

Finish discovery before recursive file searches, and scope them to the selected checkout rather than the worktree container.

workspace is the shared .agents root and is always reported. container is where checkouts live and is reported for bare repositories. They differ when the container is nested, as in project/{.agents,worktrees/{.bare,main,…}}. Values are resolved from any starting depth, including inside a checkout, so use reported values rather than deriving them from cwd.

Structure

  • Use or create .agents once, at the reported workspace; never add a per-worktree copy.
  • For new single-repository containers, use project/{.agents,worktrees/{.bare,main,…}}.
  • When container is reported, create additional checkouts as its children. Otherwise inspect existing worktree paths and follow their convention.
  • Follow existing path and branch conventions.
  • Never clone another repository inside a worktree container; check for an existing checkout under the project's own paths first.
  • Use the clean-git-repo skill for bulk cleanup.

Create a checkout

  • Give git -C <bare> worktree add an absolute path; a relative one resolves under the bare repository.
  • Create review worktrees from the pinned head SHA; git fetch --prune can delete manually fetched remote-tracking refs without a corresponding remote branch.
  • Address the new checkout explicitly (git -C, workdir, pnpm --dir); creating a worktree or clone does not change the shell's directory.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts11d3 checks · Risk SAFE
  • Gen Agent Trust Hub11d

    The skill provides instructions and a utility script for managing Git worktrees and identifying workspace layouts. It performs local environment discovery and does not engage in network operations or exfiltrate sensitive data.

  • Socket11d

    No alerts

  • Snyk11d

    Risk: LOW · No issues

Signed by skilld at 30e66c9. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 weeks ago.

Activeupdated 2 weeks ago

README badge

README badge for webpro/skills/using-git-worktrees