opencode-api-control-skillA powerful skill to control Open Code CLI via a local web server API. Allows executing commands, managing sessions, and automating code generation remotely i...
Install via ClawdBot CLI:
clawdbot install malek262/opencode-api-control-skill[!IMPORTANT]
OPERATIONAL GUIDELINES:
While you may use ls or basic file system checks to verify that files/directories exist, you are EXPLICITLY PROHIBITED from reading or modifying the project's source code files directly.
Your primary channel for task execution and progress monitoring is the OpenCode API and the provided scripts.
This skill provides a set of tools to programmatically interface with the Open Code CLI through its local web server API. It enables you to act as a Supervisor/Orchestrator who directs OpenCode to handle all coding, file operations, and quality checks.
bash ./scripts/start_server.sh)./config.json./scripts/ directoryRead settings from ./config.json:
BASE_URL=$(jq -r '.base_url' ./config.json)
PROJECTS_DIR=$(jq -r '.projects_base_dir' ./config.json)
You are the supervisor and communication bridge between the user and OpenCode.
Operational Boundaries:
ls or simple directory checks only to confirm file existence if necessary.Required Workflow:
monitor_session.sh or check_status.sh to track progress.get_diff.sh to see a summary of what was changed.CRITICAL: After starting OpenCode web server, it takes 10-15 seconds to fully initialize. You MUST verify server readiness before sending any requests.
Correct initialization sequence:
# Start server using the robust backgrounding script
bash ./scripts/start_server.sh
# 3. Now safe to proceed with operations
bash ./scripts/update_providers.sh
# ... continue workflow
Never send requests immediately after starting the server - always verify health first.
For long-running tasks, use smart monitoring strategies:
Option 1: Event-based monitoring (Recommended)
# Start task
bash ./scripts/send_message.sh "Complex task" &
# Monitor events (blocks until completion)
bash ./scripts/monitor_session.sh
Option 2: Intelligent polling
# For environments where event streaming is unreliable
bash ./scripts/send_message.sh "Build application"
# Smart polling with exponential backoff
SLEEP_TIME=2
MAX_SLEEP=30
while true; do
STATUS=$(bash ./scripts/check_status.sh)
if [ "$STATUS" = "idle" ]; then
echo "ā Task completed"
break
elif [ "$STATUS" = "busy" ]; then
echo "ā³ Still working... (checking again in ${SLEEP_TIME}s)"
sleep $SLEEP_TIME
# Increase wait time (but cap at MAX_SLEEP)
SLEEP_TIME=$((SLEEP_TIME < MAX_SLEEP ? SLEEP_TIME + 2 : MAX_SLEEP))
else
echo "ā Unexpected status: $STATUS"
break
fi
done
Option 3: Timeout-based waiting
# For predictable task durations
bash ./scripts/send_message.sh "Quick task"
# Wait reasonable time before checking
sleep 10
# Then check once
if [ "$(bash ./scripts/check_status.sh)" = "idle" ]; then
bash ./scripts/get_diff.sh
fi
Anti-patterns to AVOID:
ls or file system checks for progressBest practices:
monitor_session.sh for real-time updatesBefore starting any task (new project, code analysis, debugging, etc.), ask the user in ONE message:
I'll help you with that. Two quick questions:
1. Provider: Use default from config, or specify a provider (opencode, anthropic, gemini, etc.)?
2. Monitoring:
- Standard (recommended): Send task ā wait for completion summary ā notify you when done (saves tokens)
- Real-time: Show live progress, file edits, and events as they happen (uses more tokens)
>
How would you like to proceed?
Default if not specified: Use config defaults + Standard mode.
send_message.sh ā waits ā shows final summary. Efficient for most tasks.monitor_session.sh with event streaming. Good for long/complex tasks where you want visibility.select_provider.sh then monitor_session.shWhen a task completes, get summary via:
# Get file changes summary (not individual files)
bash ./scripts/get_diff.sh
# Output example:
# added: src/App.tsx (+120/-0)
# modified: package.json (+5/-2)
# added: src/components/Dashboard.tsx (+89/-0)
This gives you all information needed to report to the user without reading actual file contents.
Only read specific files if:
Otherwise, trust the diff summary and OpenCode's implementation.
# Check health
curl -s "$BASE_URL/global/health" | jq
# Expected: {"healthy": true, "version": "..."}
# Run provider update script
bash ./scripts/update_providers.sh
This caches only connected providers to ./providers.json.
New Project:
PROJECT_NAME="dashboard-app"
PROJECT_PATH="$PROJECTS_DIR/$PROJECT_NAME"
mkdir -p "$PROJECT_PATH"
Existing Project:
PROJECT_NAME="existing-app"
PROJECT_PATH="$PROJECTS_DIR/$PROJECT_NAME"
# Verify exists
[ -d "$PROJECT_PATH" ] || { echo "Project not found"; exit 1; }
Create a session in the project directory using the provided script:
SESSION_ID=$(bash ./scripts/create_session.sh "$PROJECT_PATH" "Session Title")
# Use state management script
bash ./scripts/save_state.sh "$SESSION_ID" "$PROJECT_PATH"
Use the provided script to send prompts to the AI:
# Use defaults from config
bash ./scripts/send_message.sh "Your prompt here"
# Or use a specific provider and model
bash ./scripts/send_message.sh "Your prompt" "anthropic" "claude-sonnet-4-5"
# Start monitoring in background
bash ./scripts/monitor_session.sh &
# Or check status periodically
bash ./scripts/check_status.sh
bash ./scripts/send_message.sh "Create app"
When the user specifies a provider (e.g., "use Gemini Pro" or "with Claude Sonnet"), use the search script:
# Search for provider and model hints
RESULT=$(bash ./scripts/select_provider.sh "gemini" "pro")
# Returns: gemini gemini-3-pro
# Extract and use the returned values
PROVIDER_ID=$(echo "$RESULT" | cut -d' ' -f1)
MODEL_ID=$(echo "$RESULT" | cut -d' ' -f2)
bash ./scripts/send_message.sh "Your prompt" "$PROVIDER_ID" "$MODEL_ID"
Default (no agent specified - recommended):
bash ./scripts/send_message.sh "Build app"
Planning phase:
bash ./scripts/send_message.sh "Analyze requirements" "plan"
Implementation phase:
bash ./scripts/send_message.sh "Implement features" "build"
# 1. Update providers
bash ./scripts/update_providers.sh
# 2. Create project directory
mkdir -p "$PROJECTS_DIR/new-app"
# 3. Create session
SESSION_ID=$(bash ./scripts/create_session.sh "$PROJECTS_DIR/new-app" "New App")
# 4. Send initial task
bash ./scripts/send_message.sh "Create React app with TypeScript and Tailwind"
# 5. Monitor progress
bash ./scripts/monitor_session.sh
# 1. Load saved project state
bash ./scripts/load_project.sh "existing-app"
# 2. Send new task
bash ./scripts/send_message.sh "Add authentication feature"
# Phase 1: Planning
bash ./scripts/create_session.sh "$PROJECT_PATH" "Planning"
bash ./scripts/send_message.sh "Plan e-commerce platform" "plan"
# Phase 2: Implementation
bash ./scripts/send_message.sh "Implement the plan" "build"
# Phase 3: Review
bash ./scripts/get_diff.sh
# User says: "Create dashboard using Claude Sonnet"
# 1. Select provider
PROVIDER_MODEL=$(bash ./scripts/select_provider.sh "claude" "sonnet")
PROVIDER_ID=$(echo "$PROVIDER_MODEL" | cut -d' ' -f1)
MODEL_ID=$(echo "$PROVIDER_MODEL" | cut -d' ' -f2)
# 2. Create project and session
mkdir -p "$PROJECTS_DIR/dashboard"
SESSION_ID=$(bash ./scripts/create_session.sh "$PROJECTS_DIR/dashboard" "Dashboard")
# 3. Send with selected provider
bash ./scripts/send_message.sh "Create dashboard" "$PROVIDER_ID" "$MODEL_ID"
For long-running tasks, monitor events:
# Start monitoring (shows progress in real-time)
bash ./scripts/monitor_session.sh
# This will:
# - Show text deltas as they're generated
# - Display status changes (busy/idle)
# - Show final token count and cost
# - Exit when task completes
All session state is saved in ./state/:
# Save current session
bash ./scripts/save_state.sh "$SESSION_ID" "$PROJECT_PATH"
# Load state (sets environment variables)
source ./scripts/load_state.sh
echo $SESSION_ID
echo $PROJECT_PATH
# Save project-specific state
bash ./scripts/save_project.sh "project-name"
# Load project-specific state
bash ./scripts/load_project.sh "project-name"
# List all saved projects
ls -1 ./state/*.json | grep -v current.json | xargs -n1 basename .json
Get session changes:
bash ./scripts/get_diff.sh
Get file content:
curl -s "$BASE_URL/file/content?directory=$PROJECT_PATH&path=src/App.tsx" \
jq -r '.content'
List directory:
curl -s "$BASE_URL/file?directory=$PROJECT_PATH&path=src" \
jq -r '.[] | "\(.type): \(.path)"'
All scripts return proper exit codes:
0 = Success1 = ErrorCheck script status:
if bash ./scripts/send_message.sh "prompt"; then
echo "Success"
else
echo "Failed - check server or authentication"
fi
This skill assumes the OpenCode server is running in a trusted local environment and does not use password authentication by default.
| Task | Command |
|------|---------|
| Update providers | bash ./scripts/update_providers.sh |
| Create session | bash ./scripts/create_session.sh "$PATH" "Title" |
| Send message | bash ./scripts/send_message.sh "prompt" |
| With provider | bash ./scripts/send_message.sh "prompt" "provider" "model" |
| Monitor progress | bash ./scripts/monitor_session.sh |
| Check status | bash ./scripts/check_status.sh |
| Get changes | bash ./scripts/get_diff.sh |
| Save state | bash ./scripts/save_state.sh "$SID" "$PATH" |
| Load state | source ./scripts/load_state.sh |
| Save project | bash ./scripts/save_project.sh "name" |
| Load project | bash ./scripts/load_project.sh "name" |
| Select provider | bash ./scripts/select_provider.sh "name" "model" |
"No active session":
# Load or create session first
bash ./scripts/create_session.sh "$PROJECT_PATH" "Title"
"Provider not found":
# Update providers cache
bash ./scripts/update_providers.sh
# Check available providers
jq -r '.providers[] | .id' ./providers.json
"HTML response instead of JSON":
directory parameterFor complex workflows, state management, or advanced patterns, see:
Reference/STATE_MANAGEMENT.md - Advanced state handlingReference/PROVIDERS_REFERENCE.md - Provider selection detailsReference/EVENTS_GUIDE.md - Event monitoring patternsReference/COMPLETE_EXAMPLES.md - Full workflow examplesReference/API_QUICK_REFERENCE.md - Raw API endpointsopencode-api-control/
āāā SKILL.md # This file
āāā config.json # Configuration
āāā providers.json # Connected providers cache
āāā scripts/ # Helper scripts
ā āāā update_providers.sh
ā āāā create_session.sh
ā āāā send_message.sh
ā āāā monitor_session.sh
ā āāā check_status.sh
ā āāā get_diff.sh
ā āāā save_state.sh
ā āāā load_state.sh
ā āāā save_project.sh
ā āāā load_project.sh
ā āāā select_provider.sh
āāā state/ # Session state
ā āāā current.json
ā āāā project-name.json
āāā Reference/ # Reference docs
āāā STATE_MANAGEMENT.md
āāā PROVIDERS_REFERENCE.md
āāā EVENTS_GUIDE.md
āāā COMPLETE_EXAMPLES.md
āāā API_QUICK_REFERENCE.md
Author: Malek RSH | Repository: OpenCode-CLI-Controller
Generated Feb 24, 2026
A startup needs to quickly prototype a web application. The orchestrator uses OpenCode to generate boilerplate code, set up project structure, and implement basic CRUD operations via API commands, reducing manual coding time.
A distributed team encounters bugs in a legacy system. The orchestrator directs OpenCode to analyze code, identify issues, and suggest fixes through automated API calls, enabling remote collaboration without direct file access.
A development agency manages multiple client projects simultaneously. The orchestrator uses OpenCode to handle different sessions, track progress via monitoring scripts, and ensure tasks are completed efficiently across projects.
A tech company wants to integrate AI models for new features. The orchestrator leverages OpenCode with specified providers (e.g., Anthropic, Gemini) to generate and test code snippets, automating the implementation process.
A software team needs regular code reviews and quality assessments. The orchestrator uses OpenCode to run automated checks, generate diff summaries, and report on code changes without manual inspection.
Offer tiered subscriptions for businesses to access the OpenCode CLI API, providing automated coding and project management tools. Revenue comes from monthly or annual fees based on usage limits and features.
Provide professional services to help companies integrate OpenCode into their workflows, including custom scripting and training. Revenue is generated through project-based contracts and ongoing support fees.
Offer a free version with basic automation capabilities, while charging for advanced features like multi-session management, priority support, and enhanced monitoring tools. Revenue comes from upgrades and add-ons.
š¬ Integration Tip
Ensure the OpenCode server is fully initialized with health checks before sending API requests to avoid errors and improve reliability.
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.