This guide covers how to create the first real Cloudflare dev environment for this project.
Provision:
- one D1 database
- one R2 bucket
- four Queues
- one deployed Worker in
env.dev
wrangler loginUse the template helper:
bash scripts/bootstrap_dev_resources.shOr run the commands manually:
wrangler d1 create mailagents-dev
wrangler r2 bucket create mailagents-dev-email
wrangler queues create mailagents-dev-email-ingest
wrangler queues create mailagents-dev-agent-execute
wrangler queues create mailagents-dev-outbound-send
wrangler queues create mailagents-dev-dead-letterWhen wrangler d1 create mailagents-dev succeeds, Cloudflare returns a database_id.
Paste that value into:
Specifically:
env.dev.d1_databases[0].database_id
Update:
env.dev.vars.SES_FROM_DOMAINenv.dev.vars.SES_CONFIGURATION_SET
Recommended:
- use a dedicated dev sending subdomain
- use a dev-only SES configuration set
Example:
SES_FROM_DOMAIN = "dev.mail.yourdomain.com"SES_CONFIGURATION_SET = "mailagents-dev"
Print the commands:
bash scripts/bootstrap_worker_secrets.sh devThen run the printed wrangler secret put commands and enter real secret values.
npm run config:check:devThis should pass before any remote migration or deploy.
npm run d1:migrate:remote:dev
npm run d1:seed:remote:devnpm run deploy:devThis deploys the existing shared Cloudflare dev worker:
mailagents-devhttps://mailagents-dev.izhenghaocn.workers.dev
Subsequent npm run deploy:dev runs update that same environment.
After deploy, verify:
- worker responds
/v2/meta/runtimeresponds- auth token route works if
ADMIN_ROUTES_ENABLED=true - agent creation works
- draft creation works
- SES webhook endpoint is reachable
Helpful commands:
curl -sS https://mailagents-dev.izhenghaocn.workers.dev/v2/meta/runtime | jq '.server'
BASE_URL='https://mailagents-dev.izhenghaocn.workers.dev' \
ADMIN_API_SECRET_FOR_SMOKE=replace-with-admin-api-secret \
WEBHOOK_SHARED_SECRET_FOR_SMOKE=replace-with-shared-secret \
bash ./scripts/local_smoke.sh
BASE_URL='https://mailagents-dev.izhenghaocn.workers.dev' \
ADMIN_API_SECRET_FOR_SMOKE=replace-with-admin-api-secret \
bash ./scripts/mcp_smoke.shOnce dev works end to end:
- create
staging - disable admin/debug routes there
- run remote migration/seed for
staging - deploy
staging
- Keep
stagingandproductionadmin/debug routes disabled by default. - Do not reuse production SES identities or configuration sets in
dev.