From agent-loops
(Industry standard: Sequential Agent / Agent as a Tool) Primary Use Case: Delegating a well-defined task to a worker agent, verifying its execution, and repeating if necessary. Inner/outer agent delegation pattern. Use when: work needs to be delegated from a strategic controller (Outer Loop) to a tactical executor (Inner Loop) via strategy packets, with verification and correction loops.
How this skill is triggered — by the user, by Claude, or both
Slash command
/agent-loops:dual-loopThis skill is limited to the following tools:
The summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill requires **Python 3.8+** and standard library only. No external packages needed.
This skill requires Python 3.8+ and standard library only. No external packages needed.
To install this skill's dependencies:
pip-compile ./requirements.in
pip install -r ./requirements.txt
See ../../requirements.txt for the dependency lockfile (currently empty — standard library only).
This skill defines the orchestration pattern for the Dual-Loop Agent Architecture. The Outer Loop (the directing agent) uses this protocol to organize work, delegate execution to an Inner Loop (the coding/tactical agent), and rigorously verify the results before merging.
This architecture is entirely framework-agnostic and can be utilized by any AI agent pairing (e.g., Antigravity directing Claude Code, or an OpenHands agent directing a specialized CLI sub-agent).
YOU MUST ACTUALLY PERFORM THE VALIDATIONS LISTED BELOW. Describing what you "would do" or marking a step complete without actually doing the verification is a PROTOCOL VIOLATION.
flowchart LR
subgraph Outer["Outer Loop (Strategy & Protocol)"]
Scout[Scout & Plan] --> Spec[Define Tasks]
Spec --> Packet[Generate Strategy Packet]
Verify[Verify Result] -->|Pass| Commit[Seal & Commit]
Verify -->|Fail| Correct[Generate Correction Packet]
end
subgraph Inner["Inner Loop (Execution)"]
Receive[Read Packet] --> Execute[Write Code & Run Tests]
Execute -->|No Git| Done[Signal Done]
end
Packet -->|Handoff| Receive
Done -->|Completion| Verify
Correct -->|Delta Fix| Receive
Reference: Architecture Diagram
handoffs/task_packet_001.md).The Outer Loop invokes the Inner Loop. Depending on the environment, this is either done by spawning a sub-process (e.g., claude "Read handoffs/task_packet_001.md"), calling an API, or asking the Human User to switch terminals.
The Inner Loop agent:
Constraint: The Inner Loop MUST NOT run version control commands.
Once the Inner Loop signals completion, the Outer Loop must verify the results:
Before handoff, both the Outer Loop and Inner Loop MUST each complete the Post-Run
Self-Assessment Survey (references/memory/post_run_survey.md). Answer every section in full.
Count-Based Signals: How many times did you not know what to do next? Miss a step? Use wrong CLI syntax? Get redirected by a human? Total friction events?
Qualitative Friction: Where were you most uncertain? Which step felt ambiguous? What was the biggest source of friction? What one change would have helped most?
Improvement Recommendation: What one change should be tested before the next run? What is the target (Skill/Prompt/Script/Rule)?
Save to: ${CLAUDE_PROJECT_DIR}/context/memory/retrospectives/survey_[YYYYMMDD]_[HHMM]_[AGENT].md
Emit survey completion:
python3 context/kernel.py emit_event --agent <ROLE> \
--type learning --action survey_completed \
--summary "retrospectives/survey_[DATE]_[TIME]_[AGENT].md"
If any single friction cause appears 3+ times this cycle, flag for Triple-Loop Retrospective
Full Loop before the next cycle begins.
Once all Work Packages are verified and surveys saved, the Dual-Loop pattern is complete.
The Outer Loop terminates and returns control to the global lifecycle manager (Orchestrator)
for memory persistence via session-memory-manager and ecosystem sealing.
Throughout the process, the Outer Loop must maintain discipline over task states. If you are operating this loop, you must ensure you or the task tracker accurately reflects:
Dual-Loop (Agent-Loops) does not manage workspaces. It receives an isolated directory or execution context from the Orchestrator and runs the loop inside it. Workspace creation (e.g., git worktrees, branches) is a delegated responsibility of the Orchestrator or the global system environment.
If an isolated workspace cannot be provided:
npx claudepluginhub richfrem/agent-plugins-skills --plugin agent-loopsAuto-loop execution workflow with quality gates. Use when starting any non-trivial implementation task. Provides automatic task decomposition, code implementation, testing (L1-L4), and iterative quality gates until completion. Invoke with /autoworker.
Executes multi-task plans by dispatching a fresh agent per task with isolated context, then applying two-stage review (spec compliance, code quality) before advancing. Use when you have 3+ sequential tasks that risk context bleed or need review gates.
Defines a 4-phase execution loop (IMPLEMENT, VALIDATE, ADVERSARIAL REVIEW, COMMIT) for orchestrating complex multi-step work units with written specs and quality gates.