Use when the user wants Claude Code to plan, review and iterate while a local model in OpenCode does the actual coding. Triggers on "have my local model build this", "delegate to Qwen/OpenCode", "plan for the local model", or when a written plan should be handed to a local harness and the result reviewed. Claude plans and reviews; the local model implements.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Skill?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/skrodahl-skill)
---
name: delegate-to-local
description: Use when the user wants Claude Code to plan, review and iterate while a local model in OpenCode does the actual coding. Triggers on "have my local model build this", "delegate to Qwen/OpenCode", "plan for the local model", or when a written plan should be handed to a local harness and the result reviewed. Claude plans and reviews; the local model implements.
---
# Delegate to a local model
Claude Code is the planner and reviewer. A local model, driven headless through OpenCode, writes the code.
Claude never trusts "done": it runs its own checks and sends back targeted fixes.
## Before you start
Check, and report what is missing instead of guessing:
1. `command -v opencode` works.
2. The model endpoint is up (for example `curl -s <baseURL>/models`). If the user's GPUs host only one model at a time, starting the right container is allowed only when the user has said so.
3. A model id exists in OpenCode config as `provider/model` (`opencode models`). If the provider needs a key, it must be an environment variable referenced as `{env:VAR}` in a **project-local** `opencode.json` placed in the work folder. Do not edit the user's global OpenCode config.
4. The work folder is a dedicated directory. `--auto` lets the model change files without asking, so never point it at a folder the user has not agreed to.
## The loop
### 1. Plan (Claude)
Write `PLAN.md` in the work folder from `templates/PLAN-template.md`. A good plan has exact names and numbers, a build order, an acceptance checklist the model can run, and a list of pitfalls. The plan is the main lever on quality: put every trap you know about in it, in plain words.
### 2. Dispatch
```bash
scripts/dispatch.sh -d WORK/PROJECT -m provider/model \
"Please implement PROJECT according to @PLAN.md"
```
- Logs go to `WORK/logs/` (`NAME.jsonl`, `.exit`, `.secs`, `.session`, and `.question` when flagged). The session id is printed.
- `dispatch.sh` prepends a preamble to every prompt: work autonomously, do not ask questions, decide and record the decision, finish with a status report. Pass `-P` only to test what the model does without it.
- Run it in the background and start `scripts/watch.sh WORK/logs NAME 15` next to it. When the user is away, run the watcher in the background and wait for it to exit instead of polling the log; its exit code tells you what happened (below).
| watch.sh | meaning | you do |
|---|---|---|
| `0 FINISHED` | exited, last message is not a question | go to review |
| `3 QUESTION` | exited, last message is a question | answer it (below) |
| `2 IDLE` | process alive, no log growth for N min | `diagnose.sh`, see recovery |
| `4 DEAD` | pid gone, no `.exit` | check `.err`, continue the session |
### 2b. When the model asks a question anyway
The preamble lowers the odds, it does not guarantee anything. `dispatch.sh` checks the last message (`summarize.py --check`: ends in `?`, "let me know / would you like / do you want", or a question tool call) and flags it. It errs toward false positives, so read the message before acting. Then:
1. If the plan decides the matter, or it is cheap to undo, answer it yourself in the same session:
```bash
scripts/dispatch.sh -d WORK/PROJECT -m provider/model -s SESSION -n NAME-a1 \
"Decide for yourself: pick the option that follows PLAN.md, state the choice in your report, and proceed. Do not ask again."
```
2. Log it in `logs/interventions.md`: what was asked, what you answered.
3. At most 3 rounds per task. After that, stop and give the open question to the user.
4. Do not guess when the question touches something the plan does not decide and that is costly to undo (deleting data, changing a public interface, spending money). Stop and give it to the user.
5. A flag on a rhetorical question inside a long report is a false positive; note it and go on to review.
### 3. Review (Claude)
Do not read the model's summary first. Test the result:
- Run the plan's acceptance checklist yourself.
- Drive the thing directly: set up exact states, step the clock, assert outcomes. Keep each check as a named test so it can be rerun.
- For UI work, take screenshots at a fixed size.
- Only then read the model's own report, and compare it to what you found.
### 4. Fix list (Claude to model)
Send numbered items, most important first, using `templates/FIXLIST-template.md`. Each item: **where**, **problem**, **change**, **check**. Ask for targeted edits, never a regeneration. Send with:
```bash
scripts/dispatch.sh -d WORK/PROJECT -m provider/model -s SESSION -n fix1 "<the list>"
```
Re-run the same checks. Repeat until green. If the same item fails twice, either fix it yourself or tell the user.
### 5. Probes (optional, recommended before trusting a model with real work)
Send one deliberately wrong review finding that sounds plausible (see `templates/PROBES.md`). A trustworthy worker reproduces the claim, finds it false, says so, and adds a regression test. A model that applies it blindly should not get unsupervised work.
## When a run goes quiet (recovery)
A watcher `IDLE` means "no log growth for N minutes". It does not mean the job is dead. Work through this, and do not ask the user unless a step needs a decision only they can make:
1. **Diagnose.** `scripts/diagnose.sh LOGS NAME [ENGINE_CONTAINER]` shows the last tool call and whether the engine is still generating.
- Engine still generating: the model is thinking or a subagent is working. Wait another interval.
- Engine idle and the last tool call is a **subagent / task / reviewer dispatch**: see below.
- Engine idle and the last message is a question: see step 2b.
- Engine idle, nothing else: the endpoint may have died. Check it, restart it if the user has allowed that, then continue the session.
2. **Hung helper.** Plan-following skills in the local harness often finish by dispatching a "most capable" reviewer or other subagent. If it names a model whose endpoint is not running (for example another engine you stopped to free the GPUs), the call never returns. Fix:
```bash
scripts/stop.sh LOGS NAME # stops by recorded pid, keeps the session
scripts/dispatch.sh -d WORK -m MODEL -s SESSION -n NAME-b \
"The reviewer model <id> is not running, so that subagent step cannot happen. Skip it. Do not ask questions. Finish with a short status: what is done, what you tested, and anything missing or deviating from PLAN.md."
```
Then do the review yourself (step 3). The local model's own reviewer is a bonus, not a gate. Record the intervention.
3. **A question in a headless run.** See step 2b (answer from the plan, 3 rounds at most, surface anything the plan does not cover).
4. **Never** stop a job with `pkill -f` or any name pattern. It can match your own shell. Use `stop.sh`.
5. **Prevent it next time.** Before dispatching, list every model endpoint the harness config can reach (`opencode models`) and make sure the ones the model might pick are running, or add one line to the prompt: `Do not dispatch subagents or reviewers on other models.` Say in the results file which you chose, because it changes what you are measuring.
6. Write every intervention in `logs/interventions.md`: time, symptom, cause, action.
## Rules
- Verify claims in both directions. The model's "tests pass" and your own review findings both need evidence.
- Keep a results file with timings, defects found per round and every intervention. Differences smaller than one or two defects are noise from a single run.
- Never put API keys, tokens or personal paths into prompts, plans or logs you share.
- The local model may start its own helpers or reviewers. If those point at endpoints that are not running, the run hangs; kill it and continue the session telling it to skip that step.
- State the limits: one task, one run, one plan says little about other tasks.