Project Specification Writer (Instruction-only)
Goal
When invoked, produce a single, comprehensive specification document for the current repository/project with all required sections:
- Architecture and technology choices
- Data model
- Key processes
- Pseudocode
- System context diagram
- Container/deployment overview
- Module relationship diagram (Backend / Frontend)
- Sequence diagram
- ER diagram
- Class diagram (key backend classes)
- Flowchart
- State diagram
Default output file: docs/specification.md
(If docs/ does not exist, create it. If user requests another path, follow it.)
Invocation behavior
Minimal questions policy
Ask at most 5 clarifying questions only if the repo does not contain enough information to avoid unsafe guessing.
If information is missing, proceed with best-effort inference and add an “Assumptions & Open Questions” section near the top.
No hallucinations rule
Do not invent details. If you cannot locate evidence in the repo, label as:
- Assumption
- Unknown/TBD
- Open question
Repo reconnaissance workflow (do this first)
- Identify repo root and high-level structure:
- Look for:
README*, docs/, architecture/, ADR*, design*, SPEC*.
- Detect tech stack and runtime:
- Backend signals:
pyproject.toml, requirements.txt, go.mod, pom.xml, build.gradle, .csproj, package.json (server), Dockerfile
- Frontend signals:
package.json, pnpm-lock.yaml, yarn.lock, vite.config.*, next.config.*
- Detect data layer:
- DB migrations:
migrations/, prisma/schema.prisma, alembic/, db/schema.sql, knexfile.*
- ORM models:
models/, entities/, schema/
- Detect deployment:
docker-compose.yml, Dockerfile*, k8s/, helm/, .github/workflows/*, terraform/
- Collect “evidence pointers” while reading (file paths + brief notes).
You will use these pointers throughout the spec.
Output requirements (strict)
- Produce one Markdown document.
- Use clear headings matching the 12 required items.
- All diagrams must be in fenced Mermaid blocks:
```mermaid
...
```
- Each section must be project-specific (grounded in repo findings).
- Keep diagrams at the right abstraction level:
- Context/Container: high-level systems and deployed containers/services
- Module diagram: major frontend/backend modules and their dependencies
- Class diagram: only key backend classes (5–15), not every class
Specification Document Template (write exactly this structure)
{{Project Name}} — Specification
Version: {{date}}
Repo: {{repo identifier if known}}
Primary stack: {{inferred stack}}
Assumptions & Open Questions
- Assumption: ...
- Open question: ...
1. Architecture and technology choices
1.1 Architecture overview
- System style (e.g., monolith, modular monolith, microservices)
- Key components and responsibilities
- Trust boundaries (auth, secrets, network zones) if applicable
1.2 Technology choices (with rationale)
Provide a table:
| Area |
Choice |
Evidence |
Why this choice |
Alternatives considered |
1.3 Non-functional requirements (NFRs)
- Performance, availability, security, observability, compliance, cost
- What the repo suggests (or what’s missing)
2. Data model
2.1 Conceptual model
- List core entities and what they represent
- Identify ownership and lifecycle boundaries
2.2 Logical model (tables/collections)
Provide a table:
| Entity/Table |
Primary key |
Key fields |
Relationships |
Notes |
2.3 Data integrity & constraints
- Uniqueness, foreign keys, soft delete, audit fields, tenancy strategy, etc.
3. Key processes
List 3–7 “key processes” (system behaviors) using this structure:
- Process name
- Trigger:
- Inputs:
- Outputs:
- Key steps:
- Error cases:
- Observability (logs/metrics/traces):
4. Pseudocode
For each key process, provide pseudocode:
- Use clear function signatures
- Include validation, error handling, retries/transactions where relevant
Example format:
function ProcessName(input):
validate input
begin transaction (if needed)
...
return result
1---2name: project-specification-writer3description: Generate a complete software specification document for the current project/repo, including architecture, data model, key processes, pseudocode, and Mermaid diagrams (context, container/deployment, module relations, sequence, ER, class, flowchart, state).4---56# Project Specification Writer (Instruction-only)78## Goal9When invoked, produce a **single, comprehensive specification document** for the **current repository/project** with **all required sections**:10111. Architecture and technology choices 122. Data model 133. Key processes 144. Pseudocode 155. System context diagram 166. Container/deployment overview 177. Module relationship diagram (Backend / Frontend) 188. Sequence diagram 199. ER diagram 2010. Class diagram (key backend classes) 2111. Flowchart 2212. State diagram 2324**Default output file:** `docs/specification.md` 25(If `docs/` does not exist, create it. If user requests another path, follow it.)2627---2829## Invocation behavior30### Minimal questions policy31Ask **at most 5** clarifying questions **only if** the repo does not contain enough information to avoid unsafe guessing. 32If information is missing, proceed with best-effort inference and add an **“Assumptions & Open Questions”** section near the top.3334### No hallucinations rule35Do **not** invent details. If you cannot locate evidence in the repo, label as:36- **Assumption**37- **Unknown/TBD**38- **Open question**3940---4142## Repo reconnaissance workflow (do this first)431. Identify repo root and high-level structure:44 - Look for: `README*`, `docs/`, `architecture/`, `ADR*`, `design*`, `SPEC*`.452. Detect tech stack and runtime:46 - Backend signals: `pyproject.toml`, `requirements.txt`, `go.mod`, `pom.xml`, `build.gradle`, `.csproj`, `package.json` (server), `Dockerfile`47 - Frontend signals: `package.json`, `pnpm-lock.yaml`, `yarn.lock`, `vite.config.*`, `next.config.*`483. Detect data layer:49 - DB migrations: `migrations/`, `prisma/schema.prisma`, `alembic/`, `db/schema.sql`, `knexfile.*`50 - ORM models: `models/`, `entities/`, `schema/`514. Detect deployment:52 - `docker-compose.yml`, `Dockerfile*`, `k8s/`, `helm/`, `.github/workflows/*`, `terraform/`535. Collect “evidence pointers” while reading (file paths + brief notes). 54 You will use these pointers throughout the spec.5556---5758## Output requirements (strict)59- Produce **one Markdown document**.60- Use **clear headings** matching the 12 required items.61- All diagrams must be in fenced Mermaid blocks: 62 \`\`\`mermaid 63 ... 64 \`\`\`65- Each section must be **project-specific** (grounded in repo findings).66- Keep diagrams at the right abstraction level:67 - **Context/Container**: high-level systems and deployed containers/services68 - **Module diagram**: major frontend/backend modules and their dependencies69 - **Class diagram**: only key backend classes (5–15), not every class7071---7273# Specification Document Template (write exactly this structure)7475# {{Project Name}} — Specification76**Version:** {{date}} 77**Repo:** {{repo identifier if known}} 78**Primary stack:** {{inferred stack}} 7980## Assumptions & Open Questions81- Assumption: ...82- Open question: ...8384## 1. Architecture and technology choices85### 1.1 Architecture overview86- System style (e.g., monolith, modular monolith, microservices)87- Key components and responsibilities88- Trust boundaries (auth, secrets, network zones) if applicable8990### 1.2 Technology choices (with rationale)91Provide a table:92| Area | Choice | Evidence | Why this choice | Alternatives considered |93|---|---|---|---|---|9495### 1.3 Non-functional requirements (NFRs)96- Performance, availability, security, observability, compliance, cost97- What the repo suggests (or what’s missing)9899## 2. Data model100### 2.1 Conceptual model101- List core entities and what they represent102- Identify ownership and lifecycle boundaries103104### 2.2 Logical model (tables/collections)105Provide a table:106| Entity/Table | Primary key | Key fields | Relationships | Notes |107|---|---|---|---|---|108109### 2.3 Data integrity & constraints110- Uniqueness, foreign keys, soft delete, audit fields, tenancy strategy, etc.111112## 3. Key processes113List 3–7 “key processes” (system behaviors) using this structure:114- **Process name**115 - Trigger:116 - Inputs:117 - Outputs:118 - Key steps:119 - Error cases:120 - Observability (logs/metrics/traces):121122## 4. Pseudocode123For each key process, provide pseudocode:124- Use clear function signatures125- Include validation, error handling, retries/transactions where relevant126127Example format:128```text129function ProcessName(input):130 validate input131 begin transaction (if needed)132 ...133 return result