Add OpenCode Provider (NanoClaw)
Step-by-step skill for swapping a NanoClaw agent group's backend from the Anthropic SDK to OpenCode (OpenRouter, DeepSeek, Google, Zen, and more).
What it does
NanoClaw runs agents in a long-lived poll loop inside a container, and the backend is chosen per group by the provider key in container.json (default claude). Trunk only ships the claude provider.
This skill walks through pulling the OpenCode provider sources from the providers branch, registering them in both the host and container barrels, installing @opencode-ai/sdk@1.4.17, adding a version-pinned opencode-ai CLI layer to the Dockerfile, and rebuilding the agent image. It also copies three guard tests — two registration guards plus a structural Dockerfile check — so broken wiring fails loudly.
Configuration coverage is unusually complete: .env shapes for DeepSeek, OpenRouter, Anthropic and OpenCode Zen, OneCLI secret registration (Bearer vs x-api-key), a safe secret-merge pattern, an overlay-refresh loop for pre-existing groups, and troubleshooting for session UUID drift, NO_PROXY, and aggressive buildkit caching.
Who it's for
- Operators self-hosting NanoClaw who want cheaper or vendor-diverse models
- Developers comfortable editing Dockerfiles and pnpm/bun build pipelines
- Teams A/B testing multiple LLM backends group by group
Examples
- Cut costs with DeepSeek — set
OPENCODE_PROVIDER=deepseekandANTHROPIC_BASE_URL=https://api.deepseek.com/v1, register the key in OneCLI, then flip one test group. - Compare models via OpenRouter — route heavy work to
anthropic/claude-sonnet-4whileOPENCODE_SMALL_MODELhandles light tasks with Haiku. - Fix
Unknown provider: opencodeafter a build — rundocker builder prune -f && ./container/build.shand copy the new provider files into eachdata/v2-sessions/*/agent-runner-src/providers/overlay.
· · · Install guide · · ·
Install in the Claude app (no terminal)
- Download the ZIP with the button below.
- In Claude, open Settings → Capabilities and turn on 'Code execution and file creation'. (one time)
- Go to Customize → Skills → + → 'Upload a skill' and upload the ZIP.
Install in Claude Code
Let Claude do it — paste this into Claude Code
Install the skill I found on Claude Skill Mart. Copy the .claude/skills/add-opencode folder from the GitHub repo nanocoai/nanoclaw into my ~/.claude/skills/add-opencode/. When it's done, tell me in one line what this skill can do.
Install with a command instead
git clone https://github.com/nanocoai/nanoclaw.git && mkdir -p ~/.claude/skills && cp -r nanoclaw/.claude/skills/add-opencode ~/.claude/skills/⚠ This is a third-party skill. Check the source repository before installing.
- Open a terminal and clone the repo:
git clone https://github.com/nanocoai/nanoclaw.git - Copy the skill where Claude Code can find it:
mkdir -p ~/.claude/skills && cp -r nanoclaw/.claude/skills/add-opencode ~/.claude/skills/ cd nanoclaw— this skill only works inside the NanoClaw repo. Make sure Docker, pnpm, bun, and OneCLI are installed.- Launch Claude Code and ask: "use the add-opencode skill to wire in the OpenCode provider".
- Follow the steps:
git fetch origin providers, copy the provider sources, appendimport './opencode.js';to both barrels, thenbun add @opencode-ai/sdk@1.4.17. Never uselatest— SDK and CLI versions must match. - Add
ARG OPENCODE_VERSION=1.4.17and a dedicatedpnpm install -g "opencode-ai@${OPENCODE_VERSION}"layer tocontainer/Dockerfile, then rebuild with./container/build.sh. - Run
pnpm run build, the container typecheck, and all three guard tests — everything must be green before moving on. - Fill in the
OPENCODE_*variables in.env, register the provider API key in OneCLI, then switch a single test group withncl groups config update --id <group-id> --provider opencode && ncl groups restart --id <group-id>and send a message to verify.