run-opencode

Invokes opencode CLI as a headless executor for delegated coding tasks with NDJSON output.

1|1|Updated Jul 6, 2026
One-click install
npx skills add https://github.com/gabesan21/project-of-projects --skill run-opencode-gabesan21
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: run-opencode
Source: https://github.com/gabesan21/project-of-projects/tree/main/.agents/skills/run-opencode
Command: npx skills add https://github.com/gabesan21/project-of-projects --skill run-opencode-gabesan21

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Delegating coding work to the opencode CLI from an orchestrator requires knowing the correct headless invocation flags, session handling, yolo-mode permission rules, and output parsing, which vary across versions and are easy to get wrong. ## Core Features & Use Cases - Headless Execution: Runs opencode run with auto-approval, timeouts, and JSON (NDJSON) output for parsing text, tool use, tokens, and cost per event. - Session and Agent Control: Continues, forks, and names sessions, selects built-in or custom agents (build, plan, explore), and picks models across Anthropic, OpenAI, and Google providers. - Use Case: An orchestrator needs tests written for a module: it invokes opencode run --auto --format json in an isolated worktree with a scoped prompt, captures the sessionID from NDJSON events, and extracts token cost from step_finish events. ## Quick Start Ask the agent to run a scoped coding task through opencode in headless mode with auto-approval and JSON output, then parse the NDJSON stream for the final text and cost.

Frequently Asked Questions about run-opencode

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run opencode headlessly from the command line?▼

Use `opencode run --auto --format json "task"` with a timeout wrapper so it processes the prompt, prints events, and exits. Never call bare `opencode` in automation since it opens the interactive TUI, and pass the message as an argument because stdin support is not guaranteed.

How do I parse opencode JSON output for tokens and cost?▼

The `--format json` output is NDJSON with one event per line, including step_start, text, tool_use, and step_finish. Pipe it through jq, selecting `.type=="step_finish"` for tokens and cost, and `.type=="text"` for the final response text.

Does opencode support multiple model providers?▼

Yes, opencode is multi-provider: pass `--model provider/model` such as anthropic/claude-sonnet-4-6, openai/gpt-5, or google/gemini-3-pro. The `--variant` flag controls reasoning effort, and `opencode models` lists available options.

Why does opencode block an action even in yolo mode?▼

An explicit `deny` rule in the repo's opencode.json still wins over the auto-approval flag, and for bash rules the last matching entry wins. Check the repository config for residual deny entries if something is blocked unexpectedly.

What should I do when opencode reports an authentication error?▼

Abort the entire orchestrator task immediately with no retry or fallback, since login is a human precondition handled outside this skill. An immediate failure with no auth signal is an invocation error, not a login problem.