A skill for Claude Code CLI that saves thousands of tokens by delegating complex tasks to OpenCode subagent.
Note: This is a skill for the Claude Code CLI tool, not a standalone application. You must have Claude Code installed to use it.
Requirements: This skill requires OpenCode (via ACP protocol) and Node.js to function.
Delegates complex tasks to a separate AI agent (OpenCode) through the ACP protocol, saving your main Claude conversation from consuming excessive tokens.
Think of it as hiring a specialized contractor: you provide the objective, they do the work independently, and you get the results without all the back-and-forth that would fill your conversation history.
- Without this skill: Main Claude reads every file → analyzes → edits → repeats. Each iteration consumes thousands of tokens.
- With this skill: Send objective to subagent → subagent works independently → get final results. Only the summary enters your conversation.
Typical savings: 50-90% fewer tokens for complex tasks.
How it achieves savings: OpenCode subagent uses free tokens to call alternative models (e.g., GLM-4.7, Qwen) instead of your paid Claude tokens.
What this means:
- ✅ Token savings: You pay nothing for the subagent's work
⚠️ Capability trade-off: Alternative models have lower reasoning ability compared to Claude⚠️ Quality variance: Results may be less nuanced or require review
Best use cases:
- Code refactoring and formatting (straightforward)
- Documentation updates and generation
- Test code generation
- Bug fixes with clear requirements
- Batch file operations
Consider alternatives for:
- Complex architecture decisions
- Nuanced code reviews
- Sensitive logic changes
- Tasks requiring deep domain expertise
- Main Claude stays responsive for other tasks
- Subagent works in parallel
- No context window limitations for the subtask
Perfect for:
- Multi-file refactoring: "Add type hints to all Python files"
- Batch operations: "Update all documentation files"
- Code reviews: "Review the entire codebase for security issues"
- Git workflows: "Create a pull request with these changes"
- You describe the task (one sentence is enough)
- OpenCode subagent receives your objective and works independently
- Results are saved to a file (not your conversation)
- You get a concise summary in your main conversation
The subagent can read files, make edits, run tests, and more—just like a full developer—without consuming your main conversation's context.
You need three things installed:
- Claude Code CLI (already installed if you're using this)
- OpenCode CLI (
npm install -g opencode) - Node.js (comes with most systems)
# 1. Install OpenCode (if not already)
npm install -g opencode
# 2. Copy the skill to Claude
cp -r skills/invoke-opencode-acp ~/.claude/skills/
# 3. Verify it works (optional)
node ~/.claude/skills/invoke-opencode-acp/tests/test_acp_client.jsCheck that OpenCode is installed:
opencode --versionCheck that the skill exists:
ls ~/.claude/skills/invoke-opencode-acp/SKILL.mdSimply tell Claude what you want done:
"Refactor all Python files in this project to use type hints"
Claude will delegate the task to OpenCode subagent and return the results.
Timeout guidelines (OpenCode is slow):
- Simple tasks (math, short answers): 180s (3min) minimum
- Medium tasks (single file, ~100 lines): 600s (10min) minimum
- Complex tasks (multi-file, refactoring): 1800s (30min) minimum
Example tasks:
- "Refactor the entire codebase"
- "Update the README.md with new instructions"
- "Add type hints to all Python files"
- "Run security audit on the codebase"
Your request: "Add type hints to all Python files in this project"
Without this skill:
- Claude reads each file (10,000 tokens)
- Claude edits each file (15,000 tokens)
- Claude verifies changes (8,000 tokens)
- Total: ~33,000 tokens consumed
With this skill:
- You send the objective (50 tokens)
- Subagent works independently (0 tokens in your conversation)
- You get a summary (200 tokens)
- Total: ~250 tokens consumed
Savings: 99% token reduction!
Your request: "Review the entire codebase for security vulnerabilities"
Without this skill:
- Claude reads every source file (25,000 tokens)
- Claude analyzes and documents (12,000 tokens)
- Total: ~37,000 tokens
With this skill:
- Objective + summary (~300 tokens)
- Total: ~300 tokens
Savings: 99% token reduction!
Your request: "Update all .md files to include the new license header"
Without this skill:
- Claude reads 20 markdown files (15,000 tokens)
- Claude edits each file (20,000 tokens)
- Total: ~35,000 tokens
With this skill:
- Objective + summary (~250 tokens)
- Total: ~250 tokens
Savings: 99% token reduction!
✅ Use this skill for:
- Tasks affecting 2+ files
- Refactoring or restructuring
- Batch operations (find and replace across many files)
- Code reviews across the entire codebase
- Multi-step tasks requiring research and analysis
- Git workflows (commit, push, pull request)
❌ Don't use for:
- Single file quick edits
- Simple text replacements
- Tasks requiring integration with your main conversation
| Aspect | Normal Claude | With invoke-opencode-acp |
|---|---|---|
| Context usage | Full file contents | Just objective |
| Token consumption | High (thousands) | Low (hundreds) |
| Your conversation | Shows all steps | Shows only results |
| Speed | Sequential | Parallel |
| Best for | Simple tasks | Complex tasks |
- Claude Projects: Still uses main context window (limited tokens)
- Manual delegation: Requires copy-pasting, no automation
- invoke-opencode-acp: Automated delegation with minimal context usage
"opencode command not found"
npm install -g opencode"Skill not enabled"
- Check the skill is in
~/.claude/skills/invoke-opencode-acp/ - Restart Claude Code
- Enable in Claude Code settings
Task timeout
- Increase the
-tparameter value - See timeout guidelines in Usage section
- OpenCode can be slow, especially for complex tasks
This skill uses the ACP (Agent Control Protocol) to communicate with OpenCode:
- Launches
opencode acpvia Node.js child_process - Creates a dedicated session via JSON-RPC
- Sends your task via
session/prompt - Streams results via
session/updateevents - Filters out
<thinking>tags - Returns only the final output
Implementation: skills/invoke-opencode-acp/acp_client.js (192 lines)
MIT License - See LICENSE for details.
中文版本:README.zh.md 日本語版本:README.ja.md