Swarm

From lemoncrow-lab/lemoncrow · View interactive version

Swarm is an AI agent skill from the GitHub repository lemoncrow-lab/lemoncrow. Parallel attempts.

How to use this skill

Skill file

Swarm

Launches N parallel attempts at the same task in isolated worktrees — each runs independently; the best result wins. For N tries at a hard problem rather than one sequential run (/orchestrate for that).

/swarm <goal> — the text after /swarm IS the goal, use it verbatim, never re-ask it.

Invoked bare (no argument) → ask ONE free-text AskUserQuestion: "What should the swarm work on?"

Whatever the phrasing — a task, or a question about swarm itself — it's the goal to launch;

never substitute a hand-written explanation for actually calling the swarm surface (step 4).

Operating loop

  1. Swarm vs single orchestrate run unclear → AskUserQuestion first.
  2. Goal missing (bare invocation) → the one free-text question above; goal already given → skip straight to 3.
  3. Launch parameters still unresolved after explicit args + repo inference → AskUserQuestion, up to 4 related unknowns per call.
  4. Launch via the existing swarm surface (lc rt swarm ... or the matching service API) — never a new custom runtime.
  5. Return the run_id + the exact status/log/apply surface to use next.

Parameters to gather → launch contract

Fill the launch contract from explicit args + repo inference first (see Elicitation); map onto:

Job kinds — the general primitive

Swarm = fan out N isolated candidates → reduce by a pluggable selector → (optionally) iterate in waves. Pick --reducer/--mode per the goal; defaults (--reducer merge --mode edit) reproduce classic solve-task behavior exactly.

| goal | --reducer | --mode | each child produces |

| --- | --- | --- | --- |

| solve a task (default) | merge | edit | a patch; LLM judge merges compatible winners |

| optimize / tune an objective | best | edit | a patch, scored by a measured fitness |

| search / audit / find-bugs | union | readonly | findings, de-duped by signature |

| verify / consensus / repro | vote | readonly | an answer; kept iff ≥ quorum agree |

Optimize / tune (measured fitness)

/swarm "optimize <X>" (--reducer best --fitness-cmd ...) needs a real measurement. Resolve in order:

  1. Reuse an existing measurable command — npm run build && stat -c%s dist/bundle.js, pytest -q | tail -1, hyperfine ./bin.
  2. Generate — a small script wrapping the repo's test/build/bench runner, printing the metric. Default for anything past a one-liner.
  3. Hand-author only for special infra/data/hardware or a subjective bar (rare).

Map it onto flags: --fitness-cmd (command run in each worktree), --metric-parse (json:<dotted.key> | regex:<pat> | stdout_float | exit_code), --direction (min/max), --gate-cmd (correctness gate that must exit 0), --baseline (auto measures HEAD once before wave 1, or a number), --improve-margin, --search-space (globs candidates may change).

Validate the fitness before any wave runs (mandatory). A buggy objective silently optimizes the wrong thing:

  1. Baseline sanity — run on HEAD: metric parses, plausible magnitude/units, gate passes on known-good HEAD.
  2. Direction check — apply a known-worse change; the metric moves the expected way (or the gate trips).
  3. Variance check — run twice on HEAD; run-to-run noise ≳ the chased improvement → raise reps or pick a steadier metric.

Only a fitness that passes validation may drive a search.

Elicitation (works in any project)

Resolve the job from the goal: (1) explicit args, (2) repo inference (test/build/bench/lint commands, an existing benchmark skill), (3) ≤3 questions for what's still missing — typically what command measures the objective?, what must not regress?, which files/knobs may candidates change?. Project-specific knowledge lives in the elicited commands, not the engine.

Execution rules

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.