Command Palette

Search for a command to run...

Back to skills
skill № 06632

opencode-subagent

> Cross-harness skill that teaches Claude Code, Codex (OpenAI), and Antigravity (Agy) how to use OpenCode as a subagent. Covers delegation triggers, task…

FreeNo executable scripts
Andersonlimahwby Andersonlimahw★ 19 GitHub stars

Install opencode-subagent in Claude Code & Claude Desktop

Sign up to install this skill

Create a free account to reveal the install command and save the skill to your library.

  • Reveal the one-line install command
  • Save skills to your synced library
  • Get notified when skills update
Sign up freeI already have an account

About this skill

OpenCode — Cross-Harness Subagent Skill

Teach Claude Code, Codex, and Antigravity (Agy) to delegate work to OpenCode efficiently. OpenCode is a standalone AI coding harness with its own provider system, plugin architecture, and MCP/ACP support. Use it as a specialist subagent for tasks your current harness handles poorly.

Why OpenCode as Subagent

OpenCode excels where other harnesses fall short:

Capability OpenCode Notes
Any provider/model Yes Opus, Sonnet, Haiku, GLM, GPT, Claude, Gemini, Ollama
ACP (Agent Client Protocol) Native Run headless servers, attach remotely
Plugin system Yes Install any plugin from npm or local
Autonomous mode --auto Complete approval-free execution
Session management --continue, --fork, --session Resume/interrupt workflows
Remote attach opencode attach <url> Connect to headless opencode servers
MCP servers Native Full Model Context Protocol support
Mini mode --mini Lightweight TUI for constrained envs
Token tracking opencode stats Per-session cost analytics
Export/Import opencode export/import Share sessions across machines

When to Delegate

Use opencode subagent when:

  1. Provider flexibility: Task needs a specific model (GLM, GPT, Opus) not available on your current harness
  2. Parallel execution: Fan out multiple independent tasks to separate opencode instances
  3. Specialized plugins: Task needs an opencode plugin not available in your ecosystem
  4. Remote execution: Task must run on a remote machine or CI/CD via ACP
  5. Session isolation: Task should not pollute your current session context
  6. Cost tracking: Need per-task token/cost accounting via opencode stats

How to Invoke

From Claude Code

# Simple task
opencode run "refactor src/utils.ts to use async/await"

# Autonomous (no prompts)
opencode run "fix all TypeScript errors in src/" --auto

# With specific model
opencode run "audit bundle size" -m anthropic:claude-opus-4

# Continue previous session
opencode run "now optimize further" --continue

# Run headless server + attach
opencode serve --port 3001 &
opencode attach http://localhost:3001

From Codex (OpenAI CLI)

# Basic delegation
opencode run "add unit tests for the auth module" --auto

# With session tracking
SESSION=$(opencode run "migrate database schema" --auto --print-logs 2>&1 | grep session.id | grep -oP 'ses_\w+')
echo "Task running in session: $SESSION"

# Export results
opencode export $SESSION > migration-results.json

From Antigravity (Agy CLI)

# Drop-in delegation
agy exec -- opencode run "deploy to staging" --auto

# Or direct
opencode run "run performance benchmarks" -m openai:gpt-4o --auto

Task Formatting Best Practices

1. Self-Contained Prompts

Include all context — OpenCode has no access to your current session:

# BAD — lacks context
opencode run "fix the bug in auth.ts" --auto

# GOOD — self-contained
opencode run "
  File: src/auth.ts (lines 42-67)
  Bug: JWT token refresh throws 'invalid signature' 
  when the token has < 5min expiry.
  Expected: Token should refresh silently.
  Fix the validateToken function to check expiry before signature.
" --auto

2. Use --continue for Multi-Step

opencode run "step 1: scaffold the component" --auto
STATUS=$?
if [ $STATUS -eq 0 ]; then
  opencode run "step 2: add styles and tests" --auto --continue
fi

3. Fan-Out Pattern (Parallel)

# Launch parallel tasks
opencode run "task A: API docs" --auto &
PID1=$!
opencode run "task B: client SDK" --auto &
PID2=$!
opencode run "task C: examples" --auto &
PID3=$!

# Wait for all
wait $PID1 $PID2 $PID3
echo "All parallel tasks complete"

4. Remote ACP Pattern

# On remote server
opencode serve --port 3001 --hostname 0.0.0.0 &

# On local machine
opencode attach http://remote-server:3001

5. Provider Routing via Models

Use OpenCode's multi-provider to route each task to the best model:

# Budget work → cheap model
opencode run "format all files" -m openai:gpt-4o-mini --auto

# Complex reasoning → quality model
opencode run "design auth architecture" -m anthropic:claude-opus-4 --auto

# Balanced → mid-tier
opencode run "implement CRUD endpoints" -m openai:gpt-4o --auto

Result Handling

Capture Output

# Capture to variable
RESULT=$(opencode run "analyze package.json dependencies" --auto --print-logs 2>&1)
echo "$RESULT" | grep -v "^timestamp="  # Strip logs, show AI output only

# Capture to file
opencode run "generate migration SQL" --auto > migration-output.txt

Check Exit Code

opencode run "validate all schemas" --auto
if [ $? -eq 0 ]; then
  echo "Validation passed"
else
  echo "Validation failed — check session output"
fi

Export Session for Review

# After task completes
opencode export
Full SKILL.md on GitHub

Allowed tools

Tools this skill is permitted to call.

No restriction — this skill can use any tool.

Bundled files

  • plugin.json
  • skills/opencode-subagent/SKILL.md

FAQ

What does the opencode-subagent skill do?

> Cross-harness skill that teaches Claude Code, Codex (OpenAI), and Antigravity (Agy) how to use OpenCode as a subagent. Covers delegation triggers, task formatting, provider routing, result handling, and the complete protocol for efficient subagent orchestration.

How do I install the opencode-subagent skill?

Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.

Does the opencode-subagent skill run scripts?

No, this skill is instructions only (SKILL.md) with no executable scripts.

Related skills

Compare opencode-subagent with