Skip to main content

/backend-scaffold

Generate production-ready backend code with routes, data models, service layers, and validation.


Overview

Generates production-ready backend scaffolds from upstream specs (API contracts, task breakdowns, data models). Supports multiple stacks — Node.js/TypeScript (Fastify + Prisma), PHP (Laravel/Symfony), and Go (Chi/stdlib + sqlc) — auto-detected from tech.md.


Usage

/backend-scaffold
/backend-scaffold backend-api-contract backend-task-breakdown backend-data-model
ArgumentRequiredDescription
backend-api-contractNoPath to OpenAPI YAML
backend-task-breakdownNoPath to BE task breakdown markdown
backend-data-modelNoPath to data model markdown

When run without arguments, launches an interactive wizard.


What It Produces

Files at $JAAN_OUTPUTS_DIR/backend/scaffold/{id}-{slug}/ (Node.js/TypeScript example):

FileContent
{id}-{slug}.mdSetup guide + architecture doc
{id}-{slug}-routes.tsRoute handlers (all resources)
{id}-{slug}-services.tsService layer (business logic)
{id}-{slug}-schemas.tsValidation schemas
{id}-{slug}-middleware.tsAuth + error handling middleware
{id}-{slug}-prisma.prismaORM data model
{id}-{slug}-config.tsPackage.json + tsconfig content
{id}-{slug}-readme.mdSetup + run instructions

File extensions adapt to detected stack (.ts for Node.js, .php for PHP, .go for Go).


What It Asks

QuestionWhenWhy
Project structureNot in tech.mdMonolith / modular monolith / microservice
Auth middlewareNot in tech.mdJWT / API key / session / none
Error handling depthNot in tech.mdBasic / full RFC 9457 with error taxonomy
LoggingNot in tech.mdStructured JSON pino / winston / none

Multi-Stack Support

Reads $JAAN_CONTEXT_DIR/tech.md to auto-detect the stack:

StackFrameworkORM/DBValidation
Node.js / TypeScriptFastify v5+PrismaZod + type-provider
PHPLaravel 12 / Symfony 7Eloquent / DoctrineForm Requests / Validator
GoChi / stdlib (Go 1.22+)sqlc / GORMgo-playground/validator

Key Patterns (Node.js/TypeScript)

  • Routing: @fastify/autoload v6 for file-based route loading
  • Validation: fastify-type-provider-zod v6.1+ with Zod schemas
  • ORM: Prisma singleton with globalThis pattern
  • Services: Plain exported functions, module caching as built-in singleton
  • Errors: RFC 9457 Problem Details with application/problem+json
  • Structure: Collocated routes + schemas + services per resource

Test Framework & Mutation Tool Recommendations

The scaffold guide includes a recommended test framework and mutation testing tool per stack:

StackTest FrameworkMutation ToolConfig File
Node.js / TypeScriptVitestStrykerJSstryker.config.mjs
PHPPHPUnit / PestInfectioninfection.json5
Gogo testgo-mutestingMakefile target

When the scaffold detects an existing test framework, it adapts its recommendations accordingly. Mutation testing config stubs are included in the scaffold output when applicable.


Workflow Chain

/backend-api-contract → /backend-task-breakdown → /backend-scaffold → /qa-test-cases

Example

Input:

/backend-scaffold path/to/api.yaml path/to/tasks.md path/to/data-model.md

Output:

jaan-to/outputs/backend/scaffold/01-user-api/
├── 01-user-api.md
├── 01-user-api-routes.ts
├── 01-user-api-services.ts
├── 01-user-api-schemas.ts
├── 01-user-api-middleware.ts
├── 01-user-api-prisma.prisma
├── 01-user-api-config.ts
└── 01-user-api-readme.md

Tips

  • Run /backend-api-contract and /backend-data-model first for best results
  • Set up $JAAN_CONTEXT_DIR/tech.md to skip stack detection questions
  • Copy scaffold files to your project directory and install dependencies
  • Use /frontend-scaffold to generate matching frontend code


Technical Details

  • Logical Name: backend-scaffold
  • Command: /backend-scaffold
  • Role: dev (backend)
  • Output: $JAAN_OUTPUTS_DIR/backend/scaffold/{id}-{slug}/