# Worktree Ports

> Discover and use stable per-app ports assigned to a local monorepo worktree. Use when starting, opening, testing, or debugging local apps, or when worktree slots, localhost ports, PORT, app URLs, or .worktree-env.json are involved.

- Skill: `franciscomoretti/worktree-ports` (Agent Skill, multi-file: 5 files)
- Install (CLI): `npx skillmds@latest add franciscomoretti/worktree-ports`
- Raw SKILL.md: https://api.skillmd.com/api/skills/franciscomoretti/worktree-ports/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: franciscomoretti (https://skillmd.com/u/franciscomoretti)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/franciscomoretti/worktree-ports

---


# Worktree Ports

- Run `bun dev:info --json` before accessing local apps. Use the returned app URLs; never assume a port.
- Start apps through the root `bun dev*` scripts so `.env.worktree.local` and `.env.local` are loaded before the wrapper runs.
- Set the slot environment variable declared in `.worktree-env.json` in a worktree-local environment file.
- Keep app offsets unique and below the configured range stride.
- Declare every variable an app needs under its `exports`, including `PORT`.
- Configure cross-app environment variables with `{apps.<name>.url}` templates.

The generic resolver and command wrapper are bundled in `scripts/`.

