Lesson 01 · Loop Engineering

Anatomy of a loop

Six parts. Learn the parts and every later lesson has a place to attach.

You prompt an agent turn by turn. You type, you read, you type again. Addy Osmani describes the alternative in one sentence:

Loop engineering is replacing yourself as the person who prompts the agent. You design the system that does it instead. Addy Osmani, Loop Engineering

A loop is a recursive goal: you define a purpose, and the AI iterates until the purpose is complete. The skill you are building across this course is not prompting. It is design.

The five pieces, and the sixth

Osmani lists five primitives, then adds one more that he calls the memory. Read the table once. You do not need to remember it yet.

PrimitiveJob in the loopIn Claude Code
AutomationsDiscovery and triage, on a scheduleScheduled tasks, cron, /loop, /goal, hooks, GitHub Actions
WorktreesKeep parallel agents off each other's filesgit worktree, --worktree, isolation: worktree
SkillsWrite down project knowledge the agent would guessAgent Skills (SKILL.md)
ConnectorsPlug the agent into your real toolsMCP servers, plus plugins to ship them
Sub-agentsOne has the idea, a different one checks itTask subagents in .claude/agents/
StateRemember what is done and what is nextMarkdown files, or Linear over MCP

The same six exist in the Codex app under different names. That is Osmani's point: the shape is the same, so stop arguing about which tool and design a loop that survives either one. See the primitive map for the full two-column comparison.

Why state is separate

The five primitives do work. The sixth remembers it. Osmani is blunt about why it sounds too small to matter and is not:

The model forgets everything between runs so the memory has to be on disk and not in the context. The agent forgets, the repo doesnt. Addy Osmani, Loop Engineering

Check yourself

What makes a loop a loop, rather than one very good agent run?

Where must a loop's memory of finished work live?

From memory: name as many of the six parts as you can. Do not scroll up.

Automations · Worktrees · Skills · Connectors (plugins) · Sub-agents · State.
Four or more is a good first pass. You will meet each one again in its own lesson.

Read the source

Primary source: Loop Engineering by Addy Osmani. Read the opening and the section titled The five pieces, and then notes. About eight minutes. Everything in this course is grounded there.

Stay sceptical Osmani is not selling this. He writes: "its still early, I'm skeptical and you absolutely have to be careful about token costs". Hold that line for the whole course.
I am your teacher. If any part of this is unclear, ask me. "Why is state separate from skills?" and "does a loop make sense for a solo repo?" are both good questions to bring back.