YouTube podcast · Podcast episode · Building AI products · Execution, roadmaps & process

How to write AI agent loops in Claude Code and Codex

Claire Vo (How I AI)Jun 17, 202640 min
SourceYouTube podcast
KindPodcast episode
PublishedJun 17, 2026
Originalyoutube.com ↗
N:

Claire Vo explains AI agent loops—automated, self-prompting workflows in Claude Code and Codex—moving beyond manual prompting. She covers loop types (heartbeat, cron, hooks, goals), essential components for effective loops, and demonstrates practical examples like PR review automation and skill discovery.

01Key learnings

  • Loops are scheduled or semi-autonomous automations that let agents prompt themselves without human input, using heartbeats, crons, hooks, or goal-based triggers.
  • Design loops like onboarding employees: define recurring jobs (e.g., 'every Friday review calendar') and let agents execute autonomously until completion or time expires.
  • Effective loops require five elements: automation trigger, schedule definition, goal setting, work isolation (git worktrees), and state tracking (to-do lists or task trackers).
  • Sub-agents and goal loops enable hierarchical automation—agents can spawn child agents for specific validation tasks, creating nested workflows that run until success criteria are met.
  • Loop prompts demand precision, especially for goal-based loops; vague success criteria cause token waste and poor outputs. Use OpenAI's goal-writing guides and have agents write their own goals.
  • Loops can become expensive if validation criteria are loose or prompts poorly written; monitor both cost and efficiency, and be thoughtful about where you apply loop-based automation.
  • Start simple with scheduled tasks (Claude Co-work routines) before advancing to goal loops; even basic time-based automations like morning briefings are functional loops.

02Frameworks mentioned

Summary and takeaways written by PM Atlas; quotes are short excerpts. © the original author.