using-git-worktrees
Use when a coding task needs a concurrent checkout, unrelated dirty state blocks safe branch switching, or the user or repository explicitly requires a…
Skill by GanyuanRan
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/ganyuanran-using-git-worktrees
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: productivity, version-control
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/using-git-worktrees
What's inside
- Skill name
using-git-worktrees- Description
- Use when a coding task needs a concurrent checkout, unrelated dirty state blocks safe branch switching, or the user or repository explicitly requires a worktree.
- License
- MIT
- Instructions
- 169 lines in SKILL.md · view on GitHub
Files (1)
- SKILL.md
SKILL.md (first lines)
# Using Git Worktrees ## Overview A worktree is an exception for simultaneously checking out another Git history, not a general safety badge. Prefer the current workspace and reuse an existing suitable worktree. A branch decision and a worktree decision are separate. **Core principle:** create only with necessity and ownership evidence; pair every created worktree with a cleanup path. **Announce at start:** explain which concrete checkout conflict requires a worktree. ## Step 0: Environment Detection Before mutation, record the repository root, `HEAD`, branch/detached state, staged/unstaged/untracked paths, active Git operations, and: ```bash git worktree list --porcelain ``` Classify the current host surface's task/chat-bound managed workspace semantics as `managed`, `non-managed`, or `unknown`. Use trusted host/session context, an explicit host contract, or a host-native lifecycle result; do not infer the classification from a product name, directory prefix, command-level `workdir`, missing tool, or absent metadata. `non-managed` requires positive evidence that the current surface lacks task-bound managed semantics. When the host exposes workspace fields, record the task workspace and the command's default `cwd` without a per-command directory override. Stop on unresolved conflicts, an active merge/rebase/cherry-pick/revert/bisect, or an unexplained detached HEAD. A detached HEAD is acceptable only when trusted host binding evidence identifies it as the intended state of the current managed worktree; Codex-managed worktrees, for example, start detached by default. Preserve user state: no automatic stash, reset, clean, broad staging, or commit. Before deciding necessity or placement, read the smallest relevant project `AGENTS.md`, `CLAUDE.md`, current authority, and existing worktree convention. Repository policy may require or forbid isolation and owns any approved in-repo location; do not discover that policy after creating the checkout. ## Step 1: Necessity Decision Create at most one task-owned worktree only when one of these is true: - another branch must remain checked out while this task proceeds; - unrelated dirty state prevents a safe checkout in the current workspace; - explicit user or current repository authority requires it. Task complexity, planning, TDD, use of subagents, or a `main`/`master` branch name is not sufficient. Same-task subagents share one workspace; do not create per-subagent or nested worktrees. If independent history is unnecessary, do not create a branch either. Record: reason, branch, exact path, creating coordinator, and expected cleanup event. If the owner or cleanup condition is unknown, stop before creation. ## Step 2: Safe Placement Use an existing repository convention only when the target directory is already ignored (`git check-ignore`). Never edit or commit `.gitignore` solely to host a worktree. If no safe in-repo convention exists, use a task-specific external user-level temporary directory outside the repository. Resolve and verify the exact path before creation; do not target a broad home, workspace, or repo root. ## Step 3: Create the Minimum Checkout Prefer reusing an existing branch carrying the same goal. Create a branch only when the approved Git lifecycle requires independent history. ### Managed-host binding gate When the host surface declares task/chat-bound managed workspaces, use its native Worktree/Handoff lifecycle instead of shell creation. Reuse the current task only when trusted host evidence says it is already bound to the intended workspace. If the native operation creates or moves work into another task, continue only in that bound task. After the native lifecycle operation, or immediately when entering/reusing an already-bound managed workspace, and before the first task content or Git history write, read back one joint postcondition: - trusted task workspace; - default command `cwd` without a command-level directory override; - intended Git worktree root; - intended `HEAD` and branch/detached state. All four must describe the same execution environment. `git worktree list`, a managed-looking path, or a per-command `workdir` proves only part of that postcondition. If native creation/handoff is unavailable, only UI-driven, or cannot be verified, stop before shell worktree creation or task content/history writes and give the user the host-native re-entry action. Do not silently fall back on `git worktree add`. Compare resolved path identity using host-appropriate semantics, not raw path strings. The default `cwd` may equal the worktree root or be inside it; running Git from that default `cwd` must resolve to the intended worktree root. An intended host-managed detached HEAD satisfies the Git-state component; do not create a branch merely to make that state look like a generic checkout. If an unbound manual worktree already exists, preserve it and report its exact path, `HEAD`, branch, status, and ownership evidence. Dirty, untracked, or ownership-unknown state is not auto-migrated, deleted, stashed, reset, or overwritten. A later commit/patch transfer follows normal Git authorization and must be verified in the new bound task before cleanup is offered. ### Generic Git fallback Use the shell path below only when trusted evidence positively classifies the current host/CLI surface as `non-managed`. An `unknown` classification fails closed; an absent native tool or missing binding metadata is not generic-fallback evidence. ```bash # Existing branch git worktree add <exact-path> <branch>
From GanyuanRan/Aegis, MIT.
More from GanyuanRan/Aegis
- 0.831score
ui-ux-governance
GanyuanRan
Use when designing, changing, or reviewing user-facing interfaces or interaction flows, including API changes that alter visible states or recovery.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.826score
using-aegis
GanyuanRan
Use when starting a turn or checking Aegis skill routing.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
subagent-driven-development
GanyuanRan
Use when executing a written implementation plan with independent tasks in the current session where delegation beats inline coordination cost; otherwise…
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
requesting-code-review
GanyuanRan
Use when requesting independent code review, after implementation slices, before merging high-risk work, or when verification exposes evidence, baseline…
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
receiving-code-review
GanyuanRan
Use when receiving code review feedback before implementing suggestions, especially when feedback is unclear, risky, disputed, or technically questionable.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
long-task-continuation
GanyuanRan
Use when a task is multi-step, may span context resets or sessions, uses subagents, or risks losing state before completion.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
goal-framing
GanyuanRan
Use when the user explicitly sets an Aegis goal with /aegis-goal, Aegis goal:, or asks to define goal, success evidence, stop condition, or task boundaries…
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
first-principles-review
GanyuanRan
Use when asked for first-principles or Occam's-razor review, or when high-risk decisions involve competing constraints, fallback growth, duplicate owners, or…
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
finishing-a-development-branch
GanyuanRan
Use when verified work needs integration or cleanup of an existing task-created branch/worktree, or the user explicitly requests merge, PR, or branch…
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
executing-plans
GanyuanRan
Use when executing a written implementation plan across sessions or with review checkpoints.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
brainstorming
GanyuanRan
Use when defining ambiguous or high-complexity new features, product behavior, UI/component design, architecture choices, contract changes, or when…
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
anti-entropy-governance
GanyuanRan
Use when touching retiring old logic, collapsing duplicate owners, removing fallbacks, or schema/persistence/source-of-truth boundaries; identify…
SkillAFreshness: A★ 1.4KClaude Code +9
Compare and alternatives
Featured in
Signals
- Stars
- 1,383
- Forks
- 78
- Open issues
- 1
- Last commit (this folder)
- Aug 27, 2026 (2 months ago)
- Last release
- Oct 21, 2026 (6 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/GanyuanRan/Aegis
- Website
- autoloom.codes/aegis/
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from GanyuanRan
- 0.831score
ui-ux-governance
GanyuanRan
Use when designing, changing, or reviewing user-facing interfaces or interaction flows, including API changes that alter visible states or recovery.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.826score
using-aegis
GanyuanRan
Use when starting a turn or checking Aegis skill routing.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
subagent-driven-development
GanyuanRan
Use when executing a written implementation plan with independent tasks in the current session where delegation beats inline coordination cost; otherwise…
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
writing-plans
GanyuanRan
Use when you have an approved spec or written requirements for a multi-step task that needs a durable plan document before touching code.
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
update-aegis
GanyuanRan
Use when the user says `aegis:update`, asks to update or upgrade an installed Aegis method-pack, wants the latest Aegis version, or asks whether Aegis is…
SkillAFreshness: A★ 1.4KClaude Code +9 - 0.825score
requesting-code-review
GanyuanRan
Use when requesting independent code review, after implementation slices, before merging high-risk work, or when verification exposes evidence, baseline…
SkillAFreshness: A★ 1.4KClaude Code +9
Cite this page
using-git-worktrees skill. Agent Mart. https://agentmart.dev/skills/ganyuanran-using-git-worktrees (last updated 2026-10-24)