spec-to-repo
Use when the user says 'build me an app', 'create a project from this spec', 'scaffold a new repo', 'generate a starter', 'turn this idea into code', 'bootstrap a project', 'I have requirements and need a codebase', or provides a natural-language project specification and expects a complete, runnable repository. Stack-agnostic: Next.js, FastAPI, Rails, Go, Rust, Flutter, and more.
Install
Copy this folder into your Claude Code project (needs Node.js):
npx degit alirezarezvani/claude-skills/product-team/skills/spec-to-repo .claude/skills/spec-to-repoOr install it for every project:
npx degit alirezarezvani/claude-skills/product-team/skills/spec-to-repo ~/.claude/skills/spec-to-repoFile content
Made by its original authors and shared under MIT. We show it unchanged, with credit and a link to the source. Source β
---
name: spec-to-repo
description: "Use when the user says 'build me an app', 'create a project from this spec', 'scaffold a new repo', 'generate a starter', 'turn this idea into code', 'bootstrap a project', 'I have requirements and need a codebase', or provides a natural-language project specification and expects a complete, runnable repository. Stack-agnostic: Next.js, FastAPI, Rails, Go, Rust, Flutter, and more."
---
# Spec to Repo
Turn a natural-language project specification into a complete, runnable starter repository. Not a template filler β a spec interpreter that generates real, working code for any stack.
## When to Use
- User provides a text description of an app and wants code
- User has a PRD, requirements doc, or feature list and needs a codebase
- User says "build me an app that...", "scaffold this", "bootstrap a project"
- User wants a working starter repo, not just a file tree
**Not this skill** when the user wants a SaaS app with Stripe + Auth specifically β use `product-team/saas-scaffolder` instead.
## Core Workflow
### Phase 1 β Parse & Interpret
Read the spec. Extract these fields silently:
| Field | Source | Required |
|-------|--------|----------|
| App name | Explicit or infer from description | yes |
| Description | First sentence of spec | yes |
| Features | Bullet points or sentences describing behavior | yes |
| Tech stack | Explicit ("use FastAPI") or infer from context | yes |
| Auth | "login", "users", "accounts", "roles" | if mentioned |
| Database | "store", "save", "persist", "records", "schema" | if mentioned |
| API surface | "endpoint", "API", "REST", "GraphQL" | if mentioned |
| Deploy target | "Vercel", "Docker", "AWS", "Railway" | if mentioned |
**Stack inference rules** (when user doesn't specify):
| Signal | Inferred stack |
|--------|---------------|
| "web app", "dashboard", "SaaS" | Next.js + TypeScript |
| "API", "backend", "microservice" | FastAPI (Python) or Express (Node) |
| "mobile app" | Flutter or React Native |
| "CLI tool" | Go or Python |
| "data pipeline" | Python |
| "high performance", "systems" | Rust or Go |
After parsing, present a structured interpretation back to the user:
```
## Spec Interpretation
**App:** [name]
**Stack:** [framework + language]
**Features:**
1. [feature]
2. [feature]
**Database:** [yes/no β engine]
**Auth:** [yes/no β method]
**Deploy:** [target]
Does this match your intent? Any corrections before I generate?
```
Flag ambiguities. Ask **at most 3** clarifying questions. If the user says "just build it", proceed with best-guess defaults.
### Phase 2 β Architecture
Design the project before writing any files:
1. **Select template** β Match to a stack template from `references/stack-templates.md`
2. **Define file tree** β List every file that will be created
3. **Map features to files** β Each feature gets at minimum one file/component
4. **Design database schema** β If applicable, define tables/collections with fields and types
5. **Identify dependencies** β List every package with version constraints
6. **Plan API routes** β If applicable, list every endpoint with method, path, request/response shape
Present the file tree to the user before generating:
```
project-name/
βββ README.md
βββ .env.example
βββ .gitignore
βββ .github/workflows/ci.yml
βββ package.json / requirements.txt / go.mod
βββ src/
β βββ ...
βββ tests/
β βββ ...
βββ ...
```
### Phase 3 β Generate
Write every file. Rules:
- **Real code, not stubs.** Every function has a real implementation. No `// TODO: implement` or `pass` placeholders.
- **Syntactically valid.** Every file must parse without errors in its language.
- **Imports match dependencies.** Every import must correspond to a package in the manifest (package.json, requirements.txt, go.mod, etc.).
- **Types included.** TypeScript projects use types. Python projects use type hints. Go projects use typed structs.
- **Environment variables.** Generate `.env.example` with every required variable, commented with purpose.
- **README.md.** Include: project description, prerequisites, setup steps (clone, install, configure env, run), and available scripts/commands.
- **CI config.** Generate `.github/workflows/ci.yml` with: install, lint (if linter in deps), test, build.
- **.gitignore.** Stack-appropriate ignores (node_modules, __pycache__, .env, build artifacts).
**File generation order:**
1. Manifest (package.json / requirements.txt / go.mod)
2. Config files (.env.example, .gitignore, CI)
3. Database schema / migrations
4. Core business logic
5. API routes / endpoints
6. UI components (if applicable)
7. Tests
8. README.md
### Phase 4 β Validate
After generation, run through this checklist:
- [ ] Every imported package exists in the manifest
- [ ] Every file referenced by an import exists in the tree
- [ ] `.env.example` lists every env var used in code
- [ ] `.gitignore` covers build artifacts and secrets
- [ ] README has setup instructions that actually work
- [ ] No hardcoded secrets, API keys, or passwords
- [ ] At least one test file exists
- [ ] Build/start command is documented and would work
Run `scripts/validate_project.py` against the generated directory to catch common issues.
## Examples
### Example 1: Task Management API
**Input spec:**
> "Build me a task management API. Users can create, list, update, and delete tasks. Tasks have a title, description, status (todo/in-progress/done), and due date. Use FastAPI with SQLite. Add basic auth with API keys."
**Output file tree:**
```
task-api/
βββ README.md
βββ .env.example # API_KEY, DATABASE_URL
βββ .gitignore
βββ .github/workflows/ci.yml
βββ requirements.txt # fastapi, uvicorn, sqlalchemy, pytest
βββ main.py # FastAPI app, CORS, lifespan
βββ models.py # SQLAlchemy Task model
βββ schemas.py # Pydantic request/response schemas
βββ database.py # SQLite engine + session
βββ auth.py # API key middleware
βββ routers/
β βββ tasks.py # CRUD endpoints
βββ tests/
βββ test_tasks.py # Smoke tests for each endpoint
```
### Example 2: Recipe Sharing Web App
**Input spec:**
> "I want a recipe sharing website. Users sign up, post recipes with ingredients and steps, browse other recipes, and save favorites. Use Next.js with Tailwind. Store data in PostgreSQL."
**Output file tree:**
```
recipe-share/
βββ README.md
βββ .env.example # DATABASE_URL, NEXTAUTH_SECRET, NEXTAUTH_URL
βββ .gitignore
βββ .github/workflows/ci.yml
βββ package.json # next, react, tailwindcss, prisma, next-auth
βββ tailwind.config.ts
βββ tsconfig.json
βββ next.config.ts
βββ prisma/
β βββ schema.prisma # User, Recipe, Ingredient, Favorite models
βββ src/
β βββ app/
β β βββ layout.tsx
β β βββ page.tsx # Homepage β recipe feed
β β βββ recipes/
β β β βββ page.tsx # Browse recipes
β β β βββ [id]/page.tsx # Recipe detail
β β β βββ new/page.tsx # Create recipe form
β β βββ api/
β β βββ auth/[...nextauth]/route.ts
β β βββ recipes/route.ts
β βββ components/
β β βββ RecipeCard.tsx
β β βββ RecipeForm.tsx
β β βββ Navbar.tsx
β βββ lib/
β βββ prisma.ts
β βββ auth.ts
βββ tests/
βββ recipes.test.ts
```
### Example 3: CLI Expense Tracker
**Input spec:**
> "Python CLI tool for tracking expenses. Commands: add, list, summary, export-csv. Store in a local SQLite file. No external API."
**Output file tree:**
```
expense-tracker/
βββ README.md
βββ .gitignore
βββ .github/workflows/ci.yml
βββ pyproject.toml
βββ src/
β βββ expense_tracker/
β βββ __init__.py
β βββ cli.py # argparse commands
β βββ database.py # SQLite operations
β βββ models.py # Expense dataclass
β βββ formatters.py # Table + CSV output
βββ tests/
βββ test_cli.py
```
## Anti-Patterns
| Anti-pattern | Fix |
|---|---|
| **Placeholder code** β `// TODO: implement`, `pass`, empty function bodies | Every function has a real implementation. If complex, implement a working simplified version. |
| **Stack override** β picking Next.js when the user said Flask | Always honor explicit tech preferences. Only infer when the user doesn't specify. |
| **Missing .gitignore** β committing node_modules or .env | Generate stack-appropriate .gitignore as one of the first files. |
| **Phantom imports** β importing packages not in the manifest | Cross-check every import against package.json / requirements.txt before finishing. |
| **Over-engineering MVP** β adding Redis caching, rate limiting, WebSockets to a v1 | Build the minimum that works. The user can iterate. |
| **Ignoring stated preferences** β user says "PostgreSQL" and you generate MongoDB | Parse the spec carefully. Explicit preferences are non-negotiable. |
| **Missing env vars** β code reads `process.env.X` but `.env.example` doesn't list it | Every env var used in code must appear in `.env.example` with a comment. |
| **No tests** β shipping a repo with zero test files | At minimum: one smoke test per API endpoint or one test per core function. |
| **Hallucinated APIs** β generating code that calls library methods that don't exist | Stick to well-documented, stable APIs. When unsure, use the simplest approach. |
## Validation Script
### `scripts/validate_project.py`
Checks a generated project directory for common issues:
```bash
# Validate a generated project
python3 scripts/validate_project.py /path/to/generated-project
# JSON output
python3 scripts/validate_project.py /path/to/generated-project --format json
```
Checks performed:
- README.md exists and is non-empty
- .gitignore exists
- .env.example exists (if code references env vars)
- Package manifest exists (package.json, requirements.txt, go.mod, Cargo.toml, pubspec.yaml)
- No .env file committed (secrets leak)
- At least one test file exists
- No TODO/FIXME placeholders in generated code
## Progressive Enhancement
For complex specs, generate in stages:
1. **MVP** β Core feature only, working end-to-end
2. **Auth** β Add authentication if requested
3. **Polish** β Error handling, validation, loading states
4. **Deploy** β Docker, CI, deploy config
Ask the user after MVP: "Core is working. Want me to add auth/polish/deploy next, or iterate on what's here?"
## Cross-References
- Related: `product-team/saas-scaffolder` β SaaS-specific scaffolding (Next.js + Stripe + Auth)
- Related: `engineering/spec-driven-workflow` β spec-first development methodology
- Related: `engineering/database-designer` β database schema design patterns
- Related: `engineering-team/senior-fullstack` β full-stack implementation patterns
## More in this skill
Load these only when the task needs them.
- [references/spec-parsing-guide.md](references/spec-parsing-guide.md) β Spec Parsing Guide