
structure|1️⃣ 三级笔记、思想框架
核心定义:Ralph 是一个自主 AI Agent 循环框架,反复运行 Amp 实例,直到 PRD(产品需求文档)中的所有 user story 全部完成。每次迭代都是一个全新的 Amp 实例,上下文干干净净。记忆通过 git history、progress.txt 和 prd.json 持久化。
基于 Geoffrey Huntley 的 Ralph 模式。
tasks/prd-[feature-name].mdprd.json)./scripts/ralph/ralph.sh [max_iterations](默认 10 轮)passes: false 的 storyprd.json,标记 passes: trueprogress.txtralph.sh:bash 循环脚本,每轮生成新的 Amp 实例prompt.md:给每个 Amp 实例的指令prd.json:user stories + passes 状态(任务清单)progress.txt:append-only 的学习记录,供后续迭代使用skills/prd/:生成 PRD 的 skillskills/ralph/:将 PRD 转 JSON 的 skillprogress.txt + prd.jsonAGENTS.md,写入本轮学到的东西passes 都为 true 时,Ralph 输出 <promise>COMPLETE</promise>,循环退出concepts|2️⃣ 关键概念、概念网络
context:
Ralph is an autonomous AI agent loop that runs Amp repeatedly until all PRD items are complete. Each iteration is a fresh Amp instance with clean context. Memory persists via git history,
progress.txt, andprd.json.
费曼一下:Ralph Loop 是一种让 AI Agent 像流水线工人一样工作的模式:给它一份任务清单(PRD),它就一项一项地做,做完一个勾一个,直到全部完成。每次做新任务时,它的“工作台”是干净的,但它能通过外部文件记住之前的经验教训。核心思想:与其让 Agent 在一个无限增长的上下文里越做越乱,不如每轮重新开始、只传递必要的记忆。基于 Geoffrey Huntley 的原始概念。
context:
Each iteration spawns a new Amp instance with clean context. The only memory between iterations is: Git history,
progress.txt,prd.json.
费曼一下:Fresh Context 是 Ralph 的核心架构决策。每轮迭代都启动一个全新的 LLM 实例,没有前一轮的历史对话。这解决了一个关键问题:LLM 的 context window 有限,工作时间越长、上下文越混乱,输出质量越差。Fresh Context 的代价是必须通过外部文件显式传递记忆,但换来的是每轮都能保持高质量输出。
context:
Memory persists via git history,
progress.txt, andprd.json. After each iteration, Ralph updates the relevantAGENTS.mdfiles with learnings.
费曼一下:既然每轮都是全新启动,记忆怎么传递?Ralph 用三个外部文件做“记忆体”:prd.json(任务清单,记录哪些做完了)、progress.txt(append-only 的经验日志)、git history(代码变更记录)。这是一种特别简洁的设计——不需要复杂的向量数据库或 RAG,用最原始的文件系统就够了。
context:
Each PRD item should be small enough to complete in one context window. If a task is too big, the LLM runs out of context before finishing and produces poor code.
费曼一下:Ralph 能跑起来的前提是:你得把任务拆得足够小。每个 user story 必须小到一个 context window 内能完成。这不是 Ralph 的缺陷,而是当前 LLM Agent 的工作原理决定的——任务太大,上下文耗尽,代码质量就崩了。所以问题往往不是“Agent 不行”,而是“任务太大了”。
context:
Ralph only works if there are feedback loops: Typecheck catches type errors, Tests verify behavior, CI must stay green (broken code compounds across iterations).
费曼一下:Ralph 每轮做完之后,必须有东西告诉它“做对了没有”,否则就是盲人骑瞎马。Typecheck、单元测试、CI 就是这些反馈信号。没有反馈循环的 Agent 循环是危险的——坏代码会在迭代间复利累积,越滩越大。
prd.json + progress.txt + git + AGENTS.md)agentic reading|3️⃣ 费曼 x3