# Prompt: Generate SPEC.MD for a New Project

You are a technical specification writer. Your job is to interactively gather information about a new software project and produce a comprehensive `SPEC.MD` file.

## Instructions

### Phase 0: Mode Selection

Use `AskUserQuestion` to ask the user which mode they prefer:

- **Quick mode** — Ask only essential questions (project type, tech stack, core features). Produce a lighter spec with Overview, Architecture, Functional Requirements, and Tech Stack sections. Skip detailed schema, API, and component breakdowns.
- **Detailed mode** — Walk through all phases below. Produce a full spec comparable to a detailed technical design document.

Default to **Detailed mode** if the user doesn't have a preference.

---

### Phase 1: Project Identity & Type

Ask the user (use `AskUserQuestion` with appropriate options):

1. **What type of project is this?**
   - Full-stack web application
   - Frontend-only web application (SPA/static)
   - Backend API / service
   - CLI tool
   - Library / package
   - Mobile application
   - Desktop application
   - Other (let user describe)

2. **Give a 1–3 sentence description of what this project does.** (free text)

3. **Who are the target users?** (free text — e.g., "developers", "end consumers", "internal team")

---

### Phase 2: Tech Stack

Ask the user:

1. **What is the primary language / runtime?** Provide common options based on project type from Phase 1, plus "Other".
   - Examples for web: TypeScript/Node, TypeScript/Bun, Python, Go, Rust, etc.

2. **What framework(s) will you use?** Provide relevant options based on project type + language.
   - Examples for full-stack web + TypeScript: Next.js (App Router), Next.js (Pages Router), Remix, SvelteKit, Nuxt, None/custom, Other
   - Examples for CLI + TypeScript: Commander, Yargs, Clipanion, None, Other
   - Examples for Python API: FastAPI, Django, Flask, Other

3. **What is the database / data storage?** (if applicable)
   - SQLite, PostgreSQL, MySQL, MongoDB, Redis, DynamoDB, None, Other

4. **What is the styling approach?** (if frontend exists)
   - Tailwind CSS, CSS Modules, styled-components, Vanilla CSS, None, Other

5. **Any key libraries or integrations already decided?** (free text — e.g., "better-auth for authentication", "Stripe for payments", "TipTap for rich text editing")

6. **Package manager?**
   - npm, yarn, pnpm, bun, Other

---

### Phase 3: Core Features

Ask the user:

1. **List the core features of this project.** (free text — ask them to list as bullet points or comma-separated)
   - Example: "User auth, note CRUD, rich text editor, public sharing via link"

2. **Does this project require authentication?** If yes:
   - What auth method? (email/password, OAuth, magic link, API keys, other)
   - What auth library or service? (better-auth, next-auth, clerk, auth0, custom, other)

3. **Are there distinct user roles or permission levels?** (e.g., admin/user, free/paid tiers)

---

### Phase 4: Data Model (Detailed mode only)

Ask the user:

1. **What are the main entities / data models?** (free text — e.g., "Users, Notes, Tags, Comments")

2. For each entity, ask:
   - What are the key fields? (name and rough type — don't require exhaustive detail)
   - What are the relationships to other entities? (belongs to, has many, etc.)

3. **Any specific indexes or constraints you know about?** (optional, free text)

If the user doesn't know detailed fields yet, note that in the spec and move on. Do not pressure for details they haven't decided.

---

### Phase 5: API Design (Detailed mode only, if applicable)

Ask the user:

1. **What API style?** REST, GraphQL, tRPC, server actions only, Other

2. **What are the main API endpoint groups?** (free text — e.g., "/api/notes, /api/auth, /api/users")

3. For each endpoint group, ask:
   - What operations? (list, create, read, update, delete, other)
   - Any notable request/response shapes they already know?

If the user doesn't have API details yet, document what's known and mark the rest as TBD.

---

### Phase 6: Frontend / UI (Detailed mode only, if applicable)

Ask the user:

1. **What are the main pages or screens?**
   - e.g., Landing page, Dashboard, Editor, Settings, Public view

2. **What are the key interactive components?**
   - e.g., Rich text editor, data table, form wizard, drag-and-drop

3. **Any specific layout or navigation patterns?**
   - e.g., Sidebar nav, top nav with breadcrumbs, tab-based

---

### Phase 7: Non-Functional Requirements

Ask the user (can be a single multi-select question):

Which of these are important for this project?
- Performance targets (ask for specifics if selected)
- Security requirements beyond auth
- Accessibility standards
- Internationalization / localization
- Offline support
- SEO requirements
- Rate limiting
- Logging / monitoring

For each selected item, ask a brief follow-up if needed.

---

### Phase 8: Development Workflow (Optional)

Ask:
1. **Any specific dev workflow preferences?** (testing framework, CI/CD, linting, formatting)
2. **What are the dev commands?** (e.g., `bun dev`, `npm run build`)
   - If unknown, skip — these can be filled in later.

---

## Output: Generate SPEC.MD

After gathering all information, use the `Write` tool to create `SPEC.MD` in the project root.

### SPEC.MD Structure

Adapt this structure based on project type and mode. Omit sections that don't apply (e.g., no "Frontend" section for a CLI tool, no "API Design" for a frontend-only app).

```markdown
# Technical Specification – {Project Name}

## 1. Overview
- 1-2 paragraph description
- ### Core Features (bullet list)
- ### Tech Stack (language, framework, DB, key libs)

## 2. Architecture
- ### High-Level Architecture (frontend, backend, DB, runtime, auth — whatever applies)
- ### Application Layers (presentation, API, data access — adapt to project type)

## 3. Functional Requirements
- ### 3.x {Feature Group} (one subsection per feature domain)
  - User-facing capabilities described concisely
  - Behavior details where known

## 4. Non-Functional Requirements
- Performance, Security, Reliability, Maintainability, UX — as applicable

## 5. Data Model & Database Schema
- Table/collection definitions with SQL or schema notation
- Field tables with Type and Description columns
- Indexes and constraints

## 6. Backend: DB & API Layer
- Database access module (file path, helper functions)
- Repository/service functions with TypeScript (or relevant language) signatures

## 7. API Design
- Auth requirements
- Endpoint table or per-endpoint documentation with method, path, request/response shapes

## 8. Frontend — Pages & Components
- Route table
- Layout & navigation description
- Key components with props/purpose

## 9. Key Integration Details
- Third-party library configurations and usage patterns

## 10. Styling
- Approach and conventions

## 11. Security Considerations
- Auth enforcement, authorization, input validation, XSS prevention, etc.

## 12. Development Workflow
- Ordered build/implementation steps
```

### Writing Guidelines

- Write only what the user has provided or confirmed. Do not invent features, endpoints, or fields.
- For information the user deferred or didn't know, write `[TBD]` in that section.
- Use concrete types and names where provided, generic placeholders where not.
- Keep the tone technical and direct — no marketing language.
- Include SQL `CREATE TABLE` statements for relational DBs when the user provided field details.
- Include TypeScript (or relevant language) type definitions and function signatures where applicable.
- For **Quick mode**, collapse sections 5–12 into brief notes or omit entirely.

### After Writing

Inform the user:
- The SPEC.MD file has been created.
- Suggest they reference it in their CLAUDE.md (e.g., `Read @SPEC.MD for architecture and database details.`)
- Remind them they can re-run this prompt to expand `[TBD]` sections later as decisions are made.
