The starter app for the Worker Previews workshop. It's a small Activity Log: a Worker with a D1 database and a UI for adding and deleting entries. The page shows a badge telling you whether you're on Production or a Preview.
In the workshop you give your branch its own Preview with a separate D1 database, test a new schema there without touching production, track down a bug the new schema causes (it's deliberate) using that Preview's Observability logs, and merge a fix.
| Path | Purpose |
|---|---|
src/ |
The Worker and its HTML UI |
migrations/ |
Production schema and seed data, applied on deploy |
preview-migrations/ |
The Preview database's schema, seed rows, and a candidate schema change. Applied only through wrangler.preview-migrations.jsonc (created in the workshop), so it never reaches production. |
wrangler.json |
Production settings at the top level; Preview settings in the previews block |
AGENTS.md |
Instructions for your coding agent: keep Preview settings in previews, never write to production data, test on the Preview URL, read the Preview's logs. CLAUDE.md points Claude Code at it. Copy it into your own repos. |
.mcp.json, .cursor/, .vscode/, .codex/, opencode.json |
Connect Claude Code, Cursor, VS Code (Copilot), Codex, and OpenCode to the read-only Workers Observability MCP server, so your agent can read your Preview's logs itself. Sign in with Cloudflare the first time your agent uses it. |
Click Deploy to Cloudflare above. It creates a copy of this repo in your GitHub account, provisions a production D1 database, connects Workers Builds, and deploys. Keep the default names in the deploy form so the workshop steps match.
- Install dependencies:
npm install
- Create a D1 database and put its ID in the
database_idfield ofwrangler.json:npx wrangler d1 create activity-log-db
- Deploy. The
predeployscript appliesmigrations/to the production database first:npm run deploy