/agent-skills:nextjs-local-devfrom Agent Skills
Manage a local Next.js dev server from the shell — start, stop, restart, monitor, tail logs — with safe isolation across git worktrees. Use whenever the user asks you to run, restart, or check the status of a Next.js (or similar JS) dev server, especially when multiple worktrees of the same project may be running concurrently. Always use the nextdev CLI; never kill node processes with pkill/killall/fuser.
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.
Run Next.js natively (not in a container) and manage the dev server through the nextdev CLI. nextdev keys each instance by absolute cwd, so a git worktree has its own independent server on its own port. The script only ever touches processes it started.
Use the active harness's shell and background execution capability. If it has no background mode, run nextdev normally because the helper itself daemonizes the server, then inspect its log file with the harness's file reader. The process-safety rules below apply unchanged to Claude Code and Codex.
These rules exist because in past sessions the assistant has killed every node process on the box, taking down unrelated work.
pkill node, pkill -f next, killall node, fuser -k, or any wildcard kill $(pgrep ...) chain.ps aux and pipe PIDs into kill to "clean up". You cannot tell from ps which server belongs to which worktree.nextdev stop from inside the worktree whose server you want to stop.nextdev list to see every server this tool knows about, across worktrees.nextdev says a pid "no longer looks like node/next", stop and report it to the user — don't force-kill. Something unexpected is using that pid.nextdev, confirm with the user first and target the single pid precisely (kill <pid>), never a pattern.--port 3000 (or any port) to nextdev start unless the user explicitly asks for a specific port.nextdev start with no --port flag — it scans for a free port automatically and prints the URL.nextdev start, read the url: line in the output to get the actual port. Do not assume 3000.All commands operate on the instance keyed by $(pwd -P) unless noted.
nextdev start # auto-detect pnpm/yarn/bun/npm; picks a free port (do NOT add --port unless user asks)
nextdev start --port 3001 # pin a specific port (fails immediately if already in use — avoid this)
nextdev start --pm pnpm # force package manager
nextdev start --cmd "pnpm dev --turbopack" # custom command
nextdev stop # graceful stop (TERM, then KILL after 10s)
nextdev restart # stop + start, flags same as start
nextdev status # current worktree's server
nextdev list # every registered instance, across worktrees
nextdev logs # tail 200 lines
nextdev logs -f # follow
nextdev logs -n 1000 # more history
nextdev clean # forget registrations whose pid is gone
nextdev doctor # show tool versions + environment
State lives in ${XDG_STATE_HOME:-~/.local/state}/nextdev/<hash-of-cwd>/ — one directory per worktree, containing pid, port, cwd, command, started_at, and dev.log.
# main checkout
cd ~/code/hiptrip
nextdev start # picks first free port ≥ 3000, prints url:
# feature branch in a worktree
git worktree add ../hiptrip-feat-x feat/x
cd ../hiptrip-feat-x
nextdev start # picks next free port automatically
nextdev list
# STATE PID PORT CWD
# running 12345 3002 /home/rick/code/hiptrip
# running 12399 3003 /home/rick/code/hiptrip-feat-x
The ports shown in nextdev start output and nextdev list are the source of truth — never guess or hardcode them.
Each worktree has its own .next/ build cache and its own nextdev instance — no interference.
User says "restart the dev server":
nextdev restart
User says "is the dev server running?":
nextdev status
User says "the server seems broken, check the logs":
nextdev logs -n 200
Checking logs after nextdev start (do NOT use sleep):
Do not block on sleep N (N ≥ 2). Run nextdev logs immediately—the background process writes the log continuously. If the harness supports background tool calls, use that mode; otherwise invoke the command normally and inspect the log path it reports.
# run with the harness's background execution capability when available
nextdev logs -n 40
Or use Monitor to watch for the "Ready" line:
# streams until "Ready" appears (or timeout)
tail -f /home/.../.local/state/nextdev/<hash>/dev.log | grep --line-buffered -m1 "Ready"
The hash is the last path segment shown by nextdev start in the logs: field.
User says "start a clean dev server":
nextdev stop || true
rm -rf .next
nextdev start
User says "what's running across all my worktrees?":
nextdev list
Port conflict with a stale server:
nextdev list # find which worktree owns the port
cd <that worktree>
nextdev stop
Next.js local dev replaces what a devcontainer would give you — but only if Node is consistent across machines. Use fnm (fast, cross-platform) and commit an .nvmrc:
echo "22" > .nvmrc # or whatever the project targets
fnm use # picks up .nvmrc
Install fnm:
brew install fnmcurl -fsSL https://fnm.vercel.app/install | bashwinget install Schniz.fnmAdd to shell init: eval "$(fnm env --use-on-cd)" — changing directory auto-switches Node.
CHOKIDAR_USEPOLLING=true (which burns CPU).node_modules bind mounts have perf + permission issues..next/ cache on a bind mount is painful.Containers are great for stateful deps (Postgres, Redis) — see the podman-postgres skill. Keep Next.js on the host.
nextdev is a single Node.js script (Node 18+, zero npm deps — just stdlib). Runs on:
Get-CimInstance Win32_Process; on Linux/macOS, ps -A -o pid=,ppid=.net.createServer().listen() and catches EADDRINUSE — portable.ps and kills leaves first, so dev servers spawned through npm run dev (npm → next-router-worker → render-workers) come down cleanly.State dir: ${XDG_STATE_HOME:-~/.local/state}/nextdev/ on Unix, %LOCALAPPDATA%\nextdev\ on Windows. Override with NEXTDEV_STATE_ROOT.
Worktrees do not inherit .env.local from the main checkout, and they don't have their own .vercel/project.json — the Vercel link only exists in the main repo. If the dev server throws auth or missing-secret errors after nextdev start, pull env vars like this:
Tip: Some projects have credential chains (cloud auth providers, custom secret managers) where a plain
vercel env pullis not sufficient. If the project has aworktree-bootstrapskill available, invoke it beforenextdev startwhen working in a fresh worktree — it handles any project-specific env setup that the standard pull can't cover.
# 1. Find where the Vercel link lives
find ~/projects/<repo> -name "project.json" -path "*/.vercel/*"
# 2. Pull from the main repo, targeting the worktree's .env.local
cd /path/to/main-repo
vercel env pull /path/to/worktree/.env.local --yes
# 3. Restart to pick up the new file
cd /path/to/worktree
nextdev restart
After pulling, nextdev logs should show - Environments: .env.local in the Next.js startup output confirming the file was loaded.
nextdev start exits immediately — check dev.log in the state dir; usually a missing env var or port already bound.
nextdev status says "running" but the site is down — Next.js is crashing per-request. nextdev logs -f and reload the page.
nextdev list shows a ghost entry — nextdev clean removes registrations whose pids no longer match node/next.
Port 3000 is taken by something not nextdev — identify with lsof -iTCP:3000 -sTCP:LISTEN or ss -tlnp | grep :3000. Ask the user before killing an unknown process.
prisma: command not found (or any other CLI tool) in dev log — the default pnpm dev script invokes CLIs that aren't in PATH inside a worktree. Use --cmd with npx:
nextdev start --cmd "npx prisma generate && npx next dev"
In a git worktree, pnpm does not surface the main repo's node_modules/.bin into the shell PATH. npx resolves the tool from the nearest node_modules regardless of PATH.
DATABASE_URL needs to be set for local Postgres — do not inject it inline on the nextdev start command line (e.g. DATABASE_URL="..." nextdev start). The inline value is not persisted and will be lost on the next nextdev restart. Instead, write it to .env.local so it survives restarts:
# Add or update DATABASE_URL in .env.local
echo 'DATABASE_URL="postgres://postgres:postgres@localhost:5433/mydb?sslmode=disable"' >> .env.local
nextdev start
If the worktree was bootstrapped via worktree-bootstrap, the correct DATABASE_URL is already written into .env.local — just run nextdev start normally.
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