agents / examples
AGENTS.md5.8k starsChanged 5 months agoMITView on GitHub
Self-contained demo apps that show how to use the Agents SDK. These are user-facing learning material — keep them simple, clear, and consistent. Each example should focus on one feature or concept (e.g., MCP servers, email routing, workflows). The exception is playground/, which is the kitchen-sink showcase covering the full spread of SDK features in a single app. Most examples have both a frontend and a backend. This makes them immediately runnable and visually demonstrable — users can pnpm run…
- Reads credentials
- Installs packages
Trending
More talk lately.about the whole repository
Who's talking about cloudflare/agents
- @threepointone.bsky.social“cloudflare agents: repo: github.com/cloudflare/a... platform docs: developers.cloudflare.com/agents/ …”Bluesky · Feb 25, 2025 · 66 likes
- mastra-ai/mastra“[FEATURE] Code Mode (generate + run code to orchestrate tool/MCP calls)”GitHub · Dec 9, 2025 · 6 reactions
- Chemically-Motivated-Solutions/promptcrafting-mcp“chore(deps): bump the npm_and_yarn group across 3 directories with 4 updates”GitHub · Apr 2, 2026 · 3 reactions
- @github-trending-js.bsky.social“📦 cloudflare / agents ⭐ 1,655 (+76) 🗒 TypeScript Build and deploy AI Agents on Cloudflare”Bluesky · May 2, 2025 · 3 likes
- abstractedfox/agents“Python package resolution”GitHub · Jul 21, 2026 · 2 reactions
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
- Dec 9, 2025[FEATURE] Code Mode (generate + run code to orchestrate tool/MCP calls) — mastra-ai/mastra6 reactions · 5 comments
- Apr 2, 2026chore(deps): bump the npm_and_yarn group across 3 directories with 4 updates — Chemically-Motivated-Solutions/promptcrafting-mcp3 reactions · 1 comment
- Jul 21, 2026Python package resolution — abstractedfox/agents2 reactions
- Jun 20, 2026chore(deps): bump the npm_and_yarn group across 2 directories with 13 updates — Chemically-Motivated-Solutions/promptcrafting-mcp2 reactions · 1 comment
- May 26, 2026Bump the npm_and_yarn group across 1 directory with 18 updates — GlacierEQ/context-engineering-intro2 reactions · 4 comments
28 more on GitHub
- May 23, 2026Bump the npm_and_yarn group across 1 directory with 9 updates — HarleyCoops/JinaMCP2 reactions · 1 comment
- Apr 14, 2026chore(deps): bump agents from 0.0.87 to 0.11.0 in /templates/cloudflare-mcp-server in the npm_and_yarn group across 1 directory — sipyourdrink-ltd/bernstein2 reactions · 2 comments
- Mar 23, 2026chore(deps): Bump agents from 0.2.35 to 0.7.9 in /packages/api — LoveLogicAILLC/secretforge-ai2 reactions · 4 comments
- Mar 16, 2026chore(deps): Bump agents from 0.2.35 to 0.7.6 in /packages/web — LoveLogicAILLC/secretforge-ai2 reactions · 6 comments
- Mar 16, 2026chore(deps): Bump agents from 0.2.35 to 0.7.6 in /packages/api — LoveLogicAILLC/secretforge-ai2 reactions · 5 comments
- Feb 23, 2026chore(deps): Bump agents from 0.2.35 to 0.5.1 in /packages/web — LoveLogicAILLC/secretforge-ai2 reactions · 6 comments
- Feb 20, 2026Bump the npm_and_yarn group across 3 directories with 8 updates — cbwinslow/opendiscourse_mcp2 reactions · 1 comment
- Jan 24, 2026chore(deps): Bump agents from 0.2.35 to 0.3.6 — LoveLogicAILLC/secretforge-ai2 reactions · 6 comments
- Jan 24, 2026chore(deps): Bump agents from 0.2.35 to 0.3.6 in /packages/web — LoveLogicAILLC/secretforge-ai2 reactions · 6 comments
- Jan 24, 2026chore(deps): Bump agents from 0.2.35 to 0.3.6 in /packages/api — LoveLogicAILLC/secretforge-ai2 reactions · 6 comments
- Aug 11, 2025Unknown connection regression — modelcontextprotocol/inspector2 reactions · 6 comments
- Jul 11, 2025Add instrumentation for `agents` — getsentry/sentry-javascript2 reactions · 10 comments
- Oct 5, 2026build(deps): Bump the minor-and-patch group across 1 directory with 20 updates — Themis128/cloudless.gr1 reaction · 4 comments
- Oct 2, 2026Add `Code Mode` meta tools to Reshapr tools — reshaprio/reshapr1 reaction · 2 comments
- Sep 28, 2026chore(deps): bump the npm-minor-and-patch group across 1 directory with 4 updates — grigoreo-dev/otask-mcp1 reaction · 1 comment
- Sep 25, 2026chore(deps): bump the patch-updates group across 1 directory with 12 updates — ClashKingInc/ClashKingDashboard1 reaction · 1 comment
- Sep 18, 2026chore(deps): bump the patch-updates group with 10 updates — ClashKingInc/ClashKingDashboard1 reaction · 1 comment
- Aug 27, 2026chore(deps): bump the minor-and-patch group across 1 directory with 14 updates — Themis128/cloudless.gr1 reaction · 2 comments
- Jul 29, 2026fix(cloudflare): Also skip cf: prefixed DOs — getsentry/sentry-javascript1 reaction
- Jun 5, 2026Bump agents from 0.13.3 to 0.14.1 — martinthommesen/snow-mcp1 reaction · 1 comment
- Feb 20, 2026chore(deps): Bump the npm_and_yarn group across 4 directories with 4 updates — Fadil369/givc-core-academy1 reaction
- Feb 20, 2026chore(symbolai-worker)(deps): bump agents from 0.2.35 to 0.5.1 in /symbolai-worker — llu77/-lmm1 reaction · 3 comments
- Feb 3, 2026Bump agents from 0.0.109 to 0.3.7 — vivekrp/youfirst-mcp1 reaction
- Feb 3, 2026Bump agents from 0.0.94 to 0.3.7 in /mcp-server-deepwiki-gpt — Cam10001110101/chatgpt-connector-deepwiki1 reaction
- Feb 3, 2026Bump agents from 0.0.65 to 0.3.7 — hackhit/remote-mcp-server-authless1 reaction
- Dec 1, 2025chore(symbolai-worker)(deps): bump the security group in /symbolai-worker with 2 updates — llu77/-lmm1 reaction · 2 comments
- Nov 7, 2025Bump ai and agents — vivekrp/youfirst-mcp1 reaction
- Nov 5, 2025will this be merged soon? — fghf136813721430ghase/fghf136813721430ghase1 reaction
On Bluesky · 9
- Feb 25, 2025cloudflare agents: repo: github.com/cloudflare/a... platform docs: developers.cloudflare.com/agents/ starter kit:… — @threepointone.bsky.social66 likes and reposts · 4 replies
- May 2, 2025📦 cloudflare / agents ⭐ 1,655 (+76) 🗒 TypeScript Build and deploy AI Agents on Cloudflare — @github-trending-js.bsky.social3 likes and reposts
- Mar 7, 2026Cloudflare's official SDK for building and deploying AI Agents - production-grade infrastructure for the agentic era!… — @u11g.com2 likes and reposts
- Feb 27, 2026Cloudflare Agents lets you deploy millions of persistent AI agents that cost nothing when idle - each with its own state, WebSocket sync,… — @arifsolmaz.bsky.social2 likes and reposts
- Feb 21, 2026📦 cloudflare / agents ⭐ 3,303 (+56) 🗒 TypeScript Build and deploy AI Agents on Cloudflare — @github-trending.bsky.social2 likes and reposts
4 more on Bluesky
- Feb 21, 2026📦 cloudflare / agents ⭐ 3,303 (+56) 🗒 TypeScript Build and deploy AI Agents on Cloudflare — @github-trending-js.bsky.social2 likes and reposts
- May 3, 2025📦 cloudflare / agents ⭐ 1,655 (+76) 🗒 TypeScript Build and deploy AI Agents on Cloudflare — @github-trending.bsky.social2 likes and reposts
- Mar 4, 2025Link: github.com/cloudflare/a... — @tinztwinshub.bsky.social1 likes and repost
- Oct 3, 2026Cloudflare Agents is an open-source SDK for stateful agents on Cloudflare Durable Objects. This investigation will examine its runtime,… — @smith.wiki0 likes and reposts · 1 reply
On Hacker News · 1
- Mar 4, 2025Cloudflare Agents1 point
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository15 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-think/AGENTS.mdAGENTS.md
- design/AGENTS.mdAGENTS.md
- docs/AGENTS.mdAGENTS.md
- examples/webmcp-react/AGENTS.mdAGENTS.md
- guides/AGENTS.mdAGENTS.md
- packages/agents/AGENTS.mdAGENTS.md
- packages/agents/src/tests/capabilities/AGENTS.mdAGENTS.md
- open-prSkill
- reproduceSkill
- debug-planSkill
- pirate-voiceSkill
- release-notesSkill
- test-planSkill
- workspace-digestSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
15 rules. About 0 are common, 4 are distinctive, and 11 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
11
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 90
Use wrangler.jsonc (not .toml)
- Very specific: line 94
Use "run_worker_first" to route API/agent paths to the Worker
- Very specific: line 95
Do not set "directory" in assets — the Vite plugin handles this
- Very specific: line 159
If the example needs secrets (API keys, etc.), include a .env.example showing what keys are needed:
- Very specific: line 165
Never commit actual secrets.
- Very specific: line 173
Use Kumo components (Button, Surface, Text, Badge, Empty, etc.) instead of hand-rolled HTML
- Very specific: line 174
Use @phosphor-icons/react for icons (Kumo's icon library)
- Very specific: line 175
Use Kumo semantic color tokens (text-kumo-default, bg-kumo-base, border-kumo-line, etc.) instead of raw Tailwind colors
- Very specific: line 177
Use the data-mode attribute for dark mode — no dark: Tailwind variants
- Distinctive: line 192
Every full-stack example should include:
- Distinctive: line 202
Every example should include an info card at the top of the page explaining what the demo shows.
- Very specific: line 270
Prefer @callable methods + useAgent/agent.call() over manual onRequest/agentFetch or raw WebSocket messages:
- Distinctive: line 288
Keep example-specific dependencies minimal — these ship as learning material
- Very specific: line 290
Only add dependencies in the example's package.json if they're specific to what the example demonstrates
- Distinctive: line 294
Every example needs one. Keep it short:
≈ “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.
Files
AGENTS.md — examples/
Self-contained demo apps that show how to use the Agents SDK. These are user-facing learning material — keep them simple, clear, and consistent.
Each example should focus on one feature or concept (e.g., MCP servers, email routing, workflows). The exception is playground/, which is the kitchen-sink showcase covering the full spread of SDK features in a single app.
Example shape
Most examples have both a frontend and a backend. This makes them immediately runnable and visually demonstrable — users can pnpm run start and see the feature in action, not just read server logs.
Focused protocol examples can be server-only when a frontend would obscure the concept. Keep MCP server examples minimal when they demonstrate Cloudflare Workers setup, raw transports, or elicitation behavior that must be exercised from an MCP client.
Early-access examples for a coordinated PR stack live under examples/next/.
Each runnable child is an independent workspace package matched by
examples/next/*. Harness examples are grouped under
examples/next/harnesses/*; examples/next/README.md records the stack order.
Move an example into the main catalog only after its public API stabilizes.
Full-stack examples use the Cloudflare Vite plugin for development and builds. Server-only examples use Wrangler directly.
Framework-specific examples that intentionally demonstrate a non-React client may replace the React Vite plugin with that framework's plugin. They must not install React-only UI dependencies such as Kumo or Streamdown merely to match the default example shell; accessible framework-native markup and focused CSS are appropriate for these examples. All other structural conventions still apply.
Required structure
Full-stack examples must have:
example-name/
package.json # name, dependencies, scripts
vite.config.ts # must use @cloudflare/vite-plugin
wrangler.jsonc # Workers config (not .toml)
tsconfig.json # must extend agents/tsconfig
index.html # Vite entry point
README.md # What this example demonstrates, how to run it
public/
favicon.ico # Cloudflare favicon
src/
server.ts # Worker entry point
client.tsx # React client entry
styles.css # Kumo + Tailwind importsServer-only examples must have:
example-name/
package.json # name, dependencies, scripts
wrangler.jsonc # Workers config (not .toml)
tsconfig.json
README.md # What this example demonstrates, how to run it
src/
index.ts # Worker entry pointConventions
Scripts
Full-stack examples use start (not dev) for the development server:
{
"scripts": {
"start": "vite dev",
"deploy": "vite build && wrangler deploy",
"types": "wrangler types env.d.ts --include-runtime false"
}
}Server-only examples can use Wrangler directly:
{
"scripts": {
"dev": "wrangler dev",
"deploy": "wrangler deploy",
"types": "wrangler types env.d.ts --include-runtime false"
}
}wrangler.jsonc
- Use
wrangler.jsonc(not.toml) - Include
"$schema": "./node_modules/wrangler/config-schema.json"— relative to the example root so it resolves both in the workspace and when the example is copied out and installed standalone compatibility_date: "2026-06-11",compatibility_flags: ["nodejs_compat"]- Full-stack apps with client routing: add
"assets": { "not_found_handling": "single-page-application" } - Use
"run_worker_first"to route API/agent paths to the Worker - Do not set
"directory"in assets — the Vite plugin handles this
vite.config.ts
Full-stack examples must use the React, Cloudflare, and Tailwind Vite plugins. Examples that use @callable() or other decorators must also include the agents() plugin from agents/vite:
import { cloudflare } from "@cloudflare/vite-plugin";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import agents from "agents/vite";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [agents(), react(), cloudflare(), tailwindcss()]
});The agents() plugin handles TC39 decorator transforms (Oxc doesn't support them yet). It's safe to include even if the example doesn't use decorators.
index.html
Include the theme flash prevention script and favicon:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" href="/favicon.ico" />
<title>Example Title</title>
<script>
(() => {
const stored = localStorage.getItem("theme");
const mode = stored || "light";
document.documentElement.setAttribute("data-mode", mode);
document.documentElement.style.colorScheme = mode;
})();
</script>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/client.tsx"></script>
</body>
</html>tsconfig.json
Extend the base config:
{
"extends": "agents/tsconfig"
}env.d.ts
Generated by pnpm exec wrangler types. Do not hand-edit. Regenerate when bindings change.
.env.example
If the example needs secrets (API keys, etc.), include a .env.example showing what keys are needed:
OPENAI_API_KEY=your-key-hereNever commit actual secrets. Use .env / .env.example.
UI — Kumo
Full-stack examples use Kumo (@cloudflare/kumo) for components, with Kumo's default theme (no custom overrides).
Kumo basics
- Use Kumo components (
Button,Surface,Text,Badge,Empty, etc.) instead of hand-rolled HTML - Use
@phosphor-icons/reactfor icons (Kumo's icon library) - Use Kumo semantic color tokens (
text-kumo-default,bg-kumo-base,border-kumo-line, etc.) instead of raw Tailwind colors Textdoes not accept aclassNameprop — wrap in a<span>if you need custom classes- Use the
data-modeattribute for dark mode — nodark:Tailwind variants
CSS imports (in src/styles.css)
@import "tailwindcss";
@import "@cloudflare/kumo/styles/tailwind";
/* Tailwind ignores node_modules by default, so we source Kumo for class extraction. */
@source "../node_modules/@cloudflare/kumo/dist/**/*.{js,jsx,ts,tsx}";The @source path is relative to src/styles.css, so it points at the example's own node_modules (../node_modules). That resolves both in the pnpm workspace (each package gets its own node_modules with symlinks) and when the example is copied out and installed standalone — don't use a monorepo-root-relative path like ../../../node_modules.
Required UI patterns
Every full-stack example should include:
PoweredByCloudflare(from@cloudflare/kumo) — footer attribution badge (required in every example)- A dark mode toggle — inline a simple
ModeTogglecomponent usinguseState/useEffect+localStorage+ KumoButtonwith sun/moon icons - Connection status (for WebSocket-based examples) — inline a simple
ConnectionIndicatorshowing a colored dot + label
See /design/visuals.md for detailed Kumo usage patterns and known gaps.
Explainer section
Every example should include an info card at the top of the page explaining what the demo shows. Use the consistent pattern:
<Surface className="p-4 rounded-xl ring ring-kumo-line">
<div className="flex gap-3">
<InfoIcon
size={20}
weight="bold"
className="text-kumo-accent shrink-0 mt-0.5"
/>
<div>
<Text size="sm" bold>
Title
</Text>
<span className="mt-1 block">
<Text size="xs" variant="secondary">
Description of what this demo shows and how to use it.
</Text>
</span>
</div>
</div>
</Surface>Chat message rendering
Any example with a chat UI (useAgentChat from @cloudflare/ai-chat/react or @cloudflare/think/react, or useChat) must render the full shape of an assistant turn — not just text. Reference implementations: examples/ai-chat (streamdown + complete tool states) and examples/assistant (adds reasoning + approvals + branches).
Rules:
- Render
message.partsin array order (chronological). Walk the parts with a singlemessage.parts.map(...)and branch onpart.typeinside it. Never split parts into separate buckets (e.g. all text, then all tools) — that reorders the turn and hides which tool ran between which sentences. - Assistant text →
streamdown. Render assistant text parts with<Streamdown>(markdown, code highlighting). User messages stay plain text (getMessageText(message)) — user input is rarely markdown. - Reasoning traces. Render
part.type === "reasoning"parts as a distinct, muted "Reasoning"/"Thinking" block (reasoning is on by default for reasoning-capable models). - Tool parts — render input, output, AND errors:
- Input for every tool (not just a
codefield) — render it while the call is still streaming (input-streaming/input-available) with a running indicator, and after it resolves. - Output on
output-available. - Errors on
output-error— showpart.errorTextin a clearly-distinct (red) block. Don't let failed tools render as nothing. - Handle
approval-requested/output-deniedwhere the example uses tool approval.
- Input for every tool (not just a
- Avoid empty bubbles while streaming. Text and reasoning parts arrive as
{ state: "streaming", text: "" }before the first delta — gate onpart.text.length > 0 || part.state === "streaming".
Streamdown setup
streamdown (+ @streamdown/code) are already repo dependencies. To add markdown rendering to an example:
// package.json dependencies
"streamdown": "^2.5.0",
"@streamdown/code": "^1.1.1"import { Streamdown } from "streamdown";
import { code } from "@streamdown/code";
<Streamdown
className="sd-theme"
plugins={{ code }}
controls={false}
isAnimating={isLastAssistant && isLastTextPart && isStreaming}
>
{part.text}
</Streamdown>;Tailwind ignores node_modules, so src/styles.css needs @source lines plus the .sd-theme bridge that maps Streamdown's tokens to Kumo. Copy the @source ".../streamdown/..." / @source ".../@streamdown/code/..." lines and the .sd-theme { ... } block from examples/assistant/src/styles.css verbatim.
Agent communication
Prefer @callable methods + useAgent/agent.call() over manual onRequest/agentFetch or raw WebSocket messages:
// server.ts
export class MyAgent extends Agent {
@callable()
async doSomething(arg: string) {
return { result: arg };
}
}
// client.tsx
const agent = useAgent({ agent: "my-agent", name: sessionId });
const result = await agent.call("doSomething", ["hello"]);Dependencies
- Keep example-specific dependencies minimal — these ship as learning material
- Shared dependencies (
react,vite,wrangler,@cloudflare/vite-plugin, etc.) live in the rootpackage.json - Only add dependencies in the example's
package.jsonif they're specific to what the example demonstrates
README.md
Every example needs one. Keep it short:
- One sentence: what this example demonstrates
- How to run it (
pnpm install && pnpm run startfor full-stack examples,pnpm install && pnpm run devfor server-only examples) - Any required env vars
- Code snippets showing the key pattern
- Links to related examples
Known issues to clean up
See TODO.md in this folder for the full checklist.
cross-domain/has avite.config.tsbut does not use@cloudflare/vite-plugin
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
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.

