<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>PRD on KnightLi Blog</title>
        <link>https://www.knightli.com/en/tags/prd/</link>
        <description>Recent content in PRD on KnightLi Blog</description>
        <generator>Hugo -- gohugo.io</generator>
        <language>en</language>
        <lastBuildDate>Mon, 27 Apr 2026 08:08:55 +0800</lastBuildDate><atom:link href="https://www.knightli.com/en/tags/prd/index.xml" rel="self" type="application/rss+xml" /><item>
        <title>What Ralph Is: Turning Claude Code and Amp into a Repeatable Autonomous Development Loop</title>
        <link>https://www.knightli.com/en/2026/04/27/ralph-autonomous-agent-loop-claude-code-amp/</link>
        <pubDate>Mon, 27 Apr 2026 08:08:55 +0800</pubDate>
        
        <guid>https://www.knightli.com/en/2026/04/27/ralph-autonomous-agent-loop-claude-code-amp/</guid>
        <description>&lt;p&gt;If you have been paying attention to long-running coding agent workflows lately, &lt;code&gt;snarktank/ralph&lt;/code&gt; is a project worth a close look. It is not another model wrapper or another chat UI. Instead, it organizes &lt;code&gt;Claude Code&lt;/code&gt; or &lt;code&gt;Amp&lt;/code&gt; into an autonomous loop that keeps running through stories in a &lt;code&gt;PRD&lt;/code&gt; until everything is done.&lt;/p&gt;
&lt;p&gt;Its core idea is simple: &lt;strong&gt;do not force the same agent to keep working inside an increasingly long and messy context. Start a brand-new AI coding session for every iteration instead.&lt;/strong&gt; That keeps context from bloating and makes task boundaries much clearer.&lt;/p&gt;
&lt;h2 id=&#34;01-what-ralph-is&#34;&gt;01 What Ralph Is
&lt;/h2&gt;&lt;p&gt;Ralph describes itself very clearly: it is an autonomous AI agent loop that repeatedly runs an AI coding tool until the items in a &lt;code&gt;PRD&lt;/code&gt; are complete.&lt;/p&gt;
&lt;p&gt;The repository currently supports two tools:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Amp CLI&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Claude Code&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Each iteration starts a fresh instance. In other words, it does not depend on one endlessly extended conversation. Instead, it keeps memory in external state:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;git history&lt;/li&gt;
&lt;li&gt;&lt;code&gt;progress.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;prd.json&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;That detail matters a lot. When people let an agent run on large tasks, the main problem is often not that the model cannot code. It is that the session becomes heavier over time, starts losing context, forgets requirements, and repeats work. Ralph is designed almost entirely around that problem.&lt;/p&gt;
&lt;h2 id=&#34;02-how-it-works&#34;&gt;02 How It Works
&lt;/h2&gt;&lt;p&gt;Ralph&amp;rsquo;s workflow has three steps.&lt;/p&gt;
&lt;h3 id=&#34;1-write-a-prd-first&#34;&gt;1. Write a PRD first
&lt;/h3&gt;&lt;p&gt;The README suggests starting with the bundled &lt;code&gt;prd&lt;/code&gt; skill to generate a requirements document and break the feature into smaller stories.&lt;/p&gt;
&lt;h3 id=&#34;2-convert-the-prd-into-prdjson&#34;&gt;2. Convert the PRD into &lt;code&gt;prd.json&lt;/code&gt;
&lt;/h3&gt;&lt;p&gt;Then the &lt;code&gt;ralph&lt;/code&gt; skill converts the Markdown PRD into a structured &lt;code&gt;prd.json&lt;/code&gt;. That file stores the user stories and whether each one has passed.&lt;/p&gt;
&lt;h3 id=&#34;3-run-the-loop-script&#34;&gt;3. Run the loop script
&lt;/h3&gt;&lt;p&gt;The actual execution is handled by &lt;code&gt;ralph.sh&lt;/code&gt;. The commands look like this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;div class=&#34;chroma&#34;&gt;
&lt;table class=&#34;lntable&#34;&gt;&lt;tr&gt;&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;lnt&#34;&gt;1
&lt;/span&gt;&lt;span class=&#34;lnt&#34;&gt;2
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;
&lt;td class=&#34;lntd&#34;&gt;
&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;./scripts/ralph/ralph.sh &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;max_iterations&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;./scripts/ralph/ralph.sh --tool claude &lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;max_iterations&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;&lt;p&gt;The default is 10 iterations. In each round, Ralph roughly does the following:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a branch from &lt;code&gt;branchName&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Pick the highest-priority story where &lt;code&gt;passes: false&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Implement only that story&lt;/li&gt;
&lt;li&gt;Run quality checks such as typecheck and tests&lt;/li&gt;
&lt;li&gt;Commit if the checks pass&lt;/li&gt;
&lt;li&gt;Update &lt;code&gt;prd.json&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Append learnings to &lt;code&gt;progress.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Continue to the next round&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;So Ralph is not trying to finish everything in one go. It compresses work into many small loops that can fit inside a single context window.&lt;/p&gt;
&lt;h2 id=&#34;03-what-makes-ralph-interesting&#34;&gt;03 What Makes Ralph Interesting
&lt;/h2&gt;&lt;h3 id=&#34;1-every-round-uses-fresh-context&#34;&gt;1. Every round uses fresh context
&lt;/h3&gt;&lt;p&gt;This is Ralph&amp;rsquo;s defining design choice. The README emphasizes that every iteration is a brand-new AI instance, and cross-iteration memory lives only in git, &lt;code&gt;progress.txt&lt;/code&gt;, and &lt;code&gt;prd.json&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;That is very different from the common pattern of keeping &lt;code&gt;Claude Code&lt;/code&gt; or another tool inside one long conversation. Once tasks get larger, that approach often slows down under its own history and gradually loses focus. Ralph accepts that no single round should remember everything, then moves memory into files instead.&lt;/p&gt;
&lt;h3 id=&#34;2-it-forces-tasks-to-stay-small&#34;&gt;2. It forces tasks to stay small
&lt;/h3&gt;&lt;p&gt;The docs explicitly say that each PRD item must be small enough to finish within one context window. Tasks like adding a filter, updating a server action, or adding a database column are about the right size. Tasks like rebuilding the whole API or creating an entire dashboard are too large.&lt;/p&gt;
&lt;p&gt;That constraint is practical. Many autonomous agent loops fail not because the loop is bad, but because the task slicing is too coarse and each round carries too much at once.&lt;/p&gt;
&lt;h3 id=&#34;3-it-preserves-learnings-not-just-code&#34;&gt;3. It preserves learnings, not just code
&lt;/h3&gt;&lt;p&gt;Beyond &lt;code&gt;progress.txt&lt;/code&gt;, the README also stresses updating &lt;code&gt;AGENTS.md&lt;/code&gt;. The reason is straightforward: future iterations and future developers will read those notes, so patterns, gotchas, and conventions discovered in each round should be written down in the project itself.&lt;/p&gt;
&lt;p&gt;Put differently, Ralph is not only trying to keep an agent coding continuously. It is also trying to help the agent build working memory about the codebase over time.&lt;/p&gt;
&lt;h2 id=&#34;04-when-it-fits-best&#34;&gt;04 When It Fits Best
&lt;/h2&gt;&lt;p&gt;Ralph is a good fit when your task looks like this:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It can already be broken into a clear set of user stories&lt;/li&gt;
&lt;li&gt;The codebase has reliable feedback loops such as tests, typecheck, or CI&lt;/li&gt;
&lt;li&gt;You want the agent to keep moving forward without putting everything into one long conversation&lt;/li&gt;
&lt;li&gt;You are fine with iterative progress instead of demanding a one-shot completion&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On the other hand, if the requirement is still vague, or the work depends on frequent discussion and constant changes of direction, Ralph may not be the first thing to reach for. It fits better once the requirements are already shaped and execution needs to be steady.&lt;/p&gt;
&lt;h2 id=&#34;05-how-it-differs-from-normal-claude-code-usage&#34;&gt;05 How It Differs from Normal Claude Code Usage
&lt;/h2&gt;&lt;p&gt;With plain &lt;code&gt;Claude Code&lt;/code&gt;, the usual pattern is simple: open a session and let it keep reading code, editing files, and running commands. That works very well for small and medium tasks, but larger tasks often hit two problems:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Context keeps growing&lt;/li&gt;
&lt;li&gt;Intermediate decisions are harder to preserve in a structured way&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Ralph turns &lt;code&gt;Claude Code&lt;/code&gt; or &lt;code&gt;Amp&lt;/code&gt; into something closer to a batch executor:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The task source is &lt;code&gt;prd.json&lt;/code&gt;, not ad hoc chat instructions&lt;/li&gt;
&lt;li&gt;Each iteration recognizes only one story&lt;/li&gt;
&lt;li&gt;Completion state is written back to files&lt;/li&gt;
&lt;li&gt;Learnings go into &lt;code&gt;progress.txt&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Code changes are preserved in git&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;So in practice, it feels less like a new AI assistant and more like an iteration controller added on top of a coding agent.&lt;/p&gt;
&lt;h2 id=&#34;06-one-important-requirement&#34;&gt;06 One Important Requirement
&lt;/h2&gt;&lt;p&gt;Whether Ralph works well depends less on the loop itself and more on the quality of your feedback loops. The README says this very directly: without typecheck, tests, and CI, errors will compound across later iterations.&lt;/p&gt;
&lt;p&gt;For frontend tasks, the repository even recommends adding browser verification to the acceptance criteria. Without real verification, an agent can easily confuse &amp;ldquo;it looks done&amp;rdquo; with &amp;ldquo;it actually works.&amp;rdquo;&lt;/p&gt;
&lt;p&gt;That point is important. Ralph is not magical automation. It is more like a force multiplier for the engineering discipline you already have. If your project already has clear task breakdowns and reliable checks, Ralph becomes much more useful. If those foundations are missing, the loop will only repeat the confusion.&lt;/p&gt;
&lt;h2 id=&#34;07-one-sentence-summary&#34;&gt;07 One-Sentence Summary
&lt;/h2&gt;&lt;p&gt;What makes &lt;code&gt;Ralph&lt;/code&gt; worth studying is not that it introduces a huge amount of new infrastructure. It takes a simple but useful idea and turns it into a practical workflow: &lt;strong&gt;let &lt;code&gt;Claude Code&lt;/code&gt; or &lt;code&gt;Amp&lt;/code&gt; handle one small story per round, keep focus with fresh context, and preserve continuity through &lt;code&gt;git&lt;/code&gt;, &lt;code&gt;prd.json&lt;/code&gt;, and &lt;code&gt;progress.txt&lt;/code&gt;.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you are already using coding agents in real projects and keep getting stuck on how to push long tasks forward reliably, Ralph&amp;rsquo;s approach is well worth borrowing.&lt;/p&gt;
&lt;h2 id=&#34;references&#34;&gt;References
&lt;/h2&gt;&lt;ul&gt;
&lt;li&gt;GitHub repository: &lt;a class=&#34;link&#34; href=&#34;https://github.com/snarktank/ralph&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://github.com/snarktank/ralph&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Interactive flowchart: &lt;a class=&#34;link&#34; href=&#34;https://snarktank.github.io&#34;  target=&#34;_blank&#34; rel=&#34;noopener&#34;
    &gt;https://snarktank.github.io&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
        </item>
        
    </channel>
</rss>
