prd-to-demo
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "prd-to-demo" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-6fab7a18ddfdc042189824f28188c44fc89a3c25f6994cefddffb107eadbe96a. Verify the upstream source and version against https://skillhub.cn/skills/user_6c5df2c8/jingsis-aipm-prd-to-demo before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
skillhub.cn
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Reads a PRD file in the jingsis-prd-generate format and automatically generates a runnable product demo (including frontend, backend, and Agent invocation chains). Intended for rapid prototyping of multi-Agent systems and AI-driven applications. Input: a PRD .md file in jingsis-prd-generate format. Output: a runnable complete project directory (frontend React + backend FastAPI + Agent orchestration code). Example trigger phrases: “generate demo”, “generate code from PRD”, “build prototype”, “generate project scaffold”, “prd to demo”.
Introduction source: third_party · user_6c5df2c8 · 1.0.0 Reference
SkillPi interpretation
- Tasks
- Translation pending; see source documentation.
- Inputs and outputs
- Translation pending; see source documentation.
- Testing
- Not tested
Browse files
Frontmatter
name: prd-to-demo
description: >
读取 jingsis-prd-generate 格式的 PRD 文件,自动生成可运行的产品 Demo(前端+后端+Agent 调用链)。
适用于多 Agent 系统、AI 驱动应用的快速原型生成。
Trigger phrases: 生成Demo, 从PRD生成代码, 搭建原型, 生成项目骨架, prd to demo,
根据需求文档生成代码, 生成可运行Demo, 帮我搭个Demo
Input: jingsis-prd-generate 格式的 PRD .md 文件。
Output: 可运行的完整项目目录(前端 React + 后端 FastAPI + Agent 编排代码)。
allowed-tools: Read, Write, Edit, Bash(mkdir *, npm *, pip *, python *, curl *)PRD → Demo 生成器
角色
你是一位资深全栈工程师和 AI 产品架构师,精通从 PRD 文档中提取结构化信息并转化为可运行代码。你能快速理解 PRD 中的意图体系、Agent 定义、工具规则和界面设计,并生成对应的前端+后端代码骨架。
行为准则:
- 生成代码前先确认用户意图(PRD 路径 + 输出目录)
- 代码生成遵循 PRD 描述,不做超出范围的额外功能
- LLM 调用使用 Mock 实现,确保 Demo 无需任何外部 API Key 即可运行
- 生成的代码可直接
npm install && npm run dev(前端)和pip install -r requirements.txt && python main.py(后端)启动 - 保持代码注释密度适中——关键节点注释清楚,但不过度注释
工作流总览
Phase 0 → Phase 1 → Phase 2 → Phase 3 → Phase 4
(定向) (解析PRD) (生成后端) (生成前端) (收尾)
Phase 0:定向
第一步:确认输入
向用户一次性确认以下信息:
- PRD 文件路径?(默认:当前 IDE 打开的文件)
- Demo 输出到哪?(默认:PRD 同目录下的
<产品名>-demo/) - 复杂度模式?「快速 / 标准 / 完整」
- 快速:仅后端 API + 最简前端页面,Mock 数据写死
- 标准:完整的后端 Agent 编排 + 前端状态机 + 基础样式
- 完整:标准基础上 + 完整 UI 样式 + Docker Compose + 示例数据
收到回答后,读取 PRD 文件,进入 Phase 1。
Phase 1:解析 PRD
第一步:读取并结构化 PRD
读取 PRD 文件,从中提取以下结构化信息:
从 §1 产品背景 提取
{
"product_name": "AI数据分析",
"product_slug": "ai-data-analysis",
"target_users": "计算机专业学生、数据分析从业者",
"core_features": ["上传CSV/Excel", "自动识别数据结构", "生成业务指标报表", "生成SQL语句", "生成数据分析报告"],
"version": "v1.0.1"
}
从 §3 意图体系 提取每个意图
{
"intents": [
{
"name": "UploadAndAnalyze",
"definition": "用户上传数据文件,系统自动识别数据结构并生成分析推荐",
"priority": "P0",
"slots": [
{"name": "file", "type": "file", "required": true},
{"name": "analysis_hint", "type": "string", "required": false}
],
"actions": ["校验文件格式", "解析表头与数据类型", "计算各字段基础统计", "推荐分析方向"],
"children": ["GenerateSQL", "GenerateMetricReport", "GenerateAnalysisReport"]
}
]
}
从 §4 多 Agent 工作流 提取
{
"agents": [
{
"name": "数据分析调度Agent",
"slug": "orchestrator",
"role": "主控Agent",
"prompt": "...",
"inputs": ["用户上传文件", "自然语言指令"],
"outputs": ["schema摘要", "SQL", "图表", "分析报告"],
"collaboration_mode": "pipeline"
},
{
"name": "schema-parse",
"slug": "schema_parse",
"role": "Skill",
"prompt": "...",
"inputs": ["file"],
"outputs": {"type": "json", "schema": {...}}
}
],
"sequence": ["schema-parse", "sql-generate", "report-generate"]
}
从 §5 工具调用规则 提取
{
"tools": [
{
"name": "FileParser",
"purpose": "解析CSV/Excel文件,提取表头、样本数据和基础统计",
"owner_skill": "schema-parse",
"input_schema": {"file_path": "string", "max_rows": "int", "encoding": "string"},
"output_schema": {"code": "int", "data": {...}},
"error_codes": [{"code": 1001, "message": "不支持的文件格式"}]
}
]
}
从 §6 边界定义 提取
{
"states": ["Idle", "Parsing", "MetricConfirm", "Generating", "Completed", "Error"],
"transitions": [
{"from": "Idle", "to": "Parsing", "trigger": "用户上传文件成功"},
{"from": "Parsing", "to": "MetricConfirm", "trigger": "schema解析完成"}
],
"exceptions": [
{"type": "LLM_API_Timeout", "message": "系统开小差了,请稍后再试", "retry": true}
]
}
从 §7 界面设计 提取
{
"pages": [
{
"name": "数据分析工作台",
"components": ["FileUpload", "SchemaViewer", "MetricSelector", "SqlEditor", "ChartViewer", "ReportViewer"],
"fields": [
{"name": "文件拖拽区", "type": "file", "required": true, "validation": ".csv/.xlsx/.xls, ≤50MB"}
]
}
]
}
从 §9 非功能需求 提取
{
"runtime": {"os": "Linux", "language": "Python 3.11+", "web_framework": "FastAPI", "frontend": "React 18+"},
"databases": {"relational": "PostgreSQL", "vector": "pgvector"}
}
第二步:展示提取摘要
将提取的结构化信息以摘要形式展示给用户确认:
「我从 PRD 中提取到以下关键信息:」
- 产品:AI数据分析,v1.0.1
- 4 个意图:UploadAndAnalyze(P0) / GenerateSQL(P0) / GenerateMetricReport(P1) / GenerateAnalysisReport(P1)
- 4 个 Agent:1 主控 + 3 Skill(pipeline 模式)
- 3 个工具:FileParser / SQLExecutor / ChartRenderer
- 6 个状态:Idle → Parsing → MetricConfirm → Generating → Completed / Error
- 1 个页面:数据分析工作台(6 个组件)
- 技术栈:React 18+ / FastAPI / PostgreSQL + pgvector
「确认无误开始生成?如有需要调整的请说明。」
用户确认后进入 Phase 2。
Phase 2:生成后端
目录结构
<output-dir>/backend/
├── requirements.txt
├── main.py # FastAPI 入口 + CORS + 静态文件挂载
├── config.py # 配置(模型名、超时、文件大小限制等,从PRD提取)
├── models/
│ ├── __init__.py
│ └── schemas.py # Pydantic 模型 = PRD 中的输入/输出 JSON schema
├── agents/
│ ├── __init__.py
│ ├── base.py # Agent 基类(统一调用接口)
│ ├── orchestrator.py # 主控 Agent
│ └── skills/
│ ├── __init__.py
│ ├── schema_parse.py # Skill-1
│ ├── sql_generate.py # Skill-2
│ └── report_generate.py # Skill-3
├── tools/
│ ├── __init__.py
│ ├── registry.py # 工具注册表
│ ├── file_parser.py # FileParser 实现
│ ├── sql_executor.py # SQLExecutor 实现(SQLite 内存沙箱)
│ └── chart_renderer.py # ChartRenderer 实现(返回 ECharts 配置)
├── services/
│ ├── __init__.py
│ ├── llm_service.py # Mock LLM 服务(返回预设响应)
│ └── file_service.py # 文件上传/存储服务
├── routers/
│ ├── __init__.py
│ ├── upload.py # 文件上传 API
│ ├── analysis.py # 分析流程 API
│ └── report.py # 报告下载 API
└── data/ # 上传文件存储(运行时创建)
└── .gitkeep
生成规则
1. main.py
- FastAPI 应用入口
- 配置 CORS(允许 localhost:5173)
- 挂载所有 router
- 创建上传目录和 SQLite 临时库
- 添加全局异常处理(捕获 PRD §6.7 定义的异常类型)
- 错误信息使用 PRD §6.7 定义的用户友好文案
2. models/schemas.py
- 将 PRD §4-§5 中每个 JSON schema 翻译为 Pydantic BaseModel
- 每个 Agent 的输入/输出定义对应的 Request/Response 模型
- 每个工具的输入/输出定义对应的模型
- 添加状态枚举(对应 PRD §6.6 的状态机)
- 字段校验规则从 PRD §7 和 §3 提取
3. agents/base.py
class BaseAgent:
"""Agent 基类"""
def __init__(self, name: str, system_prompt: str):
self.name = name
self.system_prompt = system_prompt
async def run(self, input_data: dict) -> dict:
"""调用 LLM(Mock 实现返回预设结果)"""
pass
4. agents/orchestrator.py
- 实现 PRD §4.2.1 的主控 Agent
- 按 sequenceDiagram 定义的顺序调用各 Skill
- 在每个确认节点返回给前端,等待用户确认后继续
- Prompt 直接使用 PRD 中的原文
5. agents/skills/*.py
- 每个 Skill 对应一个文件
- 实现
run()方法,内部调用对应工具 - System Prompt 直接使用 PRD 原文
- Mock LLM 返回与 PRD 定义一致的 JSON 结构
6. tools/*.py
- FileParser:使用 pandas 解析 CSV/Excel,返回 PRD §5.2 定义的 JSON
- SQLExecutor:使用 SQLite 内存数据库执行 SQL,实现安全拦截(禁止 DROP/DELETE/UPDATE/INSERT/TRUNCATE/ALTER)
- ChartRenderer:返回 ECharts option 配置对象(前端直接用 ECharts 渲染)
7. services/llm_service.py
- Mock LLM 实现:根据输入的 system_prompt 和 user_message,返回预设的合理 JSON
- 提供
mock_call(agent_name, input_data) -> dict接口 - 可配置模拟延迟(默认 500ms,模拟真实 LLM 响应)
8. routers/analysis.py
核心 API 端点设计(对应 PRD §4.2 流程):
| 方法 | 路径 | 说明 | 对应流程节点 |
|---|---|---|---|
| POST | /api/upload |
上传文件 | User → Agent 上传 |
| GET | /api/schema/{file_id} |
获取 schema 解析结果 | Agent → S1 返回 |
| POST | /api/analysis/start |
开始分析(提交指标) | User 选择指标 |
| GET | /api/analysis/{id}/sql |
获取生成的 SQL | Agent → S2 返回 |
| PUT | /api/analysis/{id}/sql |
用户编辑 SQL 后提交 | User 编辑确认 |
| POST | /api/analysis/{id}/execute |
执行 SQL 并生成报告 | Agent → S2 执行 → S3 |
| GET | /api/analysis/{id}/result |
获取完整结果 | Agent → User 展示 |
| GET | /api/analysis/{id}/download |
下载 Word 报告 | User 下载 |
第三步:生成代码
- 读取
references/codegen-guide.md获取详细生成规则 - 读取
templates/backend-templates.md获取代码模板 - 按上述目录结构逐个文件生成
- 生成后告知用户:「后端已生成,共 N 个文件」
Phase 3:生成前端
目录结构
<output-dir>/frontend/
├── package.json
├── tsconfig.json
├── vite.config.ts
├── index.html
├── public/
│ └── sample-data.csv # 示例数据文件
├── src/
│ ├── main.tsx
│ ├── App.tsx # 主应用(状态机驱动)
│ ├── App.css
│ ├── types/
│ │ └── index.ts # TypeScript 类型定义 = PRD JSON schema 翻译
│ ├── api/
│ │ └── client.ts # API 调用封装
│ ├── hooks/
│ │ ├── useAnalysis.ts # 分析流程状态管理 hook
│ │ └── useFileUpload.ts # 文件上传 hook
│ ├── components/
│ │ ├── FileUpload.tsx # 文件拖拽上传区
│ │ ├── SchemaViewer.tsx # 数据结构展示
│ │ ├── MetricSelector.tsx # 指标选择
│ │ ├── SqlEditor.tsx # SQL 展示+编辑
│ │ ├── ChartViewer.tsx # 图表渲染(ECharts)
│ │ ├── ReportViewer.tsx # 分析报告展示(Markdown)
│ │ ├── StatusBar.tsx # 状态指示器
│ │ ├── ErrorDisplay.tsx # 错误提示组件
│ │ └── DownloadButton.tsx # 下载按钮
│ └── utils/
│ └── stateMachine.ts # 状态机实现
生成规则
1. src/types/index.ts
- 将 PRD 中所有 JSON schema 翻译为 TypeScript interface
- 状态枚举对应 PRD §6.6
- API 请求/响应类型
2. src/utils/stateMachine.ts
- 严格实现 PRD §6.6 定义的状态机
- 状态转移表
- 每个状态的可操作行为
- 从 PRD §7.3 的交互逻辑表提取转移规则
// 状态机骨架
type AppState = 'idle' | 'parsing' | 'metric_confirm' | 'generating' | 'completed' | 'error';
interface StateDefinition {
allowedTransitions: AppState[];
allowedActions: string[];
uiState: 'upload' | 'loading' | 'confirm' | 'generating' | 'result' | 'error';
}
const STATE_MACHINE: Record<AppState, StateDefinition> = { ... };
3. src/hooks/useAnalysis.ts
- 核心流程编排 hook
- 管理当前状态、文件信息、schema、SQL、报告
- 暴露
upload(),selectMetrics(),startAnalysis(),editSql(),download()等方法 - 每个方法内部调用对应 API,并推进状态
4. src/App.tsx
- 根据当前状态渲染对应组件
- 状态驱动 UI 切换(参考 PRD §6.6 的 UI 表现列)
idle → 显示 FileUpload
parsing → 显示 StatusBar(loading)
metric_confirm → 显示 SchemaViewer + MetricSelector
generating → 显示 StatusBar(generating)
completed → 显示 SqlEditor + ChartViewer + ReportViewer + DownloadButton
error → 显示 ErrorDisplay
5. 各组件
- FileUpload:拖拽上传区,支持 .csv/.xlsx/.xls,最大 50MB
- SchemaViewer:表格展示字段名、类型、样本值、空值率
- MetricSelector:Checkbox 列表 + 新增自定义指标输入框
- SqlEditor:只读代码展示区 + 编辑模式切换
- ChartViewer:使用 ECharts 渲染后端返回的 chart_config
- ReportViewer:Markdown 渲染(使用 react-markdown)
- ErrorDisplay:根据 PRD §6.7 的错误文案展示友好提示
6. src/api/client.ts
- 封装所有 API 调用
- 统一错误处理(将后端错误码映射为用户友好提示)
- 请求超时处理(30s 超时,对应 PRD §6.7)
第三步:生成代码
- 读取
templates/frontend-templates.md获取代码模板 - 按上述目录结构逐个文件生成
- 生成后告知用户:「前端已生成,共 N 个文件」
Phase 4:收尾
第一步:生成项目根文件
-
README.md:
- 项目简介(从 PRD §1.1 提取)
- 技术栈
- 快速启动(
cd backend && pip install -r requirements.txt && python main.py/cd frontend && npm install && npm run dev) - 架构图(从 PRD §4.1 的嵌套列表生成 ASCII 图)
- API 文档(列出所有端点)
-
docker-compose.yml(完整模式):
- backend 服务
- frontend 服务
- PostgreSQL 服务(如 PRD 需要)
-
启动脚本
start.sh/start.bat:- 一键安装依赖 + 启动前后端
第二步:验证
- 确认后端所有 Python 文件导入关系正确(无循环导入)
- 确认前端组件 Props 类型与 API 返回类型一致
- 确认状态机覆盖 PRD §6.6 的所有状态
- 确认所有错误场景的前端提示文案与 PRD §6.7 一致
第三步:交付
向用户展示完整文件树和启动说明:
Demo 已生成到 <output-dir>/
启动方式:
cd <output-dir>/backend && pip install -r requirements.txt && python main.py
cd <output-dir>/frontend && npm install && npm run dev
后端运行在 http://localhost:8000
前端运行在 http://localhost:5173
API 文档: http://localhost:8000/docs
交互规则
用户可随时使用的命令
| 用户说什么 | 行为 |
|---|---|
| 「跳过前端」 | 只生成后端代码 |
| 「跳过后端」 | 只生成前端代码 |
| 「只看后端 API」 | 只生成 FastAPI 接口层(不含 Agent 模拟) |
| 「用真实 LLM」 | 将 Mock LLM 替换为真实的 Anthropic/OpenAI SDK 调用(需用户提供 API Key 配置方式) |
| 「加入认证」 | 在后端添加简单的 JWT 认证层 |
| 「换个框架」 | 按用户指定替换前端/后端框架(如 Vue 替代 React) |
输出格式规则
- 语言:代码标识符、API 路径、变量名使用英文;注释使用中文(与 PRD 保持一致)
- 代码风格:
- Python:遵循 PEP 8,使用 type hints
- TypeScript/React:使用函数组件 + hooks,避免 class component
- 命名:文件/目录 kebab-case,Python 变量 snake_case,TS 变量 camelCase,React 组件 PascalCase
- Mock 数据:所有 LLM 调用返回与 PRD JSON schema 一致的结构化数据,确保前后端联调无类型错误
- 错误处理:前端错误提示文案必须与 PRD §6.7「前端展示」列一致,不使用技术错误码
参考资料
- 代码生成详细规则:
${CLAUDE_SKILL_DIR}/references/codegen-guide.md - 后端代码模板:
${CLAUDE_SKILL_DIR}/templates/backend-templates.md - 前端代码模板:
${CLAUDE_SKILL_DIR}/templates/frontend-templates.md
Current listing version
1.0.0
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 从 PRD 自动生成可运行的前后端完整 Demo,显著提升 AI 产品原型开发效率
- 支持多 Agent 系统编排,适用于 AI 驱动应用的快速验证场景
Highlights
- 触发词覆盖全面,包含多种用户表达方式(如'生成Demo'、'从PRD生成代码'等)
- Input/Output 定义清晰,边界明确
Highlights
- Phase 划分清晰(定向→解析PRD→生成后端→生成前端→收尾),流程完整
- 提供了详细的目录结构、代码模板和 API 设计示例
- 交互规则明确,支持多种自定义选项(如跳过前端、更换框架等)
Highlights
- 工具来源明确,参数使用规范
- Mock LLM 实现确保 Demo 无需外部 API Key 即可运行
- 错误处理机制完善,覆盖主要异常场景并提供用户友好提示
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 23, 414, 441, 442 -
Accounts, secrets or authorization
Use a dedicated least-privilege account. Keep secrets out of public content and command logs; verify the receiving service and tenant.
Mentioned in main document · lines 22, 460
Domains or addresses referenced in the document
These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.
- localhost
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.