Skip to content

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

  1. 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.

  2. 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
  3. Generate the files

    Let OpenCode write the layout, config, and boilerplate.

  4. Verify the build

    npm install
    npm run build
    npm test
  5. 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 /health route, and an env-based config loader. Make sure npm install && npm run build works 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.

Next up