Orange Book
Guides

Build Cloudflare applications with AI assistance

Give AI current context, constraints, and an acceptance contract before generating, reviewing, and verifying a normal Web application.

Edited and verified by Orange Book Editorial Team ·

AI ASSISTEDBEGINNER25 minutesOutcome: an executable AI development contract

AI-assisted development is a working method, not a product category. It can help you complete a SaaS, CMS, image utility, or PDF utility without any model call in the final application. What matters is that AI receives current Cloudflare documentation, project versions, runtime constraints, and acceptance criteria instead of guessing interfaces from memory.

Separate two ideas first

“Use AI to write the application” describes development. “Add AI capability to the application” describes a runtime product feature. This guide covers the first; the second stays optional.

The context packet

Environment facts

Node, Wrangler, Next/Fumadocs versions, package manager, and target runtime.

Resource contract

Existing D1, R2, KV, and Queue binding names, plus resources that do not exist yet.

Business boundary

Users, tenants, public routes, administration routes, input limits, and permissions.

Acceptance evidence

Required commands, HTTP states, failure branches, and rollback conditions.

Cloudflare Docs for Agents provides documentation entry points for coding assistants. Give AI the current primary pages together with the real project configuration. Do not provide only an old blog post, and do not let the assistant decide to create remote resources on its own.

Four-pass workflow

Ask AI to restate constraints

It should list confirmed facts, unknowns, and actions that mutate external state. If it misstates Pages, Workers, bindings, or a Wrangler field, repair the context before coding.

Define interfaces and failures first

Specify input, output, authentication, tenant boundary, maximum body, timeout, and downstream failure. Ask for a test matrix before implementation.

Generate in small units and verify locally

Complete one route or data-access layer at a time. Run lint, types, unit tests, and a workerd preview. Return exact errors to AI rather than saying that something “seems broken.”

Review external boundaries manually

Inspect secrets, token scope, remote migrations, DNS/WAF changes, cost, and deletion. AI may list commands, but it must not run remote writes without authorization.

Review focus

SurfaceFrequent AI mistakeAcceptable evidence
InterfaceInventing an old configuration fieldCurrent primary link and local type check
SecurityPutting a secret in client environmentServer binding and clean secret scan
DataMissing a tenant predicate or building SQL stringsBound query and cross-tenant test
RuntimeDepending on local disk or a resident processReal execution in workerd
ReleaseTreating upload, deploy, and migration as one actionSeparate preview, version, and rollback steps

Completion checkpoint

The result should be independent of one AI vendor. If you change models, the same facts, boundaries, and tests still apply. If the assistant cannot identify unknowns or only covers the success path, development is not ready to start.

Next: build the complete application foundation.

Primary sources

Did this page help you complete your goal?

Beta feedback is generated in this browser and is never uploaded automatically.

On this page