Scaffold a Project from Scratch
Go from an empty directory to a running project. Describe the stack and conventions, and OpenCode generates the folder layout, config files, and a working starter that builds on first try.
When to use this recipe
- You’re starting a new project and want a sensible default structure.
- Your team has conventions you want applied consistently.
- You want a starter that builds and runs immediately.
Prerequisites
- An empty or initialized git repo.
- OpenCode installed.
Steps
-
Describe the stack and goals
Be specific about the tech, conventions, and what “done” means.
Scaffold a TypeScript Node.js service using Fastify. Include a
src/layout with routes, services, and config separation. Add ESLint, Prettier, Vitest, and a health check route. The project must build and the health check must pass on first run. -
Review the proposed structure
OpenCode lays out the tree first. Adjust before it writes files.
src/ routes/health.ts services/ config/index.ts index.ts -
Generate the files
Let OpenCode write the layout, config, and boilerplate.
-
Verify the build
npm install npm run build npm test -
Commit the baseline
git add -A && git commit -m "chore: initial scaffold"
Key prompt
Create a TypeScript Fastify service. Use the layout:
src/routes,src/services,src/config. Add ESLint + Prettier + Vitest, a/healthroute, and an env-based config loader. Make surenpm install && npm run buildworks with no errors.
Common pitfalls
- Vague specs: “Make a web app” yields generic output — specify the stack, layout, and success criteria.
- Missing success check: Always include a build/test command in the prompt so the scaffold is verified, not just written.
- Ignoring conventions: If your team uses specific patterns (e.g. feature folders), state them explicitly or the scaffold won’t match.
Related recipes
- git-commit-workflow —
reason.scaffold.to-git - mcp-server —
reason.scaffold.to-mcp - custom-skill —
reason.scaffold.to-skill
Related docs
Next up
- git-commit-workflow —
next.scaffold.to-git