When to Use
- •Bootstrapping a reproducible workstation for QuizApp (local laptop, Codespaces, remote VM)
- •Updating tool versions (Node, pnpm, Turbo, Docker CLI) in
devbox.json - •Running repo commands inside
devbox shellto guarantee the pinned toolchain - •Troubleshooting differences between host Node/pnpm versions and the expected stack
Critical Patterns
Required Files (all at repo root)
| File | Purpose |
|---|---|
devbox.json | Declares packages, shell hooks, and scripts. Commit it. |
devbox.lock | Nix lockfile produced by Devbox. Commit it for deterministic installs. |
devbox.d/*.sh | Optional shell hooks (e.g., pnpm install). Keep scripts idempotent. |
Package Baseline
- •Pin Node 20.x via
nixpkgs#nodejs_20(matches repopackage.jsonengines) - •Pin pnpm 9.x via
nixpkgs#pnpm - •Install
nixpkgs#turbofor runningturbo runoutside node_modules (still keep repo devDependency) - •Include
nixpkgs#docker(CLI only) sodocker composeworks inside Devbox shells - •Optional but helpful:
nixpkgs#git,nixpkgs#openssl,nixpkgs#watchman
Shell Behavior
- •Expose
node_modules/.binonPATHinside the init hook (export PATH="$PWD/node_modules/.bin:$PATH") - •Prefer hooking
pnpm installindevbox.d/post-start.shonly when.pnpm-lock.yamlchanges (guard with checksum) - •Never install global npm packages inside Devbox; rely on pnpm workspace + nix packages
Example devbox.json
json
{
"$schema": "https://raw.githubusercontent.com/jetpack-io/devbox/main/devbox.schema.json",
"packages": [
"nixpkgs#nodejs_20",
"nixpkgs#pnpm",
"nixpkgs#turbo",
"nixpkgs#docker",
"nixpkgs#git"
],
"shell": {
"init_hook": [
"export PATH=$PWD/node_modules/.bin:$PATH"
]
},
"env": {
"QUIZAPP_NODE_VERSION": "20"
}
}
Keep the file minimal; extra scripts belong in devbox.d/*.sh.
ALWAYS
- •Run
devbox shell(ordevbox run <cmd>) before invokingpnpm,turbo, ordocker - •Commit both
devbox.jsonanddevbox.lock - •Rebuild the lock after changing packages:
devbox update - •Document any non-standard packages in
docs/architecture.md
NEVER
- •Mix host and Devbox installs (e.g.,
pnpm installoutside Devbox while expecting Devbox paths) - •Add OS-specific packages (stick to nixpkgs identifiers)
- •Rely on Devbox to start long-running services automatically; keep that logic in
pnpm dev/ Docker
Commands
bash
# Initialize Devbox in repo root (one-time) # Add packages devbox add nixpkgs#nodejs_20 nixpkgs#pnpm nixpkgs#turbo nixpkgs#docker # Enter the shell (preferred for iterative work) # Run Turbo task once without spawning a shell devbox run pnpm test # Update the lockfile after package changes
Resources
- •
docs/architecture.md— source of truth for required toolchain versions - •Devbox docs — https://www.jetpack.io/devbox/docs/ (reference only, do not link from AGENTS)
- •Use
devbox envto inspect resolved environment when debugging version drift