agentleFS
CloudflareKnown publishercloudflare/agents/AGENTS.md

agents

AGENTS.md5.8k starsChanged 5 months agoMITView on GitHub

Cloudflare Agents SDK — a framework for building stateful AI agents on Cloudflare Workers. This is a monorepo containing the core SDK packages, examples, guides, sites, and documentation. Some directories have their own AGENTS.md with deeper guidance: Node 24+ required. Uses pnpm workspaces with Nx for task orchestration, caching, and affected detection. Run from the repo root: Run an exampl

  • Reads credentials
  • Installs packages

Trending

More talk lately.about the whole repository

Dec 2025: 2 mentionsJan 2026: 3 mentionsFeb 2026: 10 mentionsMar 2026: 4 mentionsApr 2026: 2 mentionsMay 2026: 2 mentionsJun 2026: 2 mentionsJul 2026: 2 mentionsAug 2026: 1 mentionSep 2026: 3 mentionsOct 2026: 3 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the cloudflare/agents repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about cloudflare/agents

The biggest 5 of 43 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 43

Talked about on GitHub, Bluesky and Hacker News (43 times).

On GitHub · 33

28 more on GitHub

On Bluesky · 9

4 more on Bluesky

On Hacker News · 1

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

17 rules. About 0 are common, 9 are distinctive, and 8 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈9

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 8

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Run from the repo root:

    line 62
  2. Distinctive:

    Run an example locally:

    line 77
  3. Very specific:

    Run pnpm run format to format all files

    line 109
  4. Distinctive:

    Always TypeScript, always ES modules

    line 114
  5. Very specific:

    All wrangler configs use compatibility_date: "2026-06-11" and compatibility_flags: ["nodejs_compat"]

    line 116
  6. Very specific:

    Never hardcode secrets — use wrangler secret put or .env

    line 117
  7. Distinctive:

    No native/FFI dependencies (must run in Workers runtime)

    line 118
  8. Very specific:

    Keep Workspace as a pure durable filesystem — do not embed execution or session logic inside it.

    line 170
  9. Distinctive:

    When a package boundary feels wrong (e.g., a helper package depending on a larger package just for an adapter), prefer moving the adapter …

    line 171
  10. Very specific:

    Run pnpm run check before considering work done

    line 177
  11. Very specific:

    Use import type for type-only imports (enforced by verbatimModuleSyntax)

    line 178
  12. Distinctive:

    Keep examples simple and self-contained — they're user-facing learning material

    line 179
  13. Distinctive:

    Use Cloudflare Workers APIs (KV, D1, R2, Durable Objects, etc.) over third-party equivalents

    line 180
  14. Distinctive:

    Use Workers AI for LLM calls in examples — not third-party APIs like OpenAI or Anthropic

    line 181
  15. Very specific:

    Add native/FFI/C-binding dependencies

    line 192
  16. Very specific:

    Use any — Oxlint will reject it

    line 193
  17. Distinctive:

    Use CommonJS or Service Worker format — ES modules only

    line 194

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md

Project overview

Cloudflare Agents SDK — a framework for building stateful AI agents on Cloudflare Workers. This is a monorepo containing the core SDK packages, examples, guides, sites, and documentation.

Repository structure

packages/          # Published npm packages (need changesets for changes)
  agents/          # Core SDK (see packages/agents/AGENTS.md)
  ai-chat/         # @cloudflare/ai-chat — higher-level AI chat agent
  hono-agents/     # Hono framework integration
  codemode/        # @cloudflare/codemode — experimental code generation

examples/          # Self-contained demo apps (see examples/AGENTS.md)
  playground/      # Main showcase app — all SDK features in one UI (uses Kumo design system)
  mcp/             # MCP server example
  mcp-client/      # MCP client example
  ...              # ~20 examples total

experimental/      # Work-in-progress experiments (not published, no stability guarantees)

site/              # Deployed websites
  agents/          # agents.cloudflare.com (Astro)
  ai-playground/   # Workers AI playground (React + Vite)

guides/            # In-depth pattern tutorials with narrative READMEs (see guides/AGENTS.md)
  anthropic-patterns/
  human-in-the-loop/

openai-sdk/        # Examples using @openai/agents SDK
  basic/ chess-app/ handoffs/ human-in-the-loop/ ...

docs/              # Markdown docs for developers.cloudflare.com (see docs/AGENTS.md)
design/            # Architecture and design decision records (see design/AGENTS.md)
scripts/           # Repo-wide tooling (typecheck, export checks, update checks)

Nested AGENTS.md files

Some directories have their own AGENTS.md with deeper guidance:

FileScope
packages/agents/AGENTS.mdCore SDK internals — exports, source layout, build, testing, architecture
examples/AGENTS.mdExample conventions — required structure, consistency rules, known issues
guides/AGENTS.mdGuide conventions — how guides differ from examples, README expectations
docs/AGENTS.mdWriting user-facing docs — Diátaxis framework, upstream sync, style
design/AGENTS.mdDesign records and RFCs — format, workflow, relationship to docs

Setup

pnpm install       # installs all workspaces

Node 24+ required. Uses pnpm workspaces with Nx for task orchestration, caching, and affected detection.

Commands

Run from the repo root:

CommandWhat it does
pnpm run buildBuilds all packages via Nx (cached, dependency-ordered)
pnpm run checkFull CI check: sherif + export checks + oxfmt + oxlint + typecheck
pnpm run testRuns all tests via Nx (cached)
pnpm run test:reactRuns Playwright-based React hook tests for agents
pnpm run typecheckTypeScript type checking across the repo (custom script)
pnpm run formatOxfmt format all files
pnpm run check:exportsVerifies package.json exports match actual build output
pnpm exec nx affected -t buildBuild only packages affected by current changes
pnpm exec nx affected -t testTest only packages affected by current changes
pnpm exec nx run <project>:buildBuild a single project (and its dependencies)

Run an example locally:

cd examples/playground   # or any example
pnpm dev                 # starts Vite dev server + Workers runtime via @cloudflare/vite-plugin

Example apps will normally hot reload when the dev server is running. When the dev server is running, make sure to rebuild changed packages (pnpm run build) to see changes reflected in the running app.

Code standards

TypeScript

  • Strict mode enabled (agents/tsconfig)
  • Target: ES2021, module: ES2022, moduleResolution: bundler
  • verbatimModuleSyntax: true — use explicit import type for type-only imports
  • JSX: react-jsx

Linting — Oxlint

Config in .oxlintrc.json. Plugins: react, jsx-a11y, typescript, react-hooks. Key rules:

  • no-explicit-any: "error" — never use any, use unknown and narrow
  • no-unused-vars: "error" — with varsIgnorePattern: "^_" and argsIgnorePattern: "^_"
  • correctness category set to "error" — catches common mistakes
  • jsx-a11y rules enabled — accessibility violations are errors
  • react-hooks/exhaustive-deps: "warn" — warns on missing hook dependencies

Oxlint does not handle formatting — Oxfmt does.

Formatting — Oxfmt

  • Run pnpm run format to format all files
  • Config in .oxfmtrc.json (trailingComma: "none", printWidth: 80)

Workers conventions

  • Always TypeScript, always ES modules
  • wrangler.jsonc (not .toml) for configuration
  • All wrangler configs use compatibility_date: "2026-06-11" and compatibility_flags: ["nodejs_compat"]
  • Never hardcode secrets — use wrangler secret put or .env
  • No native/FFI dependencies (must run in Workers runtime)

Testing

Tests use vitest with @cloudflare/vitest-pool-workers for running inside the Workers runtime.

pnpm run test             # agents + ai-chat unit/integration tests
pnpm run test:react       # Playwright-based React hook tests (agents package)

Test locations:

  • packages/agents/src/tests/ — core SDK tests
  • packages/agents/src/react-tests/ — React hook tests (Playwright + vitest-browser-react)
  • packages/ai-chat/src/tests/ — AI chat tests
  • packages/agents/src/tests-d/ — type-level tests (.test-d.ts)

Each test directory has its own vitest.config.ts and (for Workers tests) a wrangler.jsonc.

For a repo-wide rollup of what proves feature X works, at which layer, and which CI run guards it — plus the tracked skip/quarantine debt — see design/test-coverage-matrix.md.

Contributing

Changesets

Changes to packages/ that affect the public API or fix bugs need a changeset:

pnpm exec changeset       # interactive prompt — pick packages, semver bump, description

This creates a markdown file in .changeset/ that gets consumed during release.

Examples, guides, and sites don't need changesets.

Pull request process

CI runs on every PR (pnpm install --frozen-lockfile && pnpm run build && pnpm run check && pnpm exec nx affected -t test); the workflow is in .github/workflows/pullrequest.yml. On push to main the Release workflow (.github/workflows/release.yml) runs the same steps but uses nx run-many -t test as a safety net against under-reported affected projects, then publishes via changesets. All checks must pass.

Generated files

  • env.d.ts files are generated by wrangler types — regenerate with pnpm exec wrangler types inside the relevant example/package, don't hand-edit
  • pnpm-lock.yaml — regenerated by pnpm install, don't hand-edit

Learned Workspace Facts

  • packages/shell/ is published as @cloudflare/shell — an experimental sandboxed JS execution and filesystem runtime for agents, built on the same dynamic Worker loader machinery as @cloudflare/codemode.
  • To run code against a Workspace: import stateTools from @cloudflare/shell/workers and DynamicWorkerExecutor/resolveProvider from @cloudflare/codemode; use executor.execute(code, [resolveProvider(stateTools(workspace))]).

Learned User Preferences

  • Keep Workspace as a pure durable filesystem — do not embed execution or session logic inside it. Execution is a caller concern wired via @cloudflare/codemode + stateTools.
  • When a package boundary feels wrong (e.g., a helper package depending on a larger package just for an adapter), prefer moving the adapter out rather than carrying the dependency.

Boundaries

Always:

  • Run pnpm run check before considering work done
  • Use import type for type-only imports (enforced by verbatimModuleSyntax)
  • Keep examples simple and self-contained — they're user-facing learning material
  • Use Cloudflare Workers APIs (KV, D1, R2, Durable Objects, etc.) over third-party equivalents
  • Use Workers AI for LLM calls in examples — not third-party APIs like OpenAI or Anthropic

Ask first:

  • Adding new dependencies to packages/ (these ship to users)
  • Changing wrangler.jsonc compatibility dates across the repo
  • Modifying CI workflows

Never:

  • Hardcode secrets or API keys
  • Add native/FFI/C-binding dependencies
  • Use any — Oxlint will reject it
  • Use CommonJS or Service Worker format — ES modules only
  • Modify node_modules/ or dist/ directories
  • Force push to main

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.