OpenCode Orchestrator
Trigger Workflow
Use the /use-opencode slash command to invoke this skill:
/use-opencode
This will guide you through constructing an optimal handoff to OpenCode.
When to Use OpenCode
| Use OpenCode When | Stay in Antigravity When |
|---|---|
| Multi-file refactoring across 15+ files | Quick single-file edits |
| Long-running code generation tasks | Answering questions about code |
| Tasks requiring Plan Mode review | Browser-based testing |
| Deep codebase exploration | Tasks needing current conversation context |
| Specialized model requirements | Interactive debugging with user |
1. Capabilities
Available Tools (within OpenCode)
- File read/write/search operations
- Shell command execution
- Code analysis and refactoring
- Git operations
- Web search and URL reading
2. Handoff Protocol
OpenCode does NOT share Antigravity's conversation context. You must explicitly provide:
- File Paths: Absolute paths to all relevant files
- Task Context: Background information and requirements
- Constraints: Any specific approaches to use or avoid
- Success Criteria: Clear definition of done
Command Structure
opencode run "YOUR_DETAILED_PROMPT"
Optional Flags
| Flag | Purpose | Example |
|---|---|---|
-m MODEL |
Specify model | -m github-copilot/claude-sonnet-4 |
-a AGENT |
Use custom agent | -a code-reviewer |
--plan |
Force Plan Mode | Review before execution |
3. Prompt Construction
<context>
Project: [Project name and type]
Working Directory: [Absolute path]
Related Files: [List of relevant file paths]
</context>
<background>
[Any necessary context not obvious from files]
</background>
<task>
[Clear, specific task description]
</task>
<requirements>
- [Specific requirement 1]
- [Specific requirement 2]
</requirements>
<constraints>
- [What to avoid or preserve]
</constraints>
<success_criteria>
- [How to know the task is complete]
</success_criteria>
4. Model Selection
For Code-Heavy Tasks
opencode run -m github-copilot/claude-sonnet-4 "..."
# or
opencode run -m github-copilot/gemini-3-pro "..."
For Research/Documentation
opencode run -m github-copilot/gpt-4o "..."
Check Available Models
opencode models
Default Behavior
If no -m flag is provided, OpenCode uses the model configured in:
~/.opencode.json$XDG_CONFIG_HOME/opencode/.opencode.json./.opencode.json(project-local)
5. Example Workflows
Code Review Delegation
opencode run "
<context>
Repository: /home/user/project
Branch: feature/new-auth
Compare against: main
</context>
<task>
Review the changes in the current branch compared to main.
Focus on security, performance, and code quality.
</task>
<requirements>
- Check for SQL injection vulnerabilities
- Identify N+1 query patterns
- Note any breaking API changes
</requirements>
<success_criteria>
- Written review summary in REVIEW.md
- Critical issues clearly flagged
- Suggested improvements provided
</success_criteria>
"
Research and Documentation
opencode run -m github-copilot/gpt-4o "
<context>
Project: /home/user/project
Tech Stack: Node.js, PostgreSQL, Redis
</context>
<task>
Research caching strategies for our API endpoints and create an implementation plan.
</task>
<requirements>
- Consider Redis caching patterns
- Evaluate cache invalidation strategies
- Account for our microservices architecture
</requirements>
<success_criteria>
- CACHING_PLAN.md created with recommendations
- Code examples for key patterns
- Migration steps outlined
</success_criteria>
"
6. Integration with Antigravity Workflow
When delegating from Antigravity to OpenCode:
- Prepare Context: Gather all relevant file paths and requirements
- Construct Prompt: Use the structured template above
- Execute Handoff: Run via
run_commandtool - Monitor Output: Read OpenCode's logs and final result
- Verify Results: Check file changes and run tests
- Continue Work: Resume in Antigravity with updated codebase
Artifact Coordination
OpenCode may create its own files (plans, documentation). After handoff:
- Check for new files in the working directory
- Review any generated documentation
- Incorporate findings into Antigravity artifacts if relevant
When to Bring Work Back
Return work to Antigravity when:
- Browser testing is needed
- User interaction is required
- Results need integration with current conversation
- Visual verification is needed
7. Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
ProviderModelNotFoundError |
Invalid model identifier | Run opencode models to list available models |
| Context too short | Auto-compact triggered | Task is self-contained; continue monitoring |
| Permission denied | File access issues | OpenCode runs with user permissions; check file ownership |
| Timeout | Long-running task | Increase WaitMsBeforeAsync or send to background |
Model-Specific Notes
- GitHub Copilot models: Require active Copilot subscription
- Anthropic models: Best for complex reasoning and code generation
- Gemini models: Strong at multi-file understanding
- OpenAI models: Effective for research and documentation
Debugging Commands
# Check OpenCode configuration
cat ~/.opencode.json
# List available models
opencode models
# List configured agents
opencode agent list
# Check authentication status
opencode auth status
8. Advanced: Custom Agents
opencode agent create
This launches an interactive wizard to define:
- Agent name and description
- Custom system prompt
- Tool permissions
- Default model
Then invoke with:
opencode run -a my-custom-agent "Task description"
Example Use Cases
- Code Reviewer: Specialized prompts for security and performance review
- Documentation Writer: Focused on JSDoc/TSDoc generation
- Test Generator: Configured for your testing framework
Quick Reference
# Basic execution
opencode run "Your task description"
# With specific model
opencode run -m github-copilot/claude-sonnet-4 "Task"
# With custom agent
opencode run -a custom-agent "Task"
# Check available models
opencode models
# Check available agents
opencode agent list