Research: Agent Loops, Codex, and Claude Code
June 8, 2026 ยท View on GitHub
Date: 2026-06-08
Takeaway
Latest loop hype points at one useful shift: stop hand-prompting every agent step, and start writing durable control flow that prompts agents for you. Practical version is not "agents decide everything." Practical version is a state machine around specs, prompts, verification, review, and backpropagation.
What "Loop" Means Here
A loop is deterministic control flow around probabilistic workers:
- input queue: specs, issues, incidents, PRs, failing checks
- planner: decides execution shape from explicit rules
- worker: Codex or Claude Code agent/subagent
- verifier: tests, lint, screenshots, logs, review agents
- state store: files, manifests, PR comments, run logs
- backpropagation: facts learned from implementation update specs/docs
- stop rule: archive accepted work, request decision, or retry bounded failure
Source-Backed Platform Notes
OpenAI Codex:
- Skills are reusable workflow packages with
SKILL.md, optional scripts/references/assets, and repo discovery through.agents/skills(OpenAI Codex manual, Agent Skills). - Codex subagents can spawn specialized agents in parallel, but only when explicitly asked; custom agents live under
.codex/agents/or~/.codex/agents/. - Codex hooks run scripts on lifecycle events such as
UserPromptSubmit,PostToolUse,SubagentStop, andStop; project hooks live in.codex/hooks.jsonor.codex/config.toml. openai/codex-action@v1runs Codex in GitHub Actions for review, patches, and repeatable CI tasks.
Claude Code:
- Skills create slash-invokable commands and auto-loaded workflows from
.claude/skills/<name>/SKILL.md. /loopreruns prompts on a schedule inside a Claude Code session;.claude/loop.mdcustomizes bare/loop.- Dynamic workflows move orchestration into JavaScript written by Claude and executed by a workflow runtime; use for dozens to hundreds of agents, codebase audits, large migrations, and cross-checked research.
- Agent teams are experimental multi-session coordination with peer communication; subagents are lower-overhead single-session workers returning summaries.
- Hooks can enforce lifecycle guardrails at tool, prompt, subagent, task, and stop events.
What Tweets Get Right
The useful framing:
- Living specs as code beat one-off prompts.
- Folder queues are simple, inspectable orchestration.
- Backpropagation keeps docs/specs from rotting.
- Humans should decide priorities and product meaning.
- Agents should execute bounded work, generate code, run checks, and summarize evidence.
Failure Modes
- Infinite loops without hard stop rules.
- Hidden product decisions in auto-generated prompts.
- Huge fan-out with no cost budget or review gate.
- Specs treated as write-only prompts instead of durable contracts.
- Review agents summarizing instead of checking diffs and tests.
- Backpropagation changing intent instead of implementation facts.
Loop Factory Mapping
| Need | Repo Primitive |
|---|---|
| Living spec queue | factory/specs/inbox, active, archive |
| Repeatable prompt generation | loop-factory dispatch, prompt, review, backprop |
| Codex-native workflow | .agents/skills, .codex/agents, .codex/hooks.json |
| Claude-native workflow | .claude/skills, .claude/agents, .claude/loop.md |
| CI review | .github/workflows/codex-review.yml |
| Backpropagation | loop-factory backprop prompt from git diff |
| Built-in loop catalog | loop-factory loops list/show/prompt |
Built-In Loop Catalog Pattern
Catalog-style loop libraries make loops discoverable by name, category, trigger mode, supported agents, check command, and exit condition. Loop Factory adopts that shape for original repo-native loops, while keeping wording and behavior tied to its own spec queue.
Current built-ins cover:
- spec grilling before dispatch
- spec dispatch
- active spec verification
- independent review gate
- spec/docs backpropagation
- cleanup pass
- docs sync
- failing test triage
- build repair
- CI branch watch
- PR health watch
- dependency audit planning
Sources
- OpenAI Codex quickstart
- OpenAI Codex skills
- OpenAI Codex hooks
- OpenAI Codex subagents
- OpenAI Codex GitHub Action
- Claude Code advanced setup
- Claude Code skills
- Claude Code scheduled tasks and
/loop - Claude Code dynamic workflows
- Claude Code subagents
- Claude Code agent teams
- Claude Code hooks
- loops catalog