Skip to content

Commit c266fdd

Browse files
author
mizuki
authored
feat: Add spec.design prompt for comprehensive system design generation (#5)
1 parent 39b7201 commit c266fdd

File tree

6 files changed

+333
-21
lines changed

6 files changed

+333
-21
lines changed

README.md

Lines changed: 181 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,194 @@
1-
# my-lib
1+
# Spec Pilot
22

3-
A TypeScript library template using **pnpm**, **tsdown**, **ESLint**, **Prettier**, and **Vitest**.
3+
**スペック駆動開発をサポートするMCP (Model Context Protocol) サーバー**
44

5-
## Quick start
5+
Spec Pilotは、システム仕様の作成から設計まで、開発プロセス全体を構造化されたワークフローで支援するMCPサーバーです。EARS (Easy Approach to Requirements Syntax) 形式での要件定義と包括的な設計ドキュメント生成を自動化します。
66

7-
```bash
8-
pnpm i
9-
pnpm build
10-
pnpm test
7+
## 概要
8+
9+
- **構造化された開発プロセス**: 仕様 → 要件 → 設計の段階的なワークフロー
10+
- **EARS形式の要件管理**: テスト可能で明確な受け入れ基準
11+
- **包括的な設計生成**: アーキテクチャから実装戦略まで
12+
- **多言語サポート**: 日本語・英語での出力対応
13+
- **MCPプロトコル**: AI エージェントとの統合が容易
14+
15+
## 主な機能
16+
17+
### 1. ワークスペース初期化 (`spec.init`)
18+
19+
- `.kiro/specs/<slug>` ディレクトリの作成
20+
- プロジェクト設定ファイルの生成
21+
- 言語設定の保存
22+
23+
### 2. 要件収集 (`spec.create-requirements`)
24+
25+
- ユーザーストーリーの構造化
26+
- EARS形式の受け入れ基準生成
27+
- テスト可能な要件ドキュメント作成
28+
29+
### 3. 設計ドキュメント生成 (`spec.design`)
30+
31+
- システムアーキテクチャの設計
32+
- コンポーネント設計とAPI仕様
33+
- 移行戦略とテスト戦略
34+
- パフォーマンスとセキュリティ考慮事項
35+
36+
### 4. 挨拶機能 (`greeting`)
37+
38+
- 基本的な挨拶とポリシー表示
39+
40+
## 使用方法
41+
42+
Spec Pilotは4つのMCPプロンプトを提供します。各プロンプトは特定の引数を受け取り、構造化されたプロンプトを生成します。
43+
44+
### 利用可能なプロンプト
45+
46+
| プロンプト名 | 説明 | 必須引数 | オプション引数 |
47+
| -------------------------- | -------------------- | -------------------------- | ---------------- |
48+
| `greeting` | 挨拶とポリシー表示 | `name` (string) | - |
49+
| `spec.init` | ワークスペース初期化 | `specDescription` (string) | `locale` (ja/en) |
50+
| `spec.create-requirements` | 要件定義生成 | `specName` (string) | - |
51+
| `spec.design` | 設計ドキュメント生成 | `specName` (string) | - |
52+
53+
### 使用例
54+
55+
#### Claude Desktopの場合
56+
57+
**プロジェクト初期化:**
58+
59+
```
60+
@spec.init specDescription="ユーザー認証システムの構築" locale="ja"
61+
```
62+
63+
**要件定義生成:**
64+
65+
```
66+
@spec.create-requirements specName="user-auth-system"
67+
```
68+
69+
**設計ドキュメント生成:**
70+
71+
```
72+
@spec.design specName="user-auth-system"
73+
```
74+
75+
#### Amazon Q CLIの場合
76+
77+
**プロジェクト初期化:**
78+
79+
```
80+
@spec.init "ユーザー認証システムの構築" "ja"
1181
```
1282

13-
## Scripts
83+
**要件定義生成:**
1484

15-
- `pnpm build` — bundle with tsdown (ESM + CJS + d.ts, sourcemaps)
16-
- `pnpm test` — run unit tests with Vitest
17-
- `pnpm lint` / `pnpm lint:fix` — ESLint
18-
- `pnpm format` / `pnpm format:write` — Prettier
19-
- `pnpm typecheck` — TypeScript type check w/o emit
85+
```
86+
@spec.create-requirements "user-auth-system"
87+
```
88+
89+
**設計ドキュメント生成:**
90+
91+
```
92+
@spec.design "user-auth-system"
93+
```
94+
95+
## ファイル詳細
96+
97+
### グローバル設定 (`.kiro/spec-pilot.json`)
98+
99+
```json
100+
{
101+
"locale": "ja"
102+
}
103+
```
104+
105+
### プロジェクト設定 (`config.json`)
106+
107+
```json
108+
{
109+
"title": "project-name",
110+
"description": "プロジェクトの説明"
111+
}
112+
```
113+
114+
### 生成されるドキュメント
115+
116+
- **`requirements.md`**: EARS形式の受け入れ基準を含む構造化された要件ドキュメント
117+
- **`design.md`**: アーキテクチャ、コンポーネント設計、移行戦略等を含む包括的な設計ドキュメント
118+
119+
## 設定
120+
121+
### サポート言語
20122

21-
## Publish
123+
- `ja` (日本語) - デフォルト
124+
- `en` (英語)
22125

23-
This template sets `prepack` to build & test before publishing.
126+
言語設定は`.kiro/spec-pilot.json`ファイルで管理され、初回実行時に自動作成されます。
127+
128+
## 開発・ビルド
129+
130+
### 開発スクリプト
24131

25132
```bash
26-
pnpm publish --access public
133+
# 開発
134+
pnpm build # TypeScriptビルド
135+
pnpm test # テスト実行
136+
pnpm test:watch # テスト監視モード
137+
138+
# コード品質
139+
pnpm lint # ESLintチェック
140+
pnpm lint:fix # ESLint自動修正
141+
pnpm format # Prettierチェック
142+
pnpm format:write # Prettier自動フォーマット
143+
pnpm typecheck # 型チェック
144+
145+
# その他
146+
pnpm clean # ビルド成果物削除
27147
```
28148

29-
## Notes
149+
### ビルド成果物
150+
151+
- `dist/index.js` - メインのMCPサーバー
152+
- `dist/index.d.ts` - TypeScript型定義
153+
- `prompts/` - プロンプトテンプレート
154+
155+
## ロードマップ
156+
157+
### 完了済み機能
158+
159+
- [x] ワークスペース初期化 (`spec.init`)
160+
- [x] 要件定義生成 (`spec.create-requirements`)
161+
- [x] 設計ドキュメント生成 (`spec.design`)
162+
- [x] 多言語サポート (日本語・英語)
163+
- [x] EARS形式の受け入れ基準生成
164+
165+
### 開発予定機能
166+
167+
- [ ] **タスク生成機能 (`spec.tasks`)** - 要件・設計からの実装タスク自動生成
168+
- [ ] 要件に基づく開発タスクの分解
169+
- [ ] 設計ドキュメントからの実装手順生成
170+
- [ ] GitHub Issues / プロジェクト管理ツール連携
171+
- [ ] 優先度付けとスケジューリング支援
172+
173+
- [ ] **npmパッケージ公開**
174+
- [ ] パッケージメタデータの最適化
175+
- [ ] バージョン管理自動化
176+
- [ ] CI/CDパイプラインによる自動公開
177+
- [ ] npmレジストリへの安定版リリース
178+
179+
## 技術仕様
180+
181+
- **言語**: TypeScript 5.6+
182+
- **ランタイム**: Node.js 22+
183+
- **パッケージマネージャー**: pnpm
184+
- **ビルドツール**: tsdown
185+
- **テストフレームワーク**: Vitest
186+
- **プロトコル**: Model Context Protocol 1.18+
187+
188+
## ライセンス
189+
190+
MIT License - 詳細は [LICENSE](./LICENSE) を参照
191+
192+
## 作者
30193

31-
- tsdown infers `target` from `engines.node`. Update `engines.node` if needed.
32-
- Add peer deps to `external` in `tsdown.config.ts` for libraries.
194+
mzkmnk

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "spec-pilot",
33
"version": "0.0.1",
4-
"description": "Spec Pilot MCP",
4+
"description": "MCP (Model Context Protocol) server supporting spec-driven development. Automates EARS-format requirements definition and comprehensive design document generation.",
55
"license": "MIT",
66
"author": "mzkmnk",
77
"type": "module",

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
44
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
55
import { z } from "zod";
66
import { registerGreetingPrompt } from "./prompts/greeting";
7+
import { registerSpecDesignPrompt } from "./prompts/spec-design";
78
import { registerSpecInitPrompt } from "./prompts/spec-init";
89
import { registerSpecRequirementsPrompt } from "./prompts/spec-requirements";
910

@@ -30,6 +31,7 @@ server.registerTool(
3031
registerGreetingPrompt(server);
3132
registerSpecInitPrompt(server);
3233
registerSpecRequirementsPrompt(server);
34+
registerSpecDesignPrompt(server);
3335

3436
const transport = new StdioServerTransport();
3537
await server.connect(transport);

src/prompts/spec-design.ts

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2+
import { z } from "zod";
3+
import { SPEC_PILOT_CONSTANTS } from "../shared/constants";
4+
import { createLanguagePolicySection } from "../shared/language-policy";
5+
import { resolveStoredLocale } from "../shared/locale";
6+
import { createPromptResponse, joinPromptSections } from "../shared/prompt-factory";
7+
8+
export const registerSpecDesignPrompt = (server: McpServer) => {
9+
server.registerPrompt(
10+
"spec.design",
11+
{
12+
title: "create system design",
13+
description: "Generate comprehensive system design document from requirements.",
14+
argsSchema: {
15+
specName: z
16+
.string()
17+
.min(3, "Please provide at least 3 characters for the spec name.")
18+
.describe(
19+
"The folder name created by spec.init (slug). Used to locate the spec workspace.",
20+
),
21+
},
22+
},
23+
async ({ specName }) => {
24+
// ロケール解決(設定ファイルの更新のため実行するが、この場所では値は使用しない)
25+
resolveStoredLocale();
26+
27+
const prompt = joinPromptSections(
28+
"# Spec Design Development",
29+
"",
30+
createLanguagePolicySection(SPEC_PILOT_CONSTANTS.CONFIG_FILE),
31+
"",
32+
"## Inputs",
33+
`- specName: ${specName}`,
34+
"- specDescription: (read from config.json and treat as authoritative source)",
35+
"- requirements: (read from requirements.md and analyze for design implications)",
36+
"",
37+
"## Workspace Context",
38+
`- Base directory: \`${SPEC_PILOT_CONSTANTS.BASE_DIR}\``,
39+
`- Spec folder path: \`${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}\``,
40+
`- Mandatory config file: \`${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}/${SPEC_PILOT_CONSTANTS.SPEC_CONFIG_FILE}\``,
41+
`- Requirements file to read: \`${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}/${SPEC_PILOT_CONSTANTS.REQUIREMENTS_FILE}\``,
42+
`- Design file to create/update: \`${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}/${SPEC_PILOT_CONSTANTS.DESIGN_FILE}\``,
43+
"",
44+
"## Goal",
45+
"- Transform structured requirements into a comprehensive, implementable system design.",
46+
"- Generate a design document that enables seamless transition from specification to implementation.",
47+
"",
48+
"## Tasks",
49+
"1. Verify the workspace:",
50+
` - Ensure \`${SPEC_PILOT_CONSTANTS.BASE_DIR}\` and \`${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}\` are directories.`,
51+
` - Confirm \`${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}/${SPEC_PILOT_CONSTANTS.SPEC_CONFIG_FILE}\` exists, parse as JSON, and capture the current title and description for context.`,
52+
` - Verify \`${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}/${SPEC_PILOT_CONSTANTS.REQUIREMENTS_FILE}\` exists and read its content for requirements analysis.`,
53+
" - Note any mismatches or missing files that could affect design generation.",
54+
"",
55+
"2. Analyze requirements:",
56+
" - Parse requirements.md to extract functional and non-functional requirements.",
57+
" - Identify system boundaries, key components, and integration points.",
58+
" - Determine appropriate architectural patterns based on requirements complexity and scale.",
59+
" - Extract technology constraints, performance requirements, and security considerations.",
60+
"",
61+
"3. Generate design document structure:",
62+
" - Create a comprehensive design document with these mandatory sections:",
63+
" - `# Design Document`",
64+
" - `## Overview` - concise summary of design goals and approach",
65+
" - `## Architecture` - system structure and component relationships",
66+
" - `## Component Design` - detailed component specifications",
67+
" - `## Data Flow` - data movement and processing patterns",
68+
" - `## Error Handling Strategy` - error management approach",
69+
" - `## Migration Strategy` - implementation phases and steps",
70+
" - `## Test Strategy` - testing approach and coverage",
71+
" - `## Performance Considerations` - scalability and optimization",
72+
" - `## Security` - security measures and compliance",
73+
"",
74+
"4. Create architectural representations:",
75+
" - Generate ASCII diagrams for system architecture using box-drawing characters.",
76+
" - Create Mermaid diagrams for complex flows when beneficial.",
77+
" - Include directory structures with clear file organization.",
78+
" - Show component interaction patterns with visual representations.",
79+
"",
80+
"5. Define implementation details:",
81+
" - Specify concrete technology choices with version numbers when relevant.",
82+
" - Provide code structure examples for key components.",
83+
" - Define API interfaces with request/response formats.",
84+
" - Include configuration examples and environment setup.",
85+
"",
86+
"6. Ensure design quality:",
87+
" - Verify all requirements are addressed in the design.",
88+
" - Ensure design is implementable with current technology standards.",
89+
" - Check for consistency across all sections.",
90+
" - Validate that migration strategy is realistic and phased.",
91+
"",
92+
"7. Write the design document:",
93+
` - Write to \`${SPEC_PILOT_CONSTANTS.DESIGN_FILE}\` in Markdown format.`,
94+
" - Use clear headings, bullet points, and code blocks for readability.",
95+
" - Include practical examples and concrete specifications.",
96+
" - Ensure each section provides actionable information for developers.",
97+
"",
98+
"## Design Document Requirements",
99+
"- **Overview**: Single paragraph summarizing the design approach and key architectural decisions.",
100+
"- **Architecture**: System structure with visual diagrams, technology stack, and component relationships.",
101+
"- **Component Design**: Detailed specifications for each major component including responsibilities and interfaces.",
102+
"- **Data Flow**: Visual representation of data movement through the system with explanatory text.",
103+
"- **Error Handling**: Comprehensive error management strategy across all system layers.",
104+
"- **Migration Strategy**: Phase-by-phase implementation plan with clear deliverables and dependencies.",
105+
"- **Test Strategy**: Testing approach covering unit, integration, and system-level testing.",
106+
"- **Performance**: Scalability considerations, optimization strategies, and performance metrics.",
107+
"- **Security**: Security measures, authentication/authorization, and compliance requirements.",
108+
"",
109+
"## Quality Standards",
110+
"- All architectural decisions must be justified based on requirements.",
111+
"- Code examples must be syntactically correct and follow best practices.",
112+
"- Visual diagrams must accurately represent system relationships.",
113+
"- Migration phases must be realistic and account for risk management.",
114+
"- Technical specifications must be detailed enough for implementation.",
115+
"",
116+
"## Checks",
117+
`- Report directory checks for \`${SPEC_PILOT_CONSTANTS.BASE_DIR}\` and \`${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}\`.`,
118+
`- Confirm \`${SPEC_PILOT_CONSTANTS.SPEC_CONFIG_FILE}\` was readable and summarize key fields (title, description).`,
119+
`- Verify \`${SPEC_PILOT_CONSTANTS.REQUIREMENTS_FILE}\` was accessible and summarize requirement count and complexity.`,
120+
"- Confirm the design document includes all 9 mandatory sections in the correct order.",
121+
"- Ensure architectural decisions align with extracted requirements.",
122+
"- Verify all diagrams are properly formatted and meaningful.",
123+
"- Check that implementation examples are concrete and actionable.",
124+
`- If writing failed, describe the error and propose next actions (permissions, missing files, invalid content).`,
125+
"",
126+
"## Output",
127+
"- IMPORTANT: Translate all headings, bullet labels, and explanatory text into the resolved output language.",
128+
"- Keep code fences, paths, identifiers, and technical terms unchanged unless translation improves clarity.",
129+
"- Maintain consistent terminology throughout the document.",
130+
"",
131+
"# Spec Design Result",
132+
`- specFolder: "${specName}"`,
133+
`- designFile: "${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}/${SPEC_PILOT_CONSTANTS.DESIGN_FILE}"`,
134+
`- workspaceCheck: "<directory, config, and requirements validation summary>"`,
135+
`- architecturalPattern: "<chosen architectural approach and justification>"`,
136+
`- componentCount: "<number of major components identified>"`,
137+
`- implementationComplexity: "<assessment of implementation complexity>"`,
138+
`- next: "<recommended follow-up prompt or action>"`,
139+
`- notes: "<design decisions, assumptions, or considerations>"`,
140+
"",
141+
"- If the workspace is invalid, requirements are missing, or information is insufficient, clearly state what needs to be fixed before retrying.",
142+
);
143+
144+
return createPromptResponse(prompt);
145+
},
146+
);
147+
};

src/prompts/spec-requirements.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export const registerSpecRequirementsPrompt = (server: McpServer) => {
8686
`- requirementsFile: "${SPEC_PILOT_CONSTANTS.BASE_DIR}/${specName}/${SPEC_PILOT_CONSTANTS.REQUIREMENTS_FILE}"`,
8787
`- workspaceCheck: "<directory and config validation summary>"`,
8888
`- highlights: "<representative requirements or decisions>"`,
89-
`- next: "<recommended follow-up prompt or action>"`,
89+
`- next: "Run @spec.design with specName=<folder>"`,
9090
`- notes: "<open questions or blockers>"`,
9191
"",
9292
"- If the workspace is invalid or information is missing, clearly state what needs to be fixed before retrying.",

0 commit comments

Comments
 (0)