AI Agents Book

Primitive of the day · 2026-10-29

worktree-detach-throwaway

For approaches you expect to discard, create the worktree with --detach (detached HEAD, no branch) — nothing to clean up branch-wise when the losing candidates are removed.

When this applies

The 'N approaches to the same problem' pattern where most worktrees will be thrown away.

Preconditions

Do this

git worktree add --detach <path>; at teardown a simple remove suffices — no orphan branch is created.

What you should see

Zero branch-hygiene debt for discarded explorations.

How it fails if ignored

A 'throwaway' that turns out to be the winner requires git branch <name> <sha> before removal or the commits dangle.

Do not use when

Work that might be kept — you would have to rescue the commits from a detached HEAD.

Kind: tool-sequence. Part of the skill Git worktree for parallel agents. Free to reuse in your own agent skills.

Get the whole skill

All 12 primitives of this skill as one package, with the order to apply them.

Get just this primitive

This one primitive for 1 credit (≈ €0.10); the other primitives of the skill are on its page.

Upgrade your own skill

Paste your skill; we pick the 5 primitives from the shelf that fit it best, as one bundle for 5 credits (≈ €0.50).

Upgrade my skill

Register interest

Interest only — no payment, no order, no reservation. After you confirm by email we send you one free sample primitive.