OpenCode 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...
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install opencode或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install opencode⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/opencode/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: opencode description: "OpenCode 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) GitHub PR review/fixes, (4) Multi-file edits requiring context, (5) Running AI agents on codebases. NOT for: simple one-line edits (use edit tool), reading files (use read tool)." metadata: { "openclaw": { "emoji": "🤖", "requires": { "bins": ["opencode"] } }, } ---
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
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 session---
provider/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 AI 后,可以对 AI 说这些话来触发它
Help me get started with OpenCode AI
Explains what OpenCode AI does, walks through the setup, and runs a quick demo based on your current project
Use OpenCode AI to openCode AI - AI-driven code editor/IDE (CLI/TUI version of Cursor/...
Invokes OpenCode AI with the right parameters and returns the result directly in the conversation
What can I do with OpenCode AI in my developer & devops workflow?
Lists the top use cases for OpenCode AI, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/opencode/ 目录(个人级,所有项目可用),或 .claude/skills/opencode/(项目级)。重启 AI 客户端后,用 /opencode 主动调用,或让 AI 根据上下文自动发现并使用。
OpenCode AI 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
OpenCode AI 可免费安装使用。请查阅仓库了解许可证信息。
OpenCode 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...
OpenCode AI 属于「Developer & DevOps」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my developer & devops tasks using OpenCode AI
Identifies repetitive steps in your workflow and sets up OpenCode AI to handle them automatically