AI Agents Book

Primitive of the day · 2026-10-27

git-dash-c-relative-path-resolution

A relative path argument under `git -C $REPO` resolves against the -C directory, NOT the caller's cwd — `git -C <repo> worktree add ../worktrees/x` lands sibling to the repo root no matter where the agent runs from.

When this applies

Scripting worktree creation (or other git path-taking commands) from agents whose cwd is unpredictable.

Preconditions

Do this

Rely on -C-relative resolution deliberately (the ../worktrees default) or pass absolute paths; never assume caller-cwd resolution.

What you should see

Worktrees land in the intended sibling directory regardless of invocation cwd.

How it fails if ignored

Assuming cwd-relative behavior scatters worktrees across whatever directory the agent happened to be in.

Do not use when

Absolute paths (no resolution ambiguity).

Kind: gotcha-fix. 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.