OCC (OpenCode Controller)
Control OpenCode to execute development tasks via CLI.
When to Use
Use this skill when:
- - You want to delegate coding tasks to OpenCode
- You need to control OpenCode from external systems (like OpenCLAW)
- You want to automate development workflows
Quick Start
Prerequisites
OpenCode CLI must be installed and available in PATH.
Workflow
Step 1: Choose Working Directory
⚠️ Important: Run the script in the directory where you want OpenCode to work. The session will be created in the current directory.
Step 2: Decide Session Mode
- - New session: Use
create command (creates session only, then use continue to execute task) - Continue existing session: Use
continue command (session ID provided by caller)
Step 3: Run Command
CODEBLOCK0
How It Works
The script automatically handles OpenCode Server:
- 1. Port Detection: Scans ports 4096-4200 to find an existing OpenCode Server
- Auto-Start: If no server is found, automatically starts a new one
- Session Management: Creates and manages development sessions through OpenCode's session API
OCC(OpenCode 控制器)
通过 CLI 控制 OpenCode 执行开发任务。
使用场景
在以下情况下使用此技能:
- - 您希望将编码任务委托给 OpenCode
- 您需要从外部系统(如 OpenCLAW)控制 OpenCode
- 您希望自动化开发工作流程
快速开始
前置条件
必须安装 OpenCode CLI 并确保其在 PATH 环境变量中可用。
工作流程
步骤 1:选择工作目录
⚠️ 重要提示:请在您希望 OpenCode 工作的目录中运行脚本。会话将在当前目录中创建。
步骤 2:决定会话模式
- - 新建会话:使用 create 命令(仅创建会话,然后使用 continue 执行任务)
- 继续现有会话:使用 continue 命令(会话 ID 由调用方提供)
步骤 3:运行命令
bash
查询现有会话
node skills/occ/scripts/bin/opencode-server.js query
创建新会话
node skills/occ/scripts/bin/opencode-server.js create 创建一个 React 登录页面
继续会话
node skills/occ/scripts/bin/opencode-server.js continue <会话ID> 添加密码重置功能
工作原理
该脚本自动处理 OpenCode 服务器:
- 1. 端口检测:扫描 4096-4200 端口以查找现有的 OpenCode 服务器
- 自动启动:如果未找到服务器,则自动启动一个新的服务器
- 会话管理:通过 OpenCode 的会话 API 创建和管理开发会话