opencode-cli

OpenCode CLI integration skill. Designed for AI agents like OpenClaw to execute coding tasks via OpenCode CLI. Core features: (1) Plan→Build workflow (2) Session management (3) MCP integration (4) Background task monitoring. Use this skill when you need: multi-step coding, Plan→Build workflow, MCP integration, or background task monitoring. NOT for: simple one-line edits (use edit tool directly), quick file reads (use read tool directly).

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "opencode-cli" with this command: npx skills add tchen6500/opencode-cli

OpenCode CLI Integration

This skill is designed for AI agents like OpenClaw to execute coding tasks via OpenCode CLI.

OpenCode is an AI-powered code editor CLI. When called via OpenClaw, only CLI mode is used.


Security Scope

What this skill does:

  • Integrates with OpenCode CLI for coding tasks
  • Manages sessions, plans, and builds
  • Optionally connects to configured MCP servers (Playwright, Supabase, Context7)

What this skill does NOT do:

  • Install or modify system-wide packages
  • Access credentials outside configured MCP servers
  • Persist beyond user-initiated sessions

Credential access:

  • MCP servers (if configured) may use environment variables like SUPABASE_URL, SUPABASE_ANON_KEY, CONTEXT7_API_KEY
  • Skills run in project context; avoid committing secrets to version control
  • Only use this skill in repositories/environments you trust

Core Command

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

Example:

opencode run -m <provider/model> -- "Add error handling to the login function"

Plan→Build Workflow (Core)

⚠️ Key Rule: Maintain Same Session

Correct approach:

# 1. Start Plan (creates session)
opencode run -m <model> -- 'Analyze task, output plan.'

# 2. Wait for user APPROVE

# 3. Switch to Build (continue same session)
opencode run --continue --agent build -- 'Implement approved plan.'

Wrong approach (context lost):

❌ opencode run --agent plan "..."   # session A
❌ opencode run --agent build "..."  # session B (separate!)

Agent Options

AgentPurpose
planPlanning, analysis, design
buildImplementation, coding, modification
exploreCodebase exploration

Session Management

opencode run --continue -- '<prompt>'
opencode run --session <id> -- '<prompt>'
opencode run --continue --fork -- '<prompt>'
opencode session list
opencode session delete <id>

OpenClaw Integration

Standard Task

opencode run -m <model> -- '<task>'

Background Task

opencode run -m <model> -- '<task>'
process action:poll sessionId:<id> timeout:30000
process action:log sessionId:<id>
process action:kill sessionId:<id>

Monitoring Discipline

⚠️ Mandatory: After starting, must actively monitor. Do not wait for system event.

Start → Get sessionId
  ↓
Every 30-60s: poll + log
  ↓
Progress → Report
Error → Report immediately
Complete → Report result (do not wait for event)

Violation criteria:

  • Start without monitoring → Abandoning responsibility
  • User asks "is it done?" before checking → Failure

MCP Integration

OpenCode supports MCP integration to extend capabilities. Must run in project root directory.

Common tools: Playwright (UI automation), Supabase (database)

Scenario guide:

ScenarioReference
Need UI automation testing (Playwright)references/mcp-config-guide.md
Need database operations (Supabase)references/mcp-config-guide.md
MCP not loading, troubleshoot configreferences/mcp-config-guide.md

Built-in Tools

OpenCode Agent built-in tools: read/write/edit, bash, grep/glob, todowrite, skill, webfetch

Scenario guide:

ScenarioReference
Unsure if Agent can perform an operationreferences/built-in-tools-guide.md
Plan Agent reports insufficient permissionsreferences/built-in-tools-guide.md (see tool permissions table)

Practical Tips

  • File reference: Use @filename to quickly reference files
  • Undo changes: /undo to undo, /redo to restore

Scenario guide:

ScenarioReference
Want to reference file instead of typing pathreferences/tips-guide.md (file reference)
Made mistake and want to rollbackreferences/tips-guide.md (undo/redo)
Want to learn TUI shortcutsreferences/tips-guide.md (shortcuts)

Skills Configuration

Scenario guide:

ScenarioReference
Want to add custom skillreferences/skills-config-guide.md
Unsure where to place skill filesreferences/skills-config-guide.md

Common Patterns

Note: Examples use openclaw system event for optional task notification. This is an OpenClaw platform command. Omit if running outside OpenClaw.

Planning Task

opencode run -m <model> -- 'Analyze task, output plan.'

For detailed plan format, see project workflow documentation.

Implementation Task

opencode run -m <model> -- 'Execute approved plan.'

Verify with: npm run build && npm test

Database Operations

cd /path/to/project
opencode run -m <model> -- 'Use Supabase MCP for database operations.'

See: references/mcp-config-guide.md for MCP setup.

UI Testing

opencode run -m <model> -- 'Use Playwright MCP for UI testing.'

See: references/mcp-config-guide.md for MCP setup.


Troubleshooting

sysctl not found

export PATH="/usr/sbin:/usr/bin:/sbin:/bin:$PATH"

MCP not loading

Ensure running in project root:

cd /path/to/project && opencode run ...

See: references/mcp-config-guide.md

Session context lost

Use --continue instead of separate starts:

✅ opencode run --continue --agent build "..."
❌ opencode run --agent build "..."

Quick Reference

Common Commands

TaskCommand
Plan taskopencode run -m <model> -- 'Analyze...'
Build (continue session)opencode run --continue --agent build -- 'Implement...'
Continue last sessionopencode run --continue
Specific sessionopencode run --session <id>
Fork sessionopencode run --continue --fork
List sessionsopencode session list
Delete sessionopencode session delete <id>
View modelsopencode models

OpenClaw Integration

TaskCommand
Background taskpty:true background:true command:"opencode run..."
Monitor progressprocess action:poll sessionId:<id>
View logsprocess action:log sessionId:<id>
Terminate taskprocess action:kill sessionId:<id>

Configuration Guide Index

ScenarioReference
UI automation / Database operationsreferences/mcp-config-guide.md
Agent tool capabilities / Permissionsreferences/built-in-tools-guide.md
Shortcuts / File reference / Undoreferences/tips-guide.md
Add custom skillreferences/skills-config-guide.md

CLI Integration v2.6 - 2026-04-05

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

Claude Chrome

Use Claude Code with Chrome browser extension for web browsing and automation tasks. Alternative to OpenClaw's built-in browser tools.

Registry SourceRecently Updated
Coding

App Builder

Build, edit, and deploy Instant-backed apps using npx instant-cli, create-instant-app (Next.js + Codex), GitHub (gh), and Vercel (vercel). Use when asked to create a new app, modify an existing app, fix bugs, add features, or deploy/update an app. Projects live under ~/apps; always work inside the relevant app folder.

Registry SourceRecently Updated
Coding

Opengraph Io

Extract web data, capture screenshots, scrape content, and generate AI images via OpenGraph.io. Use when working with URLs (unfurling, previews, metadata), capturing webpage screenshots, scraping HTML content, asking questions about webpages, or generating images (diagrams, icons, social cards, QR codes). Triggers: 'get the OG tags', 'screenshot this page', 'scrape this URL', 'generate a diagram', 'create a social card', 'what does this page say about'.

Registry SourceRecently Updated
Coding

Xlsx Pro

Compétence pour manipuler les fichiers Excel (.xlsx, .xlsm, .csv, .tsv). Utiliser quand l'utilisateur veut : ouvrir, lire, éditer ou créer un fichier tableur ; ajouter des colonnes, calculer des formules, formater, créer des graphiques, nettoyer des données ; convertir entre formats tabulaires. Le livrable doit être un fichier tableur. NE PAS utiliser si le livrable est un document Word, HTML, script Python standalone, ou intégration Google Sheets.

Registry SourceRecently Updated