# Send OpenCode AI to your agent
Hand the extracted package to your coding agent with a concrete install brief instead of figuring it out manually.
## Fast path
- Download the package from Yavira.
- Extract it into a folder your agent can access.
- Paste one of the prompts below and point your agent at the extracted folder.
## Suggested prompts
### New install

```text
I downloaded a skill package from Yavira. Read SKILL.md from the extracted folder and install it by following the included instructions. Then review README.md for any prerequisites, environment setup, or post-install checks. Tell me what you changed and call out any manual steps you could not complete.
```
### Upgrade existing

```text
I downloaded an updated skill package from Yavira. Read SKILL.md from the extracted folder, compare it with my current installation, and upgrade it while preserving any custom configuration unless the package docs explicitly say otherwise. Then review README.md for any prerequisites, environment setup, or post-install checks. Summarize what changed and any follow-up checks I should run.
```
## Machine-readable fields
```json
{
  "schemaVersion": "1.0",
  "item": {
    "slug": "opencode",
    "name": "OpenCode AI",
    "source": "tencent",
    "type": "skill",
    "category": "效率提升",
    "sourceUrl": "https://clawhub.ai/csuwl/opencode",
    "canonicalUrl": "https://clawhub.ai/csuwl/opencode",
    "targetPlatform": "OpenClaw"
  },
  "install": {
    "downloadUrl": "/downloads/opencode",
    "sourceDownloadUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=opencode",
    "sourcePlatform": "tencent",
    "targetPlatform": "OpenClaw",
    "packageFormat": "ZIP package",
    "primaryDoc": "SKILL.md",
    "includedAssets": [
      "CHEATSHEET.md",
      "INDEX.md",
      "INSTALL.md",
      "README.md",
      "SKILL.md",
      "SUMMARY.md"
    ],
    "downloadMode": "redirect",
    "sourceHealth": {
      "source": "tencent",
      "status": "healthy",
      "reason": "direct_download_ok",
      "recommendedAction": "download",
      "checkedAt": "2026-04-30T16:55:25.780Z",
      "expiresAt": "2026-05-07T16:55:25.780Z",
      "httpStatus": 200,
      "finalUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
      "contentType": "application/zip",
      "probeMethod": "head",
      "details": {
        "probeUrl": "https://wry-manatee-359.convex.site/api/v1/download?slug=network",
        "contentDisposition": "attachment; filename=\"network-1.0.0.zip\"",
        "redirectLocation": null,
        "bodySnippet": null
      },
      "scope": "source",
      "summary": "Source download looks usable.",
      "detail": "Yavira can redirect you to the upstream package for this source.",
      "primaryActionLabel": "Download for OpenClaw",
      "primaryActionHref": "/downloads/opencode"
    },
    "validation": {
      "installChecklist": [
        "Use the Yavira download entry.",
        "Review SKILL.md after the package is downloaded.",
        "Confirm the extracted package contains the expected setup assets."
      ],
      "postInstallChecks": [
        "Confirm the extracted package includes the expected docs or setup files.",
        "Validate the skill or prompts are available in your target agent workspace.",
        "Capture any manual follow-up steps the agent could not complete."
      ]
    }
  },
  "links": {
    "detailUrl": "https://openagent3.xyz/skills/opencode",
    "downloadUrl": "https://openagent3.xyz/downloads/opencode",
    "agentUrl": "https://openagent3.xyz/skills/opencode/agent",
    "manifestUrl": "https://openagent3.xyz/skills/opencode/agent.json",
    "briefUrl": "https://openagent3.xyz/skills/opencode/agent.md"
  }
}
```
## Documentation

### OpenCode AI - AI Code Editor

OpenCode is an AI-native code editor that runs in your terminal. Think of it as Cursor or Windsurf, but as a CLI/TUI tool.

Version: 1.2.10 (Homebrew)
Platform: macOS Darwin x64

### Prerequisites

CRITICAL: OpenCode requires sysctl to detect system architecture. Ensure /usr/sbin is in your PATH:

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

If missing, OpenCode will fail with:

Executable not found in $PATH: "sysctl"

Add this to ~/.zshrc permanently:

echo 'export PATH="/usr/sbin:/usr/bin:/sbin:/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

### When to Use OpenCode

✅ Use for:

Complex refactoring across multiple files
AI-assisted feature implementation
GitHub PR review and automated fixes
Exploring and understanding unfamiliar codebases
Running multi-step coding tasks with context
Session-based coding (continue previous work)

❌ Don't use for:

Simple one-line edits (use edit tool)
Reading file contents (use read tool)
Non-coding tasks

### Core Operations (TUI Slash Commands)

When running OpenCode in TUI mode (opencode), you can use these slash commands to control the AI workflow:

### /sessions - Session Management

/sessions

Opens session selector
Choose to continue an existing session
Create a new session (with user approval)
Recommended: Select existing session for current project

### /agents - Agent (Mode) Control

/agents

Available agents:

plan - Planning mode (analyze and design)
build - Build mode (implement and code)
explore - Exploration mode (understand codebase)
general - General assistance

Best Practice: Always select plan first, then switch to build after approval.

### /models - Model Selection

/models

Opens model selector
Filter by provider (OpenAI, Anthropic, Google, Z.AI, etc.)
Select preferred model for the task
If authentication required, follow the login link provided

### Agent Workflow

Plan Agent Behavior

Ask OpenCode to analyze the task
Request a clear step-by-step plan
Allow OpenCode to ask clarification questions
Review the plan carefully
If plan is incomplete, ask for revision
Do not allow code generation in Plan mode

Build Agent Behavior

Switch to Build using /agents
Ask OpenCode to implement the approved plan
If OpenCode asks questions, switch back to Plan
Answer and confirm the plan, then switch back to Build

Plan → Build Loop

Select plan agent with /agents
Describe the task
Review and approve the plan
Switch to build agent with /agents
Implement the plan
Repeat until satisfied

Key Rules:

Never skip Plan
Never answer questions in Build mode (switch to Plan first)
Always show slash commands explicitly in output

### Other Useful Commands

/title - Change session title
/summary - Generate session summary
/compaction - Compact conversation history

### 1. Quick Tasks (One-Shot)

# Run a single AI command on a project
opencode run "Add input validation to the login form"

# With specific directory
opencode run --dir ~/path/to/project "Refactor this code to use async/await"

# With specific model
opencode run -m openai/gpt-4o "Optimize the database queries"

# Attach files for context
opencode run -f src/auth.js -f src/database.js "Fix the authentication bug"

# Continue last session
opencode run --continue

# Continue specific session
opencode run --session abc123 --fork

### 2. Interactive TUI Mode

# Start TUI in current directory
opencode

# Start TUI in specific project
opencode ~/path/to/project

# Start with specific model
opencode -m anthropic/claude-sonnet-4

### 3. Authentication

# List configured providers
opencode auth list

# Login to a provider (e.g., OpenCode, OpenAI, Anthropic)
opencode auth login [url]

# Logout
opencode auth logout

### 4. Model Management

# List all available models
opencode models

# List models for specific provider
opencode models openai

# List with cost metadata
opencode models --verbose

# Refresh model cache
opencode models --refresh

### 5. Session Management

# List all sessions
opencode session list

# Delete a session
opencode session delete <sessionID>

# Export session data
opencode export [sessionID]

# Import session from file
opencode import <file>

### 6. GitHub Integration

# Fetch and checkout a PR, then run OpenCode
opencode pr 123

# Manage GitHub agent
opencode github --help

### 7. MCP Servers (Model Context Protocol)

# List MCP servers
opencode mcp list

# Add an MCP server
opencode mcp add

# Authenticate with OAuth MCP server
opencode mcp auth [name]

# Debug OAuth connection
opencode mcp debug <name>

### 8. Agent Management

# List all agents
opencode agent list

# Create a new agent
opencode agent create

### 9. Server Mode

# Start headless server
opencode serve

# Start server and open web interface
opencode web

# Start ACP (Agent Client Protocol) server
opencode acp

### 10. Statistics

# Show token usage and costs
opencode stats

### Key Options (Global)

OptionDescription-m, --modelModel to use (format: provider/model)-c, --continueContinue last session-s, --sessionContinue specific session--forkFork session when continuing--agentUse specific agent--dirDirectory to run in--formatOutput format: default or json--thinkingShow thinking blocks--variantModel reasoning effort (high, max, minimal)

### Pattern 1: Refactor Code

opencode run "Refactor this function to be more readable and add error handling"

### Pattern 2: Add Features

opencode run "Add a new API endpoint for user registration with email verification"

### Pattern 3: Fix Bugs

opencode run -f error.log -f src/auth.js "Fix the authentication bug described in the error log"

### Pattern 4: Review Code

opencode run "Review this code for security vulnerabilities and suggest improvements"

### Pattern 5: GitHub PR Workflow

# Auto-fix a PR
opencode pr 123

### Pattern 6: Continue Previous Work

# Continue last session
opencode run --continue

# Fork and continue (keeps original intact)
opencode run --continue --fork

### Session-Based Work

OpenCode maintains sessions that preserve context across runs:

# Start a new session
opencode run "Implement user authentication"

# Continue it later
opencode run --continue

# Or continue a specific session
opencode run --session session-abc123

### Session Lifecycle

Create: Run opencode run "prompt" or opencode
Continue: Use --continue or --session <id>
Fork: Use --fork to branch from a session
Export: Save session data as JSON
Delete: Remove old sessions

### Format

provider/model

Examples:

openai/gpt-4o
anthropic/claude-sonnet-4
opencode/gpt-4o
google/gemini-2.5-pro

### List Available Models

# All models
opencode models

# Provider-specific
opencode models openai
opencode models anthropic

### Model Variants (Reasoning Effort)

Some models support reasoning effort levels:

opencode run --variant high "Solve this complex algorithm problem"
opencode run --variant max "Architect a distributed system"
opencode run --variant minimal "Quick code review"

### JSON Mode (For Automation)

Use --format json for machine-readable output:

opencode run --format json "Refactor this code" | jq .

Useful for:

CI/CD integration
Scripting
Parsing results programmatically

### Web Interface

For a GUI experience:

# Start server + open browser
opencode web

# Custom port
opencode web --port 8080

# Custom hostname
opencode web --hostname 0.0.0.0

### "sysctl not found" Error

Problem: OpenCode can't find sysctl command
Solution:

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

Add to ~/.zshrc to make permanent.

### "Failed to change directory" Error

Problem: OpenCode treats arguments as directory paths
Solution: Use flags like --version, --help, or run explicitly:

# Wrong
opencode version

# Right
opencode --version

### OpenCode hangs or freezes

Problem: Interactive TUI waiting for input
Solution: Press Ctrl+C to exit, or use run mode for non-interactive tasks.

### Permission issues

Problem: Can't write to files
Solution: Ensure file/directory permissions allow your user to write:

chmod +w ./path/to/file

### Use via exec tool

# For simple tasks
bash command:"opencode run 'Add error handling'"

# For longer tasks (background)
bash background:true command:"opencode run 'Refactor entire codebase'"

### Check current sessions

bash command:"opencode session list"

### View stats

bash command:"opencode stats"

### Tips & Best Practices

Be specific: Clear prompts produce better results
Use files: Attach relevant files with -f for context
Iterate: Use --continue to build on previous work
Fork experiments: Use --fork to try variations safely
Choose models wisely: Different models excel at different tasks
Monitor costs: Use opencode stats to track token usage
Leverage sessions: Sessions maintain context across interactions

### Comparison to Other Tools

FeatureOpenCodeCursorWindsurfClaude CodeInterfaceCLI/TUIGUIGUICLITerminal-native✅❌❌✅Session management✅✅✅✅GitHub PR integration✅✅✅✅Model supportMultiMultiMultiAnthropicMCP support✅❌❌❌

Choose OpenCode when:

You prefer terminal workflows
Need CI/CD integration
Want headless/server mode
Require MCP protocol support

### Documentation & Resources

Version: opencode --version
Help: opencode --help or opencode <command> --help
Models: opencode models --verbose
Sessions: opencode session list

Last updated: 2026-02-25
## Trust
- Source: tencent
- Verification: Indexed source record
- Publisher: csuwl
- Version: 1.1.0
## Source health
- Status: healthy
- Source download looks usable.
- Yavira can redirect you to the upstream package for this source.
- Health scope: source
- Reason: direct_download_ok
- Checked at: 2026-04-30T16:55:25.780Z
- Expires at: 2026-05-07T16:55:25.780Z
- Recommended action: Download for OpenClaw
## Links
- [Detail page](https://openagent3.xyz/skills/opencode)
- [Send to Agent page](https://openagent3.xyz/skills/opencode/agent)
- [JSON manifest](https://openagent3.xyz/skills/opencode/agent.json)
- [Markdown brief](https://openagent3.xyz/skills/opencode/agent.md)
- [Download page](https://openagent3.xyz/downloads/opencode)