ralph
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRalph PRD Converter
Ralph PRD 转换器
Converts existing PRDs to the prd.json format that Ralph uses for autonomous execution.
将现有PRD转换为Ralph用于自主执行的prd.json格式。
The Job
任务内容
Take a PRD (markdown file or text) and convert it to in your ralph directory.
prd.json将PRD(Markdown文件或文本)转换为你的ralph目录下的文件。
prd.jsonOutput Format
输出格式
json
{
"project": "[Project Name]",
"branchName": "ralph/[feature-name-kebab-case]",
"description": "[Feature description from PRD title/intro]",
"userStories": [
{
"id": "US-001",
"title": "[Story title]",
"description": "As a [user], I want [feature] so that [benefit]",
"acceptanceCriteria": [
"Criterion 1",
"Criterion 2",
"Typecheck passes"
],
"priority": 1,
"passes": false,
"notes": ""
}
]
}json
{
"project": "[Project Name]",
"branchName": "ralph/[feature-name-kebab-case]",
"description": "[Feature description from PRD title/intro]",
"userStories": [
{
"id": "US-001",
"title": "[Story title]",
"description": "As a [user], I want [feature] so that [benefit]",
"acceptanceCriteria": [
"Criterion 1",
"Criterion 2",
"Typecheck passes"
],
"priority": 1,
"passes": false,
"notes": ""
}
]
}Story Size: The Number One Rule
用户故事规模:首要规则
Each story must be completable in ONE Ralph iteration (one context window).
Ralph spawns a fresh Amp instance per iteration with no memory of previous work. If a story is too big, the LLM runs out of context before finishing and produces broken code.
每个用户故事必须能在一次Ralph迭代(一个上下文窗口)内完成。
Ralph每次迭代都会生成一个全新的Amp实例,不会保留之前工作的记忆。如果用户故事过大,大语言模型会在完成前耗尽上下文,导致生成的代码出现问题。
Right-sized stories:
合适规模的用户故事:
- Add a database column and migration
- Add a UI component to an existing page
- Update a server action with new logic
- Add a filter dropdown to a list
- 添加数据库列和迁移脚本
- 向现有页面添加UI组件
- 使用新逻辑更新服务端动作
- 向列表添加筛选下拉框
Too big (split these):
过大的用户故事(需要拆分):
- "Build the entire dashboard" - Split into: schema, queries, UI components, filters
- "Add authentication" - Split into: schema, middleware, login UI, session handling
- "Refactor the API" - Split into one story per endpoint or pattern
Rule of thumb: If you cannot describe the change in 2-3 sentences, it is too big.
- "构建完整的仪表盘" - 拆分为:数据库模式、查询语句、UI组件、筛选功能
- "添加认证功能" - 拆分为:数据库模式、中间件、登录UI、会话处理
- "重构API" - 拆分为每个端点或模式对应一个用户故事
**经验法则:**如果你无法用2-3句话描述变更内容,说明这个故事太大了。
Story Ordering: Dependencies First
用户故事排序:依赖优先
Stories execute in priority order. Earlier stories must not depend on later ones.
Correct order:
- Schema/database changes (migrations)
- Server actions / backend logic
- UI components that use the backend
- Dashboard/summary views that aggregate data
Wrong order:
- UI component (depends on schema that does not exist yet)
- Schema change
用户故事按优先级顺序执行。前面的故事不能依赖后面的故事。
正确顺序:
- 数据库模式/变更(迁移脚本)
- 服务端动作/后端逻辑
- 调用后端的UI组件
- 聚合数据的仪表盘/汇总视图
错误顺序:
- UI组件(依赖尚未存在的数据库模式)
- 数据库模式变更
Acceptance Criteria: Must Be Verifiable
验收准则:必须可验证
Each criterion must be something Ralph can CHECK, not something vague.
每条准则必须是Ralph可以检查的内容,而非模糊描述。
Good criteria (verifiable):
良好的准则(可验证):
- "Add column to tasks table with default 'pending'"
status - "Filter dropdown has options: All, Active, Completed"
- "Clicking delete shows confirmation dialog"
- "Typecheck passes"
- "Tests pass"
- "向tasks表添加列,默认值为'pending'"
status - "筛选下拉框的选项:全部、进行中、已完成"
- "点击删除按钮显示确认对话框"
- "类型检查通过"
- "测试通过"
Bad criteria (vague):
糟糕的准则(模糊):
- "Works correctly"
- "User can do X easily"
- "Good UX"
- "Handles edge cases"
- "正常工作"
- "用户可以轻松完成X操作"
- "良好的用户体验"
- "处理边缘情况"
Always include as final criterion:
必须包含的最终准则:
"Typecheck passes"For stories with testable logic, also include:
"Tests pass""Typecheck passes"对于包含可测试逻辑的故事,还需添加:
"Tests pass"For stories that change UI, also include:
对于变更UI的故事,还需添加:
"Verify in browser using dev-browser skill"Frontend stories are NOT complete until visually verified. Ralph will use the dev-browser skill to navigate to the page, interact with the UI, and confirm changes work.
"Verify in browser using dev-browser skill"前端故事只有在视觉验证后才算完成。Ralph会使用dev-browser技能导航到页面、与UI交互并确认变更正常工作。
Conversion Rules
转换规则
- Each user story becomes one JSON entry
- IDs: Sequential (US-001, US-002, etc.)
- Priority: Based on dependency order, then document order
- All stories: and empty
passes: falsenotes - branchName: Derive from feature name, kebab-case, prefixed with
ralph/ - Always add: "Typecheck passes" to every story's acceptance criteria
- 每个用户故事对应一个JSON条目
- ID:按顺序编号(US-001、US-002等)
- 优先级:基于依赖顺序,再参考文档顺序
- 所有故事:且
passes: false为空notes - branchName:从功能名称衍生,使用短横线命名法,前缀为
ralph/ - 必须添加:每个故事的验收准则中包含"Typecheck passes"
Splitting Large PRDs
拆分大型PRD
If a PRD has big features, split them:
Original:
"Add user notification system"
Split into:
- US-001: Add notifications table to database
- US-002: Create notification service for sending notifications
- US-003: Add notification bell icon to header
- US-004: Create notification dropdown panel
- US-005: Add mark-as-read functionality
- US-006: Add notification preferences page
Each is one focused change that can be completed and verified independently.
如果PRD包含大型功能,需要拆分:
原始需求:
"添加用户通知系统"
拆分后:
- US-001:向数据库添加通知表
- US-002:创建用于发送通知的通知服务
- US-003:向页面头部添加通知铃铛图标
- US-004:创建通知下拉面板
- US-005:添加标记为已读功能
- US-006:添加通知偏好设置页面
每个都是独立的聚焦变更,可以单独完成和验证。
Example
示例
Input PRD:
markdown
undefined输入PRD:
markdown
undefinedTask Status Feature
任务状态功能
Add ability to mark tasks with different statuses.
添加标记任务不同状态的功能。
Requirements
需求
- Toggle between pending/in-progress/done on task list
- Filter list by status
- Show status badge on each task
- Persist status in database
**Output prd.json:**
```json
{
"project": "TaskApp",
"branchName": "ralph/task-status",
"description": "Task Status Feature - Track task progress with status indicators",
"userStories": [
{
"id": "US-001",
"title": "Add status field to tasks table",
"description": "As a developer, I need to store task status in the database.",
"acceptanceCriteria": [
"Add status column: 'pending' | 'in_progress' | 'done' (default 'pending')",
"Generate and run migration successfully",
"Typecheck passes"
],
"priority": 1,
"passes": false,
"notes": ""
},
{
"id": "US-002",
"title": "Display status badge on task cards",
"description": "As a user, I want to see task status at a glance.",
"acceptanceCriteria": [
"Each task card shows colored status badge",
"Badge colors: gray=pending, blue=in_progress, green=done",
"Typecheck passes",
"Verify in browser using dev-browser skill"
],
"priority": 2,
"passes": false,
"notes": ""
},
{
"id": "US-003",
"title": "Add status toggle to task list rows",
"description": "As a user, I want to change task status directly from the list.",
"acceptanceCriteria": [
"Each row has status dropdown or toggle",
"Changing status saves immediately",
"UI updates without page refresh",
"Typecheck passes",
"Verify in browser using dev-browser skill"
],
"priority": 3,
"passes": false,
"notes": ""
},
{
"id": "US-004",
"title": "Filter tasks by status",
"description": "As a user, I want to filter the list to see only certain statuses.",
"acceptanceCriteria": [
"Filter dropdown: All | Pending | In Progress | Done",
"Filter persists in URL params",
"Typecheck passes",
"Verify in browser using dev-browser skill"
],
"priority": 4,
"passes": false,
"notes": ""
}
]
}- 在任务列表中切换待处理/进行中/已完成状态
- 按状态筛选列表
- 在每个任务上显示状态徽章
- 在数据库中持久化状态
**输出prd.json:**
```json
{
"project": "TaskApp",
"branchName": "ralph/task-status",
"description": "Task Status Feature - Track task progress with status indicators",
"userStories": [
{
"id": "US-001",
"title": "Add status field to tasks table",
"description": "As a developer, I need to store task status in the database.",
"acceptanceCriteria": [
"Add status column: 'pending' | 'in_progress' | 'done' (default 'pending')",
"Generate and run migration successfully",
"Typecheck passes"
],
"priority": 1,
"passes": false,
"notes": ""
},
{
"id": "US-002",
"title": "Display status badge on task cards",
"description": "As a user, I want to see task status at a glance.",
"acceptanceCriteria": [
"Each task card shows colored status badge",
"Badge colors: gray=pending, blue=in_progress, green=done",
"Typecheck passes",
"Verify in browser using dev-browser skill"
],
"priority": 2,
"passes": false,
"notes": ""
},
{
"id": "US-003",
"title": "Add status toggle to task list rows",
"description": "As a user, I want to change task status directly from the list.",
"acceptanceCriteria": [
"Each row has status dropdown or toggle",
"Changing status saves immediately",
"UI updates without page refresh",
"Typecheck passes",
"Verify in browser using dev-browser skill"
],
"priority": 3,
"passes": false,
"notes": ""
},
{
"id": "US-004",
"title": "Filter tasks by status",
"description": "As a user, I want to filter the list to see only certain statuses.",
"acceptanceCriteria": [
"Filter dropdown: All | Pending | In Progress | Done",
"Filter persists in URL params",
"Typecheck passes",
"Verify in browser using dev-browser skill"
],
"priority": 4,
"passes": false,
"notes": ""
}
]
}Archiving Previous Runs
归档之前的运行记录
Before writing a new prd.json, check if there is an existing one from a different feature:
- Read the current if it exists
prd.json - Check if differs from the new feature's branch name
branchName - If different AND has content beyond the header:
progress.txt- Create archive folder:
archive/YYYY-MM-DD-feature-name/ - Copy current and
prd.jsonto archiveprogress.txt - Reset with fresh header
progress.txt
- Create archive folder:
The ralph.sh script handles this automatically when you run it, but if you are manually updating prd.json between runs, archive first.
在编写新的prd.json之前,检查是否存在来自其他功能的旧版本prd.json:
- 如果存在,读取当前的
prd.json - 检查是否与新功能的分支名称不同
branchName - 如果不同且的内容超出头部:
progress.txt- 创建归档文件夹:
archive/YYYY-MM-DD-feature-name/ - 将当前的和
prd.json复制到归档文件夹progress.txt - 重置为全新的头部内容
progress.txt
- 创建归档文件夹:
当你运行ralph.sh脚本时,它会自动处理这个过程,但如果你在两次运行之间手动更新prd.json,请先归档旧版本。
Checklist Before Saving
保存前检查清单
Before writing prd.json, verify:
- Previous run archived (if prd.json exists with different branchName, archive it first)
- Each story is completable in one iteration (small enough)
- Stories are ordered by dependency (schema to backend to UI)
- Every story has "Typecheck passes" as criterion
- UI stories have "Verify in browser using dev-browser skill" as criterion
- Acceptance criteria are verifiable (not vague)
- No story depends on a later story
在编写prd.json之前,验证以下内容:
- 之前的运行已归档(如果存在不同branchName的prd.json,先归档)
- 每个故事都能在一次迭代内完成(足够小)
- 故事按依赖顺序排列(从数据库模式到后端再到UI)
- 每个故事的准则中都包含"Typecheck passes"
- UI故事的准则中包含"Verify in browser using dev-browser skill"
- 验收准则是可验证的(非模糊描述)
- 没有故事依赖后续的故事