Level 7Lesson 58โฑ๏ธ 50 min

Building Block 1 & 2 - Automations + Worktrees

The heartbeat that makes a loop run by itself, and the trick that lets many agents work at once without stepping on each other

The Five Building Blocks (Your Map)

Every loop is made of the same five pieces, plus a memory. We'll take them one or two at a time. Here's the whole map so you always know where you are:

1. Automations  โ† the heartbeat (this lesson)
2. Worktrees    โ† parallel without chaos (this lesson)
3. Skills       โ† write down project knowledge (next lesson)
4. Connectors   โ† touch your real tools
5. Sub-agents   โ† one makes, one checks
+  State file   โ† the memory that outlives the chat

Block 1 - Automations: The Heartbeat

An automation is what turns "a thing you did once" into "a thing that keeps happening." It's the heartbeat - everything else in the loop hangs off it. An automation fires on a schedule (every morning), on an event(someone opened a pull request), or on a condition.

Think of it like an alarm clock for your agent. You set when it wakes up and what it does when it does.

In real tools today: Claude Code has scheduled tasks, cron, hooks, and GitHub Actions. The Codex app has an Automations tab where you pick a project, a prompt, and a cadence, and results land in a triage inbox. Different names, same idea: define an autonomous task, give it a rhythm, and let the findings come to you.

Two Kinds of "Keep Going": /loop vs /goal

There are two flavors of automation, and the difference matters a lot:

/loop - run on a cadence

"Do this every 30 minutes (or every morning), no matter what." Good for regular health checks. It runs on a clock.

/goal - run until something is true

"Keep going until all the auth tests pass and the linter is clean." It doesn't stop on the clock - it stops when a goal is actually met. Crucially, a separate, smaller AI checks whether the goal is met, so the agent that wrote the code isn't the one grading its own homework.

Example of combining them:

> /loop 30m  /goal All tests in test/auth pass and lint is clean.
  Scan src/auth for new failures, propose fixes in a branch,
  open a draft pull request when the goal holds.

Translation: "Every 30 minutes, look at the auth code. Keep
working until the tests pass AND the linter is clean - and let
a different checker decide when that's actually true."
Remember this phrase: maker-vs-checker split. The thing that decides "we're done" should not be the same thing that did the work. You'll see it again in Lesson 61 - it's the backbone of trustworthy loops.

Block 2 - Worktrees: Parallel Without Chaos

The moment you run two agents at once, a new problem appears: they both try to edit the same files and collide - exactly like two people editing the same paragraph of a document at the same time and overwriting each other.

The fix is a git worktree. In plain terms: it's a separate working copy of your project, on its own branch, that still shares the same project history. Each agent gets its own clean room to work in, so their edits physically cannot touch each other's.

WITHOUT worktrees                WITH worktrees
โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€                โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
Agent A โ”                        Agent A โ†’ copy A (branch A)
        โ”œโ”€ same files โ†’ ๐Ÿ’ฅ        Agent B โ†’ copy B (branch B)
Agent B โ”˜   collision!           ...no collision, merge later
Analogy: Worktrees are like giving each cook their own cutting board instead of making them all chop on one. Nobody bumps elbows. When everyone's done, you combine the results on purpose, not by accident.

The Real Ceiling: You

Worktrees remove the mechanical collisions, so you can run ten agents at once. But should you? Each one produces work that you still have to review. Your review bandwidth - not the tool - is the true limit on how many parallel loops make sense.

Don't confuse "possible" with "wise." Ten agents producing ten pull requests you can't read is worse than two you can. Start with one.

Hands-On: Write Your Heartbeat in English

Hands-on (15 min): For your candidate task from Lesson 57, write its automation in plain English first (no tools yet). Fill in this template:
WHEN: __________  (a schedule like "every morning at 7am",
                   or an event like "when a PR is opened")

DO:   __________  (the one job, e.g. "scan last night's
                   test failures and draft fixes")

UNTIL / STOP: ____ (a /goal condition like "tests pass",
                   plus a hard cap like "max 20 minutes")
If you can fill this in clearly, you understand the heartbeat. If the "UNTIL/STOP" line is fuzzy, that's a sign the task isn't loop-ready yet - exactly the kind of thing this level teaches you to notice.
Lesson 58 Quick Reference
Automation

The heartbeat: fires on a schedule, an event, or a condition and kicks off the loop

/loop

Runs on a cadence ("every 30 min"), regardless of state

/goal

Runs until a condition is true; a separate small model verifies "done"

Maker-vs-checker split

The thing that decides "done" should not be the thing that did the work

Git worktree

A separate working copy on its own branch - a clean room so parallel agents don't collide

Your review is the ceiling

Worktrees let you run many agents, but your ability to review caps how many you should

โ† Should You Even Build a Loop?
Unlocks in ~13 min of reading