Start In A Fresh Worktree
Use this skill at the start of every session contributing to WarpDrive itself, before reading code or making any change. Each session gets its own git worktree branched from a freshly fetched origin/main — never the shared primary checkout, and never whatever commit that checkout's HEAD happens to be parked on.
Steps
Don't work in the primary checkout, even for a "quick" one-file change.
pnpm installin this repo also builds every package and rewrites hardlinks into thenode_modulesof every other package and test app that depends on it (see Setting Up The Project), so two sessions installing or building in the same checkout clobber each other's build output — and the failures show up later as stale or half-writtendistcontent, not as an obvious conflict.Branch from a freshly fetched
origin/main, not from the currentHEAD. Any long-lived checkout is usually sitting on an unrelated feature branch; branching off it silently folds someone else's unmerged commits into your diff and your PR.mainis also the branch PRs target, so branching anywhere else guarantees an unnecessary rebase.shgit fetch origin main git worktree add -b <branch-name> ../warp-drive-worktrees/<topic> origin/mainAlways make the worktree a sibling of the repo, under
../warp-drive-worktrees/<topic>, never a directory nested inside it. This is not a tidiness preference — Node's resolution algorithm searches upward fornode_modules, so a worktree at<repo>/anything/my-worktreesilently resolves any dependency orbinits own install hasn't provided from<repo>/node_modules— the primary checkout's tree. Three properties of this repo turn that into a wrong answer rather than an error:pnpm-workspace.yamlsetshoist: falseand uses injected workspace packages specifically to keep each test app's dep tree isolated,pnpm installhardlinks built output into consumers'node_modules, and the packages lean on branded types. So a nested worktree gets the other checkout'sdist, mismatched versions, duplicate modules in a bundle, and private-brand type errors that point nowhere near the cause. A sibling has no shared ancestor holding anode_modules, so resolution can't cross over. Keeping every worktree under the one../warp-drive-worktrees/directory, rather than scattered siblings named after each topic, is also what lets the pruning in the next step tell its own worktrees apart from a checkout you created some other way.Nesting is also the default for Claude Code's own worktree mechanisms —
--worktree,EnterWorktree, andAgentwithisolation: "worktree". This repo replaces that default with aWorktreeCreatehook (.claude/settings.json,scripts/worktree-create.sh) that lands every worktree those mechanisms create at../warp-drive-worktrees/<name>instead, branched from a freshly fetchedorigin/main— the same place and the same base as the command above. So--worktree <topic>, asking Claude mid-session to work in a worktree, and subagentisolation: "worktree"are all safe to use directly here instead of runninggit worktree addby hand; use whichever is more convenient..gitignorestill ignores.claude/worktrees/as a backstop for a nested one that shows up anyway — a different repo, a session where the hook didn't run — but that entry is damage control, not the expected path.Install from the new worktree's root.
node_modulesis not shared between worktrees, so a fresh worktree has no dependencies and no built packages at all until you install:shcd ../warp-drive-worktrees/<topic> pnpm installTwo setup steps are not per-worktree and don't need repeating:
mise installfetches the pinnednode/pnpmtoolchain globally, and@warp-drive/holodeck'sensure-certwritesholodeck-localhost.peminto your home directory. Only run those if you've never set the project up on this machine.Run every command from the worktree root for the rest of the session, and don't
cdback into the primary checkout to run tests, lint, or builds — that reintroduces exactly the cross-session build clobbering the worktree exists to prevent.Remember that some git state is shared across all worktrees of a repo, not isolated by one. The stash stack is global: a bare
git stash popcan restore another session's work into your tree, so set work aside with a temporary WIP commit instead, or usegit stash push -u -m "<unique-tag>"andgit stash apply <sha>against the entry you can identify by tag. Branch checkouts are also global — a branch already checked out in another worktree cannot be checked out in yours.Clean up once the PR merges, so the next session's
git worktree liststays readable:shgit worktree remove ../warp-drive-worktrees/<topic> git worktree pruneA worktree a session created for itself automatically, rather than one you named for a topic, doesn't need this: a
SessionStarthook (scripts/session-worktree.sh) prunes those on a later session's startup once they're clean and their commits are merged intomainor pushed to a branch elsewhere, so nothing is deleted while it's the only copy of unpushed work.
Why "fresh" and "off main" are separate requirements
They fail in different ways. Reusing an existing worktree gets you a dirty tree, stale node_modules, and leftover build output from unrelated work — a green local test run there tells you nothing about your change. Branching off the wrong commit gets you a clean worktree whose diff against main contains commits you never wrote; that one survives all local verification and only surfaces in review, as a PR touching files the task never mentioned.