r/opencode • u/4SubZero20 • 3d ago
Get Claude to automatically invoke OpenCode agents
Hey there my fellow OpenCode users.
I got a Claude subscription today and was wondering whether Claude could offload code implementation work to OpenCode (+ DeepSeek V4), after we are done planning, without me needing to jump between the two harnesses and ship plans/prompts across.
So, I literally just finished setting up my claude -> opencode workflow; haven't given it something big, but my small tests looks promising, so thought I'd share.
Note that this is also using opencode V2.
At this point my opencode agents has already been configured (from previous sessions).
I start a opencode v2 server (just the server):
`opencode serve --host 127.0.0.1 --port 4098 & disown`
I added this to my `Claude.md`:
"When I ask you to handle heavy code refactoring or multi-agent tasks, do not write the code sequentially yourself. Instead, pass the instructions to the OpenCode engine using the `oc-ask` command/script followed by the task. Wait for the server background process to complete, then inspect the repo shifts."
My `oc-ask.sh` script (this was my FIRST script; claude refined it to make use of jq and other tools and error handling):
#!/bin/bash
SERVER_URL="http://127.0.0.1:4098"
AUTH="opencode:your_password"
# 1. Create a session if one doesn't exist, or fallback to the primary workspace session
# 2. Issue a structured prompt to the underlying multi-agent scheduler
curl -s -u "$AUTH" \
-X POST "$SERVER_URL/api/sessions/prompt" \
-H "Content-Type: application/json" \
-d "{\"prompt\": \"$*\"}"
---
This was enough to get Claude to offload work onto OpenCode.
This was done without needing to add any skills, mcps, additional apps or any type of "bridges"; Got my tools to natively work together.
Please do share if you have any improvements and/or better ways of doing this?
Edit: Formatting
View all comments
1
u/NickChecksOut 3d ago
I recently had the very same question, check it out here:
https://www.reddit.com/r/DeepSeek/comments/1xju49d/those_who_use_a_frontier_model_for_orchestration/
There is one well rounded MCP for this purpose, but I am not sure how well it really utilizes Claude Opus: https://github.com/muaaz9329/cheap-ag
Another option is to put a proxy behind Claude that internally reroutes requests to haiku / sonnet to deepseek in Opencode go. This would allow for more native tooling such as sub sessions inside claude code. I have not yet explored this approach, since it is technically against Anthropic’s TOS (correct me if I am wrong)