Provides an interface to manage and execute headless LLM workflows using the OpenCode CLI.

Install

mkdir -p .claude/skills/opencode-cli && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/482" && unzip -o skill.zip -d .claude/skills/opencode-cli && rm skill.zip

Installs to .claude/skills/opencode-cli

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

This skill should be used when configuring or using the OpenCode CLI for headless LLM automation. Use when the user asks to "configure opencode", "use opencode cli", "set up opencode", "opencode run command", "opencode model selection", "opencode providers", "opencode vertex ai", "opencode mcp servers", "opencode ollama", "opencode local models", "opencode deepseek", "opencode kimi", "opencode mistral", "fallback cli tool", or "headless llm cli". Covers command syntax, provider configuration, Vertex AI setup, MCP servers, local models, cloud providers, and subprocess integration patterns.
595 chars✓ has a “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Advanced

Key capabilities

  • Execute headless LLM commands via subprocess
  • Configure model providers and Vertex AI settings
  • Manage project-level and global CLI configurations
  • Integrate MCP servers for extended functionality
  • Verify CLI installation and model connectivity

How it works

The skill invokes the OpenCode CLI as a subprocess, passing model parameters and prompts to the headless run command.

Inputs & outputs

You give it
Model identifier and prompt text
You get back
LLM response captured from stdout

When to use opencode-cli

  • Configure opencode settings
  • Run headless LLM commands
  • Set up model providers
  • Verify opencode CLI installation

About this skill

OpenCode CLI Skill

Use OpenCode CLI for headless LLM automation via subprocess invocation.

Table of Contents

Quick Start

  1. Install OpenCode CLI (see OpenCode documentation)
  2. Set environment variables for the provider:
    export ANTHROPIC_API_KEY="sk-..."  # For Anthropic
    # OR
    export GOOGLE_CLOUD_PROJECT="project-id"  # For Vertex AI
    
  3. Verify installation:
    opencode --version
    
  4. Test with a simple prompt:
    opencode run --model google/gemini-2.5-pro "Hello, world"
    

Overview

OpenCode is a Go-based CLI that provides access to 75+ LLM providers through a unified interface. This skill focuses on the headless run command for automation and subprocess integration.

Basic Usage

Command Format

opencode run --model <provider/model> "<prompt>"

Key points:

  • Use run subcommand for headless (non-interactive) mode
  • Model format is always provider/model
  • Prompt is a positional argument at the end
  • No stdin support (unlike Claude CLI's -p flag)

Examples

# Using Anthropic Claude
opencode run --model anthropic/claude-sonnet-4-20250514 "Explain this code"

# Using Google Gemini
opencode run --model google/gemini-2.5-pro "Review this architecture"

# Using free Grok tier
opencode run --model opencode/grok-code "Generate tests for this function"

Model Format

Models use the pattern provider/model-name:

ProviderExample Model
anthropicanthropic/claude-sonnet-4-20250514
googlegoogle/gemini-2.5-pro
opencodeopencode/grok-code (free tier)
openaiopenai/gpt-4o
google-vertexgoogle-vertex/gemini-2.5-pro

Configuration

Config File Locations

  1. Environment variable: OPENCODE_CONFIG path
  2. Project-level: opencode.json in project root
  3. Global: ~/.config/opencode/opencode.json

Configs are merged (project overrides global).

Basic Configuration

{
  "$schema": "https://opencode.ai/config.json",
  "model": "anthropic/claude-sonnet-4-5",
  "small_model": "anthropic/claude-haiku-4-5"
}

Authentication

Credentials stored in ~/.local/share/opencode/auth.json after running /connect in TUI mode, or configure via environment variables.

Reference Guides

Load the appropriate reference for detailed configuration:

TaskReference File
Setting up Google Vertex AIvertex-ai-setup.md
Configuring providers (Anthropic, OpenAI, etc.)provider-config.md
Cloud providers (Deepseek, Kimi, Mistral, etc.)cloud-providers.md
Local models (Ollama, LM Studio)local-models.md
MCP server configurationmcp-servers.md
Subprocess integration patternsintegration-patterns.md

Vertex AI Setup

See vertex-ai-setup.md for Vertex AI configuration including environment variables and service account setup.

Subprocess Invocation

Basic Pattern

import subprocess

result = subprocess.run(
    ["opencode", "run", "--model", "google/gemini-2.5-pro", prompt],
    capture_output=True,
    text=True,
    timeout=600
)
output = result.stdout

Key Considerations

  1. Stagger parallel calls - Add 5-10 second delays between parallel invocations to avoid cache race conditions
  2. Implement fallback - Consider Claude CLI as fallback if OpenCode fails
  3. Health check - Use opencode --version to verify availability
  4. Timeout handling - Set appropriate timeouts (default 600s for long generations)

See integration-patterns.md for complete patterns.

Limitations vs Claude CLI

FeatureOpenCodeClaude CLI
Headless moderun subcommand-p flag with stdin
Hooks/settingsNot supported--settings flag
Directory accessNot supported--add-dir flag
Tool pre-approvalNot supported--allowedTools flag
Prompt inputPositional argumentStdin or -p

Environment Variables

VariablePurpose
OPENCODE_CONFIGCustom config file path
GOOGLE_CLOUD_PROJECTGCP project for Vertex AI
GOOGLE_APPLICATION_CREDENTIALSService account JSON path
VERTEX_LOCATIONVertex AI region

Verify Setup

Complete this checklist to verify a working installation:

  1. Check version - Confirm CLI is installed:
    opencode --version
    
  2. Test default model - Verify basic connectivity:
    opencode run --model google/gemini-2.5-pro "Say hello"
    
  3. Check configuration - Review active config:
    cat ~/.config/opencode/opencode.json
    
  4. Verify MCP servers (if configured) - Test MCP connectivity by running a command that uses MCP tools

Best Practices

  1. Use project-level config - Create opencode.json for project-specific settings
  2. Prefer environment variables - Use {env:VAR_NAME} syntax in config for secrets
  3. Implement retries - Network failures are common; implement retry logic
  4. Log output - Capture both stdout and stderr for debugging
  5. Stagger parallel calls - Prevent cache race conditions with delays

When not to use it

  • Interactive TUI sessions
  • Direct stdin input for prompts

Prerequisites

OpenCode CLI installedAPI keys or cloud credentials

Limitations

  • No stdin support for prompts
  • Requires manual delay implementation for parallel calls

How it compares

It provides a programmatic interface for headless automation rather than relying on manual CLI interaction.

Compared to similar skills

opencode-cli side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
opencode-cli (this skill)147moReviewAdvanced
computer-use-agents106moReviewAdvanced
crewai-developer28moReviewAdvanced
extra-rlhf01moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

computer-use-agents

davila7

Build AI agents that interact with computers like humans do - viewing screens, moving cursors, clicking buttons, and typing text. Covers Anthropic's Computer Use, OpenAI's Operator/CUA, and open-source alternatives. Critical focus on sandboxing, security, and handling the unique challenges of vision-based control. Use when: computer use, desktop automation agent, screen control AI, vision-based agent, GUI automation.

1040

crewai-developer

smallnest

Comprehensive CrewAI framework guide for building collaborative AI agent teams and structured workflows. Use when developing multi-agent systems with CrewAI, creating autonomous AI crews, orchestrating flows, implementing agents with roles and tools, or building production-ready AI automation. Essential for developers building intelligent agent systems, task automation, and complex AI workflows.

213

extra-rlhf

veceno

Use for anything about the ExtraArena RLHF data-collection & training-orchestration environment (rlhf_env, port 8090, MCP stdio): running semi-synthetic battles, generating training traces, orchestrating the Extra-LR training pipeline, or playing battles as a sub-agent. Routes to three sub-skills —

00

npc

pipecat-ai

Runs an autonomous AI task agent as a game character. Resolves a character name to its UUID, then launches the `npc-run` script which connects to the game server and executes the given task using a Pipecat + Gemini LLM pipeline.

00

agr

JoaquinMulet

AGR: Artificial General Research — autonomous iterative optimization framework for Claude Code. Generalizes Karpathy's autoresearch to any measurable problem with variance-aware acceptance, correctness verification, and fresh-context-per-iteration (Ralph Loop). Use when setting up autoresearch, crea

00

autonomous-loops

Rajbharti06

Self-improvement loop patterns — eval → learn → improve cycles running without human input

00

Search skills

Search the agent skills registry