The Ralph Wiggum Loop, evolved

Lorenzo Wynberg8 min readEngineering
Diagram showing the evolution from a simple bash loop to Trinity's multi-agent release pipeline

In mid-2025, Geoffrey Huntley published something that changed how developers think about AI coding. He called it the Ralph Wiggum Loop — a beautifully simple idea:

while :; do cat PROMPT.md | claude-code ; done

Feed a PRD to Claude Code in an infinite bash loop. Each iteration, the agent reads the current codebase, picks up where the last run left off, implements one task, commits, and loops back. Fresh context every time. No hallucination drift. Just persistent, autonomous code generation.

It worked. Huntley built CURSED — a full programming language — using nothing but the loop. Others followed. At a Y Combinator hackathon, teams shipped six repositories overnight for $297 in API costs — work estimated at $50K in contractor time. The technique spawned dozens of open-source tools: ralphy, ralph-orchestrator, open-ralph-wiggum, smart-ralph. The community exploded.

The Ralph Wiggum Loop proved something fundamental: AI agents can autonomously ship real, production code from a specification. That was the breakthrough.

But it only answered one question.

The questions the loop doesn't answer

The Ralph Loop is brilliant at turning a PRD into code. But software development isn't just "turn spec into code." At Broccoli Studios, we were managing six brands across entertainment, blockchain, and esports. We tried the loop approach. It worked for isolated tasks. Then reality hit:

Who reviews the code before it ships? What happens when you have five PRDs and only three should go in the next release? How do you coordinate parallel execution across multiple repositories? How do you keep humans in control without becoming the bottleneck? How do you know if the agents are actually getting better?

The loop doesn't answer any of that. It was never designed to. It's a proof of concept — and a great one. But we needed a production system.

So we built Trinity. Here are the five evolutions that took us from bash loop to release pipeline.

1. From PRDs to releases

The Ralph Loop thinks in PRDs. One spec, one loop, one pile of code at the end.

Trinity thinks in releases.

You can create multiple PRDs — plan iterations that break your project into phases, epics, and stories with dependency graphs. A 4-phase AI planning pipeline handles the breakdown: Architect designs the structure, Story Writer creates the stories, Dependency Mapper wires them together, and Calibrator scores difficulty.

But here's what matters: you choose which PRDs go into each release. Not everything ships at once. You link PRDs to a release, Trinity auto-creates checkpoint stories, validates the dependency graph, and manages the lifecycle from created through releasing to released. Per-repo semver tagging. Automatic changelogs. Optional release branch isolation.

The Loop
Single PRDfeature-spec.md
One Loop
Pile of codeNo versioning. No structure.
VS
Trinity
PRD 1PRD 2PRD 3
Select & Map to Release
v1.2.0Checkpoint release with changelog
createdreleasingreleased
important

Shipping code isn't the hard part. Shipping the right code at the right time is.

2. Multi-agent review, not single-agent looping

In the Ralph Loop, one agent does everything: read the spec, write the code, run the tests, commit. If it makes a mistake, the next loop iteration might catch it. Or it might not.

Trinity doesn't have one pipeline — it has three, each designed for a different job:

  • Story pipeline — the workhorse. Four agents (Analyst → Implementer → Auditor → Documenter) take a single story from spec to shipped PR.
  • Checkpoint pipeline — quality gates mid-release. Analyst → Audit/Fix loop → Documenter → Human Gate. Catches codebase-wide issues before they compound.
  • Release pipeline — the final pass before a version ships. Analyst → Audit/Fix loop → SEO Audit → Documenter → Human Gate. Includes an SEO audit for web targets.
Phase 1

Analyst

Reads the story requirements, analyzes the codebase for context, and creates a detailed implementation plan. Identifies risks, dependencies, and required services. Read-only — no code changes.

Phase 2

Implementer

Executes the Analyst's plan. Writes code across files, runs tests and fixes failures, handles Docker services. Does not commit.

Phase 31–7 passes

Auditor

Runs 1–7 simplification passes scaled by story difficulty and surface area. Full code review, build verification, and early exit on clean code.

Phase 4

Documenter

Commits the work and creates the PR with a generated description. Records learnings to the Knowledge Vault and updates roadmap progress.

Story in→ AnalystImplementerAuditorDocumenterPR shipped

The Auditor alone changes everything. It's a dedicated review agent that sees the code fresh — no sunk cost, no attachment to what the Implementer wrote. Up to seven simplification passes. That's what catches the bugs that single-shot generation misses. And that same principle — specialized agents with specific jobs — carries through to the checkpoint and release pipelines, where audit/fix loops run until the codebase meets the bar.

3. Configurable human oversight

The Ralph Loop runs unsupervised. That's the feature — and the risk.

Trinity gives you deterministic execution gates that pause the pipeline for human input. Not vague "approval" steps — specific, typed checkpoints:

  • Deviation approval when the Analyst proposes an alternative to your specified tech stack
  • Missing asset checks when stories reference images you haven't uploaded
  • Missing business details when a story needs context like company name or API keys
  • Missing secrets when execution needs API keys that aren't configured
  • External dependencies when a story requires services you haven't set up
  • PR review after implementation, before merge
  • Checkpoint approval before a release ships
  • Quality checkpoint for non-release quality assurance
  • Story blocked when the audit finds critical issues
  • Release to base when merging release branch to production

And here's the key: it's fully configurable, per story.

Ralph LoopTrinity
SupervisionRuns unsupervisedAutopilot or Manual with configurable gates
ScopeAll or nothingPer-story configuration
ControlHuman stops the loop manuallyTyped gates at specific pipeline stages
FlexibilitySame process for every taskCritical features get oversight, routine ones fly
Autopilot

Full pipeline runs end-to-end without intervention. Analyze, implement, audit, document, PR, merge.

Manual

Pipeline pauses at gates for your approval. Toggle per-story: auto-clarify, auto-PR, auto-merge, auto-approve checkpoints.

Before PipelineDeviation ApprovalMissing AssetsMissing DetailsMissing SecretExternal Deps
After PipelinePR ReviewStory Blocked
Release-LevelCheckpoint ApprovalQuality CheckpointRelease to Base

You decide the balance. Auth system rewrite? Gate everything. Docs update? Let it fly. The same project, the same pipeline, different levels of trust for different stories.

4. True parallel execution

The Ralph Loop is sequential by nature. One agent, one loop, one task at a time.

Trinity runs up to five workers in parallel, each executing a different story in its own isolated git worktree. A coordinator manages the job queue per release, with atomic job claims and dependency-aware scheduling. Stories only become runnable when their dependencies are satisfied.

Conflicts happen — that's unavoidable when multiple agents touch the same codebase. Trinity handles them with a dedicated resolver agent that understands the full context of both branches. It merges intelligently, not mechanically. No manual resolution, no broken builds.

Multi-repo workspaces

A single story can span multiple repositories with coordinated branching. Branch names are derived from configurable templates at runtime — not stored — so the system stays flexible. Each repo tracks its own version independently.

Parallel Execution — 5 Workers, 5 Worktrees, AI-Powered Conflict Resolution

Worker 1

1:1.2.1Auth flow

feature/auth-flow
Auditing
Worker 2

1:1.2.2API routes

feature/api-routes
Implementing
Worker 3

1:3.1.1Dashboard UI

feature/dashboard
Documenting
Worker 4

1:2.1.1Billing

feature/billing
Analyzing
Worker 5

1:2.1.2Webhooks

feature/webhooks
Implementing

5 stories · 5 branches · 5 worktrees · conflicts auto-resolved

Five stories. Five branches. Five worktrees. Conflicts auto-resolved.

5. Knowledge that compounds

The Ralph Loop's most elegant constraint is also its biggest limitation: fresh context every iteration. No memory of previous runs. Each loop starts from zero, reading the codebase to figure out what happened before.

Trinity's Knowledge Vault flips that. Every execution writes learnings back to a database-backed knowledge system. Architecture decisions, framework gotchas, project-specific patterns — organized into books, chapters, and pages. Agents query the vault before every run.

Run 1: the Auditor catches a React hydration bug caused by a specific library pattern. It writes the gotcha to the vault. Run 2: the Analyst reads the vault, sees the gotcha, and the Implementer avoids the pattern entirely. Run 47: the team has a living knowledge base that no single developer could maintain.

1

Auditor catches hydration bug

React hydration mismatch caused by useLayoutEffect in SSR context. Writes gotcha to vault.

2

Analyst reads vault before planning

Sees the hydration gotcha. Flags the pattern in the implementation plan. Implementer avoids it entirely.

47

Living knowledge base

Architecture decisions, framework gotchas, project patterns — compounding across every execution.

Knowledge Vault
GOTCHAReact hydration fails with useLayoutEffect in SSR
ARCHITECTUREAPI routes use middleware chain pattern for auth
PATTERNForm validation uses Zod schemas shared with API
CONVENTIONAll DB queries go through repository layer, not direct
DECISIONChose Turso over Planetscale for edge replication

47 entries across 6 books · agents query before every run

The loop starts from scratch. The pipeline gets smarter.

We're just getting started

Everything above — releases, multi-agent review, execution gates, parallel workers, compound knowledge — is the execution pipeline. It's the core of Trinity.

It doesn't even begin to scratch the surface.

We haven't talked about team collaboration — real-time sync across your team with shared projects, coordinated execution, and role-based access. We haven't talked about the activity feed that gives you a live stream of everything happening across your projects, filterable by project, team member, agent, or date. We haven't mentioned the gotchas library that automatically catalogs every pitfall your agents discover so the whole team benefits. Or the metrics dashboard that tracks execution performance, audit pass rates, and agent efficiency over time — so you can see, empirically, whether your pipeline is getting better.

There's the codebase audit tracking that monitors code health across releases. Project assets management for design files, brand guidelines, and reference materials that agents can access during execution. Configurable AI model tiers so you can run Opus on your critical architecture stories and Haiku on your boilerplate. And recaps that summarize what shipped, what's blocked, and what's next — generated automatically after every execution cycle.

The pipeline is the engine. But Trinity is the whole car.

From loop to pipeline

The Ralph Wiggum Loop deserves its place in the history of AI-assisted development. It proved the concept. It showed that AI agents, given a clear spec and persistent access to the codebase, can ship real software autonomously.

Trinity is what happens when you take that proof of concept and ask: now how do we actually run a software project with this?

The loop proved AI can build from a PRD. Trinity proves it can ship releases.

Multiple PRDs feeding into coordinated releases. Three specialized pipelines instead of one generalist looping. Ten typed execution gates instead of unsupervised execution. Parallel workers with AI-powered conflict resolution instead of sequential tasks. Compound knowledge instead of amnesia.

From loop to pipeline. From PRD to release. From proof of concept to production system.

💡tip

Ready to evolve past the loop? Download Trinity — available for macOS and Linux.

Lorenzo Wynberg

Founder

Share
#ai-agents#autonomous-coding#release-pipeline#code-review