cf-opencode

Close the laptop. The agent keeps working.

cf-opencode runs OpenCode in a workspace on Cloudflare Containers, in your own account. The workspace sleeps when it is idle and wakes when you connect.

npx cf-opencode init

Open source, Apache-2.0. Not affiliated with Cloudflare or OpenCode.

$ cf-opencode connect0.4s container ready2.4s egress CA: trusted3.4s repo: cloned4.9s workspace ready; opencode on port 40964.9s spawn done
A first connect from a private repository. OpenCode opens next.

One workspace, one day

You pay for compute while the workspace is awake. It is awake while you or the agent work.

  1. 09:00You connect and give the agent a task
  2. 09:40Laptop closed. The agent works on
  3. 11:30Task done. 20 idle minutes
  4. 11:50Paused. The disk is a snapshot. No compute
  5. 15:10You connect. It wakes in a few seconds, with the session

An example day. The times are an illustration; the 20-minute idle pause is the default.

What you get

Your account, your data
The Worker, the containers and the snapshots are in your Cloudflare account. There is no hosted service between you and them.
No model key
Models run through your account's Workers AI and AI Gateway. You make no API key and store none.
Private repositories work
Setup connects GitHub one time. Workspaces clone, push and run gh. The token stays in the Worker and never enters a workspace.
Idle time costs nothing
An idle workspace saves its disk and stops. The next connect restores the files, the installed tools and the session.
A full Linux machine
A terminal in tmux, SSH, sudo apt-get, web search and a browser. cf-opencode preview 3000 opens the agent's dev server at localhost on your machine.
Hand off a task
cf-opencode run "<task>" starts an agent in the workspace and returns. cf-opencode tasks shows the result: the summary, the branch and the pull request.

How it works

  1. Install

    npx cf-opencode init

    This checks your machine, then deploys one Worker and the workspace image into your Cloudflare account.

  2. Connect

    npx cf-opencode connect

    Run it in a git checkout. It starts a workspace, clones the repository there, and opens your local OpenCode against it.

  3. Leave and come back

    npx cf-opencode connect --continue

    The agent works with no client attached. When you return, this opens the last session in the workspace.

What you need

  • Node 22 or newer
  • Docker, with the buildx plugin
  • A Cloudflare account on the Workers Paid plan
  • OpenCode 2 on your machine

What it costs

cf-opencode is free. Cloudflare bills your account for what a workspace uses: container time while it is awake, model usage, and browser hours. The docs list the limits.

Limits and costs