← All Guides

Coding Agent Guide

Hermes Agent + OpenCode: Handing Coding Jobs to the Open-Source Coding Agent

OpenCode is an open-source coding agent for the terminal. Hermes Agent is an always-on agent that lives in your chat apps. Hermes ships a skill that lets it start OpenCode, give it a coding task, watch it work and report back. This guide covers what that skill does, what you need installed, and how it differs from putting an OpenCode Go key into Hermes.

Which OpenCode page do you need?

“OpenCode” names both a coding agent and a model subscription, and they solve different problems:

  • OpenCode Go as Hermes’s model backend — one key for Kimi, Qwen, DeepSeek, GLM and more, used by Hermes for its own replies. See OpenCode Go on Hermes Agent.
  • OpenCode as a product — how a terminal coding agent compares with a managed agent platform. See OpenClaw Launch vs OpenCode.
  • OpenCode working for Hermes — Hermes delegating coding tasks to the OpenCode CLI. This page.

What OpenCode is

OpenCode is an MIT-licensed coding agent with a terminal UI and a scriptable CLI. It reads and edits files, runs commands, reviews pull requests, and keeps named sessions you can resume. It is provider-agnostic: you log in to whichever model providers you use with opencode auth login, or set their API keys as environment variables, and switch models per task. It ships two built-in agents, build for making changes and plan for read-only analysis.

Hermes Agent does a different job. It runs as a long-lived gateway on Telegram, Discord, Slack and other platforms, with memory, skills and scheduled tasks. Pairing them lets you send a coding request from your phone and have a real coding agent carry it out on the machine where the repo lives.

How Hermes delegates to OpenCode

Upstream Hermes bundles an opencode skill in skills/autonomous-ai-agents/, the same folder as its claude-code and codex skills. There is no special integration layer: the skill tells Hermes which OpenCode commands to run through its terminal tool and how to supervise them with its process tool. The skill loads when you ask for OpenCode by name, or when Hermes decides an external coding agent suits the task.

One-shot tasks with opencode run

For a bounded task, Hermes runs a single non-interactive command in the project folder. It needs no PTY and exits when done:

terminal(command="opencode run 'Add retry logic to API calls and update tests'", workdir="~/project")

# attach files, force a model, or show thinking
opencode run 'Review this config for security issues' -f config.yaml
opencode run 'Refactor the auth module' --model openrouter/anthropic/claude-sonnet-4
opencode run 'Debug why tests fail in CI' --thinking

Other flags the skill documents: --agent plan for analysis only, --format json for machine-readable events, --variant for reasoning effort, -c or -s <id> to continue a session, and --attach <url> to reuse a running OpenCode server.

Long sessions in the background

For work that needs back-and-forth, Hermes starts the TUI with background=true, pty=true, sends prompts with process(action="submit"), and checks progress with poll or log. Two quirks the skill calls out: Enter sometimes has to be pressed twice to submit, and /exit is not an OpenCode command. Hermes ends the session with Ctrl+C or by killing the process.

PR review and parallel work

OpenCode has a built-in opencode pr 42 command, and the skill also shows a review run in a throwaway clone. For several tasks at once, Hermes gives each OpenCode run its own directory or git worktree, since two sessions sharing a folder will trip over each other’s edits. When a run finishes, the skill has Hermes summarise the files changed, the test results and what is left, so the reply in your chat is a report rather than a raw log. opencode stats shows token use and cost afterwards.

Setup prerequisites

  1. Install OpenCode where Hermes runs. npm i -g opencode-ai@latest or brew install anomalyco/tap/opencode. The skill only calls the binary; it cannot install it.
  2. Give OpenCode a provider. Run opencode auth login, or export a key such as OPENROUTER_API_KEY. opencode auth list should show at least one provider.
  3. Check which binary Hermes sees. Hermes’s shell can resolve a different opencode than your terminal. Compare which -a opencode and opencode --version, and pin a full path such as ~/.opencode/bin/opencode if they differ.
  4. Work inside a git repo. Changes are easy to review and revert, and worktrees keep parallel runs apart.
  5. Smoke test. Ask Hermes to run opencode run 'Respond with exactly: OPENCODE_SMOKE_OK'. The marker in the output with no provider errors means the chain works.

OpenCode edits files and runs commands on its own, so point it at a checkout you can afford to throw away, not a directory with secrets or your only copy of the work.

OpenCode vs OpenCode Go: which one you are setting up

OpenCode (this page)OpenCode Go
What it isA coding agent programA model subscription with one API key
Role in HermesA worker Hermes launches for repo tasksHermes’s own LLM backend
What you set upInstall the opencode binary and log it inAdd the key as a provider
Who pays for tokensWhatever provider OpenCode is logged in toYour OpenCode Go plan
GuideYou are hereOpenCode Go on Hermes

They combine well. Hermes can reply on an OpenCode Go model, and OpenCode can also be logged in to OpenCode Go, so one subscription can pay for both the chat and the coding runs.

How it compares with Hermes + Codex and Claude Code

The three delegation skills share a shape: a CLI run through terminal, long jobs supervised with process, one workdir per task. The difference is the tool behind them. Codex ties you to OpenAI models and a ChatGPT or API login, Claude Code to Anthropic’s. OpenCode is the pick when you want to choose the model per task, or already pay for a provider the other two cannot use. Hermes has no bundled skill for Gemini CLI, though it can still drive it through terminal.

The OpenClaw equivalent

OpenClaw rolls all three into one bundled coding-agent skill. It becomes available when any of claude, codex or opencode is installed, and in current upstream source it also has to be switched on with skills.entries.coding-agent.enabled. For OpenCode it runs opencode run with pty:true background:true in an isolated git worktree it prepares first. The worker then reports its result with openclaw message send instead of relying on a heartbeat, so the reply lands in the chat you asked from. If you want OpenCode Go models as OpenClaw’s own brain, see OpenClaw + OpenCode Go.

On OpenClaw Launch

The opencode skill runs the CLI on whatever machine Hermes itself runs on. For repositories on your laptop, the practical split is to keep OpenCode local for coding and let a hosted bot on OpenClaw Launch handle the always-on part: Telegram, Discord, memory and schedules, without a server to keep alive. If you want the hosted bot to think with Kimi, Qwen or DeepSeek, add an OpenCode Go key on the API Keys page as described in the OpenCode Go guide.

Hermes + OpenCode FAQ

Does Hermes Agent support OpenCode out of the box?

Yes. Upstream Hermes ships an opencode skill under skills/autonomous-ai-agents/, next to its claude-code and codex skills. It teaches Hermes to run the OpenCode CLI through its terminal and process tools. The skill does not install OpenCode for you: the opencode binary has to be on the machine and logged in to at least one provider.

Is this the same as using an OpenCode Go key in Hermes?

No. An OpenCode Go key makes a model gateway Hermes’s own LLM backend, so Hermes itself thinks with Kimi, Qwen, DeepSeek or GLM. That is covered in OpenCode Go on Hermes Agent. This page is about OpenCode the coding agent: a separate program Hermes starts to do repo work. You can use either one, or both.

Which model does OpenCode use when Hermes calls it?

Whatever OpenCode is configured with, not Hermes’s model. OpenCode is provider-agnostic: opencode auth login or provider environment variables decide what it can reach, and opencode run … --model provider/model forces a specific one for a single task. So a Hermes bot can chat on one model while OpenCode codes on another.

Why does /exit not close OpenCode when Hermes drives it?

Because /exit is not an OpenCode command. The Hermes skill warns that it opens an agent selector instead. To end an interactive session, Hermes sends Ctrl+C through the process tool or kills the process. For most automation you can avoid the question by using opencode run, which exits on its own.

Can OpenClaw use OpenCode too?

Yes. OpenClaw bundles a coding-agent skill that delegates to Claude Code, Codex or OpenCode, whichever binary is present. For OpenCode it launches opencode run in the background with a PTY inside an isolated worktree, and the worker reports back with openclaw message send when it finishes.

Related guides

Run Hermes 24/7 without a server

OpenClaw Launch hosts Hermes Agent and OpenClaw with Telegram, Discord and more connected in minutes. Keep OpenCode where your code lives; let the hosted bot handle the always-on part.

Deploy Managed Hermes