Modern Creator
How I AI · YouTube

Loop engineering for beginners

A plain-English field guide to every loop type — heartbeat, cron, hook, and goal — with two live builds in Claude Code and Codex.

Posted
yesterday
Duration
Format
Tutorial
educational
Views
8.5K
312 likes
Big Idea

The argument in one line.

Loops are just automated prompts pointed at agents rather than software — heartbeats, crons, and hooks you already know — and the only genuinely new primitive is the goal loop, which runs until a measurable outcome is met instead of on a fixed schedule.

Who This Is For

Read if. Skip if.

READ IF YOU ARE…
  • You use Claude Code or Codex daily and keep manually typing the same prompt to kick off recurring work.
  • You manage a product or engineering team and want agents to babysit PRs, triage issues, or surface skill gaps without human reminders.
  • You have seen the loops-are-in hype and want a plain-English explanation before touching any tooling.
  • You are comfortable with basic automations (Zapier, crons) and want to understand how AI agents plug into the same mental model.
SKIP IF…
  • You are looking for a deep technical implementation guide with code — this is conceptual plus live UI demo, not a coding tutorial.
  • You are already running production loop infrastructure and want advanced optimization strategies.
TL;DR

The full version, fast.

A loop is simply an automated prompt — the agent prompts itself on a heartbeat, a cron, a hook, or until a goal is met, rather than waiting for a human to type. The four loop types map directly onto automation primitives developers have always used, and the only new one is the goal loop, which exits only when a defined success criterion is reached. Two live builds demonstrate a daily aging-PR reviewer in Claude Code and a weekly Codex automation that spawns goal-based subagents to validate its own skill recommendations. The main warning: goal loops burn tokens aggressively when success criteria are vague, so prompt precision matters far more here than in conversational use.

Free for members

Chat with this breakdown — free.

Sign in and you get 23 free chat messages on us — ask for the hook, quote a framework, find the exact transcript moment, generate a markdown action plan. Bring your own key when you want unlimited.

Create a free account →
Chapters

Where the time goes.

00:0001:33

01 · Cold open + sponsors

Hook: prompts are out, loops are in. WorkOS sponsor read covering enterprise auth APIs.

01:3403:03

02 · Defining a loop

Traces the claim to a Peter Steinberger tweet. References prior OpenClaw article. A loop is any automated way to prompt an agent without a human typing.

03:0306:07

03 · Four loop types

Heartbeat (interval timer), cron (fixed schedule), hook (lifecycle/webhook), and goal (runs until outcome validated). All four exist in Claude Code and Codex.

06:0709:26

04 · Five things every loop needs

Worktrees, skills, plugins/connectors, subagents, state tracking. Comparative table: Codex vs Claude Code.

09:2611:58

05 · Onboarding-an-employee model

Design loops like job descriptions: EA gets a Friday calendar review, engineer gets hourly GitHub triage, PM gets a goal loop over PR checks.

11:5814:21

06 · Non-technical loop intro

Morning briefing in Claude Co-work is already a loop. Scheduled tasks = loops. Easy entry point.

14:2115:07

07 · Runway sponsor

Runway AI creative platform sponsor read.

15:0718:51

08 · Live build #1: aging-PR loop

Creates Daily aging PR review routine: scans ChatPRD app for PRs open over 12h, spins off subagent threads to babysit, sends mean Slack message. Scheduled 10:15 AM daily.

18:5119:00

09 · Subagents inside loops

Routine spawns per-PR threads. Master loop delegates; subagents work independently. Slack MCP fix live on camera.

19:0024:57

10 · Live build #2: skills loop

Codex Skill progression map template, customized to find missing CLI/MCP tool skills, spawns goal-based subagent per skill to validate against base branch. Named agents Gauss and Galileo spin up live.

24:5728:37

11 · Warning signals

Two risks: goal loops burn tokens with weak exit criteria; loop prompts need far more precision than conversational prompts. References OpenAI goals guide.

Atomic Insights

Lines worth screenshotting.

  • A loop is just an automated prompt — the agent prompts itself instead of waiting for a human to type.
  • Heartbeats, crons, and hooks predate AI by decades; you are not learning a new paradigm, you are pointing a familiar one at agents.
  • The goal loop is the only genuinely new primitive: it runs until a measurable outcome is reached, not until a clock fires.
  • Five things every effective loop needs: worktrees for isolation, skills for reusable task knowledge, plugins/connectors for tools, subagents for federated work, and state tracking.
  • Design loops the same way you would onboard an employee: define the job, the schedule, and the success condition before writing a single prompt.
  • A scheduled task in Claude Co-work or a routine in Claude Code is already a loop — most people have been writing loops without knowing it.
  • A loop can spawn subagents, and those subagents can themselves run on goal loops — the hierarchy goes as deep as the job requires.
  • Goal loops with vague exit criteria are the fastest way to burn a large API bill for underwhelming output.
  • Loop-based prompting requires far more precision about evaluation and success criteria than conversational prompting does.
  • Both Claude Code and Codex are at parity on loop primitives: scheduled tasks/automations, /goal, worktrees, skills, subagents, and state tracking all exist in both.
  • The morning briefing is the simplest entry point into loops — a scheduled task that runs on a cron, no goal logic required.
  • When a routine spins off subagents, the master thread does not need to monitor the work — that is the whole point of delegation.
  • Codex automation templates are a useful source of loop inspiration before you write from scratch.
Takeaway

Four loop types, one mental model, two warnings.

WHAT TO LEARN

An AI loop is just an automated prompt — and the only new thing worth learning is the goal loop, which runs until an outcome is met rather than until a clock fires.

  • Heartbeats, crons, and hooks are not new concepts — they are the same automation primitives developers have used for years, now pointed at AI agents instead of software jobs.
  • The goal loop is the genuinely new primitive: it runs until a defined success criterion is measurably met, which means exit conditions must be written with the same care as the task itself.
  • Every effective loop needs five things in place before it touches production: isolated worktrees, reusable skills, tool connectors, the ability to spawn subagents, and a way to track state.
  • Design loops the same way you would describe a job to a new employee — specify the task, the schedule or trigger, and what done looks like before writing a single line of prompt.
  • Both Claude Code and Codex expose the same loop primitives under different names: routines vs automations, scheduled tasks vs crons, /goal in both.
  • Scheduled tasks and morning briefings in Claude Co-work are already loops — most practitioners have been writing them without recognizing the pattern.
  • A loop can spawn subagents, and those subagents can themselves run on goal loops — hierarchy depth is limited only by the complexity of the job, not the tooling.
  • Goal loops with vague or unmeasurable exit criteria burn tokens aggressively and produce disappointing output — precision in success criteria is the highest-leverage investment in loop quality.
  • Loop-based prompting is its own discipline: the skills that make a good conversational prompt do not automatically transfer, especially around evaluation logic.
Glossary

Terms worth knowing.

Heartbeat
A loop type that fires on a regular interval — every 5 minutes, every 30 minutes — regardless of external events. The system wakes up, checks what needs doing, and acts.
Cron
A loop type tied to a fixed point in time — 9 AM every weekday, every Sunday night. More scheduled than a heartbeat, less reactive than a hook.
Hook
A loop type triggered by an internal lifecycle event (a tool was called, a session started) or an external webhook (an email arrived, a PR was opened).
Goal loop
A loop type that runs an agent against a defined outcome until the outcome is measurably met or the agent is blocked. Unlike crons and heartbeats, it has no fixed end time — it exits on completion.
Worktree
An isolated copy of a repository where one agent does its work without interfering with other agents running on the same codebase simultaneously.
Skill (Claude Code / Codex)
A reusable, stored procedure that tells an agent how to perform a common task — the agent invokes the skill by name rather than re-deriving the steps each time.
Subagent
A child agent thread spawned by a parent agent to handle a specific piece of federated work, such as validating a single PR or testing a single skill, so the parent can delegate rather than serialize.
Resources

Things they pointed at.

Quotables

Lines you could clip.

11:36
Do not set your alarm and wake up and type into Codex or Claude Code the prompt that would kick it off. Instead, set it up to do that itself.
Self-contained one-liner that lands the entire argument for loopsTikTok hook↗ Tweet quote
26:10
I think these loops are a great way to spend money. So just be thoughtful about where you apply it.
Honest warning that cuts against the hype — earns trustIG reel cold open↗ Tweet quote
27:10
Goal based prompting is just its own thing because you have to be very precise about evaluation and success criteria. If you are not, you will be very disappointed and use a lot of tokens for not a lot of output.
Practical warning with consequences stated clearlynewsletter pull-quote↗ Tweet quote
The Script

Word for word.

Read-along

Don't just watch it. Burn it in.

See every word as it's spoken — crank it to 2× and still catch all of it. The same dual-channel trick behind Amazon's Kindle + Audible.

metaphoranalogystory
00:00Prompts are out and loops are in. If your agent isn't able to prompt itself through an automation, what are you even doing? In today's episode, I'm gonna teach you what a prompt is in normal person speak, how to write one, when it's useful, and some pitfalls to watch out for.
00:16We will be doing this in Codex and in Cloud Code. And at the end of this episode, you'll be one of the cool kids whose agents prompt itself. Let's get to it.
00:24This episode is brought to you by WorkOS. AI has already changed how we work. Tools are helping teams write better code, analyze customer data, and even handle support tickets automatically.
00:36But there's a catch. These tools only work well when they have deep access to company systems. Your copilot needs to see your entire code base.
00:45Your chatbot needs to search across internal docs. And for enterprise buyers, that raises serious security concerns. That's why these apps face intense IT scrutiny from day one.
00:56To pass, they need secure authentication, access controls, audit logs, the whole suite of enterprise features. Building all that from scratch, it's a massive lift.
01:06That's where Work OS comes in. Work OS gets you drop in APIs for enterprise features so your app can become enterprise ready and scale up market faster. Think of it like Stripe for enterprise features.
01:20OpenAI, Perplexity, and Cursor are already using Work OS to move faster and meet enterprise demands. Join them and hundreds of other industry leaders at workos.com.
01:32Start building today. Okay. So why are we all prompt maxing?
01:37Of course, it's Pete at OpenClaw who told us we are old news if we are prompting, and we really need to be designing loops where our agents can prompt themselves. Now this one tweet spun off tons of content about what is a loop, how to use a loop.
01:53And to be honest, I don't think any of them explained it very well. So I am here to answer your safe space questions about what is a loop, how do I get one set up, is it really that useful, and should I really be letting my agents prompt itself? I think the answer is yes and.
02:10Yes. There are tons of great use cases for loops, and we're gonna talk about how you can use those and how they can be beneficial, especially with software engineering.
02:18But there are some reasons why you wouldn't want to use loops, and honestly, I still do a little prompting. So don't worry if you are not loop maxing. You're in good company, and you can still get a lot done with AI.
02:31So to answer what a loop is, I'm just gonna make this super simple for you all. And this goes back to one of the earliest articles I wrote on OpenClaw, which was this article about why OpenClaw feels alive even though it's not.
02:44And the core of this article was explaining that there are many ways you can prompt an AI agent. And often, we only think about one way to prompt an agent, but actually, there are many ways an agent like Claude Code, like Codex, like ChatGPT, like name your favorite agent here, can be prompted.
03:03And I wanna go over what those ways are. First, there are messages. This is a human triggered input.
03:09This is probably how most of us are prompting our agents. We are going to a chatbot, and we are typing in some sort of prompt, waiting for a response, and then typing another response. That is a message turn based prompting strategy.
03:23I still think there's use for this kind of prompting. I use it all the time, but that is not what we're talking about when we're talking about loops. Instead, when we're talking about loops, we're talking about automated prompting of an agent.
03:36And there are a couple form factors that can take, and I just wanna remind you what what those are. And I'm using OpenCloud because I think it demonstrates these types of prompt loops, but it's not the only system that does them.
03:48So the first one is a heartbeat. You can set a schedule, like, every 30 minutes, every hour, every five minutes. And on that schedule, it's going to kick off a task.
03:58And so you're gonna say, every five minutes, check if I have a new Jira ticket. And if so, start a coding agent to triage and fix that Jira agent. That's sort of like on a heartbeat.
04:07Every five minutes, I want it to do that. Then there is a cron. A cron is at this time or on this schedule do this.
04:15So it can be at 9AM. It can be at a specific time.
04:20It could be every Sunday night. These crons are a little bit more scheduled. A heartbeat is kind of on a regular basis.
04:28Crons are more on a set defined schedule. And then the last thing that I've talked about are hooks. So you can prompt an agent based on an internal life cycle, like a tool was called, a session was started, a session was reset, or an external hook, like a webhook from an external session.
04:48Every time I receive an email, I wanna get a webhook and kick off some sort of agent. And I only remind you of these things because these are common ways to do automations outside of AI.
04:59So we were doing automations on heartbeats, on crons, on hooks way before AI even happened, but now you can do that in order to prompt your AI. And so I think this whole concept of a loop is really just reminding people you do not have to use your human fingers to type in a prompt in order for your agent to do work on your behalf.
05:21Now what's different between when I wrote this article in Now is a new type of loop has been shipped as a first class citizen of both Claude Code and Codex, which is a goal. A goal is a type of loop that sets an outcome and runs an agent against that outcome until the outcome can be measured and validated or the agent is blocked.
05:42And so I'd say there's one more loop type that's becoming pretty common in AI coding in particular, although I think there's lots of use cases for it. But, again, pretty simply, a loop is a scheduled or kind of semiautonomous automation that allows an agent to instruct itself what to do, prompt itself, and get that work done.
06:04Now what do you need to write an effective loop? I like this article by Addie Osmani about loop engineering.
06:13I think it's really good. It does break this down pretty well. You can see it's fairly recent.
06:17It's from this month. But my favorite part about this article is what you need to write a good loop.
06:24To write an effective loop, you need these five things. I like how this is written out in this block in that it tells you what the thing is. It's an automation, kind of what its job is.
06:33So it's like triage of a task to be done or a prompt to be set on a schedule. And then it shows you how Codex and ClaudeCode do this. And so for Codex, your automations come can come out of the automations tab, and you can actually define your automation in the schedule there.
06:49And then in Claude code, you have scheduled tasks. Both of them have slash goal, and then they all have different hooks and integrations.
06:57Claude code has the benefit of GitHub actions, which I think is nice for engineers. But both of them are basically at parity in terms of the types of automations that you can run. And then a couple other foundational things that I think are helpful when you're running loops.
07:11And why are these things helpful before we get into what they are? They just keep the work clean. If you are gonna be yoloing loops all over the place, you're going to want some consistency in execution.
07:23You're gonna want clean workspaces. You're gonna want conflicts resolved and avoided. And so all these things are really to make those loops effective.
07:32And so what what are those things? They are work trees. I feel like this entire podcast could be get one zero one.
07:39But work trees are just basically a way to isolate the work, especially the coding work of an agent away from other agents' work in a sandbox. There are skills, repeated ways to do common tasks. We have a full episode on what skills are from earlier last year when they came out.
07:56Plugins and connectors, these are just the tools that your agent has access to. And so those can be, like, GitHub connectors, connectors to Google Docs and Google Calendar, and plus plugins, which are some instructions on how to use those tools.
08:10Subagents, both Codex and ClogCode allow you to kick off subagents. This is just a way to federate out work from the main thread so that subagents can do specific tasks, especially validation.
08:22And then there's some way to track state. And, essentially, just think of this as like a to do list.
08:28So you can save it in a markdown to do list. You could use linear as a task tracker.
08:34Both Cloud Code and Codex use this. And so if you put all this together, basically, what you have is a way to kick off an automatic prompt, a way to keep that prompt going until the job is done.
08:48And the way you keep it going is you can keep it scheduled, or you can give it a goal, and it can't exit the loop until it's hit that goal. And then you empower this agent that has been kicked off autonomously with the isolation it needs not to get in each other's way and tools it needs to get the job done, including its little army of sub agents.
09:07That's it. So, again, I promised you I'd explain it to you very basically what a loop is.
09:13A loop is a way to autonomously kick off an agent with a prompt or set of prompts on a schedule or on kind of a recurring basis until it's done. It could be done because the time's up, or it could be done because the job's done.
09:27Now people are gonna ask, what should I use a loop for? And when you're designing loops or designing agents, I say this is the time for the manager.
09:36You are designing a job. And so just imagine that you're onboarding an employee.
09:43That employee could be an executive assistant. That employee could be a customer service agent. That employee could be a software engineer.
09:52You're onboarding this person. And you're gonna say, you know what? Every Friday, EA, I would like you to review my calendar, see who canceled on me, where I could've used my time more effectively, if there are any follow ups, and send me a Slack to get this done.
10:09And I want you to do that every Friday. Guess what? You've just designed a loop for your executive assistant.
10:15If you have a software engineer and you say, you know what? Every hour, I want you to check if there's a GitHub issue that needs to be addressed. And if there is, triage it.
10:25Write some code. Put it up for code review. Congratulations.
10:29You just wrote a loop. And if you have another software engineer and you say, every time you get a PR to review, I wanna make sure that you iterate over it until it meets our defined code standards. All the links and checks are clean, and it's ready to deploy.
10:44And you just work on it until all the checks in the GitHub PR are clean. Guess what? That is a goal loop.
10:50So I really like to think about loops as designing workflows and designing jobs to be done for people. It just happens to be that you can put this intelligent agent against the loop, and then it's ready to go.
11:02So that that's it. That that's a loop.
11:05And, you know, I think people get intimidated by these complex, like, dynamic workflow diagrams and these hype boy posts about how they're running thousands of loops all over the place, and they never prompt anything themselves. And, again, I just wanna make this really accessible for folks.
11:22If there is something where you feel like every day or every hour a set job can be done, that's a good time for a loop. And don't set your alarm and wake up and type into Codex or Claude code the prompt that would kick it off.
11:37Instead, set it up to do that itself. And the one magical thing I would let people know is you can create loops to have your agent prompt other loops.
11:49So, again, you can think about a human with a team of agents who all have their own team of agents, and you can start to get really creative about what these loops are. But let's go ahead and build one.
12:01So I'm gonna build one in Claude code and one in Codex, and I'm gonna do one sort of nontechnical one and one technical one. And then we will end with some warnings about using loops.
12:14Okay. I wanted to start with a nontechnical example, and I pulled up Claude Cowork instead of Claude Co.
12:20Just to really break this down for the people who are not technical. And what makes me laugh is there is a loop front and center here in Claude Cowork, which is my morning briefing.
12:32And so if you had used a scheduled task in Claude Cowork, guess what, babe? You have written a loop.
12:39It's a loop that kicks off on a regular basis. It prompts itself on what it needs to do. It gets the job done.
12:47And when I have my morning briefing, I am finished. And so scheduled tasks are a loop.
12:54Now it's not a goal style loop, but it is a loop itself. So if you are wanting to tiptoe your way into loops, I would say co work schedule tasks or in Claude code, what we call routines are perfect ways to get started.
13:09So the morning briefing is a perfect loop one zero one for you all to start. But let's actually make this a little bit more intelligent. I'm gonna go into Claude Code, and I am going to create a loop that's a little bit more technical but for the product folks that are watching.
13:26Okay. To start in Claude Code, I'm gonna write a loop or a routine that's a little helpful for the product managers, engineering teams out there.
13:35It's not a super technical one, but it's one I think is really useful. And so what I'm gonna do is I'm gonna create a routine. It can run locally, which means it's gonna run on my computer, which means I gotta keep the laptop screen open.
13:48But don't worry. I do that anyways. Or it can work on the cloud.
13:51I'm just gonna have it run locally. And I'm gonna call it daily aging PR review.
13:57And so if you can guess from the description, this is gonna be a loop or a routine that looks for open PRs that have been open more than twelve hours and babysits them till they are ready for merge or alerts the team about aging.
14:22This episode is brought to you by Runway, a new kind of creative platform that has everything you need to generate any image, video, or piece of content you want all in one place. With Runway, it's now possible to go from initial idea to a finished deliverable in a matter of minutes.
14:41From turning low fidelity product shots into campaign ready imagery all the way through putting together big brand films, runway can help your team scale your creative ambitions ambitions while keeping your budgets and timelines from doing the same. Runway brings together the world's most advanced AI models, which is why enterprises like Microsoft, Robinhood, Amazon, and Adobe, along with studios like Lionsgate and Legendary, all use Runway to ship real work every day.
15:10Try it yourself at runwayml.com/howiai. Promo code, howiai. Okay.
15:21So the problem I'm having is that we ship a lot of PRs because we do agents everywhere and loops everywhere. And then I kind of get bored of babysitting them, and we forget to merge them in a timely basis.
15:33And so we probably have, like, I don't know, 40 PRs that we need to go through. And the ones that I'm most worried about are the ones that, like, we kinda moved on from and are letting age. And so I'm gonna give it some instructions, and I am going to say, look at the PRs open on the ChatPRD app app.
15:52If there are any PRs open more than twelve hours, please review their merge readiness. If there is anything that you can babysit, spin up a thread to babysit that PR until all merge checks are green.
16:06Otherwise, send a Slack in the product channel to the team about the open PRs that are ready for approval and merge.
16:17Be mean when you send the Slack. Okay. So I am putting in that those instructions, and I'm gonna say I want this to run, let's see, daily at 9AM.
16:31That's fine. Actually, let's have it daily at 10:15AM because it's about to be 10:15. Okay.
16:38And then I am going to have it work in my Chat PRD branch on base is fine, and I'm gonna create that automation.
16:50Now there's a loop. And a couple things I wanna call out about this loop. It happens every day at 10:15, so it happens on a schedule.
16:58I don't have to come in and say what PRs do I need to review, and it's gonna tell me the next time it's gonna run. And then one thing that I wanna call out is you remember I said your agent can have agents?
17:09I called out here that if there are any PRs that need to be babysat, you can spin up a thread to babysit that PR until all merge checks are green. So not all the work has to happen in the one master thread. It can actually kick off sub agents or other threads to watch the work.
17:25And so I'm gonna go ahead and not wait the four minutes and run this now. Okay. So once this is kicked off, yes, it's gonna prompt with that original prompt that I put in the routine or automation.
17:37But then it's gonna be pretty autonomous and work itself. And, you know, I've given it basically two outcomes it needs to go after. It needs to identify anything over twelve hours that it can watch and actually monitor and make sure all the merge checks are green itself.
17:54That's success criteria one. And then success criteria two is it would use our Slack connector to send us a message. Again, I'm not gonna make you watch this, but you can see here it's gonna work all by itself.
18:08I am not gonna have to monitor it, and all I'm gonna get at the end of the day is a good set of PRs that are ready to merge and some mean messages about how we're ignoring good PRs and not putting awesome product in the hands of our customers. So, again, I wanted to demystify what a loop is.
18:25It is just something that happens on a schedule. Now this is a very simple loop, and it has access to a bunch of connectors. It has access to GitHub.
18:34It's gonna have access to Slack. That's already set up. So I feel like this agent or this, like, pseudo employee with a job is well set up to be successful.
18:42But this is a perfect use case for a loop and a very, very simple time based one. K. And it says no Slack MCP surfaced.
18:53I am going to make sure that Slack is turned on. There we go.
18:58Now it should be fine. Okay. Now let's talk about a more advanced loop.
19:05So I wrote that one in Claude code. It is a scheduled routine. It is pretty sam simple.
19:10But I'm gonna also pull up Codex and show you another loop that I think is really interesting that's a little bit more complicated and a little bit more technical. Before I go into writing a more complicated loop, I wanted to call out some of the things that I like in Codex when you're thinking about or learning how to write loops.
19:28So in Cloud Code, they're called routines. In Codex, they're called automations. And what I like about what Codex has done is they have these templates.
19:39And so they actually have given you a couple good ideas of, quote, unquote, loops, automations, routines that you can run.
19:46So if you're looking for inspiration, I would really look at these automation templates. And I'm actually going to use one. I think it's this from recent PRs and reviews to suggest next skills to deepen.
19:58And so this is sort of a meta tool that I'm gonna use, which is look at all the code we shipped, look at all the code commits and comments, and then come up with skills that our coding team, including agents, could use to deepen the work.
20:17And so I'm gonna select that one. It's gonna happen Fridays at 10AM.
20:22It's gonna happen weekly. I think weekly is right. Again, you want enough data in these loops for it to do a good long job, but I'm gonna give it a little bit more information.
20:33So the prompt is out of the box. From recent PRs and reviews, suggest next skills to deepen. Grounding rules, anchor each suggestion to concrete evidence, avoid generic advice, make each recommendation actionable and specific.
20:44I'm actually gonna be more specific. If we have developed any tools for agents or developers to automatically validate their work, ensure that we have a skill for those tools, specifically command line tools or MCPs, where an agent or a software engineer can run a test suite or smoke test against a specific use case are very important to build skills around.
21:12I'm gonna add one more thing to the skill just to show the power of sub agents and automations. If you identify a skill, spin up its own thread, and use that skill validate validated against the base branch of the repo, We want to confirm that the skill actually works and outputs high quality.
21:33Okay. So this is like a a loop with sub agents that is probably gonna generate its own loop.
21:41I'm actually gonna force it to generate its own loop by saying, you should use a goal when validating the skill. So when you prompt the sub agent, make sure you prompt it with a very specific goal it can use to validate against.
21:57You know, basically, when you write a loop or a goal or an agent, you just say validate loop goal, validate loop goal, and you're good to go. But this basic prompt is saying, okay. Every Friday, I want you to look at all the code I merged.
22:08I want you to identify skills that are missing. There are specific types of skills that I think are very important, which is skills to use some of the internal tools we've developed. If you see a new skill, I want you to spin up a sub thread, another chat.
22:22I want you to validate that skill with a goal loop. So not only are we setting a loop at the schedule basis, we are setting up sub agents to work on specific things, and then we're using a goal in those sub agents, which is a different type of loop, to validate the work.
22:40So this is, like, a very meta task, but I think one that illustrates the power of loop based prompting. It doesn't just have to be on a schedule.
22:49It can be on a schedule, set up a team that does work on a schedule, or on a schedule, set up a team that does work on a loop until it's done. And so I'm gonna go ahead and create that. And then, again, I'm gonna just run this now.
23:04And we're gonna see here that this agent is going to spin up. The automation is going to start.
23:11One of the things that Codex does that's kind of interesting is it sets up its own memory. So you can see here a little bit of the scaffolding of what an automation looks like, and then it just gives its own prompt.
23:24Now, again, it's gonna go ahead and search the code, run its own commands. It's gonna look at GitHub, and it's hopefully going to create those new skills.
23:35And then what I ideally, we're gonna see in the left hand side in these all chats is new threads being kicked off to test the skills that it's identified it needs to run. And so it found one strong automation candidate.
23:48Let's see if it actually kicks off a thread to validate it. Okay. So it did it.
23:53Identified a chat smoke CLI skill. Basically, this is a command line tool I built to sort of test chats without having to use the UI in ChatPRD.
24:04And it basically spawned a dedicated sub agent to test the skill with a goal to test it against the base branch and tell us whether its instructions actually hold up in practice. So look.
24:16It spun up this agent. You can see agent. It's got a little key name, and it's given it a goal.
24:23So you can see here it's pursuing this goal, which is validate the local repo chat smoke CLI skill on the base branch. And it's basically gonna loop until that validation is done. So what we're gonna see is more and more sub agents being kicked off.
24:36You can click them here by clicking this little drop down.
24:41So I see Gauss, which is working on my smoke CLI skill. And then let's see. Galileo is working on a different skill.
24:50It's working on the GitHub address comment skill. So it's basically like a babysitter PR skill. And so this automation that I've set up happens on a Friday.
24:58It's gonna look at our repo. It's gonna create skills, and then it's gonna create sub agents that are on, again, a goal, which is a type of loop to validate that those skill works. And it's just gonna do it over and over again until it has done as many skills as thinks is appropriate for the last week.
25:18And so that is, like, my mega loop that actually I I did not think to do until live on this episode, and it's gonna be really useful for me on a regular basis. So I'm gonna let that run. But before I get you out of here, I just wanna talk about a couple warning signals around loops.
25:36This is amazing. We all want our agents to work for us on a schedule whenever we want doing work that we don't wanna do. It's great.
25:44What are some of the problems? One, loops can get expensive. So I just kicked off an automation that happens on a regular basis.
25:53It does wide ranging work. It decides when to spin off sub agents, and it does loop based validation, which means it's burning tokens until it hits a threshold that it decides is successful.
26:05If you do not write that loop well or your validation criteria is too thin, guess what? Your agent is going to burn tokens.
26:13I think we've seen this with OpenClaw in particular or some of these, like, agent harnesses is they're really good at loops. They're very diligent. They get interesting work done.
26:22But, man, do they love to burn tokens. And so I think these loops are a great way to spend money. So just be thoughtful about where you apply it, and then make sure you're monitoring it for both cost and efficiency of the setup.
26:35So I think that's thing number one. Thing number two is I wrote actually pretty pretty poor loop prompts. I would not recommend people follow my prompting.
26:46It did fine, but I think loops, especially goal based loops, are ones where writing the prompt really precisely is super, super important. OpenAI has a great guide to writing goals for codex.
26:59I use that all the time. And in fact, what I often have codex do is write its own goals. Loop based prompting is just its own thing.
27:08Goal based prompting in specific is just its own thing because you have to be very precise about evaluation and success criteria.
27:17If you are not, you will be very disappointed and use a lot of tokens for not a lot of output. So, again, I would be much more careful with loop based prompting than I would be prompts or conversations where I am actually monitoring it myself. Other than that, I think there are lots of places where you can use loops.
27:36I gave some examples that are really more about product and engineering, but you can use goals and loops for all sorts of things. We talked about the morning brief.
27:46That's a scheduled loop. I used a goal loop in another episode to clean out my Gmail inbox. That's another great example.
27:54You can have agents that prompt themselves to do effective research and spawn off sub agents if a specific topic seems interesting to you personally or your business. And so I just think there are tons of ways for you to think about how could I put my little agent worker on a schedule, or how could I give my little diligent agent a job that can be done and validating it against a goal, and then how can I leave it alone until that work's done?
28:21That is a loop. That is my summary. I cannot wait to hear in the comments what you're using looping for or if you think this is just totally overbuilt stuff that's wasting tokens, I found it useful, but I'd love to hear what you think.
28:35Thanks for joining How I AI. Thanks so much for watching. If you enjoyed the show, please like and subscribe here on YouTube or even better, leave us a comment with your thoughts.
28:46You can also find this podcast on Apple Podcasts, Spotify, or your favorite podcast app.
28:52Please consider leaving us a rating and review which will help others find the show. You can see all our episodes and learn more about the show at howiaipod.com. See you next time.
The Hook

The bait, then the rug-pull.

One tweet from the head of OpenAI developer experience declared that prompting agents was over — and Claire Vo decided someone needed to explain what loops actually are before the hype fully outpaced the explanation. This is the plain-English field guide that followed.

Frameworks

Named ideas worth stealing.

03:03list

Four loop types

  1. Heartbeat (interval)
  2. Cron (fixed schedule)
  3. Hook (lifecycle/webhook)
  4. Goal (runs until outcome met)

Taxonomy of every way an agent can be prompted without human input.

Steal forAny slide or doc explaining when to use scheduled vs event-driven vs outcome-driven automation
06:07list

Five things every effective loop needs

  1. Worktrees
  2. Skills
  3. Plugins/connectors
  4. Subagents
  5. State tracking

Infrastructure checklist before deploying any production loop.

Steal forAgent architecture review, loop design doc template
09:26model

Onboarding an employee

Design loops the same way you would describe a recurring job to a new hire: define the task, the schedule, and what done looks like.

Steal forExplaining loop design to non-technical stakeholders or PM teams
CTA Breakdown

How they asked for the click.

VERBAL ASK
28:37subscribe
If you enjoyed the show, please like and subscribe. Leave a comment with what you are using looping for.

Standard subscribe/comment CTA at outro with podcast directories listed. Low friction, no product pitch.

Storyboard

Visual structure at a glance.

open
hookopen00:00
loop definition
promiseloop definition01:34
four loop types
valuefour loop types03:03
five needs table
valuefive needs table06:07
employee model
valueemployee model09:26
Claude routines
valueClaude routines14:21
build #1 setup
valuebuild #1 setup16:59
loop running live
valueloop running live18:51
Codex automations
valueCodex automations19:00
subagents live
valuesubagents live24:57
warnings
ctawarnings25:28
Frame Gallery

Visual moments.

Watch next

More from this channel + related breakdowns.

14:18
Jay E | RoboNuggets · Tutorial

STOP Prompting Claude

A 14-minute tutorial on the three tiers of self-running Claude Code workflows — and why the creator of Claude Code stopped prompting it manually.

June 12th
20:04
Chase AI · Tutorial

Claude Code Has Evolved

Why the skill backbone — not the dashboard — is where all the real value in a Claude Code Agentic OS lives.

May 14th
Chat about this