moltworker: Instructions file for Codex

AGENTS.md

moltworker AGENTS.md is an instructions file for Codex, OpenCode from cloudflare/moltworker. It costs 2,483 tokens per session, scanned C, original, Apache-2.0.

A project guide for agents working on a Cloudflare Worker that runs OpenClaw in a Cloudflare Sandbox container.

In plain words
What is it for?
Use it when modifying the worker's gateway proxy, admin and device-pairing APIs, Cloudflare Access authentication, or debugging endpoints.
Why use it?
It gives agents the project overview, file structure, naming conventions, and environment-variable details needed to change the code safely.

Instructions file for CodexOpenCode ✓ vendor

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions AGENTS.md; built for openclaw.

This is cloudflare/moltworker's own configuration. It tells Codex and OpenCode how to work on moltworker itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything moltworker configures →

About the project

Moltworker runs OpenClaw, a personal AI assistant, inside a Cloudflare Sandbox managed through Cloudflare Workers. It is intended for people who want to deploy that assistant using Cloudflare's infrastructure and services. The catalogue entries provide instructions and a skill for operating this deployment.

cloudflare/moltworker · 9,948 stars · on GitHub · blog.cloudflare.com

Reuse

Borrowing it

Nothing to install: this file belongs to cloudflare/moltworker. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/cloudflare/moltworker/main/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/cloudflare/moltworker

Made for: Codex, OpenCode.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for moltworker AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/cloudflare/moltworker/agents-md/github.svg)](https://agentmods.dev/instructions/cloudflare/moltworker/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/cloudflare/moltworker/agents-md"><img src="https://agentmods.dev/badge/instructions/cloudflare/moltworker/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for moltworker AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/cloudflare/moltworker/agents-md"><img src="https://agentmods.dev/badge/instructions/cloudflare/moltworker/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 2,483 This file is loaded in full into every session.
When invoked 2,483 The same file — it is already loaded in full.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.02483 $0.02483
Opus 5.5 $0.00993 $0.00993
Sonnet 5.5 $0.00497 $0.00497
Haiku 4.5 $0.00248 $0.00248

Measured 2mo ago against content hash dfcf55474871, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

moltworker AGENTS.md scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- **Never delete R2 data**: The mount directory `/data/moltbot` IS the R2 bucket. Running `rm -rf /data/moltbot/*` will DELETE your backup data. Always check mount status before any destructive operations.
AGENTS.md · 262 lines

How it starts

The opening of the file, as written. The whole thing — 262 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Instructions

Guidelines for AI agents working on this codebase.

Project Overview

This is a Cloudflare Worker that runs OpenClaw (formerly Moltbot/Clawdbot) in a Cloudflare Sandbox container. It provides:

  • Proxying to the OpenClaw gateway (web UI + WebSocket)
  • Admin UI at /_admin/ for device management
  • API endpoints at /api/* for device pairing
  • Debug endpoints at /debug/* for troubleshooting

Note: The CLI tool and npm package are now named openclaw. Config files use .openclaw/openclaw.json. Legacy .clawdbot paths are supported for backward compatibility during transition.

Project Structure

src/
├── index.ts          # Main Hono app, route mounting
├── types.ts          # TypeScript type definitions
├── config.ts         # Constants (ports, timeouts, paths)
├── auth/             # Cloudflare Access authentication
│   ├── jwt.ts        # JWT verification
│   ├── jwks.ts       # JWKS fetching and caching
│   └── middleware.ts # Hono middleware for auth
├── gateway/          # OpenClaw gateway management
│   ├── process.ts    # Process lifecycle (find, start)
│   ├── env.ts        # Environment variable building
│   ├── r2.ts         # R2 bucket mounting
│   ├── sync.ts       # R2 backup sync logic
│   └── utils.ts      # Shared utilities (waitForProcess)
├── routes/           # API route handlers
│   ├── api.ts        # /api/* endpoints (devices, gateway)
│   ├── admin.ts      # /_admin/* static file serving
│   └── debug.ts      # /debug/* endpoints
└── client/           # React admin UI (Vite)
    ├── App.tsx
    ├── api.ts        # API client
    └── pages/

Key Patterns

Environment Variables

  • DEV_MODE - Skips CF Access auth AND bypasses device pairing (maps to OPENCLAW_DEV_MODE for container)
  • DEBUG_ROUTES - Enables /debug/* routes (disabled by default)
  • See src/types.ts for full MoltbotEnv interface

CLI Commands

When calling the OpenClaw CLI from the worker, always include --url ws://localhost:18789:

sandbox.startProcess('openclaw devices list --json --url ws://localhost:18789')

Read the full file on GitHub · 262 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2mo ago First seen · 262 lines · 2,483 tokens per session scan C dfcf55474871

Subscribe to this mod's changes

moltworker AGENTS.md is an instructions file published in the GitHub repository cloudflare/moltworker (9,948 stars, last pushed 6mo ago), licensed Apache-2.0. It adds 2,483 tokens to every session, about $0.0099 per session on Opus 5.5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

moltworker AGENTS.md compared with instructions from other repositories

moltworker AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
moltworker AGENTS.mdcloudflare/moltworkerInstructions file9.9k6mo agoApache-2.0C2,483Codex, OpenCode
plan-forge naming.instructions.mdsrnichols/plan-forgeInstructions file63d agoMITA1,453GitHub Copilot
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,516GitHub Copilot
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot