How to Write AI Agent Loops in Claude Code and Codex
Claire Vo breaks down the four agent loop types (heartbeat, cron, hook, goal), then live-builds a daily PR reviewer in Claude Code and a self-validating skills loop in Codex.
"Prompts are out and loops are in." In this How I AI episode, ChatPRD founder Claire Vo gives agent loops their plainest definition: a loop is just an automated prompt, not a scary new paradigm. She sorts loops into four types — heartbeat, cron, hook, and goal — and explains when each one actually fits your workflow.
The heart of the video is two live builds. First, a daily "aging PR reviewer" in Claude Code that schedules itself at 10:15 a.m., spins off its own subagents to review stale pull requests, and alerts the team. Second, a weekly skills-identification loop in Codex that spawns goal-based subagents to validate its own output in real time — a self-improving automation.
She also shares a practical design framework — treat writing a loop like onboarding a new employee — plus the five things every effective loop needs: worktrees, skills, plugins/connectors, subagents, and state tracking. The closing warning matters most: goal-based loops are the hardest to write well, most people burn tokens for nothing, and there are two early signals that a loop will get expensive before it gets useful. Best for engineers and PMs already using Claude Code or Codex who want to move from one-off prompts to production automation.
FAQ
What is an AI agent loop?
Per the video's definition, a loop is just an automated prompt — an AI coding tool re-running a task on a schedule or trigger instead of you typing it each time. It's not a new paradigm, just automation applied to prompting.
What are the types of agent loops?
Four: heartbeat (fixed-interval polling), cron (scheduled), hook (event-triggered), and goal (goal-driven). The video covers when each fits; goal loops are the hardest to write well and the easiest way to burn tokens for nothing.
What does an effective loop need before production?
Five things, per the video: worktrees (isolated working copies), skills, plugins/connectors, subagents, and state tracking. Without them a loop breaks down before it ever reaches production.
What two loops are built live in the video?
A daily aging-PR reviewer in Claude Code that schedules itself at 10:15 a.m. and spins off subagents to review stale PRs, and a weekly skills-identification loop in Codex that spawns goal-based subagents to validate its own output in real time.
Who is this video for?
Engineers and PMs already using Claude Code or Codex. Host Claire Vo is the founder of ChatPRD; the episode runs about 29 minutes, with companion written workflow guides published on chatprd.ai.