/scaffold
Generate a new module, component, or screen with boilerplate, tests, and wiring.
Usage
code
/scaffold <type> <name> [--path <path>]
Arguments
- •
type: What to generate —module,component,screen,endpoint,model,service - •
name: Name of the thing to create (PascalCase or kebab-case) - •
--path: Override default location
Instructions
When this skill is invoked:
Agent Behavior
Autonomy:
- •Read
prd/00_technology.mdto determine stack and patterns - •Follow existing code conventions (read similar files first)
- •Create all related files (implementation + tests + wiring)
Quality:
- •Match existing code style exactly
- •Include type annotations and docstrings
- •Create test file with basic test cases
- •Wire into existing routing/exports
Scaffold Types
Module (/scaffold module <name>)
Create a complete backend module (service + model + route + tests):
code
src/{project}/{name}/
├── __init__.py # or index.ts
├── service.py # Business logic
├── models.py # Request/response schemas
└── router.py # API route handlers
tests/unit/
└── test_{name}_service.py
tests/integration/
└── test_{name}_api.py
Steps:
- •Read existing modules to match patterns
- •Create service with CRUD operations skeleton
- •Create models with validation schemas
- •Create router with standard endpoints
- •Create unit test for service layer
- •Create integration test for API endpoints
- •Register router in main app
Component (/scaffold component <name>)
Create a React/UI component (web or mobile):
code
src/components/{name}/
├── {name}.tsx # Component implementation
├── {name}.test.tsx # Tests
└── index.ts # Re-export
Steps:
- •Read existing components to match patterns
- •Create component with props interface
- •Create test with render + interaction tests
- •Add re-export from index
- •Add to component barrel export if one exists
Screen (/scaffold screen <name>)
Create a full screen/page:
Web (Next.js):
code
src/app/{name}/
├── page.tsx # Page component
├── layout.tsx # Layout (if needed)
└── loading.tsx # Loading state
Mobile (React Native):
code
src/screens/{name}/
├── {Name}Screen.tsx # Screen component
├── {Name}Screen.test.tsx
└── index.ts
iOS (SwiftUI):
code
Sources/{Feature}/
├── {Name}View.swift
├── {Name}ViewModel.swift
└── {Name}ViewTests.swift
Android (Compose):
code
app/src/main/java/.../feature/{name}/
├── {Name}Screen.kt
├── {Name}ViewModel.kt
└── {Name}UiState.kt
app/src/test/java/.../feature/{name}/
└── {Name}ViewModelTest.kt
Steps:
- •Read existing screens to match patterns
- •Create screen component with standard layout
- •Create view model / state if pattern exists
- •Create test file
- •Add to navigation / router
Endpoint (/scaffold endpoint <name>)
Create a single API endpoint:
- •Add route handler in appropriate router file
- •Add request/response models with validation
- •Add service method for business logic
- •Add tests for happy path + error cases
- •Register route in app
Model (/scaffold model <name>)
Create a data model / database entity:
- •Create schema definition (Prisma, SQLAlchemy, SwiftData, Room)
- •Create request/response DTOs
- •Generate migration if database model
- •Add basic CRUD queries
- •Create test fixtures
Service (/scaffold service <name>)
Create a service layer class/module:
- •Create service with dependency injection
- •Add interface/protocol if pattern exists
- •Create unit tests with mocked dependencies
- •Wire into DI container if applicable
Convention Detection
Before generating, read 2-3 existing files of the same type to detect:
- •File naming convention (kebab-case, PascalCase, snake_case)
- •Import style (relative, absolute, aliases)
- •Export pattern (default, named, barrel)
- •Test naming and structure
- •Documentation style
Scaffold Checklist
- • Matches existing code conventions
- • Type annotations complete
- • Docstrings / documentation added
- • Test file created with basic cases
- • Wired into app (routes, navigation, exports)
- • Linting passes on new files
Example Output
code
$ /scaffold module notifications
Reading existing modules for patterns...
Detected: Python + FastAPI + SQLAlchemy
Creating notification module...
src/myapp/notifications/__init__.py
src/myapp/notifications/service.py
- NotificationService with create, get, list, mark_read
src/myapp/notifications/models.py
- CreateNotificationRequest, NotificationResponse
src/myapp/notifications/router.py
- POST /api/v1/notifications
- GET /api/v1/notifications
- GET /api/v1/notifications/{id}
- PUT /api/v1/notifications/{id}/read
tests/unit/test_notifications_service.py (6 tests)
tests/integration/test_notifications_api.py (4 tests)
Wiring...
Updated src/myapp/main.py — registered notifications router
Verification...
Lint: passing
Tests: 10/10 passing
Module 'notifications' scaffolded successfully.