Run openclaw attach in a terminal and OpenClaw launches Claude Code against your live Gateway session with temporary, revocable access — that is the entire openclaw attach claude code hand-off, and when Claude Code exits, the access is revoked automatically. Per the official OpenClaw blog post on the feature, published 13 July 2026, the command exists for one job: letting you hand a coding task to Claude Code with the full context of one OpenClaw session, without exposing the rest of your agent setup or leaving permanent credentials lying around.
📺 Watch: Claude Code Just Got a HUGE Customization Upgrade
🔥 Get the Agent OS as a free bonus: AI Profit Boardroom members get the full Agent OS zip, prompt libraries, daily tutorials and weekly live coaching calls. → Get inside · Want AI SEO help 1-on-1? Book a free SEO strategy session →
What OpenClaw Attach Claude Code Actually Does
OpenClaw and Claude Code solve different problems. OpenClaw runs your always-on agents — the Gateway sessions holding your ongoing context, messaging channels and tools. Claude Code is a coding harness you spin up for a focused build or debugging session. The attach command bridges the two: it takes one Gateway session and makes it available to Claude Code as an MCP connection, so Claude Code can work from that session's context while it runs.
Per the July 2026 OpenClaw blog post, the sequence under the hood has four steps. OpenClaw mints a per-session access grant, writes a temporary MCP configuration file, launches Claude Code pointed at only that configuration, and revokes the grant the moment Claude Code exits. Two details in that flow are worth noticing. First, Claude Code is started with a strict configuration flag, which stops any other MCP servers configured on your machine from silently joining the attached session — the connection is exactly one session wide. Second, the bearer token travels through an environment variable rather than a command-line argument, so it never lands in your shell history.
The result is a hand-off with a built-in expiry. You are not adding Claude Code to your agent stack permanently; you are lending it one session, for one piece of work, on a timer.
The Command and Its Flags
The basic form is just openclaw attach, which targets your main session. The blog post documents four flags for everything else:
- --session — target a specific Gateway session key instead of the main session. The post's example is openclaw attach --session agent:main:telegram:123 --ttl 600000, attaching to one Telegram-bound session.
- --ttl — request how long the grant should live, in milliseconds. You ask for a positive duration, and the Gateway still applies its own ceiling, so a request for hours can come back capped.
- --bin — point at a specific Claude binary if the default claude on your path is not the one you want.
- --print-config — show the configuration and launch command without actually starting Claude Code, which is the sensible first run while you are learning what the command builds.
The command arrived in the v2026.7.1-beta release line as an external-harness attachment feature, so any current OpenClaw install has it. If yours predates that line, the OpenClaw 2.0 install guide covers getting onto a modern build first.
If you want working agent hand-offs like this turned into actual income — automations built, deployed and earning — the AI Profit Boardroom hands you the full playbook, daily tutorials and weekly live calls → see how members run OpenClaw for profit. Want AI SEO built into the same stack? Book a free SEO strategy session and map it 1-on-1.
When the Attach Workflow Beats the Alternatives
The obvious question: why not just open Claude Code in the project folder and start typing? Because the context you need often is not in a folder — it is in the OpenClaw session. The chat where you scoped the task, the notes your agent gathered, the state of the workspace it has been managing. Per the OpenClaw blog post, attach is built for exactly the hand-offs where "the selected Gateway session is the context you want Claude Code to work from" — and where temporary access beats permanent credentials.
That maps to a few practical situations:
- Escalating a task an agent started. Your OpenClaw agent has triaged a bug or drafted a change inside a session; you attach Claude Code to that session to finish the heavy coding, then detach. Pairs naturally with how OpenClaw task workspaces organise per-task state.
- Keeping tool access narrow. A permanently configured MCP bridge between Claude Code and your whole OpenClaw setup is a standing liability. Attach scopes access to one session and deletes it after use.
- Working across a team of agents. If you run several agents under one roof — the pattern the OpenClaw mission control guide describes — attach lets you drop Claude Code into precisely the lane that needs it, without the other lanes ever being visible.
For the broader picture of connecting agent systems to Claude Code — beyond OpenClaw specifically — the Hermes Agent and Claude Code guide covers the same hand-off idea from the Hermes side, and multi-agent orchestration for Claude Code goes deeper on running Claude Code as one worker among many. The attach command is OpenClaw's native, security-conscious version of that pattern.
📺 Watch: Free Claude Code Is CRAZY GOOD!
Security: What Attach Does and Does Not Protect
The OpenClaw post is refreshingly blunt about limits, and the warnings are worth repeating. A session identifier is a routing selector, not proof of authorisation — knowing a session key must never be the only thing standing between an outsider and your agent. Attach is also explicitly not a multi-user access system, and not something to expose to the public internet. The baseline controls still apply: keep the Gateway local-only, require explicit authentication, and grant tools selectively.
What attach does well is reduce blast radius inside a setup that is already sensibly secured. The strict configuration flag keeps unrelated local MCP servers out of the attached session. The TTL means a forgotten grant dies on its own. The automatic revocation on exit means the clean-up happens even when you forget. None of that replaces securing the Gateway itself — it narrows what one Claude Code session can ever see, which is the right default when you are handing an external harness the keys to live agent context.
One more operational note: attaching grants access to a session, not to your agent's long-term knowledge. What persists between sessions is governed by OpenClaw's own storage — the OpenClaw memory persistence guide explains what survives and where it lives.
Quick Reference: OpenClaw Attach at a Glance
| Piece | What it does |
|---|---|
| openclaw attach | Launches Claude Code bound to your main Gateway session with a temporary grant |
| --session | Targets a specific Gateway session key instead of the main session |
| --ttl | Requested grant lifetime in milliseconds; the Gateway applies its own ceiling |
| --bin | Uses a specific Claude binary instead of the default on your path |
| --print-config | Prints the generated configuration and launch command without starting Claude Code |
| On exit | The grant is revoked and the temporary MCP configuration is no longer usable |
Details per the official OpenClaw blog post of 13 July 2026.
OpenClaw Attach Claude Code: FAQs
Does openclaw attach give Claude Code access to all my agents?
No. The grant is scoped to one Gateway session, and Claude Code is launched with a strict configuration that blocks other MCP servers from joining. Everything outside the selected session stays invisible.
What happens when Claude Code exits?
OpenClaw revokes the grant automatically. Combined with the TTL you request at launch, access ends either when you finish or when the timer runs out — whichever comes first.
Which OpenClaw version do I need?
The command arrived in the v2026.7.1-beta release line, per the official blog post, so any install updated since mid-July 2026 includes it. Older installs should update first.
Is this how I should connect Claude Code permanently?
No — attach is deliberately temporary. If you find yourself attaching to the same session daily, that is a signal to design a proper standing integration with its own authentication, rather than stretching a short-lived grant into infrastructure. It is also worth watching where the desktop side of OpenClaw is heading — the OpenClaw desktop app guide covers what already ships there.
Verdict: A Small Command That Fixes a Real Problem
Handing an external coding tool access to live agent context used to mean either copying context around by hand or wiring up permanent credentials you would eventually regret. The openclaw attach claude code workflow replaces both with a scoped, expiring, self-cleaning grant — one command in, automatic revocation out. It fits a bigger pattern worth building towards: specialised tools, connected narrowly, coordinated deliberately — the philosophy the Agent OS is built around. And whichever model ends up doing the coding on the other side of the hand-off, the Goldie Bench write-up covers how the leading brains compare in hands-on tests, so you can pick the right one for the job.
If you want hand-offs like this earning for you — agents that research, build and ship while you sleep — check out the AI Profit Boardroom → get the complete automation playbook. And for a 1-on-1 roadmap on the AI SEO side, book a free SEO strategy session.











