GLM-V PRD-to-App: Full-Stack Application Builder
Language: Respond in the same language the user uses. Code comments should match.
Build a complete, deployed web application from PRD + prototypes + resources.
The result must be fully reproducible via a single bash /workspace/start.sh.
Phase 0: Material Discovery & Analysis
Before anything else, understand what you're working with.
0a. Locate all inputs
CODEBLOCK0
If the materials are in a different location, adapt accordingly. Read the PRD fully.
0b. Deep prototype analysis
For every prototype image:
- 1. Read each image using the Read tool — you are multimodal, examine them directly.
- For each image, document:
-
Page identity: which page/view this represents
-
Layout structure: header, sidebar, main content, footer, modals
-
Component inventory: every button, form, card, table, list, nav element
-
Content inventory: all visible text, numbers, labels, placeholder content
-
Color extraction: primary, secondary, accent, background, text colors (hex values)
-
Typography: font sizes, weights, hierarchy observed
-
Interactive states: hover effects, active tabs, selected items, toggles
-
Data patterns: what data populates lists/tables/cards — this drives seed data
- 3. Build a page map showing navigation flow between prototype pages.
0c. Resource inventory
List all files in /workspace/resources/ and map each to where it appears in the prototypes.
Every resource file must be used in the final application where relevant.
Phase 1: System Design Document
Produce a comprehensive design document at /workspace/docs/design.md.
1a. Data Model
For each entity, specify:
- - Table/collection name
- All fields with types, constraints, defaults
- Relationships (foreign keys, many-to-many)
- Indexes needed for query patterns
- Content mapping: which prototype elements map to which fields
Example:
CODEBLOCK1
1b. API Design
For every page interaction, define an API endpoint:
- - Method + path
- Request params/body schema
- Response schema with example
- Which prototype interaction triggers this API
- Error responses
1c. Frontend Architecture
- - Component hierarchy (tree structure)
- Route definitions mapping to prototype pages
- State management approach
- How each prototype page maps to components
1d. Technology Stack
Choose based on PRD complexity. Recommended defaults:
| Layer | Choice | When to use |
|---|
| Frontend | React + TypeScript + Vite | Default for SPAs |
| Frontend |
Next.js | If SSR/SEO needed |
| Styling | Tailwind CSS | Default |
| Backend | Node.js + Express | Simple APIs |
| Backend | Python + FastAPI | If PRD mentions Python |
| Database | SQLite | Simple apps, <10 tables |
| Database | PostgreSQL | Complex apps, relationships |
| ORM | Prisma (Node) / SQLAlchemy (Python) | Match backend |
Document the choice and reasoning.
1e. Directory Structure
CODEBLOCK2
Phase 2: Seed Data Generation
Seed data is critical — it makes the app look real from the first launch.
Rules
- 1. Extract from prototypes: Every piece of visible text, image, number in the prototype
images must appear in seed data. Read each prototype image again and transcribe content.
- 2. Complete coverage:
- Every list/table must have the exact number of items shown in prototypes
- Every card must have the content matching the prototype
- Every dropdown must have options matching the prototype
- Navigation items must match prototype navigation
- Statistics/counters must match prototype numbers
- 3. Use resource files: Map resource files (images, videos, icons) from
/workspace/resources/ to seed data entries. Use relative paths or copy to public/static dir.
- 4. No placeholders: No "Lorem ipsum", no "Test Item 1", no
placeholder.com images.
- 5. Support all states: Include data that exercises empty states, loaded states,
error scenarios as specified in the PRD.
Output
Save seed data as:
- - SQL seed files, or
- JSON fixtures, or
- ORM seed scripts
Place in /workspace/backend/src/seed/ (or equivalent).
Phase 3: Backend Implementation
3a. Database schema
- - Create migration files for all tables
- Include proper constraints, indexes, foreign keys
- Run migrations to verify they work
3b. API endpoints
For each endpoint from the design doc:
- 1. Implement route handler
- Add input validation (validate types, required fields, ranges)
- Add error handling with proper HTTP status codes
- Test with curl or equivalent to verify response format
3c. Seed data loading
- - Implement a seed script that:
- Clears existing data (for idempotent re-seeding)
- Inserts all seed data in correct dependency order
- Copies resource files to the correct static serving location
- - Verify seed data loads without errors
3d. Static file serving
- - Configure the backend to serve resource files (images, videos, etc.)
- Ensure frontend can access them via proper URLs
Phase 4: Frontend Implementation
This is where visual fidelity matters most. The prototypes are the definitive reference.
4a. Global styles and tokens
Before building components, establish:
- - Color variables matching prototype colors
- Typography scale matching prototype fonts
- Spacing/sizing system matching prototype spacing
- Common component styles (buttons, cards, inputs, etc.)
4b. Page-by-page implementation
For each prototype image, in order:
- 1. Re-read the prototype image — keep it fresh in your context
- Build the page component matching the layout exactly:
- Match spacing and proportions
- Match colors and typography
- Match visual hierarchy
- Match content placement
- 3. Wire up API calls to the backend
- Implement all interactions visible or implied:
- Navigation between pages
- Form submissions
- Search and filter
- Sorting
- Modals and dialogs
- Loading states
- Error states
- Hover effects
- Active/selected states
4c. Resource integration
- - Copy all resources from
/workspace/resources/ to frontend assets - Reference them correctly in components
- Ensure images render at proper sizes matching prototypes
4d. Responsive considerations
- - Match the viewport width shown in prototypes
- If prototypes show mobile views, implement responsive breakpoints
Phase 5: Visual Verification Loop
This phase is what separates a good implementation from a great one.
Repeat this loop for every page.
5a. Render the page to a screenshot
Use Playwright to capture the running application:
CODEBLOCK3
5b. Visual comparison
Read both images (prototype and screenshot) side by side:
- 1. Read the prototype image from INLINECODE7
- Read the rendered screenshot
- Compare systematically:
-
Layout: Are sections in the right positions?
-
Colors: Do colors match?
-
Typography: Are font sizes/weights correct?
-
Content: Is all prototype content present?
-
Spacing: Are margins and paddings close?
-
Images: Are all images rendering?
-
Components: Are all UI components present and correct?
5c. Fix discrepancies
For each difference found:
- 1. Identify the specific CSS/component change needed
- Apply the fix
- Re-render and re-compare
5d. Repeat until satisfied
Max 3 iterations per page. Focus on the most impactful differences first.
Phase 6: Integration Testing
6a. API health check
Run the API health checker to verify all endpoints:
CODEBLOCK4
Or manually test each endpoint with curl:
CODEBLOCK5
6b. End-to-end flow verification
Walk through every user flow defined in the PRD:
- 1. Open the app at INLINECODE8
- Navigate to each page
- Test each interactive feature
- Verify data loads from the database
- Verify forms submit correctly
- Verify search/filter/sort work
6c. Fix any issues found
Address integration issues: CORS, API URL mismatches, data format mismatches, etc.
Phase 7: Deployment Script
Generate /workspace/start.sh — the single command that makes everything work from scratch.
Requirements
The script must:
- 1. Be fully self-contained — no prior setup assumed
- Work in a fresh environment
- Install all system dependencies (Node.js, Python, DB, etc.)
- Clean any previous state
- Set up the database from scratch
- Run all migrations
- Load all seed data
- Build the frontend (if needed)
- Start both backend and frontend
- Make the app available at INLINECODE10
Template
CODEBLOCK6
Verification
After generating start.sh:
- 1. INLINECODE11
- Run it: INLINECODE12
- Wait for startup
- Verify
http://localhost:3000 responds - Spot-check a few API endpoints
- Fix any startup issues
Phase 8: Documentation
8a. Software Design Document (/workspace/docs/design.md)
Already created in Phase 1 — update with any changes made during implementation:
- - Final system architecture
- Final data model (with any fields added during dev)
- Technology stack
- Deployment architecture
- API reference
8b. README (/workspace/README.md)
CODEBLOCK7
Deliverables Checklist
Before declaring done, verify every item:
- - [ ] All PRD features implemented — no features skipped
- [ ] All prototype pages built — no pages merged or omitted
- [ ] Visual match with prototypes — verified via screenshot comparison
- [ ] All resource files used where they appear in prototypes
- [ ] Seed data matches prototype content exactly
- [ ] All API endpoints working and returning correct data
- [ ] All interactive elements functional (forms, search, filters, modals, navigation)
- [ ]
bash /workspace/start.sh works from a clean state - [ ] App accessible at INLINECODE17
- [ ] Design document complete
- [ ] README with deployment instructions
Critical Principles
- 1. Prototypes are truth — when PRD text and prototype images conflict, the prototype wins
for visual/layout decisions.
- 2. No shortcuts on data — every piece of content visible in prototypes must come from the
database via APIs. No hardcoded data in frontend components.
- 3. Complete implementation — every page, every feature, every interaction. Don't skip
"minor" features. Don't merge separate pages into one.
- 4. Resources must be used — if the prototype shows an image and a matching file exists in
/workspace/resources/, use that file. Don't substitute with placeholder URLs.
- 5. Reproducibility —
start.sh must work from absolute zero. If it needs Node 18+,
it installs Node 18+. If it needs PostgreSQL, it sets up PostgreSQL.
- 6. Verify, don't assume — use the visual verification loop (Phase 5) to actually compare
your output against prototypes. Use API checks to verify endpoints. Run start.sh to verify
deployment.
GLM-V PRD到应用:全栈应用构建器
语言:使用用户所用的语言回复。代码注释应保持一致。
根据PRD(产品需求文档)+ 原型图 + 资源文件,构建一个完整的、已部署的Web应用。
最终结果必须能通过单个命令 bash /workspace/start.sh 完全复现。
阶段0:材料发现与分析
在开始任何工作之前,先了解你手头有什么材料。
0a. 定位所有输入
/workspace/prd.md ← 产品需求文档
/workspace/prototypes/*.jpg ← UI原型图(视觉真相)
/workspace/resources//* ← 图片、视频、图标及其他资源
如果材料位于不同位置,请相应调整。完整阅读PRD。
0b. 深度原型分析
针对每一张原型图:
- 1. 使用读取工具读取每张图片——你是多模态的,直接检查它们。
- 针对每张图片,记录:
-
页面标识:这代表哪个页面/视图
-
布局结构:页眉、侧边栏、主内容区、页脚、弹窗
-
组件清单:每个按钮、表单、卡片、表格、列表、导航元素
-
内容清单:所有可见文本、数字、标签、占位内容
-
颜色提取:主色、辅色、强调色、背景色、文本色(十六进制值)
-
排版:观察到的字号、字重、层级结构
-
交互状态:悬停效果、激活标签、选中项、开关
-
数据模式:填充列表/表格/卡片的数据——这驱动种子数据的生成
- 3. 构建页面地图,展示原型页面之间的导航流程。
0c. 资源清单
列出 /workspace/resources/ 中的所有文件,并将每个文件映射到它在原型中出现的位置。
每个资源文件都必须在最终应用中相关的位置被使用。
阶段1:系统设计文档
在 /workspace/docs/design.md 中生成一份全面的设计文档。
1a. 数据模型
针对每个实体,明确:
- - 表/集合名称
- 所有字段及其类型、约束、默认值
- 关系(外键、多对多)
- 查询模式所需的索引
- 内容映射:原型中的哪些元素映射到哪些字段
示例:
products 表:
id SERIAL PRIMARY KEY
name VARCHAR(200) NOT NULL ← 来自产品卡片标题
price DECIMAL(10,2) NOT NULL ← 来自产品卡片价格标签
image_url TEXT NOT NULL ← 来自产品卡片图片
category_id INTEGER REFERENCES categories(id) ← 来自分类筛选器
...
1b. API设计
针对每个页面交互,定义一个API端点:
- - 方法 + 路径
- 请求参数/请求体模式
- 响应模式及示例
- 哪个原型交互触发了此API
- 错误响应
1c. 前端架构
- - 组件层级(树形结构)
- 映射到原型页面的路由定义
- 状态管理方法
- 每个原型页面如何映射到组件
1d. 技术栈
根据PRD的复杂度进行选择。推荐的默认选项:
| 层级 | 选择 | 使用时机 |
|---|
| 前端 | React + TypeScript + Vite | 单页应用的默认选项 |
| 前端 |
Next.js | 需要SSR/SEO时 |
| 样式 | Tailwind CSS | 默认选项 |
| 后端 | Node.js + Express | 简单API |
| 后端 | Python + FastAPI | PRD提到Python时 |
| 数据库 | SQLite | 简单应用,少于10个表 |
| 数据库 | PostgreSQL | 复杂应用,有表关系 |
| ORM | Prisma (Node) / SQLAlchemy (Python) | 与后端匹配 |
记录选择及其理由。
1e. 目录结构
/workspace/
├── frontend/ ← 或 client/
│ ├── src/
│ │ ├── components/
│ │ ├── pages/
│ │ ├── hooks/
│ │ ├── services/ ← API客户端
│ │ ├── types/
│ │ └── assets/ ← 从 /workspace/resources 复制
│ └── ...
├── backend/ ← 或 server/
│ ├── src/
│ │ ├── routes/
│ │ ├── models/
│ │ ├── controllers/
│ │ ├── middleware/
│ │ └── seed/
│ └── ...
├── docs/
│ ├── design.md
│ └── README.md
├── start.sh
└── prd.md
阶段2:种子数据生成
种子数据至关重要——它让应用在首次启动时就看起来真实。
规则
- 1. 从原型中提取:原型图片中每一段可见的文本、图片、数字都必须出现在种子数据中。再次读取每张原型图片并转录内容。
- 2. 完整覆盖:
- 每个列表/表格必须包含原型中显示的精确数量的项目
- 每张卡片的内容必须与原型匹配
- 每个下拉菜单的选项必须与原型匹配
- 导航项必须与原型导航匹配
- 统计/计数器必须与原型数字匹配
- 3. 使用资源文件:将 /workspace/resources/ 中的资源文件(图片、视频、图标)映射到种子数据条目中。使用相对路径或复制到public/static目录。
- 4. 无占位符:不要使用Lorem ipsum、测试项1或placeholder.com图片。
- 5. 支持所有状态:包含能展示空状态、加载状态、错误场景的数据,按PRD中的规定。
输出
将种子数据保存为:
- - SQL种子文件,或
- JSON固定数据,或
- ORM种子脚本
放置在 /workspace/backend/src/seed/(或等效目录)中。
阶段3:后端实现
3a. 数据库模式
- - 为所有表创建迁移文件
- 包含适当的约束、索引、外键
- 运行迁移以验证其工作正常
3b. API端点
针对设计文档中的每个端点:
- 1. 实现路由处理器
- 添加输入验证(验证类型、必填字段、范围)
- 添加错误处理,使用正确的HTTP状态码
- 使用curl或等效工具测试,验证响应格式
3c. 种子数据加载
- 清除现有数据(用于幂等重新播种)
- 按正确的依赖顺序插入所有种子数据
- 将资源文件复制到正确的静态服务位置
3d. 静态文件服务
- - 配置后端以服务资源文件(图片、视频等)
- 确保前端可以通过正确的URL访问它们
阶段4:前端实现
这是视觉保真度最重要的阶段。原型是决定性参考。
4a. 全局样式和令牌
在构建组件之前,建立:
- - 与原型颜色匹配的颜色变量
- 与原型字体匹配的排版比例
- 与原型间距匹配的间距/尺寸系统
- 通用组件样式(按钮、卡片、输入框等)
4b. 逐页面实现
针对每张原型图片,按顺序:
- 1. 重新读取原型图片——保持它在你的上下文中是新鲜的
- 构建页面组件,精确匹配布局:
- 匹配间距和比例
- 匹配颜色和排版
- 匹配视觉层级
- 匹配内容放置
- 3. 连接后端的API调用
- 实现所有可见或隐含的交互:
- 页面间导航
- 表单提交
- 搜索和筛选
- 排序
- 弹窗和对话框
- 加载状态
- 错误状态
- 悬停效果
- 激活/选中状态
4c. 资源集成
- - 将所有资源从 /workspace/resources/ 复制到前端资源目录
- 在组件中正确引用它们
- 确保图片以与原型匹配的适当尺寸渲染
4d. 响应式考虑
- - 匹配原型中显示的视口宽度
- 如果原型显示移动端视图,实现响应式断点
阶段5:视觉验证循环
这个阶段是区分优秀实现和普通实现的关键。
对每个页面重复此循环。
5a. 将页面渲染为截图
使用Playwright捕获运行中的应用:
bash
python ${SKILLDIR}/scripts/renderpage.py \
--url http://localhost:3000/page-path \
--output /workspace/docs