Cloudflare Agents Agent Rules

An SDK for building stateful AI agents on Cloudflare Workers.

Overview

Cloudflare Agents gives packages, examples, tutorials, and design records their own local instructions. The root guide explains the split between runtime and browser tests, generated bindings, and public package releases.

Documents

├── 
├── design
│   ├── 
│   └── 
├── docs
│   └── 
├── examples
│   └── 
├── guides
│   └── 
├── packages
│   └── agents
│       └── 
└── wip
    └── 

Techniques in this file

01 / Router files

Route by the purpose of a directory

The nested-guide table separates SDK internals from examples, narrative tutorials, user documentation, and design records. The routing carries writing and consistency expectations as well as code conventions.

Source excerpt starting at line 42.
Some directories have their own AGENTS.md with deeper guidance:

02 / Verification by change type

Distinguish runtime tests from browser hook tests

Workers tests run in the Workers pool, while React hooks use a separate Playwright-based command and directory. The guide also points to a coverage matrix that maps features to layers and CI evidence.

Source excerpt starting at line 125.
pnpm run test             # agents + ai-chat unit/integration testspnpm run test:react       # Playwright-based React hook tests (agents package)

03 / Generated file guards

Name the generator for environment types

Environment declaration files must be regenerated inside the relevant package or example. The command and working directory matter because bindings are scoped to that configuration.

Source excerpt starting at line 160.
- `env.d.ts` files are generated by `wrangler types` — regenerate with `pnpm exec wrangler types` inside the relevant example/package, don't hand-edit

04 / Contribution etiquette

Keep published behavior distinct from learning material

Public API and bug-fix changes in packages need changesets. Examples, guides, and sites do not, so the rule follows what is released to package consumers.

Source excerpt starting at line 152.
Examples, guides, and sites don't need changesets.

Ideas for your repo

  1. Route documentation and examples by their purpose, not just their file type.
  2. State which tests exercise the actual runtime and which require a browser.
  3. Put the generator and working directory beside generated-file restrictions.
  4. Base release-note requirements on the published surface.
Sponsored byModem

Give your agents the whole story.

These instructions explain how to work in Cloudflare Agents. Modem shows your agents what customers said, who is affected, and what changed.

See how Modem works