opencode-client
by @tornado404
OpenCode CLI for submitting coding tasks, managing sessions, delegating work to coding agents, checking status, and configuring OpenCode settings.
clawhub install opencode-clientπ About This Skill
name: oho description: OpenCode CLI for submitting coding tasks, managing sessions, and delegating work to coding agents. Use when: (1) submitting coding tasks, (2) creating/managing sessions, (3) delegating work to coding agents, (4) checking task status, (5) configuring OpenCode settings.
OpenCode Server API Skill Handbook
> Version: v4.6.0 | Server: v1.2.15 | oho CLI: v1.1.2 > > β οΈ Important: All OpenCode operations must be sent via oho CLI. Python SDK or curl are no longer supported.
π« Telegram Message Guidelines (Important)
Prohibited Content:
Correct Approach:
Example:
β
Task submitted
Session: ses_xxx
Project: babylon3DWorld
π Quick Start
Submit Tasks (Async Mode to Avoid Timeout)
# Most common: create session + send message in one command, directory is the project path
oho add "Fix login bug" --title "Bug Fix" --directory /mnt/d/fe/babylon3DWorld --model "minimax-cn-coding-plan:MiniMax-M2.7" --no-replyAnother example: summarize today's progress
oho add "Summarize today's changes" --title "Command Test" --directory /mnt/d/fe/opencode_cli --model "minimax-cn-coding-plan:MiniMax-M2.7" --no-replySpecify Agent
oho add "@hephaestus Fix login bug" --title "Bug Fix" --directory /mnt/d/fe/project --model "minimax-cn-coding-plan:MiniMax-M2.7" --no-reply
Attach files
oho add "Analyze logs" --file /var/log/app.log --directory /mnt/d/fe/project --no-reply
Key Parameters
| Parameter | Type | Description | Default |
|------|------|------|--------|
| --title | string | Session title (auto-generated if not provided) | Auto-generated |
| --parent | string | Parent session ID (for creating child sessions) | - |
| --directory | string | Session working directory, project path | Current directory |
| --agent | string | Agent ID for the message | - |
| --model | string | Model ID for the message (e.g., provider:model) | minimax-cn-coding-plan/MiniMax-M2.7 |
| --no-reply | bool | Do not wait for AI response | false |
| --system | string | System prompt | - |
| --tools | string[] | Tool list (can be specified multiple times) | - |
| --file | string[] | File attachments (can be specified multiple times) | - |
| --timeout | int | Request timeout in seconds | 300 |
| -j, --json | bool | JSON output | false |
π Common Commands
Session Management
# List all sessions
oho session listFilter by ID (fuzzy match)
oho session list --id ses_abcFilter by title (fuzzy)
oho session list --title "test"Filter by project ID
oho session list --project-id proj1Filter by directory
oho session list --directory babylonFilter by timestamp
oho session list --created 1773537883643
oho session list --updated 1773538142930Filter by status
oho session list --status running # running/completed/error/aborted/idle
oho session list --running # Show only running sessionsSort and pagination
oho session list --sort updated --order desc # Sort by updated descending
oho session list --limit 10 --offset 0 # PaginationJSON output
oho session list -jCreate session
oho session create
oho session create --title "name"
oho session create --parent ses_xxx # Create child session
oho session create --path /path # Create in specified directoryGet session details
oho session get Update session
oho session update --title "New Title"Get child sessions
oho session children Get todo items
oho session todo Branch session
oho session fork Abort session
oho session abort Share/unshare session
oho session share
oho session unshare Get file diff
oho session diff Session summary
oho session summarize Revert message
oho session revert --message
oho session unrevert Respond to permission request
oho session permissions --response allowDelete session
oho session delete ses_xxxArchive session
oho session achieve --directory /mnt/d/fe/project
Message Management
# List messages
oho message list -s ses_xxxGet message details
oho message get -s ses_xxx Send message (sync)
oho message add -s ses_xxx "Continue task"Send async (don't wait for response)
oho message prompt-async -s ses_xxx "Task content"Execute command
oho message command -s ses_xxx /helpRun shell command
oho message shell -s ses_xxx --agent default "ls -la"
Project Management
# List all projects
oho project listGet current project
oho project currentGet current path
oho pathGet VCS info
oho vcsDispose current instance
oho instance dispose
Global Commands
# Check server health
oho global healthListen to global event stream (SSE)
oho global event
Configuration Management
# Get configuration
oho config getUpdate configuration
oho config set --theme darkList providers
oho config providers
Provider Management
# List all providers
oho provider listGet authentication methods
oho provider authOAuth authorization
oho provider oauth authorize Handle callback
oho provider oauth callback
File Operations
# List files
oho file list [path]Read file content
oho file content Get file status
oho file status
Find Commands
# Search text
oho find text "pattern"Find files
oho find file "query"Find symbols
oho find symbol "query"
Other Commands
# List agents
oho agent listList commands
oho command listList tool IDs
oho tool idsList tools
oho tool list --provider xxx --model xxxLSP status
oho lsp statusFormatter status
oho formatter statusMCP servers
oho mcp list
oho mcp add --config '{}'TUI
oho tui open-help
oho tui show-toast --message "message"Auth setup
oho auth set --credentials key=value
β οΈ Timeout Handling (Important)
The oho add command waits for AI response by default. For complex tasks, the AI may need more time to think, which could cause timeout.
Ways to Avoid Timeout
Method 1: Use --no-reply Parameter (Recommended)
# β
Returns immediately after sending message, no waiting for AI response
oho add "Analyze project structure" --directory /mnt/d/fe/project --no-replyCheck results later
oho message list -s
Method 2: Increase Timeout
# Set timeout to 10 minutes (600 seconds)
export OPENCODE_CLIENT_TIMEOUT=600
oho add "Complex task" --directory /mnt/d/fe/projectOr set temporarily
OPENCODE_CLIENT_TIMEOUT=600 oho add "Complex task" --directory /mnt/d/fe/project
Method 3: Use --timeout Parameter (Most Convenient)
# Temporarily set timeout to 10 minutes
oho add "Complex task" --directory /mnt/d/fe/project --timeout 600Set timeout to 1 hour
oho add "Large refactor" --directory /mnt/d/fe/project --timeout 3600
Method 4: Use Async Commands
# Create session first
oho session create --title "task" --path /mnt/d/fe/projectSend message async
oho message prompt-async -s "Task description"
Timeout Configuration
| Configuration Method | Priority | Description |
|----------|--------|-------------|
| --timeout parameter | Highest | Temporary override, only effective for current command |
| OPENCODE_CLIENT_TIMEOUT env var | Medium | Effective for current shell session |
| Default value | Lowest | 300 seconds (5 minutes) |
Timeout Error Messages
If timeout occurs, you will see a friendly error:
Request timeout (300 seconds)Suggestions:
1. Use --no-reply parameter to avoid waiting
2. Increase timeout via env var: export OPENCODE_CLIENT_TIMEOUT=600
3. Use async command: oho message prompt-async -s "task"
Background Polling (Optional)
#!/bin/bash
session_id=$(oho add "task" --directory /mnt/d/fe/project --json | jq -r '.sessionId')while true; do
count=$(oho message list -s "$session_id" -j | jq 'length')
[ "$count" -ge 2 ] && echo "β
Done" && break
echo "β³ Running... ($count messages)"
sleep 10
done
π€ Agent System
| Agent | Role | Use Cases | |-------|------|---------| | @sisyphus | Main coordinator | Large feature development, parallel execution | | @hephaestus | Deep worker | Code exploration, performance optimization | | @prometheus | Strategic planner | Requirements clarification, architecture design |
π Practical Examples
babylon3DWorld Project Tasks
#!/bin/bash
Submit coding task
oho add "@hephaestus ulw optimize navigation logic between editor and world pages
Coding Goals:
1. When returning from editor to world page: refresh directly, no longer check if editor made changes
2. When entering editor from world page: no longer cache the world itself
Keywords: ulw" \
--directory /mnt/d/fe/babylon3DWorld \
--title "ulw - Optimize editor navigation logic" \
--no-reply
echo "β
Task submitted"
Multi-Project Batch Tasks
#!/bin/bash
Batch submit tasks
oho add "Task 1" --directory /mnt/d/fe/babylon3DWorld --no-reply
oho add "Task 2" --directory /mnt/d/fe/wujimanager --no-reply
oho add "Task 3" --directory /mnt/d/fe/armdraw --no-reply
echo "β
All tasks submitted"
OpenCode Server Usage
1. rerun.sh
#!/bin/bashecho "π΄ stopping opencode web service..."
pkill -f "opencode web"
sleep 2
if pgrep -f "opencode web" > /dev/null; then
pkill -9 -f "opencode web"
sleep 1
fi
echo "β
opencode web stopped"
echo "π’ starting opencode web service..."
bash run.sh &
echo "β
opencode web started"
2. run.sh
OPENCODE_SERVER_PASSWORD=cs516123456 opencode web --hostname 0.0.0.0 --port 4096 --mdns --mdns-domain opencode.local
π§ Troubleshooting
Restart OpenCode Server
Standard Restart (Recommended):
# Switch to project directory and run restart script
cd /mnt/d/fe && bash rerun.sh &
Description:
rerun.sh automatically stops old service and starts new one& to run in background to avoid blockingVerify Service is Running:
# Wait for service to start
sleep 5Check processes
ps aux | grep "opencode web"Test API
oho session list
View Logs:
# View run.sh output logs
tail -f /tmp/opencode.logOr view recent logs
tail -50 /tmp/opencode.log
If Restart Script Gets Stuck:
# Force kill stuck process
pkill -9 -f "bash rerun.sh"Manual restart
cd /mnt/d/fe
pkill -f "opencode web"
sleep 2
OPENCODE_SERVER_PASSWORD=yourpassword opencode web --hostname 0.0.0.0 --port 4096 --mdns --mdns-domain opencode.local &
401 Unauthorized
# Check password
echo $OPENCODE_SERVER_PASSWORDOr specify via command line
oho --password yourpassword session list
Session Not Found
# Recreate session
oho session create --path /mnt/d/fe/babylon3DWorld
Task Timeout
# Use --no-reply to submit async
oho add "task" --directory /mnt/d/fe/project --no-reply
ConfigInvalidError (500 Error)
Symptoms:
Error: API Error [500]: {"name":"ConfigInvalidError","data":{"path":"/path/to/project/.opencode/opencode.json","issues":[...]}}
Cause:
The opencode.json or .opencode/opencode.json config file in the project does not comply with the schema requirements.
Common Errors:
// β Wrong: tools.lint should be boolean, not object
{
"tools": {
"lint": {
"type": "shell",
"command": ["yarn", "lint"]
}
}
}// β Wrong: lsp config format is incorrect
{
"lsp": {
"vue": {
"disabled": false // Should be true/false, but schema expects different format
}
}
}
Solution:
# 1. Backup incorrect config file
mv opencode.json opencode.json.bak
mv .opencode/opencode.json .opencode/opencode.json.bak2. Restart opencode server (using rerun.sh)
cd /mnt/d/fe && bash rerun.sh &3. Verify service is running
sleep 5
oho session list4. If you need config, use correct format
cat > .opencode/opencode.json << 'EOF'
{
"$schema": "https://opencode.ai/config.json",
"model": "alibaba-cn/qwen3.5-plus"
}
EOF
Prevention:
opencode.json before modifyingoho config get to verify config is validπ MCP Server
oho can act as an MCP (Model Context Protocol) server, allowing external MCP clients (like Claude Desktop, Cursor, etc.) to call OpenCode API via MCP protocol.
Start MCP Server
# Start MCP server (stdio mode)
oho mcpserver
Available MCP Tools
| Tool | Description |
|------|------|
| session_list | List all sessions |
| session_create | Create new session |
| session_get | Get session details |
| session_delete | Delete session |
| session_status | Get all session statuses |
| message_list | List messages in session |
| message_add | Send message to session |
| config_get | Get OpenCode configuration |
| project_list | List all projects |
| project_current | Get current project |
| provider_list | List AI providers |
| file_list | List files in directory |
| file_content | Read file content |
| find_text | Search text in project |
| find_file | Find files by name |
| global_health | Check server health status |
MCP Client Configuration
#### Claude Desktop (macOS/Windows)
Add to claude_desktop_config.json:
{
"mcpServers": {
"oho": {
"command": "oho",
"args": ["mcpserver"],
"env": {
"OPENCODE_SERVER_HOST": "127.0.0.1",
"OPENCODE_SERVER_PORT": "4096",
"OPENCODE_SERVER_PASSWORD": "your-password"
}
}
}
}
#### Cursor
Add to Cursor settings (JSON mode):
{
"mcpServers": {
"oho": {
"command": "oho",
"args": ["mcpserver"],
"env": {
"OPENCODE_SERVER_HOST": "127.0.0.1",
"OPENCODE_SERVER_PORT": "4096",
"OPENCODE_SERVER_PASSWORD": "your-password"
}
}
}
}
π Related Resources
*Created: 2026-02-27 13:46 CST* *Last Updated: 2026-04-02 00:43 CST - Added session achieve command*