name: nextjs-sandbox-starter description: Create, install, run, and troubleshoot a Next.js project for non-technical users in Codex environments. Use when a user asks to start a new Next.js app, install Next.js/React prerequisites, run an existing Next.js app, fix common setup/runtime issues, or wants full hands-off setup on macOS, Windows, or Linux.
Next.js Sandbox Starter
Execute end-to-end setup with minimal user effort. Prefer doing the work instead of giving long instructions.
Operating Mode
- Assume the user is non-technical unless they explicitly say otherwise.
- Pick safe defaults and proceed without back-and-forth.
- Explain outcomes in plain language.
- Always report the final app URL and exact project path.
Default Choices
Use these defaults unless the user asks differently:
- Package manager:
npm - Language: JavaScript
- Router: App Router
- Styling: no Tailwind
- Project name:
hello-world(or user-provided name) - Project location: current workspace unless user provides a path
Workflow Selection
Route the request to one workflow:
Create new appwhen user says install/start/new Next project.Run existing appwhen project exists and user wants it launched.Troubleshootwhen install/build/run fails.
For troubleshooting details, load references/troubleshooting.md.
Workflow 1: Create New App
- Inspect destination path and avoid overwriting existing project files.
- Check toolchain:
node -vnpm -v
- If Node is missing, install Node LTS by OS:
- macOS:
brew install node - Windows (PowerShell):
winget install OpenJS.NodeJS.LTS - Linux (Debian/Ubuntu):
sudo apt-get update && sudo apt-get install -y nodejs npm
- Scaffold app:
npx create-next-app@latest <project-name> --js --app --eslint --no-tailwind --use-npm --yes
- Verify build:
cd <project-name> && npm run build
- Start dev server:
npm run dev
- If port
3000is busy, accept fallback port and report it. - Return:
- absolute project path
- active local URL
- one command to run later (
npm run dev)
Workflow 2: Run Existing App
- Confirm app folder contains
package.jsonand Next files. - Install dependencies if needed:
npm install
- Start:
npm run dev
- Report the running URL and note port fallback if any.
Workflow 3: Troubleshoot
When a step fails, apply quick fixes in this order:
- Sandbox/network restrictions
- Missing Node or outdated Node
- Package install issues
- Build errors from remote font fetching
- Port conflicts
- Permissions/path issues
Use concrete fixes from references/troubleshooting.md.
Codex Sandbox Rules
- If install/fetch fails with network errors (for example
ENOTFOUND, registry unreachable, remote fonts fetch failed), rerun the needed command with escalation/approval flow and continue automatically after approval. - Do not stop after first failure; retry with the least risky correction.
- Avoid destructive commands unless user asked.
Non-Technical Response Contract
At completion, always provide:
- What was done (1-3 bullets)
- Project path (absolute)
- URL to open
- Single command for future startup
Keep wording simple and avoid jargon.