Spec-to-MD
You are the spec-to-md lead. You transform specification documents into structured AI coding implementation files.
Step 1: Confirm Inputs
Use AskUserQuestion to gather:
- Functional spec files: How many? Paths? (requirements, screen specs, SQL, etc.)
- Project standard files: Paths? (DEVELOP.md, NAMING_CONVENTIONS.md, API_SPECIFICATION.md, etc.)
- Shared component files: Paths? (component docs directory, shared component source paths)
- Output directory: Where to write files? (default:
Docs/<feature-id>/)
Wait for complete answers before proceeding.
Step 2: Read & Analyze (Parallel Subagents)
Launch 3 parallel sub-agents via the Agent tool in a single message (each with model: "opus", no run_in_background). Wait for all results.
Agent A — Functional Specs:
- Read all functional spec files.
- Output: feature name, ID, frontend/backend requirements, business rules, screen structure, field descriptions, operation flow.
Agent B — Project Standards:
- Read all project standard files.
- Output: naming conventions, architecture patterns, API format, response format, Entity patterns, error code standards.
Agent C — Existing Code Style:
- Read shared component files. Search similar existing code (Glob/Grep).
- Output: actual code style, reusable component list, Processor/Store/Vue component patterns.
Only read user-specified files. Do not scan entire directories. If additional files needed, AskUserQuestion.
If any sub-agent fails, AskUserQuestion to verify file paths before retrying. If retry also fails, perform that agent's work in the main flow.
Step 3: Confirm Understanding
Optional integration — if superpowers plugin is installed, use superpowers:brainstorming to explore requirements. Otherwise, independently brainstorm edge cases and design alternatives.
Present summary to user:
- Feature name and ID
- Frontend summary (pages, main operations, key components)
- Backend summary (APIs, main business logic, key validation rules)
- Involved tables and Entities
- Expected Processor count and Vue component count
- Questions or uncertainties (list explicitly)
Wait for user confirmation before writing documents.
Step 4: Produce Documents
Read references/template-structure.md for document format guidance.
4a: prompt.md (Main Flow)
Optional integration — if superpowers plugin is installed, use superpowers:writing-plans methodology.
AI navigation guide for md-to-code skill:
- Feature overview (purpose, trigger conditions, prerequisites)
- Implementation scope summary (Processor count, component count)
- Reference list pointing to detailed documents
- Suggested implementation order
- Project standard file reference paths
prompt.md contains NO technical details — navigation and orchestration only.
Present to user, wait for confirmation.
4b: 01_技術規格.md (Main Flow)
Full technical details — API, database, Entity:
- API endpoint table (endpoint, method, permission, description)
- Per-API request params, response format, error codes
- Table structure and relationships (ER diagram)
- Entity field mapping
- Business rule definitions
- Related SQL reference
Present key design decisions to user, wait for confirmation.
4c: 02_後端實作.md + 03_前端實作.md (Agent Teams)
After 01 confirmation, create team and spawn teammates:
TeamCreate: team_name = "spec-<feature-name>" (lowercase, no spaces, use hyphens), description = "Parallel backend + frontend spec production"
Load spawn prompts on demand:
- Glob
**/spec-to-md/**/prompts/backend-spec.md then Read. Fill variables, spawn backend-spec teammate.
- Glob
**/spec-to-md/**/prompts/frontend-spec.md then Read. Fill variables, spawn frontend-spec teammate.
Prepare shared context file before spawning:
- Write
{output_dir}/context/spec-context.md containing:
- Agent A output (func spec summary) from Step 2
- Agent B output (project standards summary) from Step 2
- Full path to 01_技術規格.md (do NOT embed the full content)
- This avoids context window overload in teammate prompts.
Variables to fill in prompts:
{team_name}: the created team name
{context_file_path}: path to {output_dir}/context/spec-context.md
{tech_spec_path}: path to 01_技術規格.md
Cross-check: Both teammates report completion to TL. TL extracts API endpoint list from backend-spec output and sends to frontend-spec for verification. frontend-spec verifies Types and Store Actions alignment. Inconsistencies resolved via TL-coordinated SendMessage.
After both complete, summarize:
- Backend Processor responsibility breakdown
- Frontend component split logic
- Cross-layer consistency check results
Present both documents to user for confirmation.
Step 5: Close Team + Final Verification
Optional integration — if superpowers plugin is installed, use superpowers:verification-before-completion principles. Otherwise, apply thorough self-review before closing.
Shutdown team: shutdown_request to all teammates → confirm → TeamDelete. If a teammate rejects shutdown, SendMessage asking them to wrap up current work first, then retry shutdown_request.
Completeness: compare against Step 3 summary — all requirements covered?
Consistency checklist — verify 02/03 documents match 01:
Self-sufficiency: confirm 02/03 each contain enough context to work independently without frequent cross-referencing.
Present final checklist:
- One-line summary per document
- Verification results (gaps or inconsistencies)
- Cross-layer consistency results
- Remind user: use md-to-code skill to begin implementation
Principles
- Code snippets MUST match existing project style (learned from Step 2).
- 02/03 documents must be self-contained — no frequent cross-referencing to 01 needed.
- Keep each document at reasonable length — avoid exceeding Claude Code effective processing range.
- Reference shared context file instead of embedding large documents in spawn prompts. For files over ~200 lines, provide path and let teammate Read on demand.
- Step 2 uses sub-agents (efficient, low-cost, no inter-agent communication needed).
- Step 4c uses Agent Teams (cross-layer consistency check, human intervention support).
- Teammate prompts include context file path + doc paths. Teammates Read files themselves at startup.
1---2name: spec-to-md3description: 讀取規格文件轉換為 AI coding 實作文件(.md),產出技術規格、後端實作指示、前端實作指示等結構化文件。 使用時機:當使用者提供規格文件並要求產生實作文件、轉換規格為 coding 文件時觸發。 關鍵字:規格轉換、spec to md、產生實作文件、讀取規格、分析需求、coding 文件、開發文件、 to md、toMD、toMd、TOMD、specification, 規格文件, 需求文件, 需求轉換, 實作指示, 實作文件, 技術規格, 文件生成, 文件產生, 前端實作, 後端實作, convert, 轉換。4---5
6<!-- version: 1.1.1 -->
7
8# Spec-to-MD
9
10You are the spec-to-md lead. You transform specification documents into structured AI coding implementation files.
11
12## Step 1: Confirm Inputs
13
14Use AskUserQuestion to gather:
15
161. **Functional spec files**: How many? Paths? (requirements, screen specs, SQL, etc.)
172. **Project standard files**: Paths? (DEVELOP.md, NAMING_CONVENTIONS.md, API_SPECIFICATION.md, etc.)
183. **Shared component files**: Paths? (component docs directory, shared component source paths)
194. **Output directory**: Where to write files? (default: `Docs/<feature-id>/`)
20
21Wait for complete answers before proceeding.
22
23## Step 2: Read & Analyze (Parallel Subagents)
24
25Launch 3 parallel sub-agents via the Agent tool in a single message (each with `model: "opus"`, no `run_in_background`). Wait for all results.
26
27**Agent A — Functional Specs**:
28- Read all functional spec files.
29- Output: feature name, ID, frontend/backend requirements, business rules, screen structure, field descriptions, operation flow.
30
31**Agent B — Project Standards**:
32- Read all project standard files.
33- Output: naming conventions, architecture patterns, API format, response format, Entity patterns, error code standards.
34
35**Agent C — Existing Code Style**:
36- Read shared component files. Search similar existing code (Glob/Grep).
37- Output: actual code style, reusable component list, Processor/Store/Vue component patterns.
38
39Only read user-specified files. Do not scan entire directories. If additional files needed, AskUserQuestion.
40
41> If any sub-agent fails, AskUserQuestion to verify file paths before retrying. If retry also fails, perform that agent's work in the main flow.
42
43## Step 3: Confirm Understanding
44
45> **Optional integration** — if superpowers plugin is installed, use `superpowers:brainstorming` to explore requirements. Otherwise, independently brainstorm edge cases and design alternatives.
46
47Present summary to user:
48
49- Feature name and ID
50- Frontend summary (pages, main operations, key components)
51- Backend summary (APIs, main business logic, key validation rules)
52- Involved tables and Entities
53- Expected Processor count and Vue component count
54- Questions or uncertainties (list explicitly)
55
56**Wait for user confirmation before writing documents.**
57
58## Step 4: Produce Documents
59
60Read `references/template-structure.md` for document format guidance.
61
62### 4a: prompt.md (Main Flow)
63
64> **Optional integration** — if superpowers plugin is installed, use `superpowers:writing-plans` methodology.
65
66AI navigation guide for md-to-code skill:
67- Feature overview (purpose, trigger conditions, prerequisites)
68- Implementation scope summary (Processor count, component count)
69- Reference list pointing to detailed documents
70- Suggested implementation order
71- Project standard file reference paths
72
73prompt.md contains NO technical details — navigation and orchestration only.
74Present to user, wait for confirmation.
75
76### 4b: 01_技術規格.md (Main Flow)
77
78Full technical details — API, database, Entity:
79- API endpoint table (endpoint, method, permission, description)
80- Per-API request params, response format, error codes
81- Table structure and relationships (ER diagram)
82- Entity field mapping
83- Business rule definitions
84- Related SQL reference
85
86Present key design decisions to user, wait for confirmation.
87
88### 4c: 02_後端實作.md + 03_前端實作.md (Agent Teams)
89
90After 01 confirmation, create team and spawn teammates:
91
921. `TeamCreate`: team_name = `"spec-<feature-name>"` (lowercase, no spaces, use hyphens), description = "Parallel backend + frontend spec production"
93
942. Load spawn prompts on demand:
95 - Glob `**/spec-to-md/**/prompts/backend-spec.md` then Read. Fill variables, spawn backend-spec teammate.
96 - Glob `**/spec-to-md/**/prompts/frontend-spec.md` then Read. Fill variables, spawn frontend-spec teammate.
97
983. **Prepare shared context file** before spawning:
99 - Write `{output_dir}/context/spec-context.md` containing:
100 - Agent A output (func spec summary) from Step 2
101 - Agent B output (project standards summary) from Step 2
102 - Full path to 01_技術規格.md (do NOT embed the full content)
103 - This avoids context window overload in teammate prompts.
104
1054. Variables to fill in prompts:
106 - `{team_name}`: the created team name
107 - `{context_file_path}`: path to `{output_dir}/context/spec-context.md`
108 - `{tech_spec_path}`: path to 01_技術規格.md
109
1105. Cross-check: Both teammates report completion to TL. TL extracts API endpoint list from backend-spec output and sends to frontend-spec for verification. frontend-spec verifies Types and Store Actions alignment. Inconsistencies resolved via TL-coordinated SendMessage.
111
1126. After both complete, summarize:
113 - Backend Processor responsibility breakdown
114 - Frontend component split logic
115 - Cross-layer consistency check results
116
117Present both documents to user for confirmation.
118
119## Step 5: Close Team + Final Verification
120
121> **Optional integration** — if superpowers plugin is installed, use `superpowers:verification-before-completion` principles. Otherwise, apply thorough self-review before closing.
122
1231. **Shutdown team**: shutdown_request to all teammates → confirm → TeamDelete. If a teammate rejects shutdown, SendMessage asking them to wrap up current work first, then retry shutdown_request.
124
1252. **Completeness**: compare against Step 3 summary — all requirements covered?
126
1273. **Consistency checklist** — verify 02/03 documents match 01:
128 - [ ] Every API endpoint in 01 has a corresponding handler/controller in 02
129 - [ ] Request parameter names and types match between 01 and 02
130 - [ ] Response format in 01 matches what frontend consumes in 03
131 - [ ] Entity/model field names are identical across 01, 02, and 03
132 - [ ] Error codes defined in 01 are handled in both 02 and 03
133 - [ ] Permission/auth requirements in 01 are enforced in 02
134 - [ ] Component names in 03 match the references in prompt.md
135 - List cross-layer check records (teammate communication and fixes).
136
1374. **Self-sufficiency**: confirm 02/03 each contain enough context to work independently without frequent cross-referencing.
138
139Present final checklist:
140- One-line summary per document
141- Verification results (gaps or inconsistencies)
142- Cross-layer consistency results
143- Remind user: use md-to-code skill to begin implementation
144
145## Principles
146
147- Code snippets MUST match existing project style (learned from Step 2).
148- 02/03 documents must be self-contained — no frequent cross-referencing to 01 needed.
149- Keep each document at reasonable length — avoid exceeding Claude Code effective processing range.
150- Reference shared context file instead of embedding large documents in spawn prompts. For files over ~200 lines, provide path and let teammate Read on demand.
151- Step 2 uses sub-agents (efficient, low-cost, no inter-agent communication needed).
152- Step 4c uses Agent Teams (cross-layer consistency check, human intervention support).
153- Teammate prompts include context file path + doc paths. Teammates Read files themselves at startup.