Wang Lei

OpenCode AI

开发编程v1.2.2
作者:Wang Lei更新于 2026-05-11共 5 个版本 · 最新版本发布于 2026-04-16opencode@clawhub_csuwl/opencode
代码生成代码审查脚本工具#Coding

据 AlphaMoat 统计,截至 2026-09,OpenCode AI 累计下载 4,493 次、获 4 个星标,在全部 5,078 个 AI 技能中排名第 2,146 位,在「开发编程」分类(577 个)中排名第 271 位。

累计安装
124
累计下载
4,493
星标
4
全站排名
#2,146
全站前 43% · 「开发编程」前 47%
平台累计安装累计下载星标评论
ClawHub ↗1244,4934-
SkillHub ↗1224,4484—

各平台的计数口径不同,统计时间不一致。

这个技能是做什么的

它适用于 AI 辅助开发、复杂重构、PR 审查与修复,以及需要上下文的多文件编辑和基于会话的编码任务。简单单行编辑和读取文件应使用相应基础工具,而不是该技能。 附带代码可能发送到配置的 AI 服务;先审查提供商与安装目录,网络开放界面时应限制访问。

资料发布于 2026-10-29

可以用来做什么

  • 在终端中开展 AI 辅助开发
  • 处理复杂重构或需要上下文的多文件修改
  • 审查或修复 GitHub PR

什么时候用

  • 任务涉及代码库上下文、多文件改动、复杂重构或 PR 审查时

示例提示词

以下是根据技能文档生成的示例,不代表实际运行结果。

请先分析这个跨多个文件的代码改动方案,列出要检查的文件和步骤;暂不修改文件。

月度数据趋势

累计下载4,493
1,8363,2634,6902026-03 · 累计下载 2,0332026-05 · 累计下载 3,2412026-06 · 累计下载 3,5292026-07 · 累计下载 4,0802026-08 · 累计下载 4,3542026-09 · 累计下载 4,49326-0326-09
星标4
3442026-03 · 星标 32026-05 · 星标 42026-06 · 星标 42026-07 · 星标 42026-08 · 星标 42026-09 · 星标 426-0326-09

2026-09 起统计方法调整:同名技能按作者分别统计,并覆盖全部技能。图中虚线为调整前的月份,与之后的数据不直接比较,也不计算跨越调整的增长。

月份累计下载环比星标
2026-094,493—4
2026-084,354+6.7%4
2026-074,080+15.6%4
2026-063,529+8.9%4
2026-053,241—4
2026-032,033—3

SKILL.md 原文

以下是作者发布的原始文件,按纯文本显示,本站未做修改或审核;其中的链接不可点击,命令请核实后再运行。抓取于 2026-10-23。

6.7 KB · ClawHub v1.2.2
---
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
---
展开全部(共 230 行)

# OpenCode AI - AI Code Editor

OpenCode is an AI-native code editor that runs in your terminal (CLI/TUI). Think Cursor/Windsurf but in the terminal.

**Version**: 1.3.9 | **Platform**: macOS Darwin x64

## Prerequisites

OpenCode requires `sysctl` for architecture detection. Ensure `/usr/sbin` is in PATH:

```bash
export PATH="/usr/sbin:/usr/bin:/sbin:/bin:$PATH"
# Add to ~/.zshrc for permanence
```

---

## When to Use

✅ **Use for:** Complex refactoring, AI-assisted features, PR review/fixes, codebase exploration, multi-file edits, session-based coding
❌ **Don't use for:** Simple one-line edits (use `edit` tool), reading files (use `read` tool)

---

## Core Commands

### Quick Tasks (One-Shot)

```bash
# Run a single task
opencode run "Add input validation to the login form"
opencode run --dir ~/project "Refactor to use async/await"
opencode run -m anthropic/claude-sonnet-4 "Optimize queries"

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

# Continue previous session
opencode run --continue
opencode run --session abc123 --fork

# Share session (creates shareable link)
opencode run --share "Implement feature X"

# Model variant (reasoning effort)
opencode run --variant high "Solve this complex problem"
```

### Key Options

| Option | Description |
|--------|-------------|
| `-m, --model` | Model (`provider/model`, e.g. `anthropic/claude-sonnet-4`) |
| `-c, --continue` | Continue last session |
| `-s, --session` | Continue specific session |
| `--fork` | Fork session when continuing |
| `--share` | Share the session |
| `-f, --file` | Attach files to message |
| `--agent` | Use specific agent |
| `--dir` | Directory to run in |
| `--format` | Output format: `default` or `json` |
| `--variant` | Reasoning effort: `high`, `max`, `minimal` |
| `--thinking` | Show thinking blocks |
| `--title` | Set session title |
| `--attach` | Attach to running server (e.g. `http://localhost:4096`) |
| `--pure` | Run without external plugins |
| `--command` | Run a specific command (use message for args) |
| `-p, --password` | Basic auth password for server mode |

### Interactive TUI

```bash
opencode              # Start in current directory
opencode ~/project    # Start in specific project
```

#### TUI Slash Commands

- `/sessions` — Session selector (continue existing or create new)
- `/agents` — Switch agent (see agents below)
- `/models` — Model selector
- `/title` — Change session title
- `/summary` — Generate session summary
- `/compaction` — Compact conversation history

#### Available Agents

| Agent | Type | Purpose |
|-------|------|---------|
| **plan** | primary | Analyze & design (no code edits) |
| **build** | primary | Implement & code |
| **explore** | subagent | Understand codebase, read-only exploration |
| **general** | subagent | General assistance |
| **compaction** | primary | Compress/summarize session context |
| **summary** | primary | Generate session summaries |
| **title** | primary | Generate session titles |
| **memory-automation** | subagent | Automated memory management |
| **memory-consolidate** | subagent | Consolidate memory entries |

> ⚠️ `--agent` flag in `opencode run` always falls back to default agent. Agent switching only works in TUI via `/agents` slash command.

#### Recommended Workflow: Plan → Build

1. Select **plan** agent (`/agents`)
2. Describe task → review/approve the plan
3. Switch to **build** agent (`/agents`)
4. Implement → iterate

---

## Other Commands

```bash
# Providers & Auth
opencode providers              # Manage AI providers/credentials (alias: auth)
opencode providers login [url] # Login to a provider

# Models
opencode models                 # List all models
opencode models --verbose       # With cost info
opencode models --refresh       # Refresh cache

# Sessions
opencode session list            # List sessions
opencode export [sessionID]      # Export as JSON
opencode import <file>           # Import session

# GitHub
opencode pr 123                  # Checkout PR + run OpenCode
opencode github --help           # GitHub agent options

# MCP Servers
opencode mcp list                # List MCP servers
opencode mcp add                 # Add MCP server
opencode mcp auth [name]         # OAuth for MCP server

# Agents
opencode agent list              # List agents
opencode agent create            # Create custom agent

# Plugins
opencode plugin <module>        # Install plugin (alias: plug)

# Server Mode
opencode serve                   # Headless server
opencode web                     # Server + open browser

# ACP (Agent Client Protocol)
opencode acp                     # Start ACP server

# Attach to Remote
opencode attach <url>            # Attach to running instance

# Utilities
opencode stats                   # Token usage & costs
opencode debug                   # Debug/troubleshooting tools
opencode upgrade [target]       # Upgrade opencode
opencode uninstall               # Remove opencode
opencode db                      # Database tools
```

---

## Integration with OpenClaw

**You are the orchestrator. OpenCode is your worker.**

### When to Delegate
- Multi-file refactoring
- Complex feature implementation
- PR review and fixes
- Code exploration requiring sustained context

### When to Do It Yourself
- Simple one-line edits
- Reading files
- Quick commands

### Pattern: Delegate via exec

```bash
# Simple task (foreground, wait for result)
opencode run "Add error handling to auth module"

# Complex task (background, check later)
# Use exec with background:true

# With file context
opencode run -f src/auth.js -f src/db.js "Fix the auth bug"

# Continue previous work
opencode run --continue
```

### Multi-Agent Pattern

```bash
# Agent 1: Analyze
opencode run --session analyze "Explore codebase structure"
# Agent 2: Implement
opencode run --session implement "Implement feature based on analysis"
# Agent 3: Test
opencode run --session test "Write tests for the implementation"
```

---

## Troubleshooting

| Problem | Solution |
|---------|----------|
| `sysctl not found` | `export PATH="/usr/sbin:/usr/bin:/sbin:/bin:$PATH"` |
| `Failed to change directory` | Use `--version` or `run` subcommand explicitly |
| Freezes/hangs | `Ctrl+C` to exit; use `run` mode for non-interactive tasks |
| Permission denied | `chmod +w ./path/to/file` |

---

*Last updated: 2026-04-16 | OpenCode v1.3.9*

「开发编程」分类下的热门技能

数据月份:2026-09 · 下载/星标/安装数聚合自公开技能注册库(ClawHub、SkillHub),按月更新。口径说明见数据方法。