workers-sdk / wrangler
AGENTS.md4.6k starsChanged 6 months agoApache-2.0View on GitHub
Wrangler-specific context only. See root AGENTS.md for monorepo conventions. Main CLI for Cloudflare Workers. ~2k-line yargs command tree in src/index.ts. Entry point is src/cli.ts (NOT src/index.ts). - No console.* — use logger singleton - No __dirname / __filename — use getBasePath() - No global fetch — use undici's fetch - Route Cloudflare v4 API calls through the existing cfetch helpers such as fetchResult, fetchListResult, and fetchPagedListResult when possible; do not use global or undici fetch directly. Prefer these helpers over…
Trending
Quiet since August.about the whole repository
Who's talking about cloudflare/workers-sdk
- cloudflare/workerd“🐛 BUG: The cache field on RequestInitializerDict is not implemented in fetch”GitHub · Apr 7, 2023 · 85 reactions
- sveltejs/kit“feat: Vite environment API”GitHub · Jul 17, 2025 · 31 reactions
- remix-run/remix“Cloudflare support for Vite”GitHub · Jan 16, 2024 · 25 reactions
- cloudflare/workerd“🐛 BUG: Workers TTFB slows down based on unused dynamic imports (additional modules)”GitHub · Mar 27, 2024 · 22 reactions
- withastro/astro“Cloudflare adapter returning [object Object]”GitHub · Oct 10, 2025 · 18 reactions
The biggest 5 of 17 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 17
Talked about on GitHub, Bluesky and Hacker News (17 times).
On GitHub · 14
- Apr 7, 2023🐛 BUG: The cache field on RequestInitializerDict is not implemented in fetch — cloudflare/workerd85 reactions · 61 comments
- Jul 17, 2025feat: Vite environment API — sveltejs/kit31 reactions · 16 comments
- Jan 16, 2024Cloudflare support for Vite — remix-run/remix25 reactions · 21 comments
- Mar 27, 2024🐛 BUG: Workers TTFB slows down based on unused dynamic imports (additional modules) — cloudflare/workerd22 reactions · 6 comments
- Oct 10, 2025Cloudflare adapter returning [object Object] — withastro/astro18 reactions · 15 comments
9 more on GitHub
- May 24, 2023Support Node Compat in Cloudflare Adaptor — sveltejs/kit17 reactions · 2 comments
- Oct 17, 2024Support Wrangler, the CLI for Cloudflare Workers — denoland/deno15 reactions · 8 comments
- Aug 10, 2026feat: `@cloudflare/vite-plugin` integration, take 2 — sveltejs/kit11 reactions · 5 comments
- Jul 22, 2023Feature Request — Runtime APIs: Superfluous throws — cloudflare/workerd11 reactions
- Oct 29, 2025Add --target=cloudflare support to bundler — oven-sh/bun8 reactions · 10 comments
- Nov 6, 2025placement just got better (finally) — cloudflare/cloudflare-docs7 reactions · 6 comments
- Oct 28, 2025vitest 4.0 fails with "TypeError: filename.replace is not a function" — withastro/astro7 reactions · 3 comments
- May 23, 2025'scopes' for Secret Store's secrets not retained in local development — cloudflare/developer-platform7 reactions · 7 comments
- Jul 23, 2024bun fetch to wrangler dev server crashes server and fails with "socket connection was closed unexpectedly" — oven-sh/bun7 reactions · 20 comments
On Bluesky · 2
- Oct 20, 2023📦 cloudflare / workers-sdk ⭐ 1,781 (+48) 🗒 TypeScript ⛅️ Home to Wrangler, the CLI for Cloudflare Workers® — @github-trending-js.bsky.social1 likes and repost
- Oct 20, 2023📦 cloudflare / workers-sdk ⭐ 1,734 (+4) 🗒 TypeScript ⛅️ Home to Wrangler, the CLI for Cloudflare Workers® — @github-trending.bsky.social1 likes and repost
On Hacker News · 1
- May 2, 2026Cloudflare Workers let you deploy serverless code instantly across the globe3 points
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 repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- packages/auto-triage-bot/AGENTS.mdAGENTS.md
- packages/create-cloudflare/AGENTS.mdAGENTS.md
- packages/miniflare/AGENTS.mdAGENTS.md
- packages/vite-plugin-cloudflare/AGENTS.mdAGENTS.md
- packages/vitest-plugin/AGENTS.mdAGENTS.md
- packages/workers-auth/AGENTS.mdAGENTS.md
- packages/workers-utils/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- local-explorerSkill
The file
We split this AGENTS.md into the rules it gives an agent
5 rules. About 0 are common, 1 is distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 32
No global fetch — use undici's fetch
- Distinctive: line 41
Keep the service/area first and the failure last so telemetry groups consistently.
- Very specific: line 62
Test files use .test.ts (not .spec.ts)
- Very specific: line 63
Never import expect from vitest — use test context ({ expect }) => {}
- Very specific: line 64
When adding expect as a parameter to helper functions, check ALL call sites (e.g., across deployments.test.ts, versions.test.ts)
≈ “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
Wrangler — Agent Guide
Wrangler-specific context only. See root AGENTS.md for monorepo conventions.
Overview
Main CLI for Cloudflare Workers. ~2k-line yargs command tree in src/index.ts. Entry point is src/cli.ts (NOT src/index.ts).
Structure
src/— CLI sourcesrc/__tests__/— Unit tests, helpers insrc/__tests__/helpers/e2e/— E2E tests, requires Cloudflare credentialsbin/wrangler.js— Shim that spawns Node to runwrangler-dist/cli.js, forwarding stdio and IPCbin/cf-wrangler.js—cf-wranglerdelegate entrypoint. Owns verb dispatch, argv parsing (parseCfWranglerArgs), and theStartDevOptionsliteral; hands off torunCfWranglerDevfromwrangler-dist/cli.jsin-process (no re-spawn — the parent tool owns the Node runtime)src/containers/ssh.ts— Thin command adapter; SSH options, authorization request, and transport live in@cloudflare/containers-shared/src/ssh.ts, shared with cf.src/cf-wrangler/— Thecf-wranglerdelegate entrypoint (see below)src/containers/images.ts— Command/presentation adapter; registry image operations live incontainers-shared/src/registry-images.ts, shared with cf.templates/— Worker templates
Entry Points
src/cli.ts— Build entry AND library API surface (dual-purpose). Callsmain()when run directly; re-exports./apiwhen imported as library. Also re-exportsparseCfWranglerArgs,parseCfWranglerBuildArgs,ArgParseError,runCfWranglerDev, andrunCfWranglerBuildfor thecf-wranglerbin to call in-process.src/index.ts— Yargs CLI tree builder (large file). Exportsmain(). NOT the package entry point despite the name.src/api/index.ts— Public programmatic API barrel.src/cf-wrangler/— Thecf-wranglerdelegate entrypoint, an experimental escape hatch for projects that can't use@cloudflare/vite-plugin. It exposesdev+ four flags (--mode,--port,--host,--local) andbuild+--mode; the wrangler config file is found via wrangler's standard discovery (no--configflag). Preview build context is supplied throughCLOUDFLARE_PREVIEW_BUILD, matching framework-owned build commands. It is NOT a separate package and does NOT use theunstable_devtest harness. It shares its spawn contract (verb dispatch, flag vocabulary, exit-2 feature detection) with the siblingcf-vitedelegate in@cloudflare/vite-plugin.bin/cf-wrangler.jsowns verb dispatch, argv parsing, and theStartDevOptionsliteral;src/cf-wrangler/dev.ts(exported asrunCfWranglerDev) wrapsstartDevin the experimental-flags context and waits for teardown.src/cf-wrangler/build.ts(exported asrunCfWranglerBuild) runs the Build Output Specification path used bywrangler build --experimental-new-config --experimental-cf-build-output, producing.cloudflare/output/v0.src/cf-wrangler/args.ts(exported asparseCfWranglerArgs,parseCfWranglerBuildArgs, andArgParseError) does the strict argv parse. The "unknown subcommand" error doubles as a feature-detection signal for the parent CLI.
Conventions (Wrangler-Specific)
- No
console.*— useloggersingleton - No
__dirname/__filename— usegetBasePath() - No global
fetch— use undici's fetch - Route Cloudflare v4 API calls through the existing
cfetchhelpers such asfetchResult,fetchListResult, andfetchPagedListResultwhen possible; do not use global or undicifetchdirectly. Prefer these helpers over adding or passing thecloudflarepackage solely for a simple request, and use the Cloudflare TypeScript SDK when its generated API surface or behavior is materially useful. telemetryMessagevalues forUserError-compatible errors must be static, safe labels. Do not usetelemetryMessage: trueunless the user-facing message cannot include user input, file paths, resource names, IDs, secret names, raw API messages, or command input. Even when safe,telemetryMessage: trueis usually less useful because user-facing copy is harder to group and parse than a stable telemetry label.- Format
telemetryMessagevalues as lower-case phrases:<service or area> <command or sub-area> <failure>, for examplekv namespace binding not found in config,r2 object put file not found, orpages deploy project name missing. - Keep the service/area first and the failure last so telemetry groups consistently. Prefer stable categories over user-facing copy; telemetry labels should not change just because CLI wording changes.
Build
- tsup: single entry
src/cli.ts→wrangler-dist/cli.js package.jsonmainpoints atwrangler-dist/cli.js- Custom
embedWorkersPlugin()bundles Worker templates via esbuild for tests
Testing
- Pool:
"forks"(not threads) — heavy global mocking runWrangler(cmd)callsmain()in-process (no subprocess)- MSW for API mocking — pre-built handlers per API domain in
src/__tests__/helpers/msw/ - Shared helpers:
runInTempDir(),mockAccountId(),mockApiToken(),mockConfirm(),mockPrompt(),mockSelect(),captureRequestsFrom() - Unit timeout: 50s, retry: 0. Note: wrangler's
vitest.config.mtsdoes NOT usemergeConfigwithvitest.shared.ts, so shared defaults (timeouts, retry, etc.) are not inherited — they must be set explicitly in the wrangler config. - E2E timeout: 90s, bail: 1, singleThread
globals: truefor vitest globals- Output normalization via
normalizeString()pipeline
Anti-Patterns
- Test files use
.test.ts(not.spec.ts) - Never import
expectfrom vitest — use test context({ expect }) => {}- When adding
expectas a parameter to helper functions, check ALL call sites (e.g., acrossdeployments.test.ts,versions.test.ts)
- When adding
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.

