Stop burning tokens: the Claude Code + OpenClaw development loop
Split coding from orchestration to cut OpenClaw token costs by 80%. Git-based handoff loop between Claude Code and OpenClaw for faster, cheaper development.
A serious development session inside OpenClaw — building a backend service, debugging integrations, iterating on an API — can burn €50 to €100+ in Sonnet tokens before you're halfway done. Not because anything is broken. OpenClaw maintains workspace state, loads context aggressively, runs reasoning loops, and executes tool calls at every step. That's what makes orchestration work. It also makes writing CRUD endpoints absurdly expensive.
The root cause: OpenClaw is built for system-level reasoning. Using it to write unit tests is like using a torque wrench to hammer nails.
Separate orchestration from coding
Split the work across two tools:
| Tool | Role |
|---|---|
| OpenClaw | Architecture, orchestration, integration validation |
| Claude Code | Implementation, tests, refactoring, documentation |
Claude Code runs on a flat subscription — roughly €17/month. Heavy coding stays inside that fixed cost. OpenClaw only touches the project when you need system-level reasoning: designing architecture, validating integrations, identifying edge cases across components.
I've seen the cost difference approach 80% on projects that would otherwise be pure Sonnet sessions.
Git as the interface between agents
Git becomes the contract between the two environments. OpenClaw commits architecture decisions. Claude Code commits implementation. Neither needs to know what the other did internally — they read the current state of the repository and work from there.
A clean repo structure matters:
repo/
├─ src/
├─ tests/
├─ docs/
├─ requirements.md
├─ architecture.md
└─ README.md
The requirements.md file is the single source of truth — the spec Claude Code reads to understand what to build, and that OpenClaw updates when scope changes. Treat it like a contract, not a rough draft.
Commit at every handoff. This gives you reproducible history and easy rollbacks if a reasoning pass goes sideways.
OpenClaw designs the framework
Start in OpenClaw, but use a cheap reasoning model like DeepSeek Chat for this phase. You don't need Sonnet to sketch architecture.
The goal is to produce artifacts, not code:
requirements.md— what the system must doarchitecture.md— how it's structured, what components exist- Initial file layout — empty files or stubs showing intended structure
- API contracts — endpoint signatures, request/response shapes, error codes
- Task list — ordered implementation work
Keep actual coding minimal. OpenClaw should define the skeleton, not fill it in. A few lines of boilerplate per file is fine. Full implementations are not.
Once the skeleton exists:
git init
git add .
git commit -m "Initial architecture and requirements"
git push
That push is the handoff.
Claude Code implements the project
Claude Code checks out the repository, reads requirements.md and architecture.md, and starts building.
This is where it earns the subscription cost. It's genuinely excellent at:
- Implementing full features from a spec
- Writing clean, idiomatic code
- Building test suites with meaningful coverage
- Running tests locally and fixing failures
- Writing inline documentation and README sections
- First-pass refactoring once features work
A typical session for a backend service:
→ Implement authentication module per architecture.md
→ Write unit tests for auth module
→ Implement user CRUD endpoints
→ Write integration tests hitting the endpoints
→ Fix three failing tests
→ Update README with setup instructions
→ Run black + isort
All of that inside the subscription. No per-token cost. When the session ends:
git add .
git commit -m "Implement auth module and user endpoints with tests"
git push
OpenClaw validates the integration
Pull the repository back into OpenClaw. Now use it for what it's actually good at.
git pull
OpenClaw's job at this stage:
- Does the implemented code match the architecture spec?
- Are there interaction bugs between components that unit tests wouldn't catch?
- Missing edge cases in the API contracts?
- Does error handling hold up across the full request lifecycle?
OpenClaw will find things Claude Code missed — not because Claude Code is worse at coding, but because integration-level reasoning requires holding the whole system in context simultaneously. That's exactly what OpenClaw's context management is built for.
The output is a list of issues, not fixes:
## Integration issues found
1. Auth token expiry not propagated to downstream services
2. User deletion endpoint doesn't cascade to related resources
3. Rate limiting applied before auth check — should be reversed
4. Missing error response for malformed JSON body
Commit this as an updated requirements file, push, and hand back to Claude Code.
The iteration loop
Development becomes a tight cycle:
OpenClaw → architecture / integration feedback / issue identification
↓
Claude Code → implementation / tests / fixes / refactoring
↓
git commit → git push → git pull
↓
repeat
Each tool operates at its natural level. Claude Code never reasons about system architecture. OpenClaw never writes a for-loop. Git keeps them cleanly separated.
A backend service that might take a full day of pure OpenClaw sessions can move through architecture, implementation, and validation in a few hours — at a fraction of the cost.
The final refactoring pass
Once the project stabilises — tests pass, integration issues resolved, spec fully implemented — hand the repo to Claude Code one last time.
- Unify coding style across modules written in different sessions
- Simplify architecture that got complicated during iteration
- Expand docstrings and documentation
- Remove dead code and unused imports
- Finalise test coverage and add missing edge cases
This pass is cheap. Pure coding work with no architectural ambiguity.
When this works and when it doesn't
Best suited for backend services, APIs, automation tools, CLI tools, infrastructure code — anything that will eventually integrate into an OpenClaw workflow.
Less useful for very small scripts (overhead isn't worth it), exploratory prototyping (you don't have a spec to hand off), or one-off tasks where total coding time is under an hour.
Practical tips
Keep OpenClaw prompts short. You're paying for reasoning, not context. Don't paste full codebases when you want an architectural opinion — describe the structure and let it reason from there.
Commit at every handoff. Don't pass a dirty working directory between tools. Every handoff is a commit.
Treat requirements.md as immutable during implementation. Changes to requirements go through OpenClaw, get committed, then Claude Code picks them up. Don't let Claude Code modify the spec.
Let Claude Code own the tests. OpenClaw identifies what needs testing at an integration level. Claude Code writes the actual test code.
Avoid writing code inside OpenClaw unless it's glue logic. The moment you're implementing business logic in an OpenClaw session, you're burning expensive tokens on cheap work.
The principle
OpenClaw is excellent at what it's designed for. The mistake is using it for everything.
Implementation, testing, refactoring, documentation — those belong in Claude Code at a flat subscription cost. Architecture, integration validation, system-level reasoning — those belong in OpenClaw where the context management justifies the token spend.
Git is the handshake. Every commit is a clean handoff. Every pull is a fresh context load. The agents never need to know about each other — just the current state of the repo.
You can paste this post's URL into Claude Code or your AI assistant of choice for context when setting up this workflow.
Where to run this
You need a VPS that can run OpenClaw reliably. Hetzner gives you €10 credit on signup — a CX22 at €4.85/month handles OpenClaw and your Git repos without drama. It's what this blog runs on.
If you'd rather skip the self-hosting entirely, xCloud offers managed OpenClaw hosting. Point, click, deploy — you still get the same hybrid workflow, just without maintaining the server yourself.
For teams that want the orchestration layer without the infrastructure work, ClawTrust is an AI automation platform that handles the OpenClaw side of this loop as a managed service.
(Affiliate links — I get a small cut if you sign up, at no cost to you.)