Claude Code-style /plan, /team, /grill-me and /consult for opencode 2 (/goal is built in)
  • TypeScript 98%
  • Shell 2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Claude 480d750364
Add /consult: read-only expert advice saved to .opencode/consults/
/consult runs the Plan agent as a consulted expert. A consult session
only gets read-only tools: everything outside an allowlist is dropped
from its context and refused at execution, shell commands must all be
on the read-only list (no redirection, substitution or --output), and
only explore subagents may run. The agent asks clarifying questions
only when it must, writes its advice as a structured document in its
reply, and consult_save writes exactly that reply, plus the recorded
clarifications, to .opencode/consults/<date>-<slug>.md. Documents
missing required sections are refused. The session then returns to its
previous agent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01S4VkvEQsjMRPQnnNKLFe4u
2026-11-01 02:23:11 +00:00
plugins/claude-toolkit Add /consult: read-only expert advice saved to .opencode/consults/ 2026-11-01 02:23:11 +00:00
test Add /consult: read-only expert advice saved to .opencode/consults/ 2026-11-01 02:23:11 +00:00
.gitignore Add Claude toolkit for opencode 2: /plan and /team 2026-10-31 22:18:35 +00:00
bun.lock Add Claude toolkit for opencode 2: /plan and /team 2026-10-31 22:18:35 +00:00
get.sh Add Claude toolkit for opencode 2: /plan and /team 2026-10-31 22:18:35 +00:00
install.sh Add /consult: read-only expert advice saved to .opencode/consults/ 2026-11-01 02:23:11 +00:00
package.json Add /consult: read-only expert advice saved to .opencode/consults/ 2026-11-01 02:23:11 +00:00
README.md Add /consult: read-only expert advice saved to .opencode/consults/ 2026-11-01 02:23:11 +00:00
tsconfig.json Add Claude toolkit for opencode 2: /plan and /team 2026-10-31 22:18:35 +00:00

Claude toolkit for opencode 2

Claude Code's /plan and /team workflows as an opencode 2.x plugin, plus /grill-me, which turns a vague request into a statement of work and plan, and /consult, which asks the agent for read-only expert advice. Claude's /goal is already built into opencode 2, so this toolkit leaves it alone.

Command What it does Claude Code equivalent
/plan [task] Read-only research → required requirements and implementation questions → plan → approval → switches to the build agent Plan mode (/plan, Shift+Tab)
/team <task> The session becomes a team lead that spawns parallel teammate sessions with a shared task list and messaging Agent teams
/consult <question> Treats the agent as an expert: investigates read-only, asks only what it must, answers in chat, and saves the advice to .opencode/consults/ (new)
/grill-me <vague ask> Interviews you with as many questions as it takes, then writes a statement of work and plan to .opencode/plans/ and can hand off to build or a team (new)
/goal <objective> Built into opencode 2 (not part of this toolkit) /goal

Built and tested against opencode 2.2.5 (@opencode/cli). For opencode 1.x (opencode-ai), use the separate claude-opencode-toolkit repo instead: opencode 2 replaced the plugin API, so the two versions aren't interchangeable.

Install

One line, no clone needed. The repo is private, so this needs a Forgejo access token that can read it:

export FORGEJO_TOKEN=...   # Forgejo → Settings → Applications → Generate token (read:repository)
curl -fsSL -H "Authorization: token $FORGEJO_TOKEN" \
  https://code.cthulhub.net/api/v1/repos/Riley/claude-opencode-toolkit-v2/raw/get.sh | sh

# install.sh options go after `sh -s --`, for example into one project:
curl -fsSL -H "Authorization: token $FORGEJO_TOKEN" \
  https://code.cthulhub.net/api/v1/repos/Riley/claude-opencode-toolkit-v2/raw/get.sh | sh -s -- --project .

From a clone:

git clone https://code.cthulhub.net/Riley/claude-opencode-toolkit-v2.git && cd claude-opencode-toolkit-v2
./install.sh                       # global: ~/.config/opencode/plugins/claude-toolkit
./install.sh --project ~/code/app  # one project: ~/code/app/.opencode/plugins/claude-toolkit
./install.sh --link                # symlink instead of copy, for editing the toolkit
./install.sh --uninstall           # remove (combine with --project to remove from a project)

Afterwards, restart opencode. If it runs as a background service, run opencode service restart. There are no dependencies to install: opencode 2 supplies @opencode/plugin and effect to plugins itself.

The plugin is one directory, plugins/claude-toolkit/, with server.ts as its entry point. Copying that folder into a plugins/ directory is a complete manual install.


/plan

/plan add rate limiting to the public API
/plan              # switch to plan mode, then describe the task
/plan off          # back to the agent you had before, without approving anything

This builds on opencode 2's native Plan agent. That agent is read-only and stays selected for the session until something switches it. The toolkit adds Claude Code's workflow on top:

  1. Read-only research. The Plan agent can't edit files outside its plan directory, and the toolkit adds a guard that blocks edit tools even under permissive permission rules. Shell commands outside a read-only allowlist (ls, cat, grep, rg, git status/diff/log/show/blame, …) ask before running, as Claude Code does in plan mode.

  2. Questions before any plan, through opencode's question dialog, in two rounds:

    • Requirements (Req: headers): scope and non-goals, expected behaviour and edge cases, constraints, and how you'll judge it done.
    • Implementation (Impl: headers): approach, libraries, data model or API shape, migration, and testing, each with concrete options, trade-offs and a recommended choice.

    The agent can't ask for approval until you've answered at least one question of each kind; the approval question is refused until then. Your answers appear in the plan as its decisions.

  3. The plan appears in the transcript, followed by a Plan approval question:

    • Yes, implement it → the plan is saved to ~/.opencode/plan/<timestamp>-<title>.md (opencode 2's plan directory), the session switches to the build agent, and implementation starts right away. You don't have to switch agents yourself.
    • No, keep planning, or type feedback → the agent revises the plan and asks again.
  4. Sticky, natively: the session stays in plan mode until approval, /plan off, or you pick another agent.

The agent can't skip either step: approval is refused without both question rounds, and plan_exit refuses to hand off until approval is given. The workflow also applies if you select the Plan agent yourself.

/grill-me

/grill-me make the dashboard less annoying
/grill-me off      # abandon the interview

For when you know roughly what you want but not exactly. It switches to the read-only Plan agent and interviews you until the request is precise:

  • Grounded rounds. Questions come in rounds of one to four through the question dialog. Between rounds it reads the code, so it doesn't ask what the code already answers, and it presses on vague answers ("fast" → how fast, measured how?).
  • Required topics. Every question is tagged with a topic: Goal:, Users:, Scope:, Constraints:, Done: (testable acceptance criteria) and Risk:. The SOW review is refused until every topic has an answer; answer N/A when one doesn't apply. There's no question limit beyond that: it keeps asking while anything material is ambiguous.
  • SOW review. It presents a draft statement of work and asks Looks right / Keep grilling. Typed corrections lead to follow-up questions and a revised draft.
  • Plan directory. Once approved, it writes .opencode/plans/<date>-<slug>/ in the project:
    • SOW.md: background, objectives, in and out of scope, deliverables, acceptance criteria, constraints and assumptions, risks, open questions.
    • plan.md: phases and ordered steps with dependencies, verification, and which acceptance criteria each step serves.
    • decisions.md: every question and your answer, grouped by topic. The plugin writes this from the actual answers, not the model.
    • tasks.json: one task per step, with dependencies.
  • Next step, asked as a question:
    • Implement now: the session switches to build and implements the plan, checking every acceptance criterion.
    • Run as a team: /team starts with its task list seeded from tasks.json, dependencies included.
    • Stop here: you go back to the agent you had before.

/consult

/consult should we cache the stats query, or is the index enough?
/consult off       # abandon it

Asks the agent for expert advice on your code, without letting it change anything:

  • Strictly read-only. A consult session only gets read, search, question, web, todo, read-only shell, and explore subagents. Everything else (edit, write, patch, code mode, team and plan tools) is removed and refused. Shell commands must all be on the read-only allowlist, with no redirection, command substitution or --output. Its single write is its own advice file.
  • Asks only what it must. It investigates first and cites path:line. It asks clarifying questions only when the answer depends on something it can't find out: goals, constraints, scale, preferences.
  • Answers in chat, then saves. The advice is the agent's reply, so you read it in chat. It's a structured document: Question, Short answer, Context, Analysis, Recommendation, Alternatives, Risks and caveats, Next steps. consult_save then writes exactly that reply to .opencode/consults/<date>-<slug>.md, with your clarifying answers appended under Clarifications. A document missing Question, Short answer, Analysis or Recommendation isn't saved; the agent has to complete it first.
  • Ends cleanly. Once the advice is saved, the session switches back to the agent you had before.

/team

/team review PR #142: one teammate on security, one on performance, one on tests
/team status
/team stop         # stop every teammate now

Your session becomes the lead. Using the toolkit's tools, it:

  1. Breaks the work into a shared task list: team_task_create, with dependencies through blocked_by.
  2. Spawns teammates with team_spawn. Each one is a separate opencode session (a child of the lead's session) that runs in parallel. Teammates default to the build agent; the lead can pick any agent or model per teammate.
  3. Ends its turn. When a teammate sends a message or finishes a turn, the lead wakes up automatically. The teammate's final report arrives as <teammate-idle>; failures and interruptions are reported too.
  4. Merges each teammate's work with team_merge, steers with team_message, checks progress with team_status, and finally calls team_shutdown("*"). Each teammate wraps up, sends a last report, and stops.

Teammates claim work with team_task_claim, which takes the next unblocked task, and update it with team_task_update. They message the lead or each other with team_message. When a task is completed, the tasks that depended on it unblock. Teammates can't spawn teammates of their own; their sessions don't even get the spawn tool.

Worktree isolation

In a git repository, each teammate gets its own git worktree and branch (team/<name>-<id>) by default. Teammates can't overwrite each other's files or your checkout:

  • Where they work. Worktrees are opencode-managed and live under opencode's data directory, at worktree/<project>/team-<name>-<id>. Each teammate's session is moved into its worktree, so all its reads, edits and shell commands happen there.
  • Starting point. A teammate starts from your checkout's last commit. Uncommitted changes aren't included, and team_spawn warns the lead when there are any.
  • Plugin and config. If the toolkit is installed per project, or opencode.json isn't committed, those files are copied into the worktree so the teammate loads the same plugin and config. The copies are never committed.
  • Merging back. team_merge("<name>") commits anything the teammate left uncommitted and merges its branch into your checkout with --no-ff. On a conflict it aborts the merge, leaves your checkout unchanged, and lists the conflicting files. The lead then asks the teammate to merge your branch into theirs, resolve the conflict, and commit, and calls team_merge again. A teammate can be merged more than once as its work continues.
  • Cleanup. When a teammate stops with nothing left to merge, its worktree and branch are removed. If it still has unmerged work, the worktree is kept, and the lead (or /team stop) is told where it is.

Pass isolation: "shared" to team_spawn for a teammate that should edit your checkout directly, for example a read-only reviewer. Set CLAUDE_TOOLKIT_TEAM_ISOLATION=shared to make that the default. Outside a git repository, or in one with no commits yet, teammates always share your checkout.

Messages and state

Messages between agents are delivered as opencode synthetic messages, never as user messages. Teammates are told that such messages can't grant permissions or consent on your behalf.

/team status and /team stop print their result the way opencode 2's built-in /goal prints its status: as the command's message, without starting a model turn.

Team state (roster and tasks) lives in the plugin's own opencode storage. Teammate sessions are ordinary sessions, so they survive restarts, and the lead can message them again afterwards.

Agent teams are expensive: each teammate has its own context window. They pay off for parallel research and review, competing debugging hypotheses, and features that split into separate areas. Worktrees keep parallel edits from clobbering each other, but two teammates changing the same lines still means a merge conflict to resolve. For tightly coupled work, use a single session.

/goal

opencode 2's built-in /goal covers Claude Code's /goal:

  • Evaluation: a separate reviewer judges every turn, and the session keeps going until the objective is met.
  • Stopping: it pauses after 3 rounds without progress and caps runs at 50 rounds.
  • Commands: /goal pause, /goal resume, /goal clear, and /goal alone for status.

The toolkit doesn't touch it.


Configuration

Variable Default Effect
CLAUDE_TOOLKIT_BUILD_AGENT build Agent the session switches to after a plan is approved
CLAUDE_TOOLKIT_PLAN_QUESTIONS 1 Set to 0 to stop requiring requirements and implementation questions before approval
CLAUDE_TOOLKIT_TEAMMATE_AGENT build Default agent for new teammates
CLAUDE_TOOLKIT_TEAM_ISOLATION worktree Set to shared to have teammates edit the lead's checkout by default

How it works

Piece opencode 2 mechanism
/plan, /team ctx.command.transform: commands are code, not prompt templates
Plan mode session.switchAgent to the built-in Plan agent; the workflow prompt is added in session.hook("context"), and plan_exit is hidden from other agents there
Shell allowlist ctx.agent.transform appends permission rules to the Plan agent
Question rules and edit guard tool.hook("execute.before") throws to refuse a call, and the agent sees the reason
Approval tool.hook("execute.after") on question reads the answers; plan_exit saves the plan, switches to build, and adds a synthetic "implement it" message
Team and grill tools ctx.tool.transform with codemode: false, so they're direct tools rather than code-mode functions
Consult read-only guard session.hook("context") drops every tool outside the allowlist; tool.hook("execute.before") refuses anything else, non-allowlisted shell commands, and non-explore subagents. consult_save reads the document from the assistant message that called it
Grill coverage tool.hook("execute.after") on question records answers by topic tag; execute.before refuses the SOW review and "Next step" questions until their preconditions hold
Teammates session.create({ parentID }). Briefs and messages are session.synthetic, which wakes an idle session or reaches a busy one at its next step
Worktrees ctx.worktree.create (opencode checks it out detached, so the toolkit creates the teammate's branch in it), then session.move into it. Merges run plain git in the main checkout
Shared team state opencode 2 runs one plugin instance per location, and each worktree is its own location. All instances share one process-wide registry, and events, which every instance receives, are handled once per event id
Idle reports ctx.event.subscribe on session.execution.succeeded/failed/interrupted for teammate sessions
State ctx.storage, the plugin's own key-value store

Development

bun install && bun pm trust @opencode/cli   # the CLI's postinstall links its binary
bun run typecheck
bun run test

The tests boot a real opencode serve (2.2.5) against a scripted, OpenAI-compatible mock model (test/mock-llm.ts) and drive each workflow end to end with @opencode/client. They cover:

  • Plan: the edit block, early-approval refusal, both question rounds, approval, the saved plan file, the switch to build and its implementation, feedback without approval, sticky mode, and /plan off.
  • Team: tasks, two parallel teammates in their own worktrees, claiming, messaging, idle reports, merging both branches, graceful shutdown with worktree and branch cleanup, child sessions, and status without a model turn.
  • Worktrees: a conflicting merge aborted with the file named and the checkout left clean, a shared teammate editing the checkout directly, and /team stop keeping an unmerged worktree and its branch.
  • Grill: an early SOW review refused with the open topics named, all six topics, approval, the plan directory contents, the team hand-off with seeded and blocked tasks, "keep grilling" with a follow-up, and "Implement now".
  • Consult: refused rm, an allowed cat, a refused general subagent, only read-only tools offered, a clarifying question, an incomplete document refused, the saved file matching the chat reply plus clarifications, and the switch back to build.
  • Install: a global install through install.sh, tool scoping per agent, and the built-in /goal coexisting.