skills/auto-swarm-nth/SKILL.md
Nth-iteration agent swarm — spawns parallel agent waves, evaluates strictly per wave, re-swarms gaps until 100% coverage and 10/10 quality. Can invoke any ProductionOS skill or command within waves.
npx skillsauth add ShaheerKhawaja/ProductionOS auto-swarm-nthInstall 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.
You are the Auto-Swarm Nth orchestrator. Unlike standard /auto-swarm which targets 85% coverage, you run an unbounded recursive swarm that deploys agent waves until 100% coverage AND 10/10 quality on every deliverable.
Target: 100% coverage. 10/10 quality. Zero gaps.
task — The task to swarm on (natural language description). Required.max_waves — Maximum swarm waves (default: 20, hard cap: 50). Optional.mode — Swarm mode: research | build | audit | fix | explore (default: auto-detect). Optional.swarm_size — Agents per wave (default: 7, max: 7). Optional.max_cost — Maximum accumulated cost in USD before halting (default: 20). Optional.isolation — Agent isolation mode: none (default) | worktree. Optional.Before executing, run the shared ProductionOS preamble:
.productionos/ for existing outputAfter each agent completes, dispatch the self-evaluator. Apply the 7-question protocol:
.productionos/self-eval/Parse the task into a structured scope map:
TASK: "{user's task description}"
SCOPE: [files | directories | concepts | domains]
TYPE: [research | build | audit | fix | explore] (auto-detect from keywords)
DELIVERABLE: [what "done" looks like]
TOTAL ITEMS: [estimated count of scope items to cover]
Read existing artifacts from .productionos/:
For the detected mode, select the agent roster:
| Mode | Primary Agents | Support Agents | |------|---------------|----------------| | research | deep-researcher, research-pipeline, comparative-analyzer | context-retriever, density-summarizer | | build | dynamic-planner, test-architect, self-healer | code-reviewer, naming-enforcer | | audit | code-reviewer, security-hardener, ux-auditor, performance-profiler | adversarial-reviewer, database-auditor | | fix | refactoring-agent, self-healer, code-reviewer | test-architect, naming-enforcer | | explore | reverse-engineer, comparative-analyzer, deep-researcher | comms-assistant, thought-graph-builder |
If isolation is worktree:
bun run scripts/worktree-manager.ts create "swarm/wave-1-agent-{i}" --base main
.productionos/swarm-tasks.jsonDefine the full coverage map:
COVERAGE MAP (0/N)
Item 1: [description] — NOT COVERED
Item 2: [description] — NOT COVERED
...
Item N: [description] — NOT COVERED
EXIT CONDITION: 100% of items covered AND every deliverable scores 10/10.
Each wave follows this structure:
WAVE N
PHASE 0: COST CHECK — Mandatory budget enforcement
PHASE 1: GAP ANALYSIS — What is uncovered?
PHASE 2: AGENT ASSIGNMENT — Which agents tackle which gaps?
PHASE 3: PARALLEL DISPATCH — Launch agents simultaneously
PHASE 4: SYNTHESIS — Merge findings, deduplicate, map coverage
PHASE 4.5: MERGE (worktree mode only) — Sequential merge with test gates
PHASE 5: EVALUATE — Score coverage + quality
PHASE 6: DECIDE — Continue, pivot, or deliver
OUTPUT: .productionos/SWARM-WAVE-{N}.md
.productionos/TOKEN-BUDGET.md for accumulated_cost.productionos/SWARM-NTH-COST-HALT.md.This check is non-negotiable. No wave may begin without passing it.
Read coverage map from previous wave. Identify:
Assign swarm_size agents to gaps. Each agent gets:
Skill chaining example within an agent:
AGENT 3 (Security Scope):
Invoke /security-audit on assigned files
Read AUDIT-SECURITY.md output
Apply fixes from findings
Invoke code-reviewer on the fixes
Validate: run tests
Report: coverage items addressed + quality score
Launch all agents using Agent tool with run_in_background: true.
Each agent prompt includes:
After all agents report:
Merge each agent's worktree branch sequentially:
Quality Criteria (ALL must be met for 10/10):
Wave score format:
Wave N Score:
Coverage: M/N items (X%)
Quality: Y/10 average
Items at 10/10: Z
Items below 10: list with reasons
New gaps discovered: G
IF coverage == 100% AND all_items_quality == 10:
DELIVER
IF coverage_increasing AND wave < max:
CONTINUE — re-swarm on uncovered + below-10 items
IF coverage_stalled (delta < 2% for 2 waves):
PIVOT — change agent assignments, try different approaches
If already pivoted twice: flag resistant items
IF quality_stalled (items stuck below 10 for 3 waves):
ESCALATE — deploy adversarial-reviewer, reverse-engineer
If still stuck: document the ceiling with evidence
IF wave >= max:
FORCED EXIT with gap report
When /omni-plan-nth invokes /auto-swarm-nth:
.productionos/SWARM-NTH-REPORT.mdConstraint: Agents cannot invoke /auto-swarm-nth recursively. Maximum nesting: auto-swarm-nth -> agent -> skill invocation.
FAIL: {agent}. Continue with remaining agents in wave.SKIP: {skill}. Continue without it..productionos/
SWARM-NTH-ASSESSMENT.md — Preliminary layer results
SWARM-WAVE-{N}.md — Per-wave results
SWARM-COVERAGE.md — Live coverage map
SWARM-GAPS.md — Remaining gaps at exit
SWARM-NTH-REPORT.md — Final delivery report
SWARM-NTH-COST-HALT.md — Cost halt state (if triggered)
WORKTREE-MERGE-LOG.md — Merge results (worktree mode)
swarm-tasks.json — Task assignments (worktree mode)
self-eval/ — Per-agent evaluation logs
TOKEN-BUDGET.md — Accumulated cost tracking
tools
Implementation planning workflow that turns approved ideas into dependency-aware execution plans.
development
Local RAG and Graph RAG over the SecondBrain wiki vault. Progressive context loading (hot cache -> index -> domain -> entity). Graph traversal via wikilink resolution. Use when agents need cross-project context, when answering questions that span multiple domains, or when building context for planning tasks. Triggers on: "wiki context", "cross-project context", "what do we know about", "check the wiki", "graph context", "/wiki-rag".
devops
UX improvement pipeline — creates user stories from UI guidelines, maps user journeys, identifies friction, dispatches fix agents. The user-experience equivalent of /production-upgrade.
development
Test-driven development workflow that writes failing tests first, implements minimally, and refactors safely.