Skip to main content

autonomous-loops

A Claude Code skill from Affaan M's everything-claude-code repo catalogues six loop architectures for running Claude Code without human intervention — sequential claude -p pipelines, NanoClaw REPL, Infinite Agentic Loop, Continuous PR Loop, De-Sloppify cleanup pass, and RFC-driven multi-agent DAG (Ralphinho). Names a successor skill (continuous-agent-loop) as the new canonical home.

Pick the right autonomy pattern (claude -p pipeline through RFC-driven DAG) for the problem

Source Affaan M
License MIT
First documented
Receipts TODO

Trigger phrases

Phrases that activate this skill when typed to Claude Code:

  • build an autonomous Claude Code loop
  • continuous PR loop with CI gates
  • claude -p pipeline for daily dev

What it does

autonomous-loops is the autonomy-pattern catalogue in Affaan M’s everything-claude-code — see skills/autonomous-loops. It covers six loop architectures along a complexity spectrum from a four-line bash pipeline to a multi-agent DAG with a merge queue. The upstream notes the skill is “retained for one release” and that the canonical name is moving to continuous-agent-loop — keep both in mind when adopting.

The simplest pattern is a sequential claude -p pipeline: each step is a focused prompt in its own fresh context window, chained with set -e so exit codes propagate. Variations include model routing (Opus for research and review, Sonnet for implementation), file-based context passing (write .claude-context.md, read it, delete it), and --allowedTools restrictions (read-only audit pass, write-only implementation pass). The “De-Sloppify Pattern” is an add-on cleanup step that removes type-system tests, overly defensive checks, and AI-generated filler after any implementer step.

The medium-complexity patterns: NanoClaw REPL (ECC’s built-in session-aware loop with markdown-as-database session persistence), Infinite Agentic Loop (orchestrator + sub-agents for parallel specification-driven generation), Continuous Claude PR Loop (multi-day iterative work with CI gates). The high-complexity Ralphinho / RFC-driven DAG is for large features with multi-unit parallel work and a merge queue — the upstream has more than 600 lines on this single pattern. Each pattern gets a table of when to use it vs. the alternatives.

When to use it

  • Setting up an autonomous workflow that runs without human intervention
  • Choosing the right loop architecture for the problem — sequential for daily dev, DAG for large features
  • Building a CI/CD-style continuous-development pipeline
  • Running parallel agents with merge coordination
  • Adding quality gates (De-Sloppify) or context persistence to an existing autonomous workflow

When not to reach for it:

  • One-off non-interactive Claude runs — that’s just claude -p, no architecture needed
  • Code review of an agent harness — that’s agent-harness-construction
  • Comparing agents on tasks — that’s agent-eval
  • Pure decision-making (go/no-go) — that’s council

Install

From affaan-m/everything-claude-code at skills/autonomous-loops/. Drop the folder into ~/.claude/skills/autonomous-loops/. The skill is a pattern catalogue — runtime dependencies vary by pattern. Sequential pipelines need only claude -p. NanoClaw needs the scripts/claw.js from the upstream repo and a session directory at ~/.claude/claw/. The DAG patterns need git worktrees and a CI runner. Upstream flags continuous-agent-loop as the canonical successor — check that skill if it’s available before committing to this one for new work.

What a session looks like

  1. Name the autonomy goal. “I want a nightly job that picks the top issue, implements it, opens a PR, and waits for CI.”
  2. Skill picks the pattern. Multi-day iterative work with CI gates = Continuous Claude PR Loop. Not the simplest pattern, not the DAG.
  3. Author the pipeline. Each step is a focused prompt: read issue → implement with tests → de-sloppify → verify build → open PR with the conventional commit message.
  4. Set --allowedTools per step. Read-only audit pass for the planning step; write-enabled for the implementation step. Negative tool restrictions are safer than negative instructions.
  5. Add the De-Sloppify pass. A separate claude -p step that removes type-system-only tests, over-defensive null checks, and language-feature tests after every implementer step. The pattern’s wedge.
  6. Set exit-code propagation. set -e at the top of the bash file so the first failure stops the chain. CI gate is the final step.
  7. Iterate. First few runs reveal which prompt is too vague or which step bleeds context. The pipeline gets tightened over a week, then runs unattended.

The discipline that makes it work: fresh context per step. The skill is explicit that each claude -p call gets a fresh context window — no context bleed between steps. The De-Sloppify pattern is the second wedge: don’t tell the implementer “don’t test type systems,” tell it nothing, then run a separate cleanup pass.

Receipts

TODO — to be filled in from a real session. Once a loop has been run autonomously end-to-end, this section will capture: which of the six patterns the workflow actually settled on (vs. the operator’s initial guess), whether the De-Sloppify cleanup step removed enough generated-filler tests to justify its own context window cost, the pass-rate and per-iteration cost over a multi-run sample, and whether continuous-agent-loop (the successor skill the upstream references) was already available and how it differed in practice.

Source and attribution

From Affaan M’s everything-claude-code — an MIT-licensed skill collection covering harness construction, agent ops, video, payments, and platform-specific patterns.

License: MIT.

Quoting the simplest-pattern justification verbatim: “If you can’t figure out a loop like this, it means you can’t even drive the LLM to fix your code in interactive mode.” The sequential pipeline isn’t a starter pattern — it’s the diagnostic for whether the rest of the catalogue is even worth attempting.