opencodeOpenCode AI - AI-driven code editor/IDE (CLI/TUI version of Cursor/Windsurf). Use when: (1) AI-assisted coding tasks, (2) Code refactoring with AI, (3) GitHu...
Install via ClawdBot CLI:
clawdbot install csuwl/opencodeOpenCode 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
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
✅ Use for:
❌ Don't use for:
edit tool)read tool)When running OpenCode in TUI mode (opencode), you can use these slash commands to control the AI workflow:
/sessions
/agents
Available agents:
Best Practice: Always select plan first, then switch to build after approval.
/models
/agents/agents/agentsKey Rules:
# 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
# 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
# List configured providers
opencode auth list
# Login to a provider (e.g., OpenCode, OpenAI, Anthropic)
opencode auth login [url]
# Logout
opencode auth logout
# 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
# 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>
# Fetch and checkout a PR, then run OpenCode
opencode pr 123
# Manage GitHub agent
opencode github --help
# 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>
# List all agents
opencode agent list
# Create a new agent
opencode agent create
# Start headless server
opencode serve
# Start server and open web interface
opencode web
# Start ACP (Agent Client Protocol) server
opencode acp
# Show token usage and costs
opencode stats
| Option | Description |
|--------|-------------|
| -m, --model | Model to use (format: provider/model) |
| -c, --continue | Continue last session |
| -s, --session | Continue specific session |
| --fork | Fork session when continuing |
| --agent | Use specific agent |
| --dir | Directory to run in |
| --format | Output format: default or json |
| --thinking | Show thinking blocks |
| --variant | Model reasoning effort (high, max, minimal) |
opencode run "Refactor this function to be more readable and add error handling"
opencode run "Add a new API endpoint for user registration with email verification"
opencode run -f error.log -f src/auth.js "Fix the authentication bug described in the error log"
opencode run "Review this code for security vulnerabilities and suggest improvements"
# Auto-fix a PR
opencode pr 123
# Continue last session
opencode run --continue
# Fork and continue (keeps original intact)
opencode run --continue --fork
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
opencode run "prompt" or opencode--continue or --session --fork to branch from a sessionprovider/model
Examples:
openai/gpt-4oanthropic/claude-sonnet-4opencode/gpt-4ogoogle/gemini-2.5-pro# All models
opencode models
# Provider-specific
opencode models openai
opencode models anthropic
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"
Use --format json for machine-readable output:
opencode run --format json "Refactor this code" | jq .
Useful for:
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
Problem: OpenCode can't find sysctl command
Solution:
export PATH="/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
Add to ~/.zshrc to make permanent.
Problem: OpenCode treats arguments as directory paths
Solution: Use flags like --version, --help, or run explicitly:
# Wrong
opencode version
# Right
opencode --version
Problem: Interactive TUI waiting for input
Solution: Press Ctrl+C to exit, or use run mode for non-interactive tasks.
Problem: Can't write to files
Solution: Ensure file/directory permissions allow your user to write:
chmod +w ./path/to/file
# For simple tasks
bash command:"opencode run 'Add error handling'"
# For longer tasks (background)
bash background:true command:"opencode run 'Refactor entire codebase'"
bash command:"opencode session list"
bash command:"opencode stats"
-f for context--continue to build on previous work--fork to try variations safelyopencode stats to track token usage| Feature | OpenCode | Cursor | Windsurf | Claude Code |
|---------|----------|--------|----------|-------------|
| Interface | CLI/TUI | GUI | GUI | CLI |
| Terminal-native | ✅ | ❌ | ❌ | ✅ |
| Session management | ✅ | ✅ | ✅ | ✅ |
| GitHub PR integration | ✅ | ✅ | ✅ | ✅ |
| Model support | Multi | Multi | Multi | Anthropic |
| MCP support | ✅ | ❌ | ❌ | ❌ |
Choose OpenCode when:
opencode --versionopencode --help or opencode --help opencode models --verboseopencode session listLast updated: 2026-02-25
Generated Mar 1, 2026
A development team uses OpenCode AI to refactor a legacy monolithic application into microservices. The plan agent analyzes dependencies and designs a step-by-step migration strategy, then the build agent implements changes across multiple files, ensuring consistency and reducing manual errors.
Maintainers of an open-source project leverage OpenCode AI to review and fix pull requests automatically. The tool fetches PR data, uses the explore agent to understand code changes, and suggests or applies fixes for bugs or style issues, speeding up the review process.
An e-commerce company employs OpenCode AI to add a new payment gateway integration. The plan agent outlines requirements and security considerations, while the build agent writes and tests code across frontend and backend files, ensuring seamless deployment with minimal downtime.
A startup uses OpenCode AI to rapidly prototype a minimum viable product. Developers describe features in TUI mode, and the AI assists in generating boilerplate code, handling multi-file edits, and iterating based on feedback, reducing time-to-market for early-stage products.
A university integrates OpenCode AI into computer science courses to help students understand complex codebases. Instructors use the explore agent for guided code analysis, and students practice refactoring assignments with AI assistance, improving learning outcomes in programming classes.
Offer a free tier for basic AI coding tasks with limited usage, and premium tiers for advanced features like GitHub integration, higher model limits, and priority support. Revenue is generated through monthly or annual subscriptions targeting individual developers and teams.
Sell enterprise licenses that include on-premise deployment, custom model training, and integration with existing DevOps tools like Jira or GitLab. Revenue comes from one-time licensing fees and ongoing support contracts for large organizations.
Create a marketplace where developers can sell or share custom AI agents, MCP servers, and plugins for OpenCode AI. Revenue is generated through transaction fees on sales and premium listings, fostering a community-driven ecosystem around the tool.
💬 Integration Tip
Integrate OpenCode AI into CI/CD pipelines by using its CLI commands for automated code reviews and fixes, ensuring seamless workflow adoption without disrupting existing tools.
Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends Claude's capabilities with specialized knowledge, workflows, or tool integrations.
Provides a 7-step debugging protocol plus language-specific commands to systematically identify, verify, and fix software bugs across multiple environments.
A comprehensive skill for using the Cursor CLI agent for various software engineering tasks (updated for 2026 features, includes tmux automation guide).
Write, run, and manage unit, integration, and E2E tests across TypeScript, Python, and Swift using recommended frameworks.
Control and operate Opencode via slash commands. Use this skill to manage sessions, select models, switch agents (plan/build), and coordinate coding through Opencode.
Coding style memory that adapts to your preferences, conventions, and patterns for consistent coding.