Development
Prerequisites
Section titled “Prerequisites”- Node.js 24
- pnpm. It switches to the version that
packageManagerinpackage.jsonpins. - Docker
- Vercel CLI
- Slack app credentials
pnpm installpnpm buildpnpm dlx vercel@latest loginpnpm dlx vercel@latest switchpnpm dlx vercel@latest link --yespnpm dlx vercel@latest env pull .env --environment=developmentIf your team account requires an explicit Vercel scope, add --scope <team-slug> to the link and env pull commands.
pnpm devThis starts the example app on http://localhost:3000 by default. It also rebuilds and watches the workspace packages that the example app consumes, so dashboard and runtime package edits are reflected without manually rebuilding first.
Before the app starts, pnpm dev runs docker compose up -d --wait. This starts Postgres, Redis and S3 from compose.yaml and waits until they are healthy. Docker must be running. Services that already run are left as they are. Then pnpm dev runs junior upgrade to apply missing database migrations to DATABASE_URL. Migrations that already ran are skipped. If either step fails, pnpm dev stops.
pnpm dev delivers background work through a local Vercel Queues server. The @sentry/junior/nitro module starts it in the nitro dev process and points the app at it with JUNIOR_QUEUE_API_URL. The server keeps messages in memory and pushes each one to its callback route, as Vercel Queues does. Local work needs no Vercel Queues access. pnpm dev keeps state in the Redis in compose.yaml (redis://localhost:6382) unless you set JUNIOR_STATE_ADAPTER. A change to apps/example/server.ts, plugins.ts, dashboard.ts or apps/example/app/ makes Nitro replace its app worker. The queue server and the state in Redis are kept. A Turn that the reload stops continues when its work lease expires, after about 2 minutes. A new Junior build restarts Nitro, and the queue server loses its messages.
pnpm dev runs inside sentry local run --session junior. Nitro sends its errors, spans, and logs to the junior session of the Sentry Local daemon on http://localhost:8969, and the terminal shows them. The session keeps its events when Nitro restarts, and for three hours after pnpm dev stops. To read them from another terminal, also after pnpm dev stops, run pnpm exec sentry local event list junior, and pnpm exec sentry local event view junior <id> for one event. Add --json for the full records. When SENTRY_SPOTLIGHT is already set, pnpm dev uses that server and starts none.
To also open the Sentry Local UI in your browser, set OPEN_SPOTLIGHT_WEB=1:
OPEN_SPOTLIGHT_WEB=1 pnpm devFor dashboard visual QA without generating real Slack traffic, replace conversation API responses with sample fixtures:
JUNIOR_DASHBOARD_MOCK_CONVERSATIONS=true pnpm devMock mode does not query or merge real conversation records. Messages that you send get a fixed reply after 2 seconds, and no agent runs. They stay until the dev server restarts.
To check a frontend change against live data, also set the origin of a live deployment:
JUNIOR_DASHBOARD_MOCK_CONVERSATIONS=true JUNIOR_DASHBOARD_LIVE_ORIGIN=https://junior.example.com pnpm devThe dashboard shows mock data and a banner with a Use live data link. The link opens a page with two choices:
- Connect: the API Tokens page of the live deployment creates a personal token and sends it to the Preview. This works only for a Preview that Junior made for you with
createPreview. Junior records each Preview with the email of the person who asked for it, for 24 hours. - Paste a token: create a personal token on the live deployment and paste it. Use this for other servers, such as
localhost.
The browser keeps the token in an HttpOnly cookie, and the dev server forwards dashboard API reads to the live deployment. The server does not store the token. Live data is read-only, because the live deployment accepts personal tokens only for GET and HEAD. API changes in your branch do not apply to live data. Only the example app knows about live data: apps/example/live-preview.ts wraps the app when this variable is set. The app refuses to start when dashboard auth is also on.
Run sandboxes in local Docker
Section titled “Run sandboxes in local Docker”By default, Junior runs agent sandboxes in Vercel Sandbox. To run them in a local Docker daemon instead, set the provider in .env:
JUNIOR_SANDBOX_PROVIDER=dockerThe Docker provider needs a Docker daemon on a unix socket. It uses /var/run/docker.sock, or the unix socket in DOCKER_HOST. On macOS, the daemon runs in a VM, so each sandbox sends its web traffic through an egress relay container. Each sandbox is a privileged container, so do not run untrusted workloads with it.
The first sandbox builds the junior-sandbox-runtime image. This takes a few minutes. Later sandboxes start in seconds. pnpm dev and pnpm cli -- chat ... both use the provider. Each process runs its own egress proxy, and the process that last acquired a sandbox carries its web traffic.
Docker sandboxes have a small toolset: gh, jq, and ripgrep. They do not include other plugin CLIs, browsers, or Docker. The agent installs other tools with sudo when it needs them. Vercel sandboxes still include every tool that the plugins declare.
Optional settings:
JUNIOR_DOCKER_SANDBOX_DIRsets the directory of the local egress CA. The default is~/.cache/junior/docker-sandbox.JUNIOR_DOCKER_SANDBOX_EXTRA_CA_CERTSnames a PEM file that each sandbox also trusts. Set it when your machine is behind a TLS proxy.
To remove all Docker sandboxes and snapshots:
docker rm -f -v $(docker ps -aq --filter label=dev.junior.sandbox)docker network prune -f --filter label=dev.junior.sandboxdocker image prune -a -f --filter label=dev.junior.sandbox=snapshotThis provider is for local development and QA only. Do not run untrusted workloads with it.
Work in isolated branches
Section titled “Work in isolated branches”Worktrees are development-only contributor tooling. Use them when you want to keep your main checkout stable while reviewing a PR, testing a fix, or running a coding agent such as Codex on a task. The repo helper creates the Git worktree, copies local development files, and installs dependencies in the new checkout.
pnpm worktree new codex/fix-slack-retry --agent "codex"Use --open "code ." instead of --agent "codex" when you want to open the worktree in an editor first:
pnpm worktree new review/pr-123 --open "code ."New worktrees are created under ../junior-worktrees by default. They start from origin/main when available, then copy matching local files from the primary checkout using scripts/worktree.include, including env files and Vercel project links.
Codex app worktrees are separate from this repo helper. When you choose Worktree in Codex, Codex creates managed, disposable worktrees under $CODEX_HOME/worktrees; do not point JUNIOR_WORKTREE_DIR there or rely on that directory for long-lived branch work. Use the repo helper when you want a named local worktree you can keep, inspect, and remove yourself.
Make sure Codex trusts the main checkout before starting agent work. In Codex, trust the project from the app prompt, or add the checkout to ~/.codex/config.toml:
[projects."/absolute/path/to/junior"]trust_level = "trusted"If you create a long-lived helper worktree and open it as its own Codex project, trust that worktree path too. Shared repo instructions stay in AGENTS.md; personal Codex defaults such as model, sandbox, approvals, and MCP servers stay in ~/.codex/config.toml or your personal .codex/config.toml layers, not in these dev-only helper files.
Run commands inside a worktree without changing directories:
pnpm worktree exec codex/fix-slack-retry -- pnpm typecheckList active worktrees before switching contexts. The checkout running the helper is marked with *:
pnpm worktree listAfter the branch is merged or no longer needed, remove the clean worktree:
pnpm worktree remove codex/fix-slack-retrySet JUNIOR_WORKTREE_DIR to change the parent directory, set JUNIOR_WORKTREE_BASE to change the default base ref, set JUNIOR_WORKTREE_SOURCE to change the checkout copied into new worktrees and setup runs, or pass --path, --from, --source, or --no-install for one-off overrides. Relative JUNIOR_WORKTREE_DIR values resolve from the primary checkout root. --from and JUNIOR_WORKTREE_BASE only apply when creating a new branch; existing branches open at their current tip.
Run checks
Section titled “Run checks”Run checks from the repo root. pnpm install does not build workspace packages, and typecheck and lint read the built declarations, so run pnpm build first:
pnpm buildpnpm testpnpm typecheckpnpm lintpnpm skills:checkpnpm docs:checkpnpm release:checkpnpm package-types:checkThe root AGENTS.md lists commands for one test file or one eval. Testing says which test layer to use.
Slack tunnel
Section titled “Slack tunnel”Install cloudflared. For a random hostname, run:
cloudflared tunnel --url http://localhost:3000For a stable hostname, create a named tunnel once. pnpm cloudflare:token writes its token to .env.local as CLOUDFLARE_TUNNEL_TOKEN, and pnpm dev then starts the tunnel:
cloudflared tunnel logincloudflared tunnel create junior-devcloudflared tunnel route dns junior-dev <tunnel-host>pnpm cloudflare:tokenpnpm devRun pnpm cloudflare:token again after vercel env pull rewrites .env.local. Set CLOUDFLARE_TUNNEL_URL when the app does not listen on port 3000.
Set the Event Subscriptions and Interactivity request URL to:
https://<tunnel-host>/api/webhooks/slackNext step
Section titled “Next step”Run focused checks from Testing, then verify behavior in Verify & Troubleshoot.