.claude/skills/worktrunk-setup/SKILL.md
Set up worktrunk (git worktree manager) with dynamic port allocation for Better-T-Stack monorepos using Doppler, Alchemy, and Vite. Use when bootstrapping a new project's worktree workflow, or when asked to "set up worktrunk", "configure worktrees", "add worktree support", or "set up dynamic ports for worktrees". Covers: post-create hooks (Doppler setup, dependency install, .env.worktree generation), env-based port overrides in Vite and Alchemy configs, and dev script modification to source worktree-specific env vars after Doppler injection.
npx skillsauth add WonderPanda/mana-vault worktrunk-setupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Configure worktrunk so each worktree gets isolated dev server ports via hash_port, preventing port conflicts when running multiple worktrees simultaneously.
wt)apps/web/vite.config.ts — read web port from env:
server: {
port: Number(process.env.DEV_WEB_PORT) || 3001,
},
packages/infra/alchemy.run.ts — read server port from env:
dev: {
port: Number(process.env.DEV_SERVER_PORT) || 3007,
},
.env.worktree after Doppler in dev scriptpackage.json — modify the dev script to source .env.worktree (if present) after Doppler injects base env vars, overriding port-dependent values in worktrees:
"dev": "doppler run -c dev -- sh -c '[ -f .env.worktree ] && set -a && . ./.env.worktree && set +a; exec turbo dev'"
In the main checkout, .env.worktree doesn't exist so Doppler defaults pass through unchanged.
.config/wt.toml project hooks[post-create]
doppler = "doppler setup -p <PROJECT_NAME> -c dev --no-interactive"
install = "bun install"
env = """
cat > .env.worktree << 'EOF'
DEV_WEB_PORT={{ branch | hash_port }}
DEV_SERVER_PORT={{ ('server-' ~ branch) | hash_port }}
CORS_ORIGIN=http://localhost:{{ branch | hash_port }}
VITE_SERVER_URL=http://localhost:{{ ('server-' ~ branch) | hash_port }}
BETTER_AUTH_URL=http://localhost:{{ ('server-' ~ branch) | hash_port }}
EOF
"""
[post-start]
copy = "wt step copy-ignored"
[pre-merge]
lint = "bun run check"
typecheck = "bun run check-types"
[list]
url = "http://localhost:{{ branch | hash_port }}"
Replace <PROJECT_NAME> with the Doppler project name.
The ('server-' ~ branch) | hash_port concatenation ensures web and server ports never collide — they hash different strings.
Add any additional port-dependent env vars to the env hook (e.g., POLAR_SUCCESS_URL, webhook URLs).
.env.worktreeAdd .env.worktree to .gitignore. Do NOT add it to .worktreeinclude — each worktree generates its own.
.worktreeincludeIf not already present, create .worktreeinclude to copy gitignored files to new worktrees:
.claude/**
node_modules/
.env
.turbo/
wt switch --create <branch> runs post-create hooks: configures Doppler, installs deps, writes .env.worktree with deterministic portsbun run dev runs Doppler, then sources .env.worktree overrides, then starts TurboDEV_SERVER_PORT, Vite reads DEV_WEB_PORT — both fall back to defaults if unsetwt list shows each worktree's dev server URLhash_port maps strings to ports in the 10000–19999 range. Ports are deterministic — the same branch always gets the same port on any machine.
tools
TanStack DB client-side reactive data patterns for Mana Vault. Use when working with useLiveQuery hooks, client-side collections, RxDB/Dexie sync, or any reactive data queries in the web app. Covers hook locations, DB setup, and query builder best practices.
development
React Native and Expo patterns for Mana Vault mobile app. Use when working on the native app in apps/native/, modifying Expo Router routes, HeroUI Native components, or Uniwind styling. Covers project structure and key conventions.
development
React component patterns, styling conventions, and UI guidelines for Mana Vault web app. Use when creating or modifying React components, working with TailwindCSS, shadcn/ui, class-variance-authority, or route components in TanStack Router.
tools
Bootstraps local-first replication architecture using RxDB + oRPC + TanStack DB in TanStack Router applications. Covers server-side EventPublisher pattern, checkpoint-based pull endpoints, push replication with conflict resolution, multiplexed SSE streaming (single connection for all entities), client-side RxDB setup with IndexedDB, replication configuration, and React integration with TanStack DB collections and useLiveQuery. Use when: (1) Setting up offline-first architecture from scratch, (2) Adding real-time replication to a TanStack Router + oRPC app, (3) Bootstrapping a local-first data layer, (4) Implementing multiplexed sync to avoid browser connection limits, (5) Adding push replication with conflict resolution, (6) Creating reactive queries with RxDB + TanStack DB. Triggers: "set up local-first", "bootstrap offline-first", "add replication architecture", "set up RxDB with oRPC", "create local-first architecture", "implement pull replication", "implement push replication", "add multiplexed sync", "set up tanstack db with rxdb", "add real-time replication", "offline-first setup".