Skip to content

Add OpenCode plugin support alongside Claude Code#8

Open
kulterryan wants to merge 2 commits into
harshilmathur:mainfrom
kulterryan:opencode-support
Open

Add OpenCode plugin support alongside Claude Code#8
kulterryan wants to merge 2 commits into
harshilmathur:mainfrom
kulterryan:opencode-support

Conversation

@kulterryan

Copy link
Copy Markdown

Summary

Adds first-class support for OpenCode alongside the existing Claude Code plugin. The skill content (protocols, personas, templates, Python validator) is shared between both hosts — OpenCode auto-discovers skills under .claude/skills/ as well as .opencode/skills/. Only the glue layer (commands + pre-declared agents + a host adapter) is OpenCode-specific.

Key properties

  • Zero regressions to Claude Code. claude-plugin/, .claude/, .claude-plugin/, scripts/sync.sh, install.sh, and .github/ are bit-identical before/after.
  • No duplicated skill content. One canonical copy of SKILL.md + references/.
  • Thin, auditable glue. 22 new files, mostly short prose. No TypeScript plugin required — deferred to a follow-up.

What ships

New files

  • .opencode/host-adapter.md — the single contract every OpenCode command reads alongside SKILL.md. Covers tool name map (Agenttask, WebSearchwebsearch, etc.), pre-declared agent roster, parallel spawn pattern, Rule 13 runtime check, websearch caveat, context-file handling, publish chain overrides.
  • .opencode/commands/*.md (10) — autodecision.md plus 9 hyphenated subcommands. OpenCode has no namespace/colon support, so commands are flat: /autodecision, /autodecision-quick, /autodecision-compare, /autodecision-revise, /autodecision-challenge, /autodecision-summarize, /autodecision-publish, /autodecision-plan, /autodecision-review, /autodecision-export.
  • .opencode/agents/ad-*.md (9) — 5 persona agents (ad-optimist, ad-pessimist, ad-competitor, ad-regulator, ad-customer), plus ad-critique, ad-adversary, ad-sensitivity, ad-decide. All mode: subagent, hidden: true. OpenCode's Task tool requires pre-declared agent files (unlike Claude Code's inline-prompt Agent tool).
  • scripts/sync-check-opencode.sh — structural validator. Confirms every command exists with valid frontmatter, every agent has mode: subagent + hidden: true, every command references the host adapter and the skill path, no orchestrator sets subtask: true.
  • OPENCODE.md — host-specific reference doc (install, command map, how subagents work differently, known limitations, troubleshooting).

Modified files

  • README.md — adds the OpenCode install section; dual command examples (colon vs hyphen) in Quick Start.
  • CLAUDE.md — notes OpenCode install path under Installation; adds .opencode/ tree to Architecture diagram.

Key research findings that shaped this design

Capability Claude Code OpenCode Port impact
Skills SKILL.md + references/ Native skill tool; auto-discovers .claude/skills/ AND .opencode/skills/ Zero duplication needed
Parallel subagents Task tool, inline prompts task tool, but agents must be pre-declared as named files 9 pre-declared agents shipped
Slash commands Colon namespace (/autodecision:quick) No namespace / no subdirs — flat filenames only Commands use hyphens
Plugin distribution Marketplace + plugin.json Local .opencode/ files OR npm JS-only plugin (npm cannot ship .md files) Distribution: "copy .opencode/ into your project"
subtask: true n/a Forces command to run in child session Not used on orchestrator — would block parallel spawning

Validator output

$ ./scripts/sync-check-opencode.sh
Checking .opencode/ tree...
  ok: all 10 commands
  ok: all 9 agents
  ok: host-adapter.md exists
  ok: skill discoverable at .claude/skills/autodecision/
  ok: validate-brief.py discoverable
sync-check-opencode: PASSED

Testing

  • Validator passes
  • Zero diffs to the Claude Code tree
  • Live end-to-end test: run /autodecision "Should we cut pricing by 20%?" inside an OpenCode install and verify Phase 3 spawns all 5 persona subagents in parallel (deferred — requires OpenCode running on the machine)

Deferred (follow-up PR)

  • Optional .opencode/plugin.ts with custom tools: autodecision_journal_append (schema-validated JSONL writes), autodecision_read_brief (slug resolver). Not required — the bash-based file I/O path works.
  • Wiring sync-check-opencode.sh into .github/workflows/sync-check.yml.
  • End-to-end smoke test automation.

Draft PR

This is a draft PR because the live end-to-end test against a real OpenCode install hasn't run yet. Once someone confirms /autodecision runs the full 10-phase loop inside OpenCode and spawns all 5 personas in parallel, this can be marked ready.

OpenCode auto-discovers skills under .claude/skills/ as well as
.opencode/skills/, so the skill content stays in one place and both
runtimes see it. Adds a thin OpenCode glue layer: 10 flat hyphenated
commands, 9 pre-declared persona/phase agents, a host adapter
documenting OpenCode-specific tool name mappings, and a structural
validator script.

Zero changes to the Claude Code tree (claude-plugin/, .claude/,
.claude-plugin/, scripts/sync.sh, install.sh, .github/).

New:
- .opencode/host-adapter.md — OpenCode override contract
- .opencode/commands/*.md (10) — /autodecision + 9 hyphenated subcommands
- .opencode/agents/ad-*.md (9) — 5 personas, critique, adversary, sensitivity, decide
- scripts/sync-check-opencode.sh — structural validator (executable)
- OPENCODE.md — host-specific reference doc

Modified:
- README.md — OpenCode install section + dual command examples
- CLAUDE.md — OpenCode install path + .opencode/ tree in Architecture

Implementation plan:
~/.plannotator/plans/port-autodecision-to-opencode-2026-04-23-approved.md
@kulterryan kulterryan marked this pull request as ready for review April 24, 2026 19:21
@harshilmathur

Copy link
Copy Markdown
Owner

Thanks for putting this together — the PR description is thorough, the "zero diffs to the Claude Code tree" discipline is exactly right, and the structural validator is a nice touch.

One bigger rework I'd want before this can merge, though. Right now .opencode/ is a hand-written parallel tree — 22 files maintained alongside claude-plugin/. Every future protocol change in claude-plugin/ would need matching edits here, and there's no content-level CI to catch drift (structural sync-check-opencode.sh only verifies files exist + have valid frontmatter).

What I'd want here:

  1. scripts/sync-opencode.sh — treat claude-plugin/ as canonical and derive .opencode/ via sed rules: /autodecision:X/autodecision-X, AskUserQuestionquestion, Agent tool references → OpenCode task equivalent, plus a small Python patch for SKILL.md frontmatter if needed. Single source of truth, near-zero drift risk.
  2. Wire it into CI — new job in .github/workflows/sync-check.yml that runs the script and fails on drift, mirroring the existing .claude/ invariant.
  3. Keep hand-written only what genuinely has to be. The 9 pre-declared agents + host-adapter.md are new surface OpenCode requires (Claude Code embeds persona prompts inline in simulate.md, so those don't transform mechanically). Commands and SKILL.md should not be hand-written.
  4. Guided installer./scripts/install.sh --opencode --global rather than "copy the directory manually."
  5. Live end-to-end test before ready-for-review — non-negotiable. 2400 lines of unverified glue, even mostly prose, isn't something I can merge on trust. Phase 3 spawning 5 parallel persona subagents is the hard part — needs to be confirmed working in OpenCode.

Also: Codex support is out of scope here, but worth noting as a follow-up if OpenCode lands cleanly.

The overall direction (additive, non-invasive, skill content shared via autodiscovery) is sound. The rework is the execution model.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants