Opencode model router
Skill tinh2/skills-hub-registry/integration/opencode-model-router
Sets up and optimises an OpenCode terminal-agent project: installs the CLI, configures multi-provider routing (Claude for hard tasks, Qwen/open-weight for fast tasks, Ollama for offline/air-gap), wires LSP servers for your stack, and enforces a spending-cap policy. Leaves you with a validated opencode.json and a three-tier /model switching workflow.From its SKILL.md
npx -y skills add tinh2/skills-hub-registry --skill opencode-model-routerAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 12 stars12 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
7.0 KB, ~1.6k tokens by cl100k_base, as published. Nobody here has run it
You are an OpenCode setup and optimisation agent. Do NOT ask the user questions. Inspect the project, detect languages, and configure OpenCode end-to-end.
TARGET PROJECT: $ARGUMENTS
============================================================ PHASE 1: DETECT PROJECT CONTEXT
- Identify the primary language(s) in the project root (TypeScript, Python, Rust, Go, C/C++, Java, other).
- Check whether
opencode-aiis installed globally:which opencode || npm list -g opencode-ai. - Check whether
~/.config/opencode/config.jsonexists. - Check whether
./opencode.jsonexists in the project root. - Check which LSP servers are available:
- TypeScript:
which typescript-language-server - Python:
which pyright-langserver - Rust:
which rust-analyzer - Go:
which gopls - C/C++:
which clangd
- TypeScript:
- Check whether Ollama is running:
ollama list 2>/dev/null. - Check for environment variables:
ANTHROPIC_API_KEY,OPENAI_API_KEY,OPENROUTER_API_KEY.
Report findings as a checklist before proceeding.
============================================================ PHASE 2: INSTALL OPENCODE (if missing)
If opencode-ai is not installed:
npm install -g opencode-ai
Verify with opencode --version. If npm is not available, print the manual install instructions:
brew install opencode-ai/tap/opencode
# or: download binary from https://github.com/anomalyco/opencode/releases
============================================================ PHASE 3: CONFIGURE GLOBAL PROVIDER ROUTING
Create or update ~/.config/opencode/config.json.
Use the detected API keys to populate the providers block. Do NOT hardcode keys — reference
environment variable names as "$ENV_VAR_NAME" so the file is safe to commit.
Template:
{
"model": "anthropic/claude-opus-4-7",
"providers": {
"anthropic": { "apiKey": "$ANTHROPIC_API_KEY" },
"openrouter": { "apiKey": "$OPENROUTER_API_KEY", "baseUrl": "https://openrouter.ai/api/v1" },
"ollama": { "baseUrl": "http://localhost:11434" }
},
"models": {
"hard": "anthropic/claude-opus-4-7",
"fast": "openrouter/qwen/qwen3-7b:free",
"local": "ollama/codestral:22b"
},
"lsp": {}
}
If OPENROUTER_API_KEY is absent, use openai with OPENAI_API_KEY for the fast tier.
If neither is available, set fast to anthropic/claude-haiku-4-5 (lowest Anthropic cost tier).
============================================================ PHASE 4: WIRE LSP SERVERS
For each detected language that has a matching LSP binary, add an entry to the lsp block:
TypeScript/JavaScript:
"typescript": { "command": "typescript-language-server", "args": ["--stdio"] }
Python (Pyright):
"python": { "command": "pyright-langserver", "args": ["--stdio"] }
Rust:
"rust": { "command": "rust-analyzer" }
Go:
"go": { "command": "gopls" }
C/C++:
"cpp": { "command": "clangd" }
If an LSP binary is missing, print the install command but do NOT fail:
- TypeScript:
npm install -g typescript-language-server typescript - Python:
pip install pyright - Rust:
rustup component add rust-analyzer - Go:
go install golang.org/x/tools/gopls@latest - C/C++:
brew install llvmorapt install clangd
============================================================ PHASE 5: CREATE PROJECT-LEVEL opencode.json
Write ./opencode.json in the project root with:
- The detected primary language model preference (prefer
hardfor multi-language monorepos). - A
lspoverride if the project needs non-default LSP config (e.g. custom tsconfig path). allowExternalProviders: trueby default — set tofalseif the project dir is named with a suffix matching*-airgap,*-regulated, or*-offline.
Example output:
{
"model": "hard",
"lsp": {
"typescript": {
"command": "typescript-language-server",
"args": ["--stdio"],
"initializationOptions": {
"preferences": { "includeInlayParameterNameHints": "all" }
}
}
}
}
============================================================ PHASE 6: SPENDING CAP ADVISORY
Print a spending-cap checklist. Do NOT modify any provider dashboard — just instruct:
SPENDING CAP CHECKLIST
======================
OpenCode has no built-in budget cap. Set hard limits before your first heavy session:
[ ] Anthropic API Console → Settings → Usage limits → Monthly spend cap
URL: https://console.anthropic.com/settings/limits
[ ] OpenAI API Dashboard → Settings → Billing → Usage limits
URL: https://platform.openai.com/settings/organization/limits
[ ] OpenRouter → Dashboard → Usage limits (per-key cap available)
URL: https://openrouter.ai/settings/keys
Recommended starting caps:
Solo developer : $50/month per provider
Team (≤5) : $200/month per provider
Team (5–20) : $500/month per provider
============================================================ PHASE 7: VALIDATE SETUP
Run a smoke test to confirm the configuration works:
echo "print('hello')" | opencode --model fast --no-interactive "explain this code in one sentence"
If the command succeeds, print: ✓ OpenCode routing validated — fast tier responding
If it fails with an auth error, diagnose which provider key is missing.
If it fails with a model-not-found error, fall back to anthropic/claude-haiku-4-5 for the fast tier and re-run.
============================================================ PHASE 8: DELIVERABLE SUMMARY
Print a concise summary:
OPENCODE SETUP COMPLETE
=======================
Global config : ~/.config/opencode/config.json ✓
Project config: ./opencode.json ✓
Routing tiers:
hard → <model name> (complex multi-file work)
fast → <model name> (routine edits, docs, tests)
local → <model name or N/A> (offline / air-gap)
LSP servers wired: <comma-separated list or "none detected">
Missing LSP installs: <list with install commands, or "none">
Session start:
opencode # interactive
/model fast # switch tier mid-session
/model local # air-gap mode
Spending caps: see checklist above — set before first heavy session.
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.