{"slug": "how-to-design-ai-agent-loops-schedules-goals-and-subagents-in-claude-code-and", "title": "How to design AI agent loops: schedules, goals, and subagents in Claude Code and Codex", "summary": "Claire Vo breaks down four types of AI agent loops—heartbeat, cron, hook, and goal—and demonstrates live builds of a daily aging-PR reviewer in Claude Code and a weekly skills-identification loop in Codex that spawns subagents. The episode covers the five essential components every effective loop needs and warns about cost pitfalls.", "body_md": "I break down every loop type from scratch—what a heartbeat, cron, hook, and goal loop actually are, when each one fits, and the five things any effective loop needs before it touches production. Then I build two live loops: a daily aging-PR reviewer in Claude Code that schedules itself at 10:15 a.m. and spins off its own subagents, and a weekly skills-identification loop in Codex that spawns goal-based subagents to validate its own output in real time.\n\n**Listen or watch on YouTube, Spotify, or Apple Podcasts**\n\n### What you’ll learn:\n\nThe plain-English definition of a loop—and why it’s just an automated prompt, not a scary new paradigm\n\nThe four loop types (heartbeat, cron, hook, and goal) and when each one actually fits your workflow\n\nHow to think about loop design using the “onboarding an employee” mental model\n\nThe five things every effective loop needs: work trees, skills, plugins/connectors, subagents, and state tracking\n\nHow to build a scheduled PR-review routine in Claude Code that babysits aging PRs and alerts your team\n\nHow to set up a weekly skills-identification automation in Codex that spawns its own validating subagents\n\nWhy goal-based loops are the hardest to write well—and where most people burn tokens for nothing\n\nThe two warning signs that your loop is going to get expensive before it gets useful\n\n### Brought to you by:\n\n** WorkOS**—Make your app enterprise-ready today\n\n** Runway**—The creative AI platform for images, video, and more\n\n### In this episode, we cover:\n\n([00:00](https://www.youtube.com/watch?v=JoXbk2fm7jM)) Prompts are out and loops are in\n\n([02:30](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=150s)) Defining a loop\n\n([03:03](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=183s)) The four ways to automate a prompt: heartbeat, cron, hooks, and goals\n\n([06:03](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=363s)) Five things every effective loop needs\n\n([09:26](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=566s)) The “onboarding an employee” framework for designing loops\n\n([11:58](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=718s)) Live build #1: Daily aging PR loop in Claude Code\n\n([17:08](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=1028s)) Subagents inside loops\n\n([19:00](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=1140s)) Live build #2: Weekly skills identification loop in Codex\n\n([22:57](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=1377s)) Watching subagents spin up in real time\n\n([25:28](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=1528s)) Warning signals around loops\n\n([27:31](https://www.youtube.com/watch?v=JoXbk2fm7jM&t=1651s)) What listeners are doing with loops\n\n### Tools referenced:\n\n• Claude Code: [https://claude.ai/code](https://claude.ai/code)\n\n• Codex: [https://chatgpt.com/codex](https://chatgpt.com/codex)\n\n• OpenClaw: [https://openclaw.ai/](https://openclaw.ai/)\n\n### Other references:\n\n• Claire’s article “Why OpenClaw Feels Alive Even Though It’s Not”: [https://x.com/clairevo/article/2017741569521271175](https://x.com/clairevo/article/2017741569521271175)\n\n• Addy Osmani’s article on loop engineering: [https://addyosmani.com/blog/loop-engineering/](https://addyosmani.com/blog/loop-engineering/)\n\n• Using Goals in Codex: [https://developers.openai.com/cookbook/examples/codex/using_goals_in_codex](https://developers.openai.com/cookbook/examples/codex/using_goals_in_codex)\n\n### Where to find Claire Vo:\n\nChatPRD: [https://www.chatprd.ai/](https://www.chatprd.ai/)\n\nWebsite: [https://clairevo.com/](https://clairevo.com/)\n\nLinkedIn: [https://www.linkedin.com/in/clairevo/](https://www.linkedin.com/in/clairevo/)\n\nProduction and marketing by [https://penname.co/](https://penname.co/). For inquiries about sponsoring the podcast, email [[email protected]](/cdn-cgi/l/email-protection).", "url": "https://wpnews.pro/news/how-to-design-ai-agent-loops-schedules-goals-and-subagents-in-claude-code-and", "canonical_source": "https://www.lennysnewsletter.com/p/how-to-design-ai-agent-loops-schedules", "published_at": "2026-06-17 12:04:04+00:00", "updated_at": "2026-06-17 12:23:33.812515+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "ai-products", "developer-tools", "generative-ai"], "entities": ["Claude Code", "Codex", "OpenClaw", "WorkOS", "Runway", "Claire Vo", "Addy Osmani", "ChatPRD"], "alternates": {"html": "https://wpnews.pro/news/how-to-design-ai-agent-loops-schedules-goals-and-subagents-in-claude-code-and", "markdown": "https://wpnews.pro/news/how-to-design-ai-agent-loops-schedules-goals-and-subagents-in-claude-code-and.md", "text": "https://wpnews.pro/news/how-to-design-ai-agent-loops-schedules-goals-and-subagents-in-claude-code-and.txt", "jsonld": "https://wpnews.pro/news/how-to-design-ai-agent-loops-schedules-goals-and-subagents-in-claude-code-and.jsonld"}}