hivemind
Orchestrate free opencode workers from Claude Code to cut token costs. Use when delegating grunt work to a single worker or a parallel swarm (scout/coder/tester) with worktree isolation, benchmarking against opencode, or when the user says "spawn a worker", "swarm", "delegate to opencode", or "/oc".
- License 许可
- Apache-2.0
- 最近更新
- 2026-10-10
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- hivemind
- description
- Orchestrate free opencode workers from Claude Code to cut token costs. Use when delegating grunt work to a single worker or a parallel swarm (scout/coder/tester) with worktree isolation, benchmarking against opencode, or when the user says "spawn a worker", "swarm", "delegate to opencode", or "/oc".
02 资源文件 17
- 其他.gitignore27 B
- 资产文件assets/agents/coder.md628 B
- 资产文件assets/agents/scout.md613 B
- 资产文件assets/agents/tester.md700 B
- 资产文件assets/commands/hive.md2.1 KB
- 资产文件assets/commands/migration.md1.4 KB
- 资产文件assets/commands/oc.md728 B
- 资产文件assets/commands/research-sweep.md1.2 KB
- 资产文件assets/commands/review-panel.md1.4 KB
- 资产文件assets/commands/swarm.md1.9 KB
- 资产文件assets/commands/test-fleet.md1.3 KB
- 许可证LICENSE.txt11.1 KB
- 脚本scripts/bench/grader-prompt.md1.3 KB
- 脚本scripts/bench/run-bench.mjs6.7 KB
- 脚本scripts/oc-aggregate.mjs2.7 KB
- 脚本scripts/oc-status.mjs2.2 KB
- 脚本scripts/oc-worker.mjs7.7 KB
03 SKILL.md 正文
Hivemind: Claude Code as Orchestrator, opencode as Free Worker Swarm
Claude Code = brain (plans, reviews, merges). opencode = disposable workers on free models
(opencode/mimo-v2.5-free default; verified $0.00 per run).
Prerequisites (external dependency)
This skill is a thin orchestration layer over opencode, a third-party CLI. It is not bundled — install and authenticate it yourself first:
| Requirement | Notes |
|---|---|
| Node.js >= 18 | The scripts use fetch and node:timers/promises. |
opencode CLI on PATH |
npm i -g opencode-ai (or the installer opencode documents). |
| An authenticated opencode account | opencode auth login. Workers run as your account. |
Default model opencode/mimo-v2.5-free |
A free tier offered by opencode, not by Anthropic. Availability, rate limits, and pricing are opencode's to change — override with --model at any time. |
Windows only: OPENCODE_GIT_BASH_PATH |
Point at C:\Program Files\Git\bin\bash.exe, set persistently. |
Nothing here calls the Anthropic API on the worker side; worker traffic goes to opencode's endpoints. Do not delegate secrets or private code you would not send there.
Setup
- Put this skill folder wherever your agent loads skills from (e.g.
~/.claude/skills/hivemind). - Export
HIVEMIND_HOMEpointing at that folder — the bundled slash commands use it:export HIVEMIND_HOME="$HOME/.claude/skills/hivemind" - Copy the bundled assets into place:
assets/commands/*.md->~/.claude/commands/(the/hive,/oc,/swarm, ... entry points)assets/agents/*.md->~/.config/opencode/agent/(the scout / coder / tester worker personas)
Both copies are optional: everything the commands do can be driven by invoking
scripts/oc-worker.mjs directly, and any opencode agent name works with --agent.
Runtime state (.runs/*.jsonl) is written inside this folder and is gitignored.
Components
| Path (relative to this skill dir) | Purpose |
|---|---|
scripts/oc-worker.mjs |
ONLY sanctioned way to invoke a worker. Hardened join point. |
scripts/oc-status.mjs |
Fleet progress from run logs (oc-status.mjs <run-id>) |
scripts/oc-aggregate.mjs |
Dedupe/synthesize N worker outputs; consensus findings first |
scripts/bench/run-bench.mjs |
Benchmark configs A (claude solo), B (opencode solo), C (orchestrated swarm) |
scripts/bench/grader-prompt.md |
Blind grading rubric (max 12 pts + PASS/FAIL gate) |
assets/commands/ |
Slash-command entry points to copy into ~/.claude/commands/ |
assets/agents/ |
scout / coder / tester agent definitions for opencode |
Slash commands (ship in assets/commands/, copy to ~/.claude/commands/):
/hive <task>- AUTO-ROUTER. Classifies task -> single worker, generic swarm, or template. Default entry point; prefer this over manual routing./oc <task>- single worker delegation/swarm <task>- generic parallel swarm/review-panel <diff>- 4-lens parallel review (correctness/security/performance/style) + consensus aggregation/research-sweep <question>- 3-5 parallel research angles, synthesized/migration <task>- batched per-worktree migration workers + sequenced merge/test-fleet <target>- partitioned parallel test runs with safety checks
Worker agents (ship in assets/agents/, copy to ~/.config/opencode/agent/):
- scout - read-only research (no write/edit/bash)
- coder - implements one subtask in its worktree
- tester - runs tests only, never edits source
Invocation contract
node "<skill-dir>\scripts\oc-worker.mjs" [--agent scout|coder|tester] [--dir <path>] [--model <p/m>] [--timeout 900] [--run <id> --label <name>] "TASK TEXT"
Returns exactly ONE compact JSON line:
{ ok, result, tokens:{total,input,output,cache}, cost_usd, duration_ms, label, agent, model }
On failure: { ok:false, stage:"args"|"exec"|"api"|"parse"|"empty", error } with stderr capped at 300 chars.
--run <id> + --label <name> append lifecycle events (start/done/fail) to .runs/<id>.jsonl
inside this skill dir. Use them for EVERY swarm worker so progress is recoverable via
oc-status.mjs even after orchestrator context loss.
The script auto-manages the shared server: health-checks 127.0.0.1:4096, spawns opencode serve if dead, waits 5s, falls back to cold start. Workers are idempotent against their --dir; re-run once on ok:false before giving up.
HIVEMIND_SERVER_URL overrides that address (default http://127.0.0.1:4096). It must be a
valid URL with a numeric port; anything else fails fast with a single stage:"args" JSON line
rather than reaching the spawned process.
Golden Rule (non-negotiable)
Raw opencode NDJSON streams must NEVER enter your context. All output arrives via the
script's single JSON line. Never pipe opencode run --format json directly into this
conversation; never re-implement what the script does.
Single worker flow (/oc)
For one read-only question or small delegation: run oc-worker.mjs without worktrees.
Read-only tasks may omit --agent/--dir. Summarize result for the user.
If files were written: show git diff before letting the user commit.
Swarm flow (multi-worker)
- Decompose task into 2-5 INDEPENDENT subtasks (no shared files).
- Writing workers get isolated worktrees FIRST:
git worktree add ../<repo>-wt-N -b swarm/N. - Issue ALL worker invocations as PARALLEL Bash tool calls in ONE message.
- Review every diff yourself (
git diff main...swarm/N). YOU are the only merger. - Merge approved branches, remove worktrees, run tests.
- Report table: subtask | agent | tokens | outcome + total worker tokens.
HARD RULES: workers never share directories; never delegate merging/reviewing; escalate to your own Sonnet only when a free-model worker demonstrably fails twice.
Benchmarking
node scripts\bench\run-bench.mjs --repo <project> [--configs a,b,c] [--task 1-5]
Appends JSONL records (ts, config, tokens, cost, duration) to bench-results.jsonl.
Grade artifacts blind with grader-prompt.md (grader sees only task spec + output).
Configs: A=claude solo baseline, B=opencode solo, C=claude orchestrating 2 workers.
Fallback ladder (all flows)
- Worker
ok:false-> re-invoke once against the same dir. - Still failing -> orchestrator performs that subtask inline, marks it
[orchestrator-sourced]. - opencode entirely down (
exec/apitwice) -> announce, abandon workers, do the task directly. Never let a swarm fail a task that Claude could have done itself.
Fleet patterns
Four reusable topologies ship as slash commands (see table above). Shared invariants:
parallel spawns in one message; --run/--label on every worker; aggregation via
oc-aggregate.mjs when 3+ workers produce findings; consensus beats single-lens claims;
worktree isolation whenever any worker writes.
Windows notes (hard-won)
- Requires
OPENCODE_GIT_BASH_PATH=C:\Program Files\Git\bin\bash.exe(set persistently). - The script resolves the REAL
opencode.exeby parsing the npm.cmdshim — Node's EINVAL policy blocks spawning.cmddirectly. Do not "simplify" resolver back towhere.exefirst-line. - Free models:
opencode/mimo-v2.5-free,opencode/nemotron-3.5-lightning-free,opencode/hy3-free. NOTE:opencode-go/*models require workspace billing — avoid.
Known limits
- Free-tier rate limits can 429 under heavy swarms; space out retries.
- Worker quality varies; always review diffs. Scout answers are evidence-cited.
- Bench config C consumes real Claude tokens for orchestration (~1-2k/task).
Anti-patterns
| Anti-pattern | Why it breaks | Do this instead |
|---|---|---|
Piping opencode run --format json straight into the orchestrator |
Raw NDJSON floods context — the exact cost the skill exists to avoid | Always go through scripts/oc-worker.mjs, which returns one compact JSON line |
| Two writing workers in one directory | Concurrent edits corrupt each other's diffs | One git worktree per writing worker, created before the spawn |
| Letting a worker merge, review, or approve its own branch | Free-tier workers are the least reliable judges of their own output | The orchestrator is the only merger and the only reviewer |
| Spawning workers sequentially, one per message | Loses the entire wall-clock benefit of a swarm | Issue every worker invocation as parallel calls in ONE message |
| Retrying a failing worker indefinitely | Burns rate limit and stalls the task | Retry once, then do the subtask inline and mark it [orchestrator-sourced] |
| Delegating secrets, credentials, or private code | Worker traffic leaves for opencode's endpoints | Keep sensitive context in the orchestrator; send workers only what is safe to share |
Trusting cost_usd: 0 as a permanent guarantee |
The free tier belongs to opencode and can change | Re-check pricing before relying on zero cost for bulk work |
Cross-references
engineering/llm-cost-optimizer— decide whether a task is worth delegating before Hivemind decides howengineering/agent-harness— harness patterns for the orchestrator side of the loopengineering/workflow-builder— for deterministic pipelines that do not need independent worker judgmentengineering/skillsandengineering/write-a-skill— authoring conventions used by the worker agent definitions inassets/agents/
04 同仓库更多 Skills
syllabus
Generates a curated supplementary reading list from any course syllabus using Consensus academic search. Grill-me intake (syllabus input format + course audience + year range) plus a grouping forcing-options checkpoint before any search runs — so the reading list matches the course's level and recency need. Parses the syllabus to extract topics and learning outcomes, searches Consensus for recent peer-reviewed papers per topic, and produces a professionally formatted .docx with clickable Consensus links, plain-language summaries calibrated to audience level, and Bloom-higher-order discussion questions tied to course learning goals. Use when the user uploads a syllabus, course outline, or curriculum document and wants supplementary readings (e.g., 'create a reading list from this syllabus', 'find recent papers for my course') — even casual mentions with a syllabus attached should trigger this skill.
pulse
Multi-source recency research skill that takes the pulse of any topic across Reddit, Hacker News, the open web, and optionally X/Twitter within a configurable recent window (default 30 days). Forcing intake clarifies topic specificity, angle (trend/sentiment/problems/opportunities/comparison), time window, and platform scope before searching. Returns a synthesized briefing with citations, engagement metrics, and cross-platform pattern analysis. Use when the user requests multi-source recency intelligence on a topic (e.g., 'pulse on [topic]', 'what's happening with [topic]', 'what are people saying about [topic]', 'current conversation about [topic]', 'take the pulse of [topic]', 'trending: [topic]', 'find me info on [topic]'), and for competitor research, trend discovery, tool comparisons, and audience sentiment analysis.
patent
Patent prior-art and landscape intelligence skill — not generic patent help. Commits to one of five sub-use-cases via forcing intake (novelty search / freedom-to-operate / competitive landscape / acquisition diligence / litigation prior-art) before any search runs. Searches Google Patents, Espacenet, USPTO, and optionally Lens.org for citation-graph signals. Output is an editable Word document (.docx) with verdict, ranked closest art (claim-text extracted), CPC-class-aware landscape, family-resolved hits, geographic coverage, FTO flags where applicable, strategy recommendations, and full audit log. Use when the user asks for patent searching or analysis (e.g., 'prior art search for [invention]', 'freedom to operate analysis for [product]'). Produces search signal, not legal advice — always recommends consulting a patent attorney before filing or licensing decisions. Trademark, copyright, and trade-secret questions are out of scope.
notebooklm
Browser automation skill for controlling Google's NotebookLM. Use when the user wants anything done in NotebookLM (e.g., 'open NotebookLM', 'check my [name] notebook', 'ask my notebook about X', 'add [source] to NotebookLM', 'generate a Video Overview from my notebook', 'use NotebookLM Studio'). Handles reading and querying notebooks, adding sources (URLs, text, files, YouTube links, synthesized content), generating Studio outputs (Audio/Video Overviews, Mind Maps, Reports incl. Briefing Doc/Study Guide/FAQ, Flashcards, Quiz, slide decks, infographics — discover the exact set from the live Studio panel; the UI evolves fast), and creating new notebooks. Requires browser automation environment — fails gracefully when unavailable.
litreview
Academic literature orientation skill that searches papers via free keyless APIs (PubMed E-utilities + OpenAlex) by default — with the Consensus MCP as an optional enhancement lane when connected — builds a strategic search plan using PICO (default) or SPIDER / Decomposition / hybrid as fallbacks, and synthesizes findings into a formatted Word (.docx) research guide. Grill-me intake (research question specificity + framework hint + tentative depth) before the recon search; a second forcing checkpoint after Phase 2 confirms framework + sub-areas + depth before searches consume budget. Configurable depth (5/10/20 queries) controls coverage vs. speed. Output is a 'launching pad' — an orientation guide that lets a researcher dive in confidently, not a finished review. Use when the user starts literature-oriented research (e.g., 'litreview on [topic]', 'literature review on [topic]', 'I'm starting a literature review on X', 'I'm writing a paper on X', 'help me research X', 'I'm doing research on X', 'can you help me research X'). Do NOT use for single one-off paper searches wanting a quick list — that's a plain PubMed/OpenAlex (or Consensus) query.
grants
NIH grant research skill for clinical researchers. Grill-me intake (research idea + career stage + preliminary data + environment + submission posture + known institute targets) locks down the funding strategy before any search runs. Runs a 5-facet Consensus positioning analysis (with draft Significance/Innovation language), maps the research to the right NIH institutes and study sections via RePORTER, finds NOSIs and funded overlap, and produces an editable Word document (.docx) with budget/scope-aware mechanism recommendations, submission timelines, and a mandatory program officer recommendation. Use when the user asks about research funding or makes any grant-related request (e.g., 'grants for [topic]', 'find grants for my research idea', 'what grants match my research', 'help me find NIH funding', 'grant opportunities for my research'). NIH-only scope — non-NIH funders (PCORI, DOD CDMRP, VA, foundations) are out of scope and flagged at intake.