$npx -y skills add Borda/AI-Rig --skill sweepNon-interactive end-to-end pipeline — auto-configure program.md (accept defaults), run judge+refine loop (up to 3 iterations), then run the campaign. Single command from goal to result.
| 1 | <objective> |
| 2 | |
| 3 | Non-interactive end-to-end research pipeline: auto-plan → judge gate → run. Single command from goal to result. Accepts goal string, passes all run/colab/team flags. |
| 4 | |
| 5 | NOT for: interactive planning (use `/research:plan`); methodology review only (use `/research:judge`); running already-approved plan (use `/research:run`). |
| 6 | |
| 7 | </objective> |
| 8 | |
| 9 | <compaction> |
| 10 | |
| 11 | Key boundaries: end of S2 — program.md written and confirmed; end of S3 — judge+refinement verdict settled. |
| 12 | Preserve at S2: program-path (output of plan), GOAL string, OUT path (TMPDIR key). |
| 13 | Mid-loop refresh: after each S3 fix-apply the contract is rewritten with refine-iter/no-fixes-iter/last-verdict (placed after fixes so the "fixes applied" claim is true) — a mid-loop compaction resumes at the current iteration instead of restarting REFINE_ITER=0. |
| 14 | Preserve at S3: judge verdict, JUDGE_REPORT path, program-path, GOAL. |
| 15 | Clear at S1 start (stale prior run) and after S5 pipeline completes. |
| 16 | |
| 17 | </compaction> |
| 18 | |
| 19 | <workflow> |
| 20 | |
| 21 | ## Agent Resolution |
| 22 | |
| 23 | <!-- Agent resolution: see _RESEARCH_SHARED/agent-resolution.md --> |
| 24 | |
| 25 | **Agent resolution**: load and follow the protocol below. Contains: foundry check + fallback table. Foundry not installed → substitute each `foundry:X` with `general-purpose` per table. |
| 26 | |
| 27 | ```bash |
| 28 | # loads: compaction-contract.md |
| 29 | _RESEARCH_SHARED=$(python "${CLAUDE_PLUGIN_ROOT:-plugins/cc_research}/bin/resolve_shared.py" 2>/dev/null) # timeout: 5000 |
| 30 | [ -z "$_RESEARCH_SHARED" ] && { echo "! Plugin path resolution failed — ensure research plugin installed and CLAUDE_PLUGIN_ROOT set, or invoke from project root."; exit 1; } |
| 31 | cat "$_RESEARCH_SHARED/agent-resolution.md" |
| 32 | ``` |
| 33 | |
| 34 | Sweep delegates to plan (S2), judge (S3), run (S5) — see each skill's Agent Resolution for fallback handling. |
| 35 | |
| 36 | ## Steps S1–S5 |
| 37 | |
| 38 | Triggered by `sweep "goal" [--flags]`. Non-interactive end-to-end: auto-plan → judge gate → run. |
| 39 | |
| 40 | **Shared path resolution** (always runs before S1): |
| 41 | |
| 42 | `_RESEARCH_SHARED` already resolved above (Agent Resolution block); reuse it here. Additionally resolve `_RESEARCH_SKILLS`: |
| 43 | ```bash |
| 44 | _RESEARCH_SKILLS="${_RESEARCH_SHARED%/_shared}" |
| 45 | [ -z "$_RESEARCH_SKILLS" ] && _RESEARCH_SKILLS="${CLAUDE_PLUGIN_ROOT:-plugins/cc_research}/skills" |
| 46 | ``` |
| 47 | |
| 48 | **Task tracking**: create tasks for S1–S5 at start. |
| 49 | |
| 50 | ### Step S1: Parse arguments |
| 51 | |
| 52 | **Existing program.md guard** — sweep creates new program.md; one already exists at output path (default: `program.md` at project root, or `--out <path>` if provided) → invoke `AskUserQuestion` immediately — never silently overwrite, never hard-stop without recovery: |
| 53 | |
| 54 | - question: "program.md already exists at `<output path>` — how to proceed?" |
| 55 | - (a) label: `Overwrite and re-sweep` — description: overwrite existing program.md, run plan+judge+run pipeline from scratch |
| 56 | - (b) label: `Abort — use existing program` — description: stop sweep; use `/research:run <program.md>` to execute the existing program |
| 57 | |
| 58 | On (a): proceed to flag extraction below. On (b): print follow-up hint and stop. Check AFTER extracting `--out` flag so correct output path known before checking. (Single overwrite gate — S2 P-P3 bypassed for sweep since decision already made here.) |
| 59 | |
| 60 | Extract `<goal>` — first positional argument (quoted or unquoted string describing optimization target). |
| 61 | |
| 62 | Extract flags: |
| 63 | |
| 64 | - `--colab[=HW]` — passed to plan (Config.compute) and run; if `=HW` present, extract `colab_hw` |
| 65 | - `--compute=local|colab|docker` — passed through |
| 66 | - `--team` — passed through to run |
| 67 | - `--codex` — passed through to run |
| 68 | - `--researcher` — passed through to run; combine with `--architect` for dual-agent SOTA + architectural hypothesis pipeline |
| 69 | - `--architect` — passed through to run; enables architectural hypothesis pass via `foundry:solution-architect` |
| 70 | - `--journal` — passed through to run when present; preserves per-iteration journal entries (requires `--researcher` or `--architect` — enforced by run R2) |
| 71 | - `--hypothesis <path>` — passed through to run when present; preloads hypothesis queue from the given file |
| 72 | - `--skip-validation` — passed to judge step (S3) |
| 73 | - `--out <path>` — optional: write program.md here instead of project root. **`.md` output target determined solely by `--out` (or default project-root `program.md`)** — never infer output path by scanning `<goal>` text for `.md` substrings; goal string is prose describing optimization target, not path argument. |
| 74 | - `--keep "<items>"` — compaction contract keep-items |