A Claude Code skill that delegates tasks to opencode — the open-source AI coding agent — non-interactively. It can run one task sequentially or split the work into small parallel lanes, each isolated in its own git worktree, then monitor them, verify the result, and clean up anything that didn't stop cleanly.
When you ask Claude Code to do something "using opencode" / "pakai opencode", this skill:
- Checks for leftover lanes from earlier sessions before adding load
- Asks sequential or parallel — and if parallel, validates your lane count against what the machine can actually take
- Splits the work into atomic subtasks, ordered into dependency waves, and shows the plan before dispatching
- Runs each lane in its own git worktree + branch, so concurrent lanes can't overwrite each other
- Monitors lanes live — what each one is doing right now, files touched, open todos
- Verifies the result — reads changed files, diffs, test output — instead of trusting opencode's "done"
- Retries via
--continuewith a specific explanation of what's still missing - Merges the lane branches back, stopping at the first conflict rather than guessing
- Reaps stuck work: graceful
abortfirst, signals only as a fallback
You can also invoke it just for step 5 or 9 — "status opencode", "opencode nyangkut", "bersihkan sisa task".
- Claude Code
- opencode 1.18+ configured with a provider (
opencode providers) jq,git,python3,curl- Parallel mode additionally needs a git repo with a clean working tree
git clone https://github.com/kabesma/delegate-to-opencode ~/.claude/skills/delegate-to-opencode
chmod +x ~/.claude/skills/delegate-to-opencode/scripts/*.shStart a new Claude Code session for the skill to appear.
Mention opencode as the executor:
suruh opencode bikin fungsi validasi email di utils
have opencode fix the failing tests
lewat opencode, refactor the auth middleware — paralel 2 lane
tell opencode to explain the auth flow in this repo
status opencode # what are the lanes doing?
opencode nyangkut # find and clean up stuck work
No slash command needed.
The scripts are usable on their own, and work across Claude sessions because all state lives in ~/.local/state/opencode-delegate/.
| Script | Purpose |
|---|---|
oc-capacity.sh |
Probe cores, free RAM, swap, load → recommend a safe lane count (JSON) |
oc-daemon.sh |
start / stop / status / health for the shared headless server |
oc-lane.sh |
init / launch / merge / cleanup — worktree lifecycle per lane |
oc-status.sh |
Table of every lane: status, age, files changed, open todos, last activity |
oc-reap.sh |
Find work that never stopped cleanly; --reap to act (dry run by default). --reap-untracked additionally stops opencode workers this skill never launched — only if old and idle |
S=~/.claude/skills/delegate-to-opencode/scripts
$S/oc-capacity.sh --want 3
$S/oc-status.sh
$S/oc-reap.sh # report only
$S/oc-reap.sh --reap # act on what is unambiguously deadOne shared opencode serve process; each lane is a thin opencode run --attach client with its own worktree. Measured on an M1/8GB: the server is ~87 MB, an attached client ~58 MB, and the client opens no port of its own — the LSP, file watcher, and snapshot tracking exist once instead of once per lane.
┌─ lane 1 → worktree oc/<run>/lane-1 → branch
opencode ────┤
serve └─ lane 2 → worktree oc/<run>/lane-2 → branch
↓
merge back, one at a time
Full procedure: references/parallel-runbook.md.
| Setting | Value | Reason |
|---|---|---|
--auto |
always on | Auto-approves permission prompts. Not --dangerously-skip-permissions — that flag does not exist, and opencode ignores unknown flags silently. |
| Confirmation before run | off | Run immediately once the task is clear |
| Confirmation before parallel dispatch | on | Shows the split plan first; lanes cost real tokens and RAM |
| Working directory | context-aware | Falls back to the project root |
| Isolation | git worktree per lane | No risk of lanes overwriting each other |
| Stuck work | auto-reap only when unambiguous | Everything else is reported for you to decide |
- Your interactive
opencodeTUI is never killed. Process matching compares argv exactly, so a bareopencode— and shell wrappers that merely mention "opencode run" — can never be selected. - Runs started by other tooling are never killed by
--reap. Anopencode runthis skill didn't launch (a build pipeline, a script, you at a shell) is reported, not stopped. Removing one needs the explicit--reap-untracked, and even then it must be older than the stall threshold and accruing no CPU across a 15-second window. - Worktrees with uncommitted changes are never deleted, only reported.
- A dirty working tree is never auto-stashed — the skill stops and asks.
- Your global
~/.config/opencode/opencode.jsonis never modified. nothing to clean upsays so honestly — it names what it did not check (sessions outside this skill, general orphans, memory pressure) instead of implying an all-clear.
dispatch → verify against the real files
↓ incomplete/wrong
--continue "here's what's still wrong: ..."
↓ verify again
repeat (max ~3 rounds) → report honestly
Claude reads the actual changes — not opencode's "done" message — before deciding whether to retry. Provider failures (rate limits, a model that never streams) are reported as infrastructure problems rather than retried as if the task were wrong.