Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add commands/dheerg/swarms/refinegit clone --depth 1 https://github.com/DheerG/swarmsWhat it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00009 | $0.02780 |
| Opus 5 | $0.00005 | $0.01390 |
| Sonnet 5 | $0.00002 | $0.00556 |
| Haiku 4.5 | $0.00001 | $0.00278 |
Grade A, and why
refine scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 81 lines — stays where its author put it; the contents beside it link to each section on GitHub.
/swarm:refine
Recursive refinement on an existing branch and pull request. Skips Research/Converge/Approve/Execute — the team enters at Review, then Refine, then Deliver.
Pass outcomes inline (/swarm:refine <outcomes>) or run without arguments to be prompted.
Read ${CLAUDE_PLUGIN_ROOT}/commands/launch.md for Step 0 (pre-flight), Step 1 (invoke swarm:workflow-rules — the governance spec), Steps 8a–8e (team creation, member spawning, pulse setup), and the Universal rules that apply across all modes in Step 8f — especially the governance spec's Live-team gate prompts rule (the AFK-timeout / durable plain-text-restatement recovery), which governs this command's decision gates (Finish, ship-approval) too. This command replaces Steps 2–7 and overrides Step 8f's phase arc — not those universal rules.
No lead research unless enabled. The pre-flight reads below are housekeeping, not research — they run unconditionally (analogous to launch.md's ship-definition detection). All other research is delegated to teammates.
Settings
- Mode: Code
- Outcomes question: "What outcomes was this branch/PR supposed to achieve? (Describe what was meant to be working differently or better — the team will refine the work against these outcomes.)"
- Cost tier: Ultra
- Lead research: No
- Roster (fixed): Principal Engineer (facilitator), Correctness Reviewer, Outcomes Reviewer, Regression Reviewer
User-Provided Context
$ARGUMENTS
Workflow
-
Pre-flight reads. Run via Bash, capture each output as a raw string. Use the exact abort messages below — they are the user's only signal that something is wrong, so consistency matters across invocations.
git rev-parse --is-inside-work-tree— if not in a git repo, abort with:Not in a git repository. /swarm:refine works on a branch and pull request.git branch --show-current— capture. If empty (detached HEAD), abort with:Cannot run /swarm:refine in detached HEAD state. Run "git checkout <branch-name>" to switch to a branch first.If equal to the repo's default branch (resolved viagit symbolic-ref refs/remotes/origin/HEAD --short 2>/dev/nullthen strippingorigin/), abort with:Cannot refine the default branch directly. Switch to a feature branch.gh pr view --json title,body,baseRefName,url 2>/dev/null— capture PR data if present. ExtractbaseRefNamefor the diff base. If no PR exists, fall back to the repo's default branch resolved earlier viagit symbolic-ref refs/remotes/origin/HEAD --short 2>/dev/null(stripped oforigin/) —master,develop, or whatever the repo actually uses. Do not hardcodemain. Ifgit symbolic-refitself returns nothing (noorigin/HEADset), abort with:Cannot determine the default branch — origin/HEAD is not set. Run "git remote set-head origin -a" or open a PR with the correct base before re-running /swarm:refine.Surface the fallback (whichever branch was resolved) explicitly in the Step 7 confirmation summary so the user can correct the base before launch.git diff <base>...HEAD— capture. If empty (HEAD == base), abort with:No changes detected between <branch> and <base>. Nothing to refine. If this is unexpected, verify the diff base is correct.(substitute the actual branch and base names).git diff --stat <base>...HEAD | tail -1— capture the one-line diff stat (e.g.,12 files changed, 340 insertions(+), 45 deletions(-)) for the Step 3 confirmation summary. If the diff is empty this is moot — the empty-diff abort above fires first.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 2d ago First seen · 81 lines · 9 tokens per session scan A 41a803ea51fa
refine is a command published in the GitHub repository DheerG/swarms (86 stars, last pushed 1mo ago), licensed MIT. It adds 9 tokens to every session and 2,780 once invoked, about $0.0000 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other commands, from other repositories
prompt
System instructions for writing effective prompts. Apply when generating commands, skills, agents, or any LLM instructions.
full
Run the full hope pipeline — intent, shape, target, freeze as needed — then execute.
token-review
Analyze SDLC token usage from .claude/sdlc/token-log.json (last run) and token-history.jsonl (rolling). Surfaces the biggest cost centers and concrete optimization candidates. Read-only.
start
Activate the SDLC workflow (opt-in), re-enable after suspension, or start a new task when already enabled. On fresh install — auto-detects repo/CI/stack/tracker (≤3 prompts), creates .enabled, takes a one-sentence task description, and auto-generates scope.md and a draft plan. On re-enable — verifies the suspension…
build
Start Phase 4 — implement the approved design with surgical-edit discipline and work-item traceability.
configure
Guided setup for config/tools.json and config/tools.local.json. Replaces manual file editing for first-time setup and common reconfigurations. Auto-invoked on fresh install (Layer 0) and when a command finds its required config missing (Layer 2). Safe to run anytime for proactive changes.