ralph-prd
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseRalph PRD Generation
Ralph PRD 生成
Generate files that define scoped work items for autonomous agent execution. Each item has explicit completion criteria and verification steps.
prd.json生成用于自主Agent执行的、定义了限定范围工作项的文件。每个工作项都包含明确的完成标准和验证步骤。
prd.jsonWhen to Use
适用场景
- Batch migrations (API changes, library upgrades, lint fixes)
- Large-scale refactoring across many files
- Any task decomposable into independent, verifiable units
- Work that benefits from "done" being explicitly defined
- 批量迁移(API变更、库版本升级、Lint修复)
- 跨多文件的大规模代码重构
- 任何可分解为独立可验证单元的任务
- 需要明确定义“完成状态”的工作
PRD Structure
PRD 结构
json
{
"instructions": "<markdown with context, examples, constraints>",
"items": [
{
"id": "<unique identifier>",
"category": "<task category>",
"description": "<what needs to be done>",
"file": "<target file path>",
"steps": [
"<action step>",
"<verification step>"
],
"passes": false,
"skipped": null
}
]
}json
{
"instructions": "<包含上下文、示例、约束的Markdown内容>",
"items": [
{
"id": "<唯一标识符>",
"category": "<任务分类>",
"description": "<需要完成的工作内容>",
"file": "<目标文件路径>",
"steps": [
"<操作步骤>",
"<验证步骤>"
],
"passes": false,
"skipped": null
}
]
}Field Reference
字段说明
| Field | Purpose |
|---|---|
| Markdown embedded in PRD - transformation examples, docs links, constraints |
| Unique identifier (typically file path or task name) |
| Groups related items |
| Human-readable summary |
| Actions + verification commands |
| |
| |
| 字段 | 用途 |
|---|---|
| 嵌入在PRD中的Markdown内容 - 包含转换示例、文档链接、约束条件 |
| 唯一标识符(通常为文件路径或任务名称) |
| 对相关工作项进行分组 |
| 易读的工作项摘要 |
| 操作步骤 + 验证命令 |
| 初始值为 |
| 若任务无法完成,设为 |
Generation Workflow
生成流程
PRD Generation Progress:
- [ ] Step 1: Define scope (what files/items are affected?)
- [ ] Step 2: Gather input data (lint output, file list, API changes)
- [ ] Step 3: Design item granularity (per-file, per-error, per-component?)
- [ ] Step 4: Define verification steps (type-check, tests, lint)
- [ ] Step 5: Write instructions (examples, constraints, skip conditions)
- [ ] Step 6: Generate items (script or manual)
- [ ] Step 7: Review sample itemsPRD 生成进度:
- [ ] 步骤1:定义范围(涉及哪些文件/工作项?)
- [ ] 步骤2:收集输入数据(Lint输出、文件列表、API变更内容)
- [ ] 步骤3:设计工作项粒度(按文件、按错误、按组件?)
- [ ] 步骤4:定义验证步骤(类型检查、测试、Lint校验)
- [ ] 步骤5:编写说明内容(示例、约束、跳过条件)
- [ ] 步骤6:生成工作项(通过脚本或手动方式)
- [ ] 步骤7:审核样本工作项Clarifying Questions
需要明确的问题
Before generating, resolve these with the user:
在生成PRD前,需与用户确认以下问题:
Granularity
粒度选择
- Per-file? Per-error? Per-component?
- Trade-off: fewer items = less overhead, more items = finer progress tracking
- 按文件?按错误?按组件?
- 权衡:工作项越少 = 管理开销越低,工作项越多 = 进度跟踪越精细
Verification Steps
验证步骤
- What commands confirm completion?
- Type-check? Tests? Lint? Build?
- Which tests - related test file only, or broader?
- 用哪些命令确认任务完成?
- 类型检查?测试?Lint校验?构建?
- 测试范围 - 仅相关测试文件,还是更广泛的测试?
Instructions Content
说明内容
- What context does the executing agent need?
- Before/after examples?
- Links to documentation?
- Type casting or naming conventions?
- 执行Agent需要哪些上下文信息?
- 是否需要提供前后对比示例?
- 是否需要链接到相关文档?
- 类型转换或命名规范?
Skip Conditions
跳过条件
- What should cause an item to be skipped rather than fixed?
- Example: "class component requires manual refactor"
- 哪些情况应标记工作项为跳过而非修复?
- 示例:“类组件需要手动重构”
Path Format
路径格式
- Relative or absolute paths?
- ID format (filename only risks collisions)
- 相对路径还是绝对路径?
- ID格式(仅用文件名可能会导致冲突)
Instructions Section Best Practices
说明部分的最佳实践
The field is markdown that the executing agent reads. Include:
instructions- Violation/task types with before/after examples
- Scope rules - what's in bounds, what's out
- Skip conditions - when to mark instead of fixing
skipped: "<reason>" - Links to relevant documentation
- Type/naming conventions specific to the codebase
Keep instructions focused. The agent discovers patterns; instructions provide guardrails.
instructions- 违规/任务类型及前后对比示例
- 范围规则 - 哪些内容在范围内,哪些不在
- 跳过条件 - 何时应标记而非修复
skipped: "<原因>" - 相关文档链接
- 代码库特定的类型/命名规范
说明内容应聚焦重点。Agent会自主发现模式,说明仅需提供规则边界。
Verification Steps
验证步骤
Each item should have at least one verification step. Common patterns:
json
"steps": [
"Fix all N lint errors for rule-name",
"Run yarn type-check:go - must pass",
"Run yarn test <path> - if test exists"
]For test detection, check:
__tests__/<filename>.test.{ts,tsx,js,jsx}- sibling
<filename>.test.{ts,tsx,js,jsx} __tests__/integration/<filename>.test.*
每个工作项至少包含一个验证步骤。常见模式:
json
"steps": [
"修复所有N个rule-name规则下的Lint错误",
"运行yarn type-check:go - 必须通过",
"若存在测试文件则运行yarn test <路径>"
]检测测试文件时,可检查以下路径:
__tests__/<filename>.test.{ts,tsx,js,jsx}- 同级目录下的
<filename>.test.{ts,tsx,js,jsx} __tests__/integration/<filename>.test.*
Example: Generating from Lint Output
示例:从Lint输出生成PRD
Input: JSON array of lint errors grouped by file
javascript
const prd = {
instructions: `## Migration Instructions...`,
items: lintErrors.map(entry => ({
id: entry.filePath.replace(REPO_ROOT + '/', ''),
category: 'migration',
description: `Fix violations in ${path.basename(entry.filePath)}`,
file: entry.filePath,
errorCount: entry.errorCount,
steps: [
`Fix all ${entry.errorCount} lint errors`,
'Run yarn type-check:go - must pass',
...(testExists ? [`Run yarn test ${testPath}`] : [])
],
passes: false,
skipped: null
}))
};输入:按文件分组的Lint错误JSON数组
javascript
const prd = {
instructions: `## 迁移说明...`,
items: lintErrors.map(entry => ({
id: entry.filePath.replace(REPO_ROOT + '/', ''),
category: 'migration',
description: `修复${path.basename(entry.filePath)}中的违规问题`,
file: entry.filePath,
errorCount: entry.errorCount,
steps: [
`修复全部${entry.errorCount}个Lint错误`,
'运行yarn type-check:go - 必须通过',
...(testExists ? [`Run yarn test ${testPath}`] : [])
],
passes: false,
skipped: null
}))
};Anti-Patterns
反模式
Vague verification
模糊的验证步骤
json
// Bad
"steps": ["Fix the issue", "Make sure it works"]
// Good
"steps": ["Fix lint error on line 42", "Run yarn type-check:go - must pass"]json
// 错误示例
"steps": ["修复问题", "确保可用"]
// 正确示例
"steps": ["修复第42行的Lint错误", "运行yarn type-check:go - 必须通过"]Missing skip conditions
缺失跳过条件
If some items can't be completed (e.g., requires larger refactor), define skip conditions in instructions so agents mark instead of attempting impossible fixes.
skipped若部分工作项无法完成(例如:需要更大规模的重构),需在说明中定义跳过条件,以便Agent标记而非尝试不可能的修复。
skippedOver-scoped items
范围过大的工作项
Items that touch many files are harder to verify and resume. Prefer one file per item for file-based migrations.
涉及多个文件的工作项更难验证和恢复。对于基于文件的迁移,建议每个工作项对应一个文件。
Under-specified instructions
说明内容不明确
The executing agent shouldn't have to guess conventions. Specify type casting, naming patterns, import sources.
执行Agent不应需要猜测规范。需明确指定类型转换、命名模式、导入来源。