More How I AI episodes

How to design AI agent loops: schedules, goals, and subagents in Claude Code and Codex thumbnail

How to design AI agent loops: schedules, goals, and subagents in Claude Code and Codex

Published 17 Jun 2026

Duration: 00:29:06

Prompts and loops in AI automation are highlighted for their role in enabling structured task execution through clear automation design, sandboxed workflows, plugins, and subagents, with applications in software engineering and integration with tools like GitHub and Slack.

Episode Description

I break down every loop type from scratchwhat a heartbeat, cron, hook, and goal loop actually are, when each one fits, and the five things any effecti...

Overview

The podcast explores the role of prompts in AI agents, explaining how they guide agents to perform tasks, best practices for crafting effective prompts, and common obstacles like ambiguity or over-reliance on vague instructions. It then shifts to loops in automation, detailing how loops enable agents to self-prompt and execute tasks autonomously, particularly in software engineering and repetitive workflows. Loops are contrasted with manual prompting, emphasizing scenarios where human oversight remains valuable. Different automation triggers are outlined, including time-based schedules (heartbeats, crons), event-driven triggers (hooks), and goal-oriented loops in platforms like Codex and Cloud Code. The discussion highlights how loops can be configured for recurring tasks, isolated workspaces (work trees), reusable skills, and integration with tools like GitHub or Slack.

Key components of effective loops include defining clear automation purposes, using subagents for task delegation, and tracking progress via state mechanisms (e.g., to-do lists). Technical examples illustrate loops in action, such as a "Daily Aging PR Review" routine in Claude Code that monitors GitHub pull requests and spawns subagents for conflict resolution or notifications. Non-technical analogs, like scheduled morning briefings, are also presented to simplify understanding. The episode caution against overcomplicating loops, advocating for simplicity and avoiding excessive token usage. It also addresses goal-based validation, where loops ensure tasks meet predefined criteria, and the use of subagents to handle specialized subtasks within broader workflows.

The discussion emphasizes the balance between automation and human input, noting that while loops streamline repetitive or time-sensitive tasks (e.g., triaging GitHub issues, generating reports), manual prompting remains essential for complex or judgment-driven work. Advanced concepts include nesting loops, using MCPs (custom tools) for validation, and leveraging templates in systems like Codex for designing automation. Warnings about potential pitfallssuch as cost inefficiencies from poorly defined loops or over-reliance on auto-spun subagentsare included, alongside examples of non-engineering use cases, like automating email management or research workflows. Ultimately, loops are framed as accessible, goal-oriented tools for delegating structured tasks to agents.

What If

  • What if you used a goal-based loop with subagents to automate code validation tasks in your personal projects?

    • Move: Set up a loop in Codex or Cloud Code to monitor your codebase every 24 hours, triggering subagents to run unit tests, lint checks, and smoke tests.
    • Why Now?: As a solo developer, you often juggle multiple projects, and manual QA is time-consuming. This loop ensures consistent validation without oversight.
    • Expected Upside: Faster bug detection, reduced manual QA load, and higher confidence in code quality before deployment.
  • What if you implemented a heartbeat-triggered loop to automate repetitive administrative tasks?

    • Move: Configure a daily heartbeat loop (e.g., 10:15 AM) to prompt an agent to clean your email inbox, summarize calendar updates, and auto-archive old project files.
    • Why Now?: Administrative tasks like email triage and file management can distract you from core development work. Automation free up mental bandwidth.
    • Expected Upside: Improved focus on development, consistent workflow hygiene, and reduced time spent on mundane tasks.
  • What if you designed a cron-based loop to automate PR triage for open-source contributions?

    • Move: Use Cloud Codes cron scheduling to create a weekly loop that identifies aging PRs, checks merge readiness, and sends automated Slack reminders to maintainers.
    • Why Now?: Open-source maintainers often struggle with PR backlogs. This loop ensures contributions dont get overlooked.
    • Expected Upside: Faster PR resolution, better community engagement, and a more sustainable contribution pipeline.

Takeaway

  • Implement scheduled loops using Codex or Cloud Code to automate repetitive tasks (e.g., daily PR reviews or hourly GitHub issue triaging) by leveraging their built-in automation templates and GitHub Actions support.
  • Isolate agent work in sandboxes (e.g., work trees) to prevent conflicts between tasks, ensuring clean execution and avoiding disruptions from overlapping processes.
  • Use precise prompts with clear success criteria for loops to avoid inefficiencies (e.g., defining goals like "validate CLI skill in repo" instead of vague instructions).
  • Track progress via state tools (e.g., Linear task tracker or markdown to-do lists) to ensure loops complete goals and provide visibility into agent workflows.
  • Start with simple, time-based loops (e.g., weekly calendar summaries) before scaling to complex nested loops, using sub-agents for validation and avoiding overcomplicated workflows.

Recent Episodes of How I AI

22 Jun 2026 How Claude Mythos found a 15-year-old bug in Mozilla Firefox | Brian Grinstead

Recommended: AI finds bugs

Firefox employs AI agents as "coding archaeologists" to detect and address security vulnerabilities in its massive codebase, leveraging models like Mythos and custom validation tools to identify and systematically fix nearly 500 bugs, while balancing automation with human oversight and open-source collaboration to enhance scalability and security.

15 Jun 2026 How Braintrust uses AI agents, evals, and CI to ship better software | Ankur Goyal

AI integration in software engineering enables agents to handle complex tasks through benchmarking and optimization, shifts engineers toward higher-level work, and addresses challenges like reliability, data parsing, and balancing automation with human expertise while emphasizing outcome-focused systems over procedural methods.

9 Jun 2026 Claude Fable 5 review: what the new Mythos model gets right (and very wrong)

Anthropic's Claude Fable Five excels in long-term technical tasks with strong coding, vision, and async workflow capabilities but faces high token costs, design limitations, and restricted use in cybersecurity/biology, making it suitable for precise, extended projects rather than creative or agile workflows.

28 May 2026 Claude Opus 4.8 is here. Is it as good as they say?

Anthropic's Opus 4.8 model improves honesty and efficiency with reduced hallucinations but struggles with contextual coding, complex strategic analysis, and depth in agentic tasks, excelling in simple prototypes yet falling short in nuanced, long-horizon applications.

More How I AI episodes