Skip to content

Cloudflare's Code Mode and Shotcup

Cloudflare's Code Mode and Shotcup serve the same pattern: a model writes a program that calls tools, and the program runs in a sandbox. Cloudflare runs that program in an isolated Worker on its own platform, or in the browser. Shotcup is a hosted runner you call over HTTPS or MCP from wherever your agent runs. There is no integration package between the two.

What Cloudflare's Code Mode is

Cloudflare introduced Code Mode in September 2025: convert MCP tools into a TypeScript API, and ask the model to write code that calls that API. Its Code Mode package (@cloudflare/codemode, marked experimental) offers createCodeTool() for the Vercel AI SDK and TanStack AI and a browser variant, and runs the code with an executor. DynamicWorkerExecutor runs each execution in an isolated Worker through the Worker Loader API, with outbound network access blocked unless you allow it, and IframeSandboxExecutor runs it in a sandboxed iframe in the browser. The program reaches your tools only through calls routed back to your code. A runtime on top of the executor records every tool call and can pause a run at a connector tool marked requiresApproval, then continue it by replaying the log once someone approves. The package also defines an Executor interface for other executors. Shotcup does not ship one.

How Shotcup relates

Shotcup runs the same kind of program as a service:

  • Where it runs. You send the program to Shotcup's API or MCP server from any backend, agent framework or MCP client. You do not need a Cloudflare account or to deploy anything. Shotcup's sandboxes and API run in the same EU region.
  • How the program reaches your tools. Declared tools become functions the program calls as await tools.crm.listCustomers(...). Your process answers each call live, or a call to a tool declared with approval: true pauses the run. The pause is a token that any process with your API key can resume within 24 hours (durable code mode).
  • What comes back. Besides what the program prints, every run answers with a diff of the files it changed and the files it wrote under /out: images, PDFs, spreadsheets and documents, with links.
  • Repeatable runs. Runs are deterministic by default: the clock is fixed and randomness is seeded, so the same program and files give the same output.
  • The language. Shotcup runs TypeScript and JavaScript as ES modules in GocciaScript; the default "strict" profile accepts semicolon insertion, var, function, classic for, while, labels and for...in with strict semantics. ==, arguments and sloppy mode need "non-strict"; a construct the run's profile leaves out fails with a hint that says what to write instead.

Choose Cloudflare's Code Mode when your agent already runs on Cloudflare and you want the program next to it. Choose Shotcup when your agent runs elsewhere, or when you want files and documents back from the run. The comparison puts Shotcup next to Cloudflare's isolates and containers, with prices and limits.

Running a Code Mode program on Shotcup

A program a model wrote for Code Mode is an async arrow function that calls codemode.<name>() and returns its result. On Shotcup the program is a module: the same calls go to declared tools as tools.<name>(), it awaits at the top level, and it prints its result or writes it under /out:

JavaScript
const customers = await tools.crm.listCustomers({ segment: "enterprise" });
const invoices = await tools.billing.getInvoices({ since: "2025-10-01" });
console.log(JSON.stringify({ customers: customers.length, invoices: invoices.length }));

Declare crm.listCustomers and billing.getInvoices with the run and answer them from your process. Code mode has the request, the stream of calls and a worked example.

This page as Markdown: /docs/cloudflare-code-mode.md