OpenCode hit Hacker News this week with 1,148 upvotes and 564 comments. If you've been building with AI tools for more than six months, you probably understand why — it's fast, open-source, and it finally feels like a coding agent that doesn't need babysitting.
But here's the question showing up in those 564 comments: "How does this fit with OpenClaw?"
The short answer: they don't compete. OpenCode writes your code. OpenClaw runs your operations. Used together, they cover most of what a solo developer needs to stay productive without hiring anyone.
This post explains what each tool actually does, where they overlap (barely), and how to wire them into a two-agent developer stack.
What OpenCode Does
OpenCode is a terminal-based coding agent. You point it at a repo, describe a task, and it reads files, makes edits, runs tests, and iterates. It's designed to stay in your terminal and integrate with your existing tools — no new UI, no cloud account required.
The 120K GitHub stars and 5 million monthly active developers aren't a coincidence. OpenCode hits a sweet spot: it's powerful enough to handle real tasks but light enough that you actually understand what it's doing. You can review every file it touches.
OpenCode's job is task-level code work: write a function, fix a bug, refactor a module, explain a codebase. It's a focused agent with a narrow scope, and that's what makes it good.
What OpenClaw Does
OpenClaw is a self-hosted AI gateway that runs persistent agents — agents with memory, schedules, channel integrations, and tool access. Where OpenCode handles a task you request, an OpenClaw agent handles tasks on its own, on a schedule, while you're doing something else.
Your OpenClaw agent might be watching for deploy failures and pinging you on Telegram. Or it might be triaging your Gmail inbox every morning and filing attachments into Drive. Or running a content production workflow on a daily cron job. These agents don't wait for you to type a command — they run on HEARTBEAT schedules and event triggers.
OpenClaw agents are configured entirely in plain markdown files: SOUL.md defines personality and boundaries, AGENTS.md defines behavior and memory rules, HEARTBEAT.md defines scheduled tasks. If you want to know what your agent can and can't do, you read the files. There's no hidden logic, no opaque JSON state machine — just text files you can version-control and diff.
Where They Overlap (And Why It Doesn't Matter)
Both tools involve an LLM doing work on your behalf. That's where the overlap ends.
OpenCode operates in synchronous, interactive mode: you're present, you review diffs, you approve changes. It's optimized for a developer who's actively working.
OpenClaw operates in asynchronous, autonomous mode: you configure it once, it runs continuously, it messages you when something needs attention. It's optimized for work that shouldn't require you to be present.
The mental model: OpenCode is a pair programmer. OpenClaw is a reliable employee. You work with your pair programmer during the day. Your employee handles the recurring work while you're focused elsewhere.
Some developers worry about overlap when they see that OpenClaw can also run code. Yes, OpenClaw has exec access. But that access is controlled by explicit tool permissions and sandboxing — you specify exactly what commands an agent can run and in what directory. It's not a general-purpose coding agent; it's an operations agent that can run specific, pre-approved commands as part of a defined workflow.
The Two-Agent Developer Stack
Here's a concrete setup that covers most of a solo developer's daily cognitive load.
Agent 1: OpenCode (Coding Tasks)
Use OpenCode interactively for:
- Writing new features from a spec
- Fixing bugs you hand it from test output
- Refactoring modules you point at
- Explaining unfamiliar codebases
- Generating boilerplate (tests, configs, migrations)
OpenCode doesn't need persistent memory for this. Each session is self-contained. You open your terminal, describe the task, review the output, merge or discard. Done.
Agent 2: OpenClaw (Operations and Monitoring)
Use OpenClaw for everything that should happen without you:
- Deploy watchdog: Check health endpoints every 5 minutes. Send a Telegram message if any return non-200.
- Daily digest: Pull yesterday's GitHub activity, error logs, and open issues. Send a morning summary to your phone.
- Inbox triage: Read new Gmail messages, flag anything marked urgent, file invoices into Drive.
- Cost alerts: Monitor your API usage via provider endpoints. Alert if daily spend exceeds a threshold.
A HEARTBEAT.md entry for the deploy watchdog looks like this:
## Check: deploy-health
- Schedule: every 5 minutes
- Task: GET https://yourapp.com/health — if status != 200, send Telegram alert with response body
- Channel: telegram
- On-failure: alert only, do not retry automatically
This runs whether you're at your desk or not. Making an agent reliable enough to run daily is a different discipline than building it in the first place — but the reward is real automation instead of a demo that impresses for five minutes.
How They Hand Off to Each Other
The interesting part of a two-agent stack is the handoff.
Your OpenClaw ops agent notices that your build is failing. It sends you a Telegram message with the error. You open your terminal, paste the error into OpenCode, and ask it to fix the failing test. OpenCode writes the fix. You review, merge, push. OpenClaw picks up the new green health check and stops alerting.
That loop — OpenClaw detects, you delegate to OpenCode, OpenCode fixes, OpenClaw confirms — handles most of the day-to-day fire drills without either agent needing to know the other exists. They communicate through you, which is the right design. You stay in the loop, you understand every action taken, and neither agent is granted more access than it needs.
Common Mistakes
- Giving OpenClaw write access to your repos. It doesn't need it. OpenClaw should report problems, not fix them — that's OpenCode's job. Keep tool permissions minimal.
- Running OpenCode on production branches without a review step. OpenCode is fast and often right. But "often right" is not "always right." Run it on a feature branch, review the diff, then merge.
- Leaving OpenClaw sessions running without a HEARTBEAT schedule. Idle continuous sessions burn tokens for nothing. Context accumulates and costs mount. Schedule what you need, scope the session tightly.
- Conflating the two tools' models. OpenCode is stateless by design. OpenClaw is stateful by design. Don't try to make OpenCode remember yesterday's context or OpenClaw handle interactive coding sessions — use each for what it's built for.
Security Guardrails
- Never put raw API keys in SOUL.md or AGENTS.md. Use environment variables or a vault. Your config files will end up in git; your credentials shouldn't.
- Restrict OpenClaw's exec tool to a specific directory and a pre-approved command list. "Can run shell commands" is not a permission — "can run
./scripts/health-check.shin/var/app" is. - Review OpenCode's diffs before merging. AI-generated code can introduce subtle issues that pass tests but create security gaps. Treat every diff as a code review, not a rubber stamp.
- Audit your OpenClaw SOUL.md and AGENTS.md regularly. If you can't explain every boundary and permission in your config in two minutes, tighten it. Transparent configs are the whole point.
Getting Started This Weekend
If you want to try the two-agent setup, here's the minimum viable version:
-
Install OpenCode: Follow the official install instructions at the OpenCode GitHub repo. Five minutes on a machine with Node or Go.
-
Set up an OpenClaw agent: Use the OpenAgents.mom wizard to generate a workspace bundle for your first ops agent. Answer the interview questions, download the ZIP, deploy to your server. Fifteen minutes.
-
Wire one HEARTBEAT task: Start with the simplest useful automation. A morning digest. A health check. A daily backup confirmation. One task, running reliably, is more valuable than ten tasks that almost work.
-
Build the handoff loop: Once your OpenClaw agent is alerting you to something real, practice the loop: get the alert, hand it to OpenCode, review the fix, close the loop. That workflow compounds.
The goal isn't a clever architecture. The goal is fewer things you have to remember to check manually.
Set Up Your Operations Agent in 15 Minutes
OpenCode handles the coding. OpenAgents.mom generates the OpenClaw workspace bundle that handles everything else — deploy monitoring, inbox triage, daily digests, and more. Answer a guided interview, download your files, deploy to your server.