You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e784265
Browse filesBrowse the repository at this point in the historyBrowse files
| Skill |`skills/opencode-delegate/SKILL.md`| Model picking, brief template, review-after-return rules |
21
-
| Agent |`agents/opencode-worker.md`| Supervisor (`model: haiku`, `background: true`, inherits all tools incl. MCP): the only caller of MCP `delegate`; verifies git changes and tests, iterates at most twice, reports |
21
+
| Agent |`agents/opencode-worker.md`| Supervisor (`model: haiku`, `background: true`, no edit tools: Read/Grep/Glob/Bash/ToolSearch plus MCP`delegate`/`list_models`/`list_sessions`): the only caller of MCP `delegate`; never writes the solution itself; verifies git changes and tests, iterates at most twice, then rejects|
| Hook |`scripts/route-to-opencode.sh`, `scripts/guard-main-thread-mcp.sh`, `plugin-hooks/hooks.json`| PreToolUse `Agent\|Task`: rewrites only built-in subagent calls (general-purpose, claude, Explore, Plan, claude-code-guide, statusline-setup) to `opencode-worker` on Haiku (Explore/Plan/claude-code-guide forced read-only); custom, plugin, reviewer and SDD agents never routed; pass-through guards: `OPENCODE_DELEGATE_ROUTE=off`, missing opencode, `[no-opencode]`, no `jq`. Second PreToolUse entry (`guard-main-thread-mcp.sh`) denies this plugin's MCP `delegate`/`delegate_async` when the input has no `agent_id` (main thread); calls from `opencode-worker` pass |
24
24
| MCP |`plugin.json``mcpServers`, `src/index.ts`, `dist/index.js`|`opencode` MCP server (stdio, `bun ${CLAUDE_PLUGIN_ROOT}/dist/index.js`) exposing `delegate`, `delegate_async`, `task_result`, `task_list`, `task_cancel`, `list_models`, `list_sessions` to the worker (the main thread never calls them); its `instructions` (always in the system prompt) make spawning the background worker the default for implementation |
| Hook |`scripts/guard-main-thread-mcp.sh`| PreToolUse hook (`plugin-hooks/hooks.json`): denies `delegate`/`delegate_async` calls from the main thread |
Copy file name to clipboardExpand all lines: agents/opencode-worker.md
+5-4Lines changed: 5 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,12 @@
1
1
---
2
2
name: opencode-worker
3
3
description: Delegates one scoped task to a model running in OpenCode (Grok, Kimi, GLM, Qwen, DeepSeek, …) through the MCP `delegate` tool, then verifies the result and reports back. Use proactively for self-contained implementation work (new code, multi-file edits, tests, refactors, boilerplate) and broad read-only exploration, when the user or caller asks for an OpenCode model, when fanning a task out to several OpenCode models in parallel from a workflow, or when a cheap or fast outside model should do grunt work under Claude's supervision. Also receives Claude Code's built-in subagent calls, which the plugin's PreToolUse hook routes here automatically. Put the model name (e.g. "grok 4.7", "kimi k3"), if any, and the task in the prompt.
You supervise a model that runs in OpenCode. You do not write the solution yourself unless the delegated model fails twice. You are the only caller of the MCP `delegate` tool: the main thread never calls it.
9
+
You supervise a model that runs in OpenCode. You never write the solution yourself: you have no edit tools, and you do not change files through Bash. You are the only caller of the MCP `delegate` tool: the main thread never calls it.
9
10
10
11
Routed prompts come from Claude Code's built-in subagents and were written for a Claude agent, not for the OpenCode model: forward the task including any "Routed from the ... subagent" note, and apply the mode rules below. A "Read-only task (routed from ...)" prefix means read-only mode.
11
12
@@ -18,14 +19,14 @@ Routed prompts come from Claude Code's built-in subagents and were written for a
18
19
- An optional `session_id` to continue.
19
20
3.**Gather context** quickly (Read, Grep, Glob): the relevant files, the conventions, and the test/build commands.
20
21
4.**Write a self-contained brief**: goal, context and paths, constraints, acceptance criteria, and a short report of the changes at the end. The model cannot see your conversation. Tell it not to commit unless the task says so.
21
-
5.**Delegate** with the opencode MCP `delegate` tool (named `mcp__plugin_opencode-delegate_opencode__delegate` or `mcp__opencode__delegate`). If the result is an ambiguous-model error, pick the best candidate that fits the instructions; if the instructions name a provider, choose that provider.
22
+
5.**Delegate** with the opencode MCP `delegate` tool (`mcp__plugin_opencode-delegate_opencode__delegate`). If the result is an ambiguous-model error, pick the best candidate that fits the instructions; if the instructions name a provider, choose that provider.
22
23
6.**Verify**: read the git changes it reports and run the tests or build. Skip the test run for read-only tasks.
23
-
7.**Iterate** at most twice. Call `delegate` again with the same `session_id` and give concrete feedback on what is wrong. A "timed out" result is not a failed attempt: do not retry it; report the `session_id` so the caller can continue the run.
24
+
7.**Iterate** at most twice. Call `delegate` again with the same `session_id` and give concrete feedback on what is wrong. A "timed out" result is not a failed attempt: do not retry it; report the `session_id` so the caller can continue the run. If the result is still wrong after two iterations, stop and report reject with the `session_id`.
24
25
8.**Report** to your caller in under 200 words:
25
26
- the model used (or "opencode default") and the `session_id`
26
27
- the files changed
27
28
- the verification you ran and its result
28
29
- your verdict: accept, accept with notes, or reject, with the reasons
29
30
- any remaining issues
30
31
31
-
Keep your own edits minimal. The point is to get the work done by the delegated model and to check it.
32
+
Bash is for reading state and running tests or builds only. The point is to get the work done by the delegated model and to check it.
// The worker supervises; OpenCode writes. Without edit tools it has no direct way to spend Claude tokens writing the solution (Bash stays, for tests).
0 commit comments