plugins/agent-loops/skills/dual-loop/SKILL.md
(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.
npx skillsauth add richfrem/agent-plugins-skills dual-loopInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
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 --> Query[Query User]
Query --> 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] --> Plan[Commit to Plan]
Plan --> 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
Before generating the Strategy Packet or executing commands, you must interactively ask the user:
agy (Antigravity CLI), claude (Claude CLI), copilot (GitHub Copilot CLI), codex (OpenAI-compatible CLI), or llama (local Gemma host).Gemini 3.5 Flash (Low)).Once confirmed, record this configuration and use the selected CLI and model in the sub-agent delegation command.
handoffs/task_packet_001.md).(Best Practice: Run a functional CLI heartbeat using a simple health prompt to verify end-to-end connectivity before the first hand-off).
The Outer Loop invokes the Inner Loop. To ensure stability, avoid shell process hangs in background/headless environments (which freeze when attempting to read standard input without redirection), and target the chosen LLM backend, the Outer Loop must run run_agent.py using relative pathing and passing the user's selected CLI and model. Always append < /dev/null to the command to prevent SIGTTIN halts:
# Explicitly delegate inner-loop execution with redirected stdin and chosen model
python scripts/run_agent.py \
handoffs/task_packet_001.md \
<target_file_to_modify> \
handoffs/result_packet.md \
"Execute the strategy packet instructions exactly." \
--cli <selected_cli> \
--model "<selected_model>" < /dev/null
If run_agent.py is unavailable, this is done by spawning a sub-process (e.g., agy -p "Read handoffs/task_packet_001.md" < /dev/null), 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 under the Trust But Verify and TDD principles:
git diff or system state checks) to see exactly what files the Inner Loop altered. Ensure no unexpected files were modified, no stubs were left, and no security regressions were introduced../friction-log.md) for the Orchestrator to review at handoff.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 a local file (e.g., ./retrospective-[YYYYMMDD]-[HHMM]-[AGENT].md) or stdout.
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). Memory promotion is the responsibility of the calling system.
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:
testing
Skill for creating and managing isolated git worktrees (`.worktrees/issue-NNN`) for issue execution branches. USE ONLY when setting up or cleaning up isolated git worktrees for specific issue execution. DO NOT USE for managing local task files (use `task-agent`) or escalating tasks to issues (use `github-issue-backlog-agent`).
data-ai
Skill for orchestrating the end-to-end GitHub issue lifecycle flow: Issue -> Worktree -> Implementation -> PR Creation -> Resolution Closure. USE ONLY when running or dry-running full lifecycle orchestration for resolving an issue with a PR. DO NOT USE for isolated worktree management only (use `issue-worktree-agent`) or logging issues (use `github-issue-agent`).
tools
Automatically ranks GitHub issues (P0-P3) based on friction tier, frequency, and blockages, synchronizing priority labels and GitHub Projects v2 custom fields.
testing
Bridge skill for escalating ephemeral local task scratchpad items (`tasks/*.md`) into durable, taxonomy-validated, evidence-rich GitHub Issues. USE ONLY when promoting a single-session local task into durable repository backlog. DO NOT USE for managing local kanban boards (use `task-agent` instead) or directly querying/commenting on issues (use `github-issue-agent` instead).