opencode-acp-control-3Control OpenCode directly via the Agent Client Protocol (ACP). Start sessions, send prompts, resume conversations, and manage OpenCode updates.
Install via ClawdBot CLI:
clawdbot install berriosb/opencode-acp-control-3Control OpenCode directly via the Agent Client Protocol (ACP).
| Action | How |
|--------|-----|
| Start OpenCode | bash(command: "opencode acp --cwd /path/to/project", background: true) |
| Send message | process.write(sessionId, data: " |
| Read response | process.poll(sessionId) - repeat every 2 seconds |
| Stop OpenCode | process.kill(sessionId) |
| List sessions | bash(command: "opencode session list", workdir: "...") |
| Resume session | List sessions → ask user → session/load |
| Check version | bash(command: "opencode --version") |
bash(
command: "opencode acp --cwd /path/to/your/project",
background: true,
workdir: "/path/to/your/project"
)
Save the returned sessionId - you'll need it for all subsequent commands.
\n)Send immediately after starting OpenCode:
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{"fs":{"readTextFile":true,"writeTextFile":true},"terminal":true},"clientInfo":{"name":"clawdbot","title":"Clawdbot","version":"1.0.0"}}}
Poll for response. Expect result.protocolVersion: 1.
{"jsonrpc":"2.0","id":1,"method":"session/new","params":{"cwd":"/path/to/project","mcpServers":[]}}
Poll for response. Save result.sessionId (e.g., "sess_abc123").
{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"sessionId":"sess_abc123","prompt":[{"type":"text","text":"Your question here"}]}}
Poll every 2 seconds. You'll receive:
session/update notifications (streaming content)result.stopReasonEach poll may return multiple lines. Parse each line as JSON:
method: "session/update" - collect these for the responseid matching your request - stop polling when stopReason appears{"jsonrpc":"2.0","method":"session/cancel","params":{"sessionId":"sess_abc123"}}
No response expected - this is a notification.
Per OpenCode instance, track:
processSessionId - from bash tool (clawdbot's process ID)opencodeSessionId - from session/new response (OpenCode's session ID) messageId - increment for each request you sendstopReason| stopReason | Meaning |
|------------|---------|
| end_turn | Agent finished responding |
| cancelled | You cancelled the prompt |
| max_tokens | Token limit reached |
| Issue | Solution |
|-------|----------|
| Empty poll response | Keep polling - agent is thinking |
| Parse error | Skip malformed line, continue |
| Process exited | Restart OpenCode |
| No response after 5min | Kill process, start fresh |
1. bash(command: "opencode acp --cwd /home/user/myproject", background: true, workdir: "/home/user/myproject")
-> processSessionId: "bg_42"
2. process.write(sessionId: "bg_42", data: '{"jsonrpc":"2.0","id":0,"method":"initialize",...}\n')
process.poll(sessionId: "bg_42") -> initialize response
3. process.write(sessionId: "bg_42", data: '{"jsonrpc":"2.0","id":1,"method":"session/new","params":{"cwd":"/home/user/myproject","mcpServers":[]}}\n')
process.poll(sessionId: "bg_42") -> opencodeSessionId: "sess_xyz789"
4. process.write(sessionId: "bg_42", data: '{"jsonrpc":"2.0","id":2,"method":"session/prompt","params":{"sessionId":"sess_xyz789","prompt":[{"type":"text","text":"List all TypeScript files"}]}}\n')
5. process.poll(sessionId: "bg_42") every 2 sec until stopReason
-> Collect all session/update content
-> Final response: stopReason: "end_turn"
6. When done: process.kill(sessionId: "bg_42")
Resume a previous OpenCode session by letting the user choose from available sessions.
bash(command: "opencode session list", workdir: "/path/to/project")
Example output:
ID Updated Messages
ses_451cd8ae0ffegNQsh59nuM3VVy 2026-01-11 15:30 12
ses_451a89e63ffea2TQIpnDGtJBkS 2026-01-10 09:15 5
ses_4518e90d0ffeJIpOFI3t3Jd23Q 2026-01-09 14:22 8
Present the list to the user and ask which session to resume:
"Which session would you like to resume?
1. ses_451cd8ae... (12 messages, updated 2026-01-11)
2. ses_451a89e6... (5 messages, updated 2026-01-10)
3. ses_4518e90d... (8 messages, updated 2026-01-09)
Enter session number or ID:"
Once user responds (e.g., "1", "the first one", or "ses_451cd8ae..."):
bash(command: "opencode acp --cwd /path/to/project", background: true, workdir: "/path/to/project")
{"jsonrpc":"2.0","id":0,"method":"initialize","params":{...}}
{"jsonrpc":"2.0","id":1,"method":"session/load","params":{"sessionId":"ses_451cd8ae0ffegNQsh59nuM3VVy","cwd":"/path/to/project","mcpServers":[]}}
Note: session/load requires cwd and mcpServers parameters.
On load, OpenCode streams the full conversation history back to you.
function resumeSession(workdir):
# List available sessions
output = bash("opencode session list", workdir: workdir)
sessions = parseSessionList(output)
if sessions.empty:
notify("No previous sessions found. Starting fresh.")
return createNewSession(workdir)
# Ask user to choose
choice = askUser("Which session to resume?", sessions)
selectedId = matchUserChoice(choice, sessions)
# Start OpenCode and load session
process = bash("opencode acp --cwd " + workdir, background: true, workdir: workdir)
initialize(process)
session_load(process, selectedId, workdir, mcpServers: [])
notify("Session resumed. Conversation history loaded.")
return process
OpenCode auto-updates when restarted. Use this workflow to check and trigger updates.
bash(command: "opencode --version")
Returns something like: opencode version 1.1.13
Extract the version number (e.g., 1.1.13).
webfetch(url: "https://github.com/anomalyco/opencode/releases/latest", format: "text")
The redirect URL contains the latest version tag:
https://github.com/anomalyco/opencode/releases/tag/v1.2.01.2.0)If latest version > current version:
process.list() # Find all "opencode acp" processes
process.kill(sessionId) # For each running instance
bash(command: "opencode acp --cwd /path/to/project", background: true, workdir: "/path/to/project")
bash(command: "opencode --version")
If version still doesn't match latest:
curl -fsSL https://opencode.dev/install | bashfunction updateOpenCode():
current = bash("opencode --version") # e.g., "1.1.13"
latestPage = webfetch("https://github.com/anomalyco/opencode/releases/latest")
latest = extractVersionFromRedirectUrl(latestPage) # e.g., "1.2.0"
if semverCompare(latest, current) > 0:
# Stop all instances
for process in process.list():
if process.command.includes("opencode"):
process.kill(process.sessionId)
# Wait briefly for processes to terminate
sleep(2 seconds)
# Restart triggers auto-update
bash("opencode acp", background: true)
# Verify
newVersion = bash("opencode --version")
if newVersion != latest:
notify("Auto-update may have failed. Manual update recommended.")
else:
notify("OpenCode is up to date: " + current)
opencodeSessionId survives restarts — use session/load to recoverGenerated Feb 24, 2026
A developer uses OpenCode ACP to get real-time coding help, such as generating code snippets, debugging, or refactoring existing TypeScript projects. The skill enables direct interaction with OpenCode via JSON-RPC, allowing for automated prompts and responses within an integrated development environment.
A tech support team integrates this skill into their chatbot to handle user queries about code errors or project setup. By starting sessions and sending prompts, the system can provide step-by-step troubleshooting guides or code fixes, reducing manual intervention and response time.
An online learning platform employs OpenCode ACP to offer personalized coding exercises and feedback to students. Instructors can create sessions for different programming languages, send prompts for assignments, and monitor progress through streaming updates, enhancing interactive learning experiences.
A project management tool uses this skill to automate code reviews and task updates. Managers can start sessions to analyze code changes, send prompts for status reports, and resume previous conversations to track ongoing issues, streamlining development workflows.
A documentation team leverages OpenCode ACP to generate API docs or code examples from existing projects. By sending prompts to describe functions or modules, the skill produces structured content that can be integrated into technical manuals, saving time on manual writing.
Offer this skill as part of a cloud-based platform where users pay a monthly fee for access to OpenCode ACP integrations. Revenue comes from tiered subscriptions based on usage limits, such as number of sessions or prompts per month, targeting small to medium-sized development teams.
Sell enterprise licenses to large organizations that need custom integrations with their existing tools. Revenue is generated through one-time licensing fees and annual support contracts, providing dedicated features like advanced session management and priority error handling.
Provide a free version with basic ACP controls and limited sessions, then upsell premium features such as faster polling, extended session history, or advanced analytics. Revenue comes from users upgrading to paid plans for enhanced functionality and scalability.
💬 Integration Tip
Ensure proper error handling for JSON-RPC messages and implement efficient polling strategies to avoid timeouts, as detailed in the skill's workflow for reliable OpenCode interactions.
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.