/agent-skills:worktree-bootstrapfrom Agent Skills
Manage git worktrees for local Next.js development — bootstrap a fresh worktree (select the Node version the repo pins, install deps, copy .env.local, verify AUTH_SECRET survived the copy, start Postgres, inject DATABASE_URL) and clean up stale worktrees and merged branches. Use when entering a fresh worktree, when `nextdev start` fails, when an install fails with ERR_PNPM_UNSUPPORTED_ENGINE, when auth fails with MissingSecret, or when asked to tidy up branches after a sprint.
Ships in Agent Skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The worktree-bootstrap command and bootstrap/cleanup workflow are harness-neutral. wtcc, wtcc-recover, and wtpr are Claude-specific helpers because they launch Claude Code; Codex sessions must use their native worktree/session launcher instead. Never invoke a Claude-specific helper from Codex merely to satisfy this skill.
Worktree path isolation: Once inside a git worktree (
.claude/worktrees/*or~/.geode/worktrees/*), run all shell/file commands against$PWDor relative paths — nevercdinto or target the parent repo checkout.
Fresh git worktrees miss several pieces the main checkout has:
node_modules — worktrees share git objects but not dependencies..env.local — vercel env pull only runs against a linked project, and .vercel/project.json lives in the main checkout, not the worktree. Note that copying the main checkout's file does not guarantee the secrets are there; see "Verify the copied secrets" below.UnauthorizedException.engines.node pin, which fails the install outright.The worktree-bootstrap CLI handles all of this in one command.
cd /path/to/worktree
worktree-bootstrap
One command, idempotent. Re-running is safe — install and .env.local copy both skip if already done.
origin/main with commit count. Does not abort..env.local from <mainRepo>/.env.local to <worktree>/.env.local. Skipped if already exists.*-pg with a postgres image. podman start if stopped.DATABASE_URL from the container's env and port mapping — postgres://<user>:<pass>@localhost:<hostPort>/<db>?sslmode=disable.DATABASE_URL to .env.local in the worktree, overwriting any existing line..env.local actually has the secretsThe copy is wholesale and unvalidated. worktree-bootstrap does
fs.copyFileSync(mainRepo/.env.local, worktree/.env.local) and then injects
DATABASE_URL. It never checks what was in the source file. If the main
checkout's .env.local is thin — and it often is, because vercel env pull
can leave behind little more than a VERCEL_OIDC_TOKEN — the worktree inherits
a file that looks populated (it has a DATABASE_URL now) but is missing the
auth secrets entirely.
Verified example: on 2026-09-19, ~/projects/compass/.env.local in the main
checkout contained exactly one variable, VERCEL_OIDC_TOKEN. Every worktree
bootstrapped from it got a .env.local with no AUTH_SECRET.
Always check after bootstrapping:
for k in AUTH_SECRET DATABASE_URL; do
grep -q "^${k}=." .env.local && echo "ok ${k}" || echo "MISSING ${k}"
done
Extend the list with whatever else the app requires (ENCRYPTION_KEY,
NEXTAUTH_URL, MCP_API_KEY, …). The grep pattern ends in . deliberately:
a present-but-empty AUTH_SECRET= fails in exactly the same way as an absent
one, and a bare grep '^AUTH_SECRET=' would call it present.
AUTH_SECRET looks likeIt does not look like a missing env var. It looks like a broken app. Every auth request fails, so nothing that requires a session renders, and the natural reading is that the branch's code is broken.
MissingSecret ([auth][error] MissingSecret: Please define a \secret``). It may appear only in the server log, not the browser.If you see MissingSecret, check .env.local before reading any source.
Note that this skill's trigger list below also names MissingSecret as a signal
for DSQL/OIDC failure. Both causes produce that string. Rule out the empty
AUTH_SECRET first — it is cheaper to check and, after a fresh bootstrap, far
more likely.
AUTH_SECRET is missingPrefer copying the value the rest of the team/other worktrees already use, so sessions and any E2E seeding stay compatible:
grep -h '^AUTH_SECRET=' ../*/.env.local 2>/dev/null | head -1 >> .env.local
If there is genuinely no existing value, generate one:
echo "AUTH_SECRET=$(openssl rand -base64 32)" >> .env.local
Never reuse a locally generated
AUTH_SECRETin a deployed environment. A dev value that has sat in a worktree, a shell history, or a log is compromised by definition. Deployed environments get their own secret, set through the platform's env-var UI/CLI (e.g.vercel env add AUTH_SECRET production --sensitive), and each environment gets a distinct one.Changing
AUTH_SECRETinvalidates every existing session signed with the old value — expected locally, disruptive in production.
export default defineConfig({
schema: 'prisma/schema.prisma',
...(process.env.DATABASE_URL
? {}
: {
adapter: /* dsql adapter with tokenProvider */,
}),
});
DATABASE_URL being set is the "local mode" signal — worktree-bootstrap always sets it.
ERR_PNPM_UNSUPPORTED_ENGINE on installStep 3 (install deps) fails outright if the repo pins engines.node to a range
the machine's default Node doesn't satisfy. This is common: the shell default
tends to be the newest Node installed, while repos pin an LTS line.
ERR_PNPM_UNSUPPORTED_ENGINE Unsupported environment (bad pnpm and/or Node.js version)
Expected version: 22.x
Got: v26.8.2
Check what the repo wants, then what you have:
node -e 'console.log(require("./package.json").engines)'
node -v
Fix: prepend the matching fnm version dir to PATH for the install. Do not
edit engines, and do not reach for --engine-strict=false — the pin usually
exists because something in the toolchain genuinely breaks on newer Node.
# List what fnm has installed
ls ~/.local/share/fnm/node-versions/
# Select the version matching engines.node (22.x -> pick the v22.* entry)
export PATH="$HOME/.local/share/fnm/node-versions/<version>/installation/bin:$PATH"
node -v # confirm it now satisfies engines.node
pnpm install --frozen-lockfile
The fnm install dir on this machine is
~/.local/share/fnm/node-versions/<version>/installation/bin. It is not~/Library/Application Support/fnm, which does not exist here — that is the first place an agent tends to look, finds nothing, and wrongly concludes fnm isn't installed. If~/.local/share/fnmis also absent, checkfnm envor$FNM_DIRrather than guessing.
Resolve the version from engines.node each time. Don't hardcode a specific
patch release into a script — the installed set changes, and different repos pin
different lines.
npx# ❌ Fails in worktrees
pnpm prisma generate
# ✅ Works
npx prisma generate
Run worktree-bootstrap when:
nextdev start exits with: Cannot find module, MissingSecret, UnauthorizedException, OIDC, token expired, DsqlSigner, ERR_PNPM_UNSUPPORTED_ENGINE, or ECONNREFUSED on :5432
MissingSecret specifically: check AUTH_SECRET in .env.local first (see step 8), then DSQL/OIDCgit worktree add …Use wtadd instead of bare git worktree add — fetches origin and fast-forwards main first:
wtadd ../feature-x -b feature-x
wtcc — tags cmux workspace with branch name and worktree path on launchwtcc-status — list all cmux workspaces with current working directorieswtcc-recover — after a cmux crash, reopen all worktree tabs with Claude launchingwtpr — find open PRs from remote agents and open selected ones as worktrees in CMUXApply via /api/admin/migrate endpoint (GET to check, POST with {"script":"your-migration.sql"}). Do not manually apply DDL to public.
pnpm install --frozen-lockfile
cp ../main-repo/.env.local .
podman start myproject-pg
grep -v '^DATABASE_URL=' .env.local > .env.local.tmp && mv .env.local.tmp .env.local
echo 'DATABASE_URL="postgres://postgres:postgres@localhost:5432/myproject?sslmode=disable"' >> .env.local
nextdev start
Removes stale local branches and prunable worktrees after confirming their PR status on GitHub.
1. Show current state
git worktree list
git branch -a
2. Check PR status
gh pr list --state all --base main --limit 100 --json headRefName,state,title,mergedAt \
| jq -r '.[] | "\(.state)\t\(.headRefName)\t\(.title)"' | sort
Categorize: MERGED → safe to delete | CLOSED → confirm with user | OPEN → leave alone | No PR → confirm with user
3. Prune worktrees
git worktree prune
Safe to run unconditionally — only removes already-prunable worktrees.
4. Delete merged branches
git branch -d <branch1> <branch2> ... # safe delete
git branch -D <confirmed-merged-branch> ... # force-delete for squash-merged
Do NOT force-delete branches with no PR, CLOSED PRs, or anything unconfirmed.
5. Report — summarize what was deleted and flag anything left for user to decide.
git branch -d considers unmerged even though GitHub shows MERGED — use -D after confirming via gh pr list.git remote prune origin to also clean stale remote-tracking refs.What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (richardbowman/agent-skills) — no native marketplace selected
npx claudepluginhub p/richardbowman-agent-skills32 skills in this plugin
/backup-vercel-secretsBack up Vercel production and preview environment variables to 1Password as individual key/value fields. Use when the user wants to snapshot or archive their Vercel secrets for a project./brain-dumpInteractive knowledge extraction interviewer. Enters a structured interview mode to extract tacit knowledge from the user and saves a full transcript plus structured notes to the Obsidian vault./brainstormActive ideation partner. The assistant leads the session by proposing angles, surfacing frameworks, filling knowledge gaps, and challenging assumptions. Produces a structured Obsidian ideation doc and session transcript.Other plugins' skills for the same job