Step 7: Select Template

Phase: plan

Context

You have app_spec and matched_template_or_null (from Step 2). Now finalize which code template(s) and common patterns to use.

What to do

Choose the starting point for the code. Three scenarios:

1. Template matched (from Step 2)

If a template was matched and accepted, use it. Fetch the template files from /templates/{category}/{template-name}/. Each template contains:

  • schema.sql — Database table definitions
  • rls.json — RLS configuration
  • index.html — Complete frontend app
  • README.md — Template docs and customization points

2. No template — build from patterns

If no template matched, assemble from common patterns. Available patterns at /templates/patterns/:

  • db-connection.js — run402 API connection setup
  • auth-flow.js — Signup, login, session management
  • crud.js — Create, read, update, delete operations
  • file-upload.js — Storage API integration
  • responsive-layout.html — Mobile-first page structure
  • polling.js — Timed data refresh for near-real-time updates

3. Template + customizations

Start from the template but plan modifications based on the user's feature answers from Step 3.

What to tell the user

If using a template: "Great news — I have a ready-made starting point that does most of what you want. I'll customize it for you."

If building from scratch: "I'll build this from our reusable building blocks. It'll be custom-made for exactly what you described."

Expected output

  • selected_templates — Template name(s) to use, or "custom" if building from patterns
  • selected_patterns — List of common patterns to include (e.g., ["db-connection", "auth-flow", "crud", "responsive-layout"])

Memory directive