Install
openclaw skills install opencode-acpCollaborate with OpenCode via ACP protocol for code modifications, refactoring, and feature implementation.
openclaw skills install opencode-acpUse OpenCode via ACP (Agent Client Protocol) for code modifications, refactoring, and feature implementation.
Use the provided Python script for automated OpenCode collaboration:
On first run, the skill auto-creates a local
.venv(Python 3.9+) in this skill directory and re-runs inside that environment. If the current interpreter is below 3.9, it auto-discovers a local Python 3.9+ executable (python3.12/python3.11/python3.10/python3.9/python3/python; on Windows alsopy -3.x).
# Run from this repository root
# Simple task
python opencode_acp_client.py \
--project /path/to/project \
--task "Add --version flag to CLI"
# With verbose logging
python opencode_acp_client.py \
--project /path/to/project \
--task "Refactor authentication module" \
--verbose
# With custom timeout (default: 600 seconds)
python opencode_acp_client.py \
--project /path/to/project \
--task "Build REST API for todos" \
--timeout 1200
What it does:
Output:
For fine-grained control, use manual JSON-RPC messages:
# Start OpenCode ACP server in background
exec pty:true workdir:/path/to/project background:true command:"opencode acp"
# Returns sessionId (e.g., "neat-zephyr")
# Initialize connection
process action:write sessionId:neat-zephyr data:'{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{"fs":{"readTextFile":true,"writeTextFile":true},"terminal":true},"clientInfo":{"name":"Claw","title":"Claw AI Assistant","version":"1.0.0"}}}\n'
# Wait for response
process action:log sessionId:neat-zephyr
# Create session
process action:write sessionId:neat-zephyr data:'{"jsonrpc":"2.0","id":1,"method":"session/new","params":{"cwd":"/path/to/project","mcpServers":[]}}\n'
# Wait for session ID
process action:log sessionId:neat-zephyr
# Send task
process action:write sessionId:neat-zephyr data:'{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"sessionId":"ses_xxx","prompt":[{"type":"text","text":"Your task here"}]}}\n'
# Monitor progress
process action:log sessionId:neat-zephyr
# Kill when done
process action:kill sessionId:neat-zephyr
Your job (as planner):
Output:
Your job (as planner):
Format:
# Task: [Task Name]
## Objective
[Goal description]
## Requirements
1. [Requirement 1]
2. [Requirement 2]
...
## Acceptance Criteria
- ✅ [Criterion 1]
- ✅ [Criterion 2]
...
## Implementation Guidance
1. [Step 1]
2. [Step 2]
...
## Verification
[How to verify]
Start OpenCode ACP server:
exec pty:true workdir:/path/to/project background:true command:"opencode acp"
Initialize connection:
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{"fs":{"readTextFile":true,"writeTextFile":true},"terminal":true},"clientInfo":{"name":"Claw","title":"Claw AI Assistant","version":"1.0.0"}}}
Create session:
{"jsonrpc":"2.0","id":1,"method":"session/new","params":{"cwd":"/path/to/project","mcpServers":[]}}
Send task:
{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"sessionId":"ses_xxx","prompt":[{"type":"text","text":"[Your plan from Step 2]"}]}}
Poll for updates:
process action:log sessionId:neat-zephyr
Key update types:
agent_thought_chunk - OpenCode's thinking processtool_call - Tool invocations (search, analyze, edit)plan - Task plan updatesstopReason - Task completion signalStop conditions:
stopReason: "end_turn" - Normal completionstopReason: "cancelled" - Task cancelledVerification checklist:
Verification methods:
Stop OpenCode:
process action:kill sessionId:neat-zephyr
Record results:
If this is OpenCode's first time working on a project, initialize the knowledge base first:
Start OpenCode TUI (not acp mode):
cd /path/to/project
opencode
Run initialization:
/init-deep
Wait for completion:
Exit and restart in acp mode:
opencode acp for collaborationWhy init-deep?
Location: /root/.opencode/opencode.json
Recommended mode: sisyphus (AI orchestrator)
Protocol version: 1
Transport format: JSON-RPC 2.0
Message delimiter: Newline (\n)
Communication: stdin/stdout
Good:
# Task: Add Version Command
## Objective
Add --version flag to display project version from package.json
## Requirements
1. Support both --version and -v
2. Display format: "QMD Memory v1.0.0\nOpenClaw memory plugin"
3. Exit after displaying version
## Acceptance Criteria
- ✅ `bun src/qmd.ts --version` works
- ✅ Version matches package.json
- ✅ No impact on existing commands
Bad:
Add version command
Good criteria:
Example:
command --version displays correct versioncommand -v displays same resultKey metrics:
Warning signs:
Common errors:
Clear requirements:
Reasonable plan:
Effective verification:
Automatic planning:
Intelligent execution:
Continuous feedback:
Requirement: Add --version command-line option
Planner's work:
bun src/qmd.ts --version displays correct version-v alias worksOpenCode's work:
Result:
A: First-time project must initialize knowledge base:
Start OpenCode TUI:
cd /path/to/project
opencode
Run initialization:
/init-deep
Exit after completion, then use acp mode for collaboration
Purpose:
A:
A:
A:
A:
All Agents follow the same workflow: analyze requirements → create plan → start OpenCode → monitor progress → verify results.
/init-deep before first useWhen spawning OpenCode in background, keep user informed:
This prevents "Agent failed before reply" confusion.
For long-running tasks, append wake trigger to prompt:
... your task here.
When completely finished, run this command to notify me:
openclaw system event --text "Done: [brief summary]" --mode now
Example:
exec pty:true workdir:~/project background:true command:"opencode acp"
# ... initialize, create session ...
# Send prompt with wake trigger:
{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"sessionId":"ses_xxx","prompt":[{"type":"text","text":"Build a REST API for todos.\n\nWhen completely finished, run: openclaw system event --text \"Done: Built todos REST API with CRUD endpoints\" --mode now"}]}}
This triggers immediate wake event — you get notified in seconds, not minutes.
Last updated: 2026-02-16
Maintainer: Claw 🐾
Status: ✅ Verified