# Omega OpenCode CLI
> Portable headless skill for running OpenCode CLI (`opencode run`) from Claude Code, Cursor, Codex, Copilot, Antigravity, and VS Code — no MCP server required.
A zero-dependency Node.js wrapper that lets any agent platform invoke **OpenCode** in non-interactive mode. Copy one folder into your project, run one verification step, and every supported agent surface can call OpenCode headlessly.
Docs research (Exa, 2026-08-13): [CLI](https://opencode.ai/docs/cli/), [Models](https://opencode.ai/docs/models/), [Config](https://opencode.ai/docs/config/), [Zen](https://opencode.ai/docs/zen/), [Install](https://opencode.ai/docs/).
## Features
- **Headless execution** — runs `opencode run "…"` non-interactively
- **Cross-platform** — Windows (`cmd.exe`) and Unix/macOS spawn with `npx opencode-ai` fallback
- **Model selection** — `provider/model` (optional `#variant`), e.g. `anthropic/claude-sonnet-5`
- **JSON output** — `--json` → `--format json`; extracts assistant `text` events
- **Auto permissions** — `--auto` / `--sandbox` → `opencode run --auto` (CI-friendly)
- **Attach mode** — `--attach http://localhost:4096` for a running `opencode serve`
- **Timeout control** — `--timeout-ms` with exit code `124`
- **Stdin + large prompts** — stdin supported; oversized prompts attached via `--file`
- **Zero runtime dependencies** — Node stdlib only
## Prerequisites
| Requirement | Minimum | Install |
| ------------ | ------- | -------------------------------------------------------------------------------- |
| Node.js | 18+ | [nodejs.org](https://nodejs.org) |
| OpenCode CLI | latest | `curl -fsSL https://opencode.ai/install \| bash` or `npm install -g opencode-ai` |
Auth once: `opencode auth login` (or `/connect` in the TUI). See [auth.md](.claude/skills/omega-opencode-cli/references/auth.md).
## Installation
```bash
# Install OpenCode
curl -fsSL https://opencode.ai/install | bash
# or: npm install -g opencode-ai
opencode auth login
# Copy skill into your project
cp -r .claude /path/to/your-project/
cd /path/to/your-project
node .claude/skills/omega-opencode-cli/scripts/verify-setup.mjs
```
## Quick Start
```bash
node .claude/skills/omega-opencode-cli/scripts/ask-opencode.mjs "Summarize this repository in three bullet points"
node .claude/skills/omega-opencode-cli/scripts/ask-opencode.mjs "Review src/index.js for bugs" \
--model anthropic/claude-sonnet-5
node .claude/skills/omega-opencode-cli/scripts/ask-opencode.mjs "Fix the failing test" --auto
node .claude/skills/omega-opencode-cli/scripts/ask-opencode.mjs "List TODOs as JSON lines" --json
```
## CLI Reference
```
node .claude/skills/omega-opencode-cli/scripts/ask-opencode.mjs "PROMPT" [OPTIONS]
```
| Option | Description |
| ---------------------- | ----------------------------------------------- |
| `PROMPT` | Required unless stdin is used |
| `--model` / `-m` | `provider/model` optional `#variant` |
| `--json` | `--format json`; print extracted assistant text |
| `--auto` / `--sandbox` | `opencode run --auto` |
| `--agent` | Agent name |
| `--attach` | Server URL (e.g. `http://localhost:4096`) |
| `--timeout-ms` | Abort after N ms (exit `124`) |
| `--help` / `-h` | Usage |
Environment: `ASK_OPENCODE_MAX_STDIN_BYTES` (default 50 MB).
### Direct CLI equivalent
```bash
opencode run -- "PROMPT"
# optional: --model provider/model --format json --auto --agent NAME --attach URL
```
## Models
Always `provider/model`. Discover live IDs:
```bash
opencode models --refresh
```
Examples: `anthropic/claude-sonnet-5`, `anthropic/claude-opus-5`, `opencode/gpt-5.5`, `openai/gpt-5.2#high`. Full notes: [models.md](.claude/skills/omega-opencode-cli/references/models.md).
## Integration
- **Claude Code** — `.claude/skills/` + slash commands `/analyze`, `/omega-opencode`, `/omega-opencode-setup`
- **Cursor** — `.cursor/rules/` routes “ask OpenCode…” to the script
- **Codex CLI** — `.agents/skills/`
- **Antigravity** — `.agent/skills/`
- **VS Code** — `.vscode/tasks.json` (**Ask OpenCode**, **Verify setup**)
## Development
```bash
npm install
npm test
npm run test:ci
```
## Resources
- [OpenCode docs](https://opencode.ai/docs/)
- [CLI reference](https://opencode.ai/docs/cli/)
- [Models](https://opencode.ai/docs/models/)
- [Zen](https://opencode.ai/docs/zen/)
- [GitHub anomalyco/opencode](https://github.com/anomalyco/opencode)
## License
[MIT License (Non-Commercial)](LICENSE). Unofficial third-party tool — not affiliated with OpenCode / anomalyco.