PTENES
Skip to content
TRACK 3

🛠️ Building your first loop

Enough theory — here you builds and runs a real loop. The track gives you the 7-step sequence, ready-to-copy-and-run prompts, the 8 ingredients of a loop that holds up, and the 8 mistakes that trip up beginners. Every prompt is real: paste it into Claude Code and it works.

A luminous path with seven numbered milestones that leads from a task to a running loop 1 · taskcorrect answer 2 · goalin one sentence 3 · toolsand guardrails 4 · statePROGRESS.md 5 · cycle4 steps 6 · hard stopmax attempts 7 · RUN observe and press
4
Modules
29
Topics
~3h
Duration
Medium
Level
Track progress: 0% 0 of 29

Track map

Detailed content

3.1~55 min

🎯 The 7-step sequence

Seven decisions in order that turn any task into your first loop running for real.

What it is:

Choose something where “done” can be checked independently of your opinion: tests pass, the format matches, the script runs without errors.

Why learn:

For your first loop, narrow it down to something with a built-in checker—that’s what makes the loop converge instead of wander.

Key concepts:

Open-ended task × task with a checker; verifiable done state.

What it is:

One sentence: "Every test in /tests passes when you run npm test." It becomes the loop’s done-state.

Why learn:

A vague objective ("clean this up") gives it no clear endpoint; the loop doesn't know when to stop.

Key concepts:

Objective in one sentence; checkable × vague.

What it is:

Allow edits to /src and /tests + running tests; NO merge or deploy permissions on the 1st run. The worker opens a PR, and a human merges it.

Why learn:

“Guardrails are the real work, not the agents.” Broad permissions too early = irreversible mess.

Key concepts:

Permissions, guardrail, PR (pull request).

What it is:

Ask it to write progress to PROGRESS.md and commit after each significant change, so you can pick up where you left off.

Why learn:

Anthropic’s harness: read state → incremental progress → self-verify → commit → leave things clean.

Key concepts:

PROGRESS.md, commit, resume between sessions.

What it is:

Gather context → make 1 change → verify (run tests) → repeat. ONE change per round is deliberate.

Why learn:

"Working on one feature at a time" was critical in the research; one change per iteration makes the loop converge.

Key concepts:

4-step cycle; iteration granularity.

What it is:

“Stop when all tests pass, or after 10 attempts, whichever comes first.” The SDKs provide max_turns.

Why learn:

Without a stop, you risk "bizarre emergent behavior" and a token bill that keeps growing.

Key concepts:

Hard stop, max_turns, attempt cap.

What it is:

Watch the 1st run live; fix the INSTRUCTIONS, not the output. When it fails, fix the failure domain and put it back in the loop.

Why learn:

Huntley: "clay on the pottery wheel" — you shape the prompt, not the piece one at a time.

Key concepts:

Tighten the prompt; observe the run; the full 7-step loop.

View Full
3.2~50 min

🧪 Loops to copy and run

Ready-to-paste prompts for Claude Code—for code and text—with an objective, a block, and how to verify it.

What it is:

A complete prompt: goal (tests pass), 4-step loop, PROGRESS.md + commit, hard stop at 10, and what not to touch.

Why learn:

It's the template you adapt for everything. Paste, run, observe.

Key concepts:

Pasteable loop; objective + block + how to verify.

What it is:

Same setup, different task: rewrite a paragraph until it’s under 50 words AND mentions the price.

Why learn:

The check is Functional—it checks the rules (counting words, finding "price"), not whether it reads well.

Key concepts:

Loop outside of code; Functional check; 5-attempt guardrail.

What it is:

Together, /goal and /loop create a loop that directs and ends itself based on the stated objective.

Why learn:

E.g., generate 10 concepts, score them using a rubric, then iterate on the best one until it reaches score X.

Key concepts:

/goal, /loop, self-directing, self-terminating.

What it is:

Add to the prompt: "Pause and ask me before deleting, sending, or paying for anything."

Why learn:

It's the “You-decide” check: irreversible actions go through you before they happen.

Key concepts:

Human checkpoint; irreversible action; approval.

What it is:

Read the state from PROGRESS.md, make progress on ONE feature, self-verify, commit with a note, leave things clean, repeat.

Why learn:

It's the loop that survives between sessions and doesn't repeat itself when the context fills up.

Key concepts:

Externalized state; commit with a note; clean working tree.

What it is:

Swap the checker (Functional → Visual with a screenshot, or Judgment with a second agent) and swap the domain.

Why learn:

The shape of the loop stays the same; mark the parts you swap out and reuse it for any task.

Key concepts:

Functional × Visual × Judgment; blank template.

View Full
3.3~45 min

🧰 8 ingredients of a solid loop

The checklist for what makes a loop hold up versus fall apart at the first stumble.

What it is:

Define “done” in a way a machine can verify, not “make it good.”

Why learn:

Without a checkable done-state, the loop has no way to know it's finished.

Key concepts:

Done-state; machine verification.

What it is:

Maximum number of attempts, budget, or time. Always.

Why learn:

It's what keeps the loop from running forever and wasting tokens.

Key concepts:

max_turns; budget; time limit.

What it is:

The actions the agent takes need to be reliable and clearly described.

Why learn:

A poorly described tool makes the model use it incorrectly, and the loop turns into noise.

Key concepts:

Clear description; reliable action.

What it is:

Keep a history, but SUMMARIZE it so the context doesn’t bloat—one notes file.

Why learn:

A full context window makes the model lose track and cost more.

Key concepts:

Summary; notes file; context window.

What it is:

Generate → judge → fix → repeat. The maker never grades their own work.

Why learn:

The person who did the work is the worst judge of it; a separate checker keeps quality in check.

Key concepts:

Maker → checker; evaluator-optimizer.

What it is:

Large, multi-step job: ask for a plan before acting. Small job: skip the plan.

Why learn:

Planning everything is wasteful for a small task; not planning breaks a large one.

Key concepts:

Plan before acting; when to skip it.

What it is:

Save every thought, action, and result.

Why learn:

When the loop fails overnight, the log is the only thing that tells you what happened.

Key concepts:

Thought/action/result trace.

What it is:

Loops burn through tokens fast; start small and bounded, then scale up.

Why learn:

A loop without a cap or cost awareness becomes a billing surprise.

Key concepts:

Start small and keep it limited; scale up later.

View Full
3.4~45 min

⚠️ The 8 common mistakes

The eight pitfalls that trip up anyone building their first loop—and how to fix each one.

What it is:

The loop acts, never checks, and confidently delivers something broken.

Why learn:

"Check your work" is the most underrated step of all.

Key concepts:

Missing verification; confident nonsense.

What it is:

“Improve the code” doesn’t provide a done state; the loop keeps spinning without a target.

Why learn:

A vague objective is the #1 cause of a loop that never "ends."

Key concepts:

Vague × checkable; the loop’s target.

What it is:

Beginners assume the model stops on its own; many loops (Ralph) have no model-side stopping condition.

Why learn:

Set a maximum number of attempts and watch the first run — the stop is yours, not the model’s.

Key concepts:

Hard stop; Ralph; first-run supervision.

What it is:

Trying to fix everything at once makes the loop struggle; one change per cycle converges.

Why learn:

Anthropic was explicit: "one feature at a time" was critical.

Key concepts:

Granularity; one change per turn.

What it is:

Letting the first loop merge, deploy, or delete = irreversible mess.

Why learn:

Scope the permissions; the worker opens a PR, it doesn’t merge it.

Key concepts:

Permission scope; PR instead of merge.

What it is:

Without progress + commits, a loop that runs beyond 1 context window forgets what it has already tried and repeats itself.

Why learn:

State on disk is what gives the loop memory across context windows.

Key concepts:

Externalized state; context window.

What it is:

Human-in-the-loop (approval gates) is supervision, not the agent’s cognition.

Why learn:

Don't copy an HITL guide expecting a loop build pattern.

Key concepts:

HITL = human supervision; agent loop = cognition.

What it is:

Handing full control to the loop and stopping reading the output — Osmani’s warning.

Why learn:

You remain the reviewer, especially at the beginning.

Key concepts:

Human reviewer; don’t give up control.

View Full
← Track 2: When to use a loop Track 4: Loop Engineering →