[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7AJZG76QDKEWH73KQZ0VCVT":3,"skill-same:01M7AJZG76QDKEWH73KQZ0VCVT":81},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":18,"linkOnly":19,"markdownContent":20,"markdownBody":21,"frontMatter":22,"refName":42,"commitSha":43,"skillDirectory":5,"forksCount":44,"repositoryHtmlUrl":45,"repositoryHomepageUrl":6,"ownerHtmlUrl":46,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":47,"install":48,"resources":60},"01M7AJZG76QDKEWH73KQZ0VCVT","cloudflare-full-stack-scaffold",null,"Production-ready starter project for React + Cloudflare Workers + Hono with core services\n(D1, KV, R2, Workers AI) and optional advanced features (Clerk Auth, AI Chat, Queues, Vectorize).\nComplete with planning docs, session handoff protocol, and enable scripts for opt-in features.\n\nUse when: starting new full-stack project, creating Cloudflare app, scaffolding web app,\nAI-powered application, chat interface, RAG application, need complete starter, avoid setup time,\nproduction-ready template, full-stack boilerplate, React Cloudflare starter.\n\nPrevents: service configuration errors, binding setup mistakes, frontend-backend connection issues,\nCORS errors, auth integration problems, AI SDK setup confusion, missing planning docs,\nincomplete project structure, hours of initial setup.\n\nKeywords: cloudflare scaffold, full-stack starter, react cloudflare, hono template, production boilerplate,\nAI SDK integration, workers AI, complete starter project, D1 KV R2 setup, web app template,\nchat application scaffold, RAG starter, planning docs included, session handoff,\ntailwind v4 shadcn, typescript starter, vite cloudflare plugin, all services configured","davidanthonyn\u002Fagent-skills","davidanthonyn","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F55152980?v=4","01M7AJ4MY8S5C2RJCGX6626J0G","01M7AJ4MZB7EC7CAP27ANCSE7N",1,"MIT","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcloudflare-full-stack-scaffold\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: cloudflare-full-stack-scaffold\ndescription: |\n  Production-ready starter project for React + Cloudflare Workers + Hono with core services\n  (D1, KV, R2, Workers AI) and optional advanced features (Clerk Auth, AI Chat, Queues, Vectorize).\n  Complete with planning docs, session handoff protocol, and enable scripts for opt-in features.\n\n  Use when: starting new full-stack project, creating Cloudflare app, scaffolding web app,\n  AI-powered application, chat interface, RAG application, need complete starter, avoid setup time,\n  production-ready template, full-stack boilerplate, React Cloudflare starter.\n\n  Prevents: service configuration errors, binding setup mistakes, frontend-backend connection issues,\n  CORS errors, auth integration problems, AI SDK setup confusion, missing planning docs,\n  incomplete project structure, hours of initial setup.\n\n  Keywords: cloudflare scaffold, full-stack starter, react cloudflare, hono template, production boilerplate,\n  AI SDK integration, workers AI, complete starter project, D1 KV R2 setup, web app template,\n  chat application scaffold, RAG starter, planning docs included, session handoff,\n  tailwind v4 shadcn, typescript starter, vite cloudflare plugin, all services configured\nlicense: MIT\nmetadata:\n  version: 1.0.0\n  last_updated: 2025-10-23\n  packages:\n    - \"react: ^19.2.0\"\n    - \"react-router-dom: ^7.1.3\"\n    - \"hono: ^4.10.2\"\n    - \"@cloudflare\u002Fvite-plugin: ^1.13.14\"\n    - \"ai: ^5.0.76\"\n    - \"@ai-sdk\u002Fopenai: ^1.0.0\"\n    - \"@ai-sdk\u002Fanthropic: ^1.0.0\"\n    - \"workers-ai-provider: ^2.0.0\"\n    - \"@ai-sdk\u002Freact: ^2.0.76\"\n    - \"@clerk\u002Fclerk-react: ^5.53.3\"\n    - \"tailwindcss: ^4.1.14\"\n  production_tested: true\n  token_savings: \"75-80%\"\n  errors_prevented: \"12+ setup and configuration errors\"\n---\n\n# Cloudflare Full-Stack Scaffold\n\nComplete, production-ready starter project for building full-stack applications on Cloudflare with React, Hono, AI SDK, and all Cloudflare services pre-configured.\n\n## When to Use This Skill\n\nUse this skill when you need to:\n\n- **Start a new full-stack Cloudflare project** in minutes instead of hours\n- **Build AI-powered applications** with chat interfaces, RAG, or tool calling\n- **Have core Cloudflare services ready** (D1, KV, R2, Workers AI)\n- **Opt-in to advanced features** (Clerk Auth, AI Chat, Queues, Vectorize)\n- **Use modern best practices** (Tailwind v4, shadcn\u002Fui, AI SDK, React 19)\n- **Include planning docs and session handoff** from the start\n- **Choose your AI provider** (Workers AI, OpenAI, Anthropic, Gemini)\n- **Enable features only when needed** with simple npm scripts\n- **Avoid configuration errors** and integration issues\n\n## What This Skill Provides\n\n### Complete Scaffold Project\n\nA fully working application you can **copy, customize, and deploy** immediately:\n\n```bash\n# Copy the scaffold\ncp -r scaffold\u002F my-new-app\u002F\ncd my-new-app\u002F\n\n# Install dependencies\nnpm install\n\n# Initialize core services (D1, KV, R2)\n.\u002Fscripts\u002Finit-services.sh\n\n# Create database tables\nnpm run d1:local\n\n# Start developing\nnpm run dev\n```\n\n**Result**: Full-stack app running in ~5 minutes with:\n- ✅ Frontend and backend connected\n- ✅ Core Cloudflare services configured (D1, KV, R2, Workers AI)\n- ✅ AI SDK ready with multiple providers\n- ✅ Planning docs and session handoff protocol\n- ✅ Dark mode, theming, UI components\n- ✅ Optional features (1 script each to enable):\n  - Clerk Auth (`npm run enable-auth`)\n  - AI Chat UI (`npm run enable-ai-chat`)\n  - Queues (`npm run enable-queues`)\n  - Vectorize (`npm run enable-vectorize`)\n\n### Scaffold Structure\n\n```\nscaffold\u002F\n├── package.json              # All dependencies (React, Hono, AI SDK, Clerk)\n├── tsconfig.json            # TypeScript config\n├── vite.config.ts           # Cloudflare Vite plugin\n├── wrangler.jsonc           # All Cloudflare services configured\n├── .dev.vars.example        # Environment variables template\n├── .gitignore               # Standard ignores\n├── README.md                # Project-specific readme\n├── CLAUDE.md                # Project instructions for Claude\n├── SCRATCHPAD.md            # Session handoff protocol\n├── CHANGELOG.md             # Version history\n├── schema.sql               # D1 database schema\n│\n├── docs\u002F                    # Complete planning docs\n│   ├── ARCHITECTURE.md\n│   ├── DATABASE_SCHEMA.md\n│   ├── API_ENDPOINTS.md\n│   ├── IMPLEMENTATION_PHASES.md\n│   ├── UI_COMPONENTS.md\n│   └── TESTING.md\n│\n├── migrations\u002F              # D1 migrations\n│   └── 0001_initial.sql\n│\n├── src\u002F                     # Frontend (React + Vite + Tailwind v4)\n│   ├── main.tsx\n│   ├── App.tsx\n│   ├── index.css           # Tailwind v4 theming\n│   ├── components\u002F\n│   │   ├── ui\u002F             # shadcn\u002Fui components\n│   │   ├── ThemeProvider.tsx\n│   │   ├── ProtectedRoute.tsx     # Auth (COMMENTED)\n│   │   └── ChatInterface.tsx      # AI chat (COMMENTED)\n│   ├── lib\u002F\n│   │   ├── utils.ts        # cn() utility\n│   │   └── api-client.ts   # Fetch wrapper\n│   └── pages\u002F\n│       ├── Home.tsx\n│       ├── Dashboard.tsx\n│       └── Chat.tsx        # AI chat page (COMMENTED)\n│\n└── backend\u002F                 # Backend (Hono + Cloudflare)\n    ├── src\u002F\n    │   └── index.ts        # Main Worker entry\n    ├── middleware\u002F\n    │   ├── cors.ts\n    │   └── auth.ts         # JWT (COMMENTED)\n    ├── routes\u002F\n    │   ├── api.ts          # Basic API routes\n    │   ├── d1.ts           # D1 examples\n    │   ├── kv.ts           # KV examples\n    │   ├── r2.ts           # R2 examples\n    │   ├── ai.ts           # Workers AI (direct binding)\n    │   ├── ai-sdk.ts       # AI SDK examples (multiple providers)\n    │   ├── vectorize.ts    # Vectorize examples\n    │   └── queues.ts       # Queues examples\n    └── db\u002F\n        └── queries.ts      # D1 typed query helpers\n```\n\n### Helper Scripts\n\n**`scripts\u002Fsetup-project.sh`**:\n- Copies scaffold to new directory\n- Renames project in package.json\n- Initializes git repository\n- Runs npm install\n- Prompts to initialize services\n\n**`scripts\u002Finit-services.sh`**:\n- Creates D1 database via wrangler\n- Creates KV namespace\n- Creates R2 bucket\n- Updates wrangler.jsonc with IDs\n- (Queues and Vectorize created when enabled)\n\n**`scripts\u002Fenable-auth.sh`**:\n- Uncomments all Clerk auth patterns\n- Enables ProtectedRoute component\n- Enables auth middleware\n- Prompts for Clerk API keys\n- Updates .dev.vars\n\n**`scripts\u002Fenable-ai-chat.sh`**:\n- Uncomments ChatInterface component\n- Uncomments Chat page\n- Enables AI SDK UI patterns\n- Adds chat route to App.tsx\n- Prompts for AI provider API keys\n\n**`scripts\u002Fenable-queues.sh`**:\n- Uncomments Queues routes and bindings\n- Enables async message processing\n- Provides queue creation instructions\n- Updates backend and config files\n\n**`scripts\u002Fenable-vectorize.sh`**:\n- Uncomments Vectorize routes and bindings\n- Enables vector search and RAG\n- Provides index creation instructions\n- Configures embedding dimensions\n\n### Reference Documentation\n\n**`references\u002Fquick-start-guide.md`**:\n- 5-minute setup walkthrough\n- First deployment guide\n- Common customizations\n\n**`references\u002Fservice-configuration.md`**:\n- Details on each Cloudflare service\n- When to use each one\n- Configuration options\n\n**`references\u002Fai-sdk-guide.md`**:\n- AI SDK Core vs UI\n- Provider switching patterns\n- Streaming and tool calling\n- RAG implementation\n\n**`references\u002Fcustomization-guide.md`**:\n- Removing unused services\n- Adding new routes\u002Fpages\n- Customizing theme\n- Project structure best practices\n\n**`references\u002Fenabling-auth.md`**:\n- Clerk setup walkthrough\n- JWT template configuration\n- Testing auth flow\n\n## Key Integrations\n\n### 1. AI SDK Integration (Three Approaches)\n\n**Direct Workers AI Binding** (fastest):\n```typescript\n\u002F\u002F Already works, no API key needed\nconst result = await c.env.AI.run('@cf\u002Fmeta\u002Fllama-3-8b-instruct', {\n  messages: [{ role: 'user', content: 'Hello' }]\n})\n```\n\n**AI SDK with Workers AI** (portable code, same infrastructure):\n```typescript\nimport { streamText } from 'ai'\nimport { createWorkersAI } from 'workers-ai-provider'\n\nconst workersai = createWorkersAI({ binding: c.env.AI })\nconst result = await streamText({\n  model: workersai('@cf\u002Fmeta\u002Fllama-3-8b-instruct'),\n  messages: [{ role: 'user', content: 'Hello' }]\n})\n```\n\n**AI SDK with External Providers** (OpenAI, Anthropic, Gemini):\n```typescript\nimport { openai } from '@ai-sdk\u002Fopenai'\nimport { anthropic } from '@ai-sdk\u002Fanthropic'\n\n\u002F\u002F Switch providers in 1 line\nconst result = await streamText({\n  model: openai('gpt-4o'),  \u002F\u002F or anthropic('claude-sonnet-4-5')\n  messages: [{ role: 'user', content: 'Hello' }]\n})\n```\n\n**AI SDK v5 UI - Chat Interface** (COMMENTED, enable with script):\n```tsx\nimport { useChat } from '@ai-sdk\u002Freact'\nimport { DefaultChatTransport } from 'ai'\nimport { useState } from 'react'\n\nfunction ChatInterface() {\n  const [input, setInput] = useState('')\n  const { messages, sendMessage, status } = useChat({\n    transport: new DefaultChatTransport({\n      api: '\u002Fapi\u002Fai-sdk\u002Fchat',\n    }),\n  })\n\n  \u002F\u002F Send message on Enter key\n  const handleKeyDown = (e) => {\n    if (e.key === 'Enter' && status === 'ready' && input.trim()) {\n      sendMessage({ text: input })\n      setInput('')\n    }\n  }\n\n  \u002F\u002F Render messages (v5 uses message.parts[])\n  return (\n    \u003Cdiv>\n      {messages.map(m => (\n        \u003Cdiv key={m.id}>\n          {m.parts.map(part => {\n            if (part.type === 'text') return \u003Cdiv>{part.text}\u003C\u002Fdiv>\n          })}\n        \u003C\u002Fdiv>\n      ))}\n      \u003Cinput\n        value={input}\n        onChange={e => setInput(e.target.value)}\n        onKeyDown={handleKeyDown}\n        disabled={status !== 'ready'}\n      \u002F>\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n### 2. Forms & Data Fetching (React Hook Form + Zod + TanStack Query)\n\n**Industry-Standard Libraries for Production Apps**:\n\n**React Hook Form** - Performant form state management:\n```tsx\nimport { useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform\u002Fresolvers\u002Fzod'\n\nconst form = useForm({\n  resolver: zodResolver(userSchema), \u002F\u002F Zod validation\n})\n\n\u003Cinput {...register('name')} \u002F>\n{errors.name && \u003Cspan>{errors.name.message}\u003C\u002Fspan>}\n```\n\n**Zod v4** - TypeScript-first schema validation:\n```typescript\n\u002F\u002F Define schema once\nconst userSchema = z.object({\n  name: z.string().min(2),\n  email: z.string().email(),\n  age: z.number().int().positive().optional(),\n})\n\n\u002F\u002F Infer TypeScript type\ntype User = z.infer\u003Ctypeof userSchema>\n\n\u002F\u002F Use in frontend (React Hook Form)\nresolver: zodResolver(userSchema)\n\n\u002F\u002F Use in backend (same schema!)\nconst validated = userSchema.parse(requestBody)\n```\n\n**TanStack Query v5** - Smart data fetching & caching:\n```typescript\n\u002F\u002F Fetch data with automatic caching\nconst { data, isLoading } = useQuery({\n  queryKey: ['users'],\n  queryFn: () => apiClient.get('\u002Fapi\u002Fusers'),\n})\n\n\u002F\u002F Update data with mutations\nconst mutation = useMutation({\n  mutationFn: (newUser) => apiClient.post('\u002Fapi\u002Fusers', newUser),\n  onSuccess: () => {\n    queryClient.invalidateQueries({ queryKey: ['users'] })\n  },\n})\n```\n\n**Full-Stack Validation Pattern**:\n- ✅ Define schema in `shared\u002Fschemas\u002F` (single source of truth)\n- ✅ Frontend validates instantly (React Hook Form + Zod)\n- ✅ Backend validates securely (same Zod schema)\n- ✅ TypeScript types inferred automatically\n- ✅ Update validation once, applies everywhere\n\n**Complete Working Examples**:\n- Profile page with form: `\u002Fprofile` route\n- Dashboard with queries: `\u002Fdashboard` route\n- Form component: `src\u002Fcomponents\u002FUserProfileForm.tsx`\n- Backend validation: `backend\u002Froutes\u002Fforms.ts`\n- Shared schemas: `shared\u002Fschemas\u002FuserSchema.ts`\n\nSee `references\u002Fsupporting-libraries-guide.md` for comprehensive guide.\n\n### 3. All Cloudflare Services Pre-Configured\n\n**Database (D1)**:\n- Schema file with example tables\n- Migrations directory\n- Typed query helpers\n- Example CRUD routes\n\n**Key-Value Storage (KV)**:\n- Get\u002Fput\u002Fdelete examples\n- TTL patterns\n- Bulk operations\n\n**Object Storage (R2)**:\n- Upload\u002Fdownload examples\n- Presigned URLs\n- Streaming large files\n\n**AI Inference (Workers AI)**:\n- Text generation\n- Embeddings\n- Image generation (Stable Diffusion)\n\n**Vector Database (Vectorize)**:\n- Insert\u002Fquery embeddings\n- RAG patterns\n- Similarity search\n\n**Message Queues**:\n- Producer examples\n- Consumer patterns\n- Batch processing\n\n### 3. Optional Clerk Authentication\n\nAll auth patterns included but **COMMENTED** - uncomment to enable:\n\n```bash\n.\u002Fscripts\u002Fenable-auth.sh\n# Prompts for Clerk keys, uncomments all patterns\n```\n\n**What gets enabled**:\n- Frontend: ProtectedRoute component, auth in api-client\n- Backend: JWT verification middleware\n- Protected API routes\n- Auth loading states\n- Session management\n\n### 4. Planning Docs + Session Handoff Protocol\n\n**docs\u002F directory** - Complete planning structure:\n- ARCHITECTURE.md: System design\n- DATABASE_SCHEMA.md: D1 schema docs\n- API_ENDPOINTS.md: All routes documented\n- IMPLEMENTATION_PHASES.md: Phased build approach\n- UI_COMPONENTS.md: Component hierarchy\n- TESTING.md: Test strategy\n\n**SCRATCHPAD.md** - Session handoff protocol:\n- Current phase tracking\n- Progress checkpoints\n- Next actions\n- References to planning docs\n\n## Usage Guide\n\n### Quick Start (5 Minutes)\n\n```bash\n# 1. Copy scaffold\ncd \u002Fpath\u002Fto\u002Fskills\u002Fcloudflare-full-stack-scaffold\ncp -r scaffold\u002F ~\u002Fprojects\u002Fmy-new-app\u002F\ncd ~\u002Fprojects\u002Fmy-new-app\u002F\n\n# 2. Run setup\nnpm install\n\n# 3. Initialize Cloudflare services\nnpx wrangler d1 create my-app-db\nnpx wrangler kv:namespace create my-app-kv\nnpx wrangler r2 bucket create my-app-bucket\nnpx wrangler vectorize create my-app-index --dimensions=1536\nnpx wrangler queues create my-app-queue\n\n# 4. Update wrangler.jsonc with IDs from step 3\n\n# 5. Create D1 tables\nnpx wrangler d1 execute my-app-db --local --file=schema.sql\n\n# 6. Start dev server\nnpm run dev\n```\n\n**Visit**: http:\u002F\u002Flocalhost:5173\n\n### Enable Authentication (Optional)\n\n```bash\n.\u002Fscripts\u002Fenable-auth.sh\n# Prompts for Clerk publishable and secret keys\n# Uncomments all auth patterns\n# Updates .dev.vars\n\nnpm run dev\n```\n\n### Enable AI Chat Interface (Optional)\n\n```bash\n.\u002Fscripts\u002Fenable-ai-chat.sh\n# Uncomments ChatInterface component\n# Uncomments Chat page\n# Prompts for OpenAI\u002FAnthropic API keys (optional)\n\nnpm run dev\n```\n\n**Visit**: http:\u002F\u002Flocalhost:5173\u002Fchat\n\n### Deploy to Production\n\n```bash\n# Build\nnpm run build\n\n# Deploy\nnpx wrangler deploy\n\n# Migrate production database\nnpx wrangler d1 execute my-app-db --remote --file=schema.sql\n\n# Set production secrets\nnpx wrangler secret put CLERK_SECRET_KEY\nnpx wrangler secret put OPENAI_API_KEY\n```\n\n## Customization Patterns\n\n### Remove Unused Services\n\n**Don't need Vectorize?**\n1. Delete `backend\u002Froutes\u002Fvectorize.ts`\n2. Remove vectorize binding from `wrangler.jsonc`\n3. Remove from `vite.config.ts` cloudflare plugin\n4. Remove route registration in `backend\u002Fsrc\u002Findex.ts`\n\n### Add New API Routes\n\n```typescript\n\u002F\u002F backend\u002Froutes\u002Fmy-feature.ts\nimport { Hono } from 'hono'\n\nexport const myFeatureRoutes = new Hono()\n\nmyFeatureRoutes.get('\u002Fhello', (c) => {\n  return c.json({ message: 'Hello from my feature!' })\n})\n\n\u002F\u002F backend\u002Fsrc\u002Findex.ts\nimport { myFeatureRoutes } from '.\u002Froutes\u002Fmy-feature'\napp.route('\u002Fapi\u002Fmy-feature', myFeatureRoutes)\n```\n\n### Switch AI Providers\n\n```typescript\n\u002F\u002F Change this line:\nmodel: openai('gpt-4o'),\n\n\u002F\u002F To this:\nmodel: anthropic('claude-sonnet-4-5'),\n\n\u002F\u002F Or this:\nmodel: google('gemini-2.5-flash'),\n\n\u002F\u002F Or use Workers AI:\nconst workersai = createWorkersAI({ binding: c.env.AI })\nmodel: workersai('@cf\u002Fmeta\u002Fllama-3-8b-instruct'),\n```\n\n### Customize Theme\n\nAll theming in `src\u002Findex.css`:\n\n```css\n:root {\n  --background: hsl(0 0% 100%);  \u002F* Change colors here *\u002F\n  --foreground: hsl(0 0% 3.9%);\n  --primary: hsl(220 90% 56%);\n  \u002F* etc *\u002F\n}\n```\n\n## Architecture Highlights\n\n### Frontend-Backend Connection\n\n**Key Insight**: The Vite plugin runs your Worker on the **SAME port** as Vite.\n\n```typescript\n\u002F\u002F ✅ CORRECT: Use relative URLs\nfetch('\u002Fapi\u002Fdata')\n\n\u002F\u002F ❌ WRONG: Don't use absolute URLs\nfetch('http:\u002F\u002Flocalhost:8787\u002Fapi\u002Fdata')\n```\n\n**No proxy configuration needed!**\n\n### Environment Variables\n\n**Frontend** (.env):\n```bash\nVITE_CLERK_PUBLISHABLE_KEY=pk_test_xxx\n```\n\n**Backend** (.dev.vars):\n```bash\nCLERK_SECRET_KEY=sk_test_xxx\nOPENAI_API_KEY=sk-xxx\n```\n\n### CORS Configuration\n\n**Critical**: CORS middleware must be applied **BEFORE** routes:\n\n```typescript\n\u002F\u002F ✅ CORRECT ORDER\napp.use('\u002Fapi\u002F*', corsMiddleware)\napp.post('\u002Fapi\u002Fdata', handler)\n\n\u002F\u002F ❌ WRONG - Will cause CORS errors\napp.post('\u002Fapi\u002Fdata', handler)\napp.use('\u002Fapi\u002F*', corsMiddleware)\n```\n\n### Auth Pattern (When Enabled)\n\n**Frontend**: Check `isLoaded` before making API calls:\n```typescript\nconst { isLoaded, isSignedIn } = useSession()\n\nuseEffect(() => {\n  if (!isLoaded) return  \u002F\u002F Wait for auth\n  fetch('\u002Fapi\u002Fprotected').then(\u002F* ... *\u002F)\n}, [isLoaded])\n```\n\n**Backend**: JWT verification middleware:\n```typescript\nimport { jwtAuthMiddleware } from '.\u002Fmiddleware\u002Fauth'\n\napp.use('\u002Fapi\u002Fprotected\u002F*', jwtAuthMiddleware)\n```\n\n## Dependencies Included\n\n```json\n{\n  \"dependencies\": {\n    \"react\": \"^19.2.0\",\n    \"react-dom\": \"^19.2.0\",\n    \"hono\": \"^4.10.2\",\n    \"@cloudflare\u002Fvite-plugin\": \"^1.13.14\",\n\n    \"ai\": \"^5.0.76\",\n    \"@ai-sdk\u002Fopenai\": \"^1.0.0\",\n    \"@ai-sdk\u002Fanthropic\": \"^1.0.0\",\n    \"@ai-sdk\u002Fgoogle\": \"^1.0.0\",\n    \"workers-ai-provider\": \"^2.0.0\",\n    \"@ai-sdk\u002Freact\": \"^1.0.0\",\n\n    \"@clerk\u002Fclerk-react\": \"^5.53.3\",\n    \"@clerk\u002Fbackend\": \"^2.19.0\",\n\n    \"tailwindcss\": \"^4.1.14\",\n    \"@tailwindcss\u002Fvite\": \"^4.1.14\",\n    \"class-variance-authority\": \"^0.7.0\",\n    \"clsx\": \"^2.1.1\",\n    \"tailwind-merge\": \"^2.5.4\",\n\n    \"zod\": \"^3.24.1\",\n    \"react-hook-form\": \"^7.54.2\",\n    \"@hookform\u002Fresolvers\": \"^3.9.1\",\n\n    \"@tanstack\u002Freact-query\": \"^5.62.11\",\n\n    \"@radix-ui\u002Freact-slot\": \"^1.1.1\",\n    \"@radix-ui\u002Freact-dropdown-menu\": \"^2.1.4\"\n  },\n  \"devDependencies\": {\n    \"@types\u002Freact\": \"^19.0.0\",\n    \"@types\u002Freact-dom\": \"^19.0.0\",\n    \"typescript\": \"^5.7.2\",\n    \"vite\": \"^7.1.11\",\n    \"wrangler\": \"^4.0.0\"\n  }\n}\n```\n\n## Token Efficiency\n\n| Scenario | Without Scaffold | With Scaffold | Savings |\n|----------|------------------|---------------|---------|\n| Initial setup | ~18-22k tokens | ~3-5k tokens | ~80% |\n| Service configuration | ~8-10k tokens | 0 tokens (done) | 100% |\n| Frontend-backend connection | ~5-7k tokens | 0 tokens (done) | 100% |\n| AI SDK setup | ~4-6k tokens | 0 tokens (done) | 100% |\n| Auth integration | ~6-8k tokens | ~500 tokens | ~90% |\n| Planning docs | ~3-5k tokens | 0 tokens (included) | 100% |\n| **Total** | **~44-58k tokens** | **~3-6k tokens** | **~90%** |\n\n**Time Savings**: 3-4 hours → 5-10 minutes (~95% faster)\n\n## Common Issues Prevented\n\n| Issue | How Scaffold Prevents It |\n|-------|-------------------------|\n| **Service binding errors** | All bindings pre-configured and tested |\n| **CORS errors** | Middleware in correct order |\n| **Auth race conditions** | Proper loading state patterns |\n| **Frontend-backend connection** | Vite plugin correctly configured |\n| **AI SDK setup confusion** | Multiple working examples |\n| **Missing planning docs** | Complete docs\u002F structure included |\n| **Environment variable mix-ups** | Clear .dev.vars.example with comments |\n| **Missing migrations** | migrations\u002F directory with examples |\n| **Inconsistent file structure** | Standard, tested structure |\n| **Database type errors** | Typed query helpers included |\n| **Theme configuration** | Tailwind v4 theming pre-configured |\n| **Build errors** | Working build config (vite + wrangler) |\n\n**Total Errors Prevented**: 12+ common setup and integration errors\n\n## When NOT to Use This Scaffold\n\n- ❌ Building a static site (no backend needed)\n- ❌ Using Next.js, Remix, or other meta-framework\n- ❌ Need SSR (use framework-specific Cloudflare adapter)\n- ❌ Building backend-only API (no frontend needed)\n- ❌ Extremely simple single-page app\n\n**For these cases**: Use minimal templates or official framework starters.\n\n## Production Evidence\n\n**Based on**:\n- Cloudflare's official agents-starter template (AI SDK patterns)\n- cloudflare-full-stack-integration skill (tested frontend-backend patterns)\n- session-handoff-protocol skill (planning docs + SCRATCHPAD.md)\n- tailwind-v4-shadcn skill (UI component patterns)\n- Multiple production Jezweb projects\n\n**Package versions verified**: 2025-10-23\n\n**Works with**:\n- Cloudflare Workers (production environment)\n- Wrangler 4.0+\n- Node.js 18+\n- npm\u002Fpnpm\u002Fyarn\n\n## Quick Reference\n\n**Setup new project**:\n```bash\ncp -r scaffold\u002F my-app\u002F\ncd my-app\u002F\nnpm install\n# Follow quick-start-guide.md\n```\n\n**Enable auth**:\n```bash\n.\u002Fscripts\u002Fenable-auth.sh\n```\n\n**Enable AI chat**:\n```bash\n.\u002Fscripts\u002Fenable-ai-chat.sh\n```\n\n**Deploy**:\n```bash\nnpm run build\nnpx wrangler deploy\n```\n\n**Key Files**:\n- `wrangler.jsonc` - Service configuration\n- `vite.config.ts` - Build configuration\n- `.dev.vars.example` - Environment variables template\n- `docs\u002FARCHITECTURE.md` - System design\n- `SCRATCHPAD.md` - Session handoff protocol\n\n---\n\n**Remember**: This scaffold is a **starting point**, not a constraint. Customize everything to match your needs. The value is in having a working foundation with all the integration patterns already figured out, saving hours of setup and debugging time.\n","# Cloudflare Full-Stack Scaffold\n\nComplete, production-ready starter project for building full-stack applications on Cloudflare with React, Hono, AI SDK, and all Cloudflare services pre-configured.\n\n## When to Use This Skill\n\nUse this skill when you need to:\n\n- **Start a new full-stack Cloudflare project** in minutes instead of hours\n- **Build AI-powered applications** with chat interfaces, RAG, or tool calling\n- **Have core Cloudflare services ready** (D1, KV, R2, Workers AI)\n- **Opt-in to advanced features** (Clerk Auth, AI Chat, Queues, Vectorize)\n- **Use modern best practices** (Tailwind v4, shadcn\u002Fui, AI SDK, React 19)\n- **Include planning docs and session handoff** from the start\n- **Choose your AI provider** (Workers AI, OpenAI, Anthropic, Gemini)\n- **Enable features only when needed** with simple npm scripts\n- **Avoid configuration errors** and integration issues\n\n## What This Skill Provides\n\n### Complete Scaffold Project\n\nA fully working application you can **copy, customize, and deploy** immediately:\n\n```bash\n# Copy the scaffold\ncp -r scaffold\u002F my-new-app\u002F\ncd my-new-app\u002F\n\n# Install dependencies\nnpm install\n\n# Initialize core services (D1, KV, R2)\n.\u002Fscripts\u002Finit-services.sh\n\n# Create database tables\nnpm run d1:local\n\n# Start developing\nnpm run dev\n```\n\n**Result**: Full-stack app running in ~5 minutes with:\n- ✅ Frontend and backend connected\n- ✅ Core Cloudflare services configured (D1, KV, R2, Workers AI)\n- ✅ AI SDK ready with multiple providers\n- ✅ Planning docs and session handoff protocol\n- ✅ Dark mode, theming, UI components\n- ✅ Optional features (1 script each to enable):\n  - Clerk Auth (`npm run enable-auth`)\n  - AI Chat UI (`npm run enable-ai-chat`)\n  - Queues (`npm run enable-queues`)\n  - Vectorize (`npm run enable-vectorize`)\n\n### Scaffold Structure\n\n```\nscaffold\u002F\n├── package.json              # All dependencies (React, Hono, AI SDK, Clerk)\n├── tsconfig.json            # TypeScript config\n├── vite.config.ts           # Cloudflare Vite plugin\n├── wrangler.jsonc           # All Cloudflare services configured\n├── .dev.vars.example        # Environment variables template\n├── .gitignore               # Standard ignores\n├── README.md                # Project-specific readme\n├── CLAUDE.md                # Project instructions for Claude\n├── SCRATCHPAD.md            # Session handoff protocol\n├── CHANGELOG.md             # Version history\n├── schema.sql               # D1 database schema\n│\n├── docs\u002F                    # Complete planning docs\n│   ├── ARCHITECTURE.md\n│   ├── DATABASE_SCHEMA.md\n│   ├── API_ENDPOINTS.md\n│   ├── IMPLEMENTATION_PHASES.md\n│   ├── UI_COMPONENTS.md\n│   └── TESTING.md\n│\n├── migrations\u002F              # D1 migrations\n│   └── 0001_initial.sql\n│\n├── src\u002F                     # Frontend (React + Vite + Tailwind v4)\n│   ├── main.tsx\n│   ├── App.tsx\n│   ├── index.css           # Tailwind v4 theming\n│   ├── components\u002F\n│   │   ├── ui\u002F             # shadcn\u002Fui components\n│   │   ├── ThemeProvider.tsx\n│   │   ├── ProtectedRoute.tsx     # Auth (COMMENTED)\n│   │   └── ChatInterface.tsx      # AI chat (COMMENTED)\n│   ├── lib\u002F\n│   │   ├── utils.ts        # cn() utility\n│   │   └── api-client.ts   # Fetch wrapper\n│   └── pages\u002F\n│       ├── Home.tsx\n│       ├── Dashboard.tsx\n│       └── Chat.tsx        # AI chat page (COMMENTED)\n│\n└── backend\u002F                 # Backend (Hono + Cloudflare)\n    ├── src\u002F\n    │   └── index.ts        # Main Worker entry\n    ├── middleware\u002F\n    │   ├── cors.ts\n    │   └── auth.ts         # JWT (COMMENTED)\n    ├── routes\u002F\n    │   ├── api.ts          # Basic API routes\n    │   ├── d1.ts           # D1 examples\n    │   ├── kv.ts           # KV examples\n    │   ├── r2.ts           # R2 examples\n    │   ├── ai.ts           # Workers AI (direct binding)\n    │   ├── ai-sdk.ts       # AI SDK examples (multiple providers)\n    │   ├── vectorize.ts    # Vectorize examples\n    │   └── queues.ts       # Queues examples\n    └── db\u002F\n        └── queries.ts      # D1 typed query helpers\n```\n\n### Helper Scripts\n\n**`scripts\u002Fsetup-project.sh`**:\n- Copies scaffold to new directory\n- Renames project in package.json\n- Initializes git repository\n- Runs npm install\n- Prompts to initialize services\n\n**`scripts\u002Finit-services.sh`**:\n- Creates D1 database via wrangler\n- Creates KV namespace\n- Creates R2 bucket\n- Updates wrangler.jsonc with IDs\n- (Queues and Vectorize created when enabled)\n\n**`scripts\u002Fenable-auth.sh`**:\n- Uncomments all Clerk auth patterns\n- Enables ProtectedRoute component\n- Enables auth middleware\n- Prompts for Clerk API keys\n- Updates .dev.vars\n\n**`scripts\u002Fenable-ai-chat.sh`**:\n- Uncomments ChatInterface component\n- Uncomments Chat page\n- Enables AI SDK UI patterns\n- Adds chat route to App.tsx\n- Prompts for AI provider API keys\n\n**`scripts\u002Fenable-queues.sh`**:\n- Uncomments Queues routes and bindings\n- Enables async message processing\n- Provides queue creation instructions\n- Updates backend and config files\n\n**`scripts\u002Fenable-vectorize.sh`**:\n- Uncomments Vectorize routes and bindings\n- Enables vector search and RAG\n- Provides index creation instructions\n- Configures embedding dimensions\n\n### Reference Documentation\n\n**`references\u002Fquick-start-guide.md`**:\n- 5-minute setup walkthrough\n- First deployment guide\n- Common customizations\n\n**`references\u002Fservice-configuration.md`**:\n- Details on each Cloudflare service\n- When to use each one\n- Configuration options\n\n**`references\u002Fai-sdk-guide.md`**:\n- AI SDK Core vs UI\n- Provider switching patterns\n- Streaming and tool calling\n- RAG implementation\n\n**`references\u002Fcustomization-guide.md`**:\n- Removing unused services\n- Adding new routes\u002Fpages\n- Customizing theme\n- Project structure best practices\n\n**`references\u002Fenabling-auth.md`**:\n- Clerk setup walkthrough\n- JWT template configuration\n- Testing auth flow\n\n## Key Integrations\n\n### 1. AI SDK Integration (Three Approaches)\n\n**Direct Workers AI Binding** (fastest):\n```typescript\n\u002F\u002F Already works, no API key needed\nconst result = await c.env.AI.run('@cf\u002Fmeta\u002Fllama-3-8b-instruct', {\n  messages: [{ role: 'user', content: 'Hello' }]\n})\n```\n\n**AI SDK with Workers AI** (portable code, same infrastructure):\n```typescript\nimport { streamText } from 'ai'\nimport { createWorkersAI } from 'workers-ai-provider'\n\nconst workersai = createWorkersAI({ binding: c.env.AI })\nconst result = await streamText({\n  model: workersai('@cf\u002Fmeta\u002Fllama-3-8b-instruct'),\n  messages: [{ role: 'user', content: 'Hello' }]\n})\n```\n\n**AI SDK with External Providers** (OpenAI, Anthropic, Gemini):\n```typescript\nimport { openai } from '@ai-sdk\u002Fopenai'\nimport { anthropic } from '@ai-sdk\u002Fanthropic'\n\n\u002F\u002F Switch providers in 1 line\nconst result = await streamText({\n  model: openai('gpt-4o'),  \u002F\u002F or anthropic('claude-sonnet-4-5')\n  messages: [{ role: 'user', content: 'Hello' }]\n})\n```\n\n**AI SDK v5 UI - Chat Interface** (COMMENTED, enable with script):\n```tsx\nimport { useChat } from '@ai-sdk\u002Freact'\nimport { DefaultChatTransport } from 'ai'\nimport { useState } from 'react'\n\nfunction ChatInterface() {\n  const [input, setInput] = useState('')\n  const { messages, sendMessage, status } = useChat({\n    transport: new DefaultChatTransport({\n      api: '\u002Fapi\u002Fai-sdk\u002Fchat',\n    }),\n  })\n\n  \u002F\u002F Send message on Enter key\n  const handleKeyDown = (e) => {\n    if (e.key === 'Enter' && status === 'ready' && input.trim()) {\n      sendMessage({ text: input })\n      setInput('')\n    }\n  }\n\n  \u002F\u002F Render messages (v5 uses message.parts[])\n  return (\n    \u003Cdiv>\n      {messages.map(m => (\n        \u003Cdiv key={m.id}>\n          {m.parts.map(part => {\n            if (part.type === 'text') return \u003Cdiv>{part.text}\u003C\u002Fdiv>\n          })}\n        \u003C\u002Fdiv>\n      ))}\n      \u003Cinput\n        value={input}\n        onChange={e => setInput(e.target.value)}\n        onKeyDown={handleKeyDown}\n        disabled={status !== 'ready'}\n      \u002F>\n    \u003C\u002Fdiv>\n  )\n}\n```\n\n### 2. Forms & Data Fetching (React Hook Form + Zod + TanStack Query)\n\n**Industry-Standard Libraries for Production Apps**:\n\n**React Hook Form** - Performant form state management:\n```tsx\nimport { useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform\u002Fresolvers\u002Fzod'\n\nconst form = useForm({\n  resolver: zodResolver(userSchema), \u002F\u002F Zod validation\n})\n\n\u003Cinput {...register('name')} \u002F>\n{errors.name && \u003Cspan>{errors.name.message}\u003C\u002Fspan>}\n```\n\n**Zod v4** - TypeScript-first schema validation:\n```typescript\n\u002F\u002F Define schema once\nconst userSchema = z.object({\n  name: z.string().min(2),\n  email: z.string().email(),\n  age: z.number().int().positive().optional(),\n})\n\n\u002F\u002F Infer TypeScript type\ntype User = z.infer\u003Ctypeof userSchema>\n\n\u002F\u002F Use in frontend (React Hook Form)\nresolver: zodResolver(userSchema)\n\n\u002F\u002F Use in backend (same schema!)\nconst validated = userSchema.parse(requestBody)\n```\n\n**TanStack Query v5** - Smart data fetching & caching:\n```typescript\n\u002F\u002F Fetch data with automatic caching\nconst { data, isLoading } = useQuery({\n  queryKey: ['users'],\n  queryFn: () => apiClient.get('\u002Fapi\u002Fusers'),\n})\n\n\u002F\u002F Update data with mutations\nconst mutation = useMutation({\n  mutationFn: (newUser) => apiClient.post('\u002Fapi\u002Fusers', newUser),\n  onSuccess: () => {\n    queryClient.invalidateQueries({ queryKey: ['users'] })\n  },\n})\n```\n\n**Full-Stack Validation Pattern**:\n- ✅ Define schema in `shared\u002Fschemas\u002F` (single source of truth)\n- ✅ Frontend validates instantly (React Hook Form + Zod)\n- ✅ Backend validates securely (same Zod schema)\n- ✅ TypeScript types inferred automatically\n- ✅ Update validation once, applies everywhere\n\n**Complete Working Examples**:\n- Profile page with form: `\u002Fprofile` route\n- Dashboard with queries: `\u002Fdashboard` route\n- Form component: `src\u002Fcomponents\u002FUserProfileForm.tsx`\n- Backend validation: `backend\u002Froutes\u002Fforms.ts`\n- Shared schemas: `shared\u002Fschemas\u002FuserSchema.ts`\n\nSee `references\u002Fsupporting-libraries-guide.md` for comprehensive guide.\n\n### 3. All Cloudflare Services Pre-Configured\n\n**Database (D1)**:\n- Schema file with example tables\n- Migrations directory\n- Typed query helpers\n- Example CRUD routes\n\n**Key-Value Storage (KV)**:\n- Get\u002Fput\u002Fdelete examples\n- TTL patterns\n- Bulk operations\n\n**Object Storage (R2)**:\n- Upload\u002Fdownload examples\n- Presigned URLs\n- Streaming large files\n\n**AI Inference (Workers AI)**:\n- Text generation\n- Embeddings\n- Image generation (Stable Diffusion)\n\n**Vector Database (Vectorize)**:\n- Insert\u002Fquery embeddings\n- RAG patterns\n- Similarity search\n\n**Message Queues**:\n- Producer examples\n- Consumer patterns\n- Batch processing\n\n### 3. Optional Clerk Authentication\n\nAll auth patterns included but **COMMENTED** - uncomment to enable:\n\n```bash\n.\u002Fscripts\u002Fenable-auth.sh\n# Prompts for Clerk keys, uncomments all patterns\n```\n\n**What gets enabled**:\n- Frontend: ProtectedRoute component, auth in api-client\n- Backend: JWT verification middleware\n- Protected API routes\n- Auth loading states\n- Session management\n\n### 4. Planning Docs + Session Handoff Protocol\n\n**docs\u002F directory** - Complete planning structure:\n- ARCHITECTURE.md: System design\n- DATABASE_SCHEMA.md: D1 schema docs\n- API_ENDPOINTS.md: All routes documented\n- IMPLEMENTATION_PHASES.md: Phased build approach\n- UI_COMPONENTS.md: Component hierarchy\n- TESTING.md: Test strategy\n\n**SCRATCHPAD.md** - Session handoff protocol:\n- Current phase tracking\n- Progress checkpoints\n- Next actions\n- References to planning docs\n\n## Usage Guide\n\n### Quick Start (5 Minutes)\n\n```bash\n# 1. Copy scaffold\ncd \u002Fpath\u002Fto\u002Fskills\u002Fcloudflare-full-stack-scaffold\ncp -r scaffold\u002F ~\u002Fprojects\u002Fmy-new-app\u002F\ncd ~\u002Fprojects\u002Fmy-new-app\u002F\n\n# 2. Run setup\nnpm install\n\n# 3. Initialize Cloudflare services\nnpx wrangler d1 create my-app-db\nnpx wrangler kv:namespace create my-app-kv\nnpx wrangler r2 bucket create my-app-bucket\nnpx wrangler vectorize create my-app-index --dimensions=1536\nnpx wrangler queues create my-app-queue\n\n# 4. Update wrangler.jsonc with IDs from step 3\n\n# 5. Create D1 tables\nnpx wrangler d1 execute my-app-db --local --file=schema.sql\n\n# 6. Start dev server\nnpm run dev\n```\n\n**Visit**: http:\u002F\u002Flocalhost:5173\n\n### Enable Authentication (Optional)\n\n```bash\n.\u002Fscripts\u002Fenable-auth.sh\n# Prompts for Clerk publishable and secret keys\n# Uncomments all auth patterns\n# Updates .dev.vars\n\nnpm run dev\n```\n\n### Enable AI Chat Interface (Optional)\n\n```bash\n.\u002Fscripts\u002Fenable-ai-chat.sh\n# Uncomments ChatInterface component\n# Uncomments Chat page\n# Prompts for OpenAI\u002FAnthropic API keys (optional)\n\nnpm run dev\n```\n\n**Visit**: http:\u002F\u002Flocalhost:5173\u002Fchat\n\n### Deploy to Production\n\n```bash\n# Build\nnpm run build\n\n# Deploy\nnpx wrangler deploy\n\n# Migrate production database\nnpx wrangler d1 execute my-app-db --remote --file=schema.sql\n\n# Set production secrets\nnpx wrangler secret put CLERK_SECRET_KEY\nnpx wrangler secret put OPENAI_API_KEY\n```\n\n## Customization Patterns\n\n### Remove Unused Services\n\n**Don't need Vectorize?**\n1. Delete `backend\u002Froutes\u002Fvectorize.ts`\n2. Remove vectorize binding from `wrangler.jsonc`\n3. Remove from `vite.config.ts` cloudflare plugin\n4. Remove route registration in `backend\u002Fsrc\u002Findex.ts`\n\n### Add New API Routes\n\n```typescript\n\u002F\u002F backend\u002Froutes\u002Fmy-feature.ts\nimport { Hono } from 'hono'\n\nexport const myFeatureRoutes = new Hono()\n\nmyFeatureRoutes.get('\u002Fhello', (c) => {\n  return c.json({ message: 'Hello from my feature!' })\n})\n\n\u002F\u002F backend\u002Fsrc\u002Findex.ts\nimport { myFeatureRoutes } from '.\u002Froutes\u002Fmy-feature'\napp.route('\u002Fapi\u002Fmy-feature', myFeatureRoutes)\n```\n\n### Switch AI Providers\n\n```typescript\n\u002F\u002F Change this line:\nmodel: openai('gpt-4o'),\n\n\u002F\u002F To this:\nmodel: anthropic('claude-sonnet-4-5'),\n\n\u002F\u002F Or this:\nmodel: google('gemini-2.5-flash'),\n\n\u002F\u002F Or use Workers AI:\nconst workersai = createWorkersAI({ binding: c.env.AI })\nmodel: workersai('@cf\u002Fmeta\u002Fllama-3-8b-instruct'),\n```\n\n### Customize Theme\n\nAll theming in `src\u002Findex.css`:\n\n```css\n:root {\n  --background: hsl(0 0% 100%);  \u002F* Change colors here *\u002F\n  --foreground: hsl(0 0% 3.9%);\n  --primary: hsl(220 90% 56%);\n  \u002F* etc *\u002F\n}\n```\n\n## Architecture Highlights\n\n### Frontend-Backend Connection\n\n**Key Insight**: The Vite plugin runs your Worker on the **SAME port** as Vite.\n\n```typescript\n\u002F\u002F ✅ CORRECT: Use relative URLs\nfetch('\u002Fapi\u002Fdata')\n\n\u002F\u002F ❌ WRONG: Don't use absolute URLs\nfetch('http:\u002F\u002Flocalhost:8787\u002Fapi\u002Fdata')\n```\n\n**No proxy configuration needed!**\n\n### Environment Variables\n\n**Frontend** (.env):\n```bash\nVITE_CLERK_PUBLISHABLE_KEY=pk_test_xxx\n```\n\n**Backend** (.dev.vars):\n```bash\nCLERK_SECRET_KEY=sk_test_xxx\nOPENAI_API_KEY=sk-xxx\n```\n\n### CORS Configuration\n\n**Critical**: CORS middleware must be applied **BEFORE** routes:\n\n```typescript\n\u002F\u002F ✅ CORRECT ORDER\napp.use('\u002Fapi\u002F*', corsMiddleware)\napp.post('\u002Fapi\u002Fdata', handler)\n\n\u002F\u002F ❌ WRONG - Will cause CORS errors\napp.post('\u002Fapi\u002Fdata', handler)\napp.use('\u002Fapi\u002F*', corsMiddleware)\n```\n\n### Auth Pattern (When Enabled)\n\n**Frontend**: Check `isLoaded` before making API calls:\n```typescript\nconst { isLoaded, isSignedIn } = useSession()\n\nuseEffect(() => {\n  if (!isLoaded) return  \u002F\u002F Wait for auth\n  fetch('\u002Fapi\u002Fprotected').then(\u002F* ... *\u002F)\n}, [isLoaded])\n```\n\n**Backend**: JWT verification middleware:\n```typescript\nimport { jwtAuthMiddleware } from '.\u002Fmiddleware\u002Fauth'\n\napp.use('\u002Fapi\u002Fprotected\u002F*', jwtAuthMiddleware)\n```\n\n## Dependencies Included\n\n```json\n{\n  \"dependencies\": {\n    \"react\": \"^19.2.0\",\n    \"react-dom\": \"^19.2.0\",\n    \"hono\": \"^4.10.2\",\n    \"@cloudflare\u002Fvite-plugin\": \"^1.13.14\",\n\n    \"ai\": \"^5.0.76\",\n    \"@ai-sdk\u002Fopenai\": \"^1.0.0\",\n    \"@ai-sdk\u002Fanthropic\": \"^1.0.0\",\n    \"@ai-sdk\u002Fgoogle\": \"^1.0.0\",\n    \"workers-ai-provider\": \"^2.0.0\",\n    \"@ai-sdk\u002Freact\": \"^1.0.0\",\n\n    \"@clerk\u002Fclerk-react\": \"^5.53.3\",\n    \"@clerk\u002Fbackend\": \"^2.19.0\",\n\n    \"tailwindcss\": \"^4.1.14\",\n    \"@tailwindcss\u002Fvite\": \"^4.1.14\",\n    \"class-variance-authority\": \"^0.7.0\",\n    \"clsx\": \"^2.1.1\",\n    \"tailwind-merge\": \"^2.5.4\",\n\n    \"zod\": \"^3.24.1\",\n    \"react-hook-form\": \"^7.54.2\",\n    \"@hookform\u002Fresolvers\": \"^3.9.1\",\n\n    \"@tanstack\u002Freact-query\": \"^5.62.11\",\n\n    \"@radix-ui\u002Freact-slot\": \"^1.1.1\",\n    \"@radix-ui\u002Freact-dropdown-menu\": \"^2.1.4\"\n  },\n  \"devDependencies\": {\n    \"@types\u002Freact\": \"^19.0.0\",\n    \"@types\u002Freact-dom\": \"^19.0.0\",\n    \"typescript\": \"^5.7.2\",\n    \"vite\": \"^7.1.11\",\n    \"wrangler\": \"^4.0.0\"\n  }\n}\n```\n\n## Token Efficiency\n\n| Scenario | Without Scaffold | With Scaffold | Savings |\n|----------|------------------|---------------|---------|\n| Initial setup | ~18-22k tokens | ~3-5k tokens | ~80% |\n| Service configuration | ~8-10k tokens | 0 tokens (done) | 100% |\n| Frontend-backend connection | ~5-7k tokens | 0 tokens (done) | 100% |\n| AI SDK setup | ~4-6k tokens | 0 tokens (done) | 100% |\n| Auth integration | ~6-8k tokens | ~500 tokens | ~90% |\n| Planning docs | ~3-5k tokens | 0 tokens (included) | 100% |\n| **Total** | **~44-58k tokens** | **~3-6k tokens** | **~90%** |\n\n**Time Savings**: 3-4 hours → 5-10 minutes (~95% faster)\n\n## Common Issues Prevented\n\n| Issue | How Scaffold Prevents It |\n|-------|-------------------------|\n| **Service binding errors** | All bindings pre-configured and tested |\n| **CORS errors** | Middleware in correct order |\n| **Auth race conditions** | Proper loading state patterns |\n| **Frontend-backend connection** | Vite plugin correctly configured |\n| **AI SDK setup confusion** | Multiple working examples |\n| **Missing planning docs** | Complete docs\u002F structure included |\n| **Environment variable mix-ups** | Clear .dev.vars.example with comments |\n| **Missing migrations** | migrations\u002F directory with examples |\n| **Inconsistent file structure** | Standard, tested structure |\n| **Database type errors** | Typed query helpers included |\n| **Theme configuration** | Tailwind v4 theming pre-configured |\n| **Build errors** | Working build config (vite + wrangler) |\n\n**Total Errors Prevented**: 12+ common setup and integration errors\n\n## When NOT to Use This Scaffold\n\n- ❌ Building a static site (no backend needed)\n- ❌ Using Next.js, Remix, or other meta-framework\n- ❌ Need SSR (use framework-specific Cloudflare adapter)\n- ❌ Building backend-only API (no frontend needed)\n- ❌ Extremely simple single-page app\n\n**For these cases**: Use minimal templates or official framework starters.\n\n## Production Evidence\n\n**Based on**:\n- Cloudflare's official agents-starter template (AI SDK patterns)\n- cloudflare-full-stack-integration skill (tested frontend-backend patterns)\n- session-handoff-protocol skill (planning docs + SCRATCHPAD.md)\n- tailwind-v4-shadcn skill (UI component patterns)\n- Multiple production Jezweb projects\n\n**Package versions verified**: 2025-10-23\n\n**Works with**:\n- Cloudflare Workers (production environment)\n- Wrangler 4.0+\n- Node.js 18+\n- npm\u002Fpnpm\u002Fyarn\n\n## Quick Reference\n\n**Setup new project**:\n```bash\ncp -r scaffold\u002F my-app\u002F\ncd my-app\u002F\nnpm install\n# Follow quick-start-guide.md\n```\n\n**Enable auth**:\n```bash\n.\u002Fscripts\u002Fenable-auth.sh\n```\n\n**Enable AI chat**:\n```bash\n.\u002Fscripts\u002Fenable-ai-chat.sh\n```\n\n**Deploy**:\n```bash\nnpm run build\nnpx wrangler deploy\n```\n\n**Key Files**:\n- `wrangler.jsonc` - Service configuration\n- `vite.config.ts` - Build configuration\n- `.dev.vars.example` - Environment variables template\n- `docs\u002FARCHITECTURE.md` - System design\n- `SCRATCHPAD.md` - Session handoff protocol\n\n---\n\n**Remember**: This scaffold is a **starting point**, not a constraint. Customize everything to match your needs. The value is in having a working foundation with all the integration patterns already figured out, saving hours of setup and debugging time.\n",{"name":5,"license":14,"metadata":23,"description":41},{"version":24,"packages":25,"last_updated":37,"token_savings":38,"errors_prevented":39,"production_tested":40},"1.0.0",[26,27,28,29,30,31,32,33,34,35,36],"react: ^19.2.0","react-router-dom: ^7.1.3","hono: ^4.10.2","@cloudflare\u002Fvite-plugin: ^1.13.14","ai: ^5.0.76","@ai-sdk\u002Fopenai: ^1.0.0","@ai-sdk\u002Fanthropic: ^1.0.0","workers-ai-provider: ^2.0.0","@ai-sdk\u002Freact: ^2.0.76","@clerk\u002Fclerk-react: ^5.53.3","tailwindcss: ^4.1.14",1761177600000,"75-80%","12+ setup and configuration errors",true,"Production-ready starter project for React + Cloudflare Workers + Hono with core services\n(D1, KV, R2, Workers AI) and optional advanced features (Clerk Auth, AI Chat, Queues, Vectorize).\nComplete with planning docs, session handoff protocol, and enable scripts for opt-in features.\n\nUse when: starting new full-stack project, creating Cloudflare app, scaffolding web app,\nAI-powered application, chat interface, RAG application, need complete starter, avoid setup time,\nproduction-ready template, full-stack boilerplate, React Cloudflare starter.\n\nPrevents: service configuration errors, binding setup mistakes, frontend-backend connection issues,\nCORS errors, auth integration problems, AI SDK setup confusion, missing planning docs,\nincomplete project structure, hours of initial setup.\n\nKeywords: cloudflare scaffold, full-stack starter, react cloudflare, hono template, production boilerplate,\nAI SDK integration, workers AI, complete starter project, D1 KV R2 setup, web app template,\nchat application scaffold, RAG starter, planning docs included, session handoff,\ntailwind v4 shadcn, typescript starter, vite cloudflare plugin, all services configured\n","main","6b73b29e4866f997b1eb47fe8d9631396265fc24",0,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn","2026-09-09 16:06:07",{"source":8,"skillName":5,"commands":49,"prompt":59,"zipAvailable":40},[50,53,56],{"tool":51,"command":52},"npx","npx skills add davidanthonyn\u002Fagent-skills --skill cloudflare-full-stack-scaffold",{"tool":54,"command":55},"bunx","bunx skills add davidanthonyn\u002Fagent-skills --skill cloudflare-full-stack-scaffold",{"tool":57,"command":58},"pnpm","pnpm dlx skills add davidanthonyn\u002Fagent-skills --skill cloudflare-full-stack-scaffold","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcloudflare-full-stack-scaffold\u002FSKILL.md",[61,67,71,75],{"path":62,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":65,"sourceHtmlUrl":66},"IMPLEMENTATION_STATUS.md","REFERENCE","参考文档",45673,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcloudflare-full-stack-scaffold\u002FIMPLEMENTATION_STATUS.md",{"path":68,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":69,"sourceHtmlUrl":70},"README.md",9540,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcloudflare-full-stack-scaffold\u002FREADME.md",{"path":72,"resourceType":63,"resourceTypeDesc":64,"sizeBytes":73,"sourceHtmlUrl":74},"SKILL.json",21784,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcloudflare-full-stack-scaffold\u002FSKILL.json",{"path":76,"resourceType":77,"resourceTypeDesc":78,"sizeBytes":79,"sourceHtmlUrl":80},"SKILL.md.backup","OTHER","其他",21551,"https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fcloudflare-full-stack-scaffold\u002FSKILL.md.backup",[82,89,97,104,111,120],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":18},"01M7AQNJDXVNVMN08N5BHBGZBF","zustand-state-management","Production-tested setup for Zustand state management in React applications with TypeScript.\nThis skill provides comprehensive patterns for building scalable, type-safe global state.\n\nUse when: setting up global state in React, migrating from Redux or Context API, implementing\nstate persistence with localStorage, configuring TypeScript with Zustand, using slices pattern\nfor modular stores, adding devtools middleware for debugging, handling Next.js SSR hydration,\nor encountering hydration errors, TypeScript inference issues, or persist middleware problems.\n\nPrevents 5 documented issues: Next.js hydration mismatches, TypeScript double parentheses\nsyntax errors, persist middleware export errors, infinite render loops, and slices pattern\ntype inference failures.\n\nKeywords: zustand, state management, React state, TypeScript state, persist middleware,\ndevtools, slices pattern, global state, React hooks, create store, useBoundStore,\nStateCreator, hydration error, text content mismatch, infinite render, localStorage,\nsessionStorage, immer middleware, shallow equality, selector pattern, zustand v5","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fzustand-state-management\u002FSKILL.md",[],[],{"skillNo":90,"name":91,"nameZh":6,"description":92,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":93,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":18},"01M7AQN2DW9DTPM8BYNZSHQANC","zetic-mlange","Help users integrate the ZETIC Melange (MLange) on-device AI SDK into Android (Kotlin\u002FJava) and iOS (Swift) mobile apps. Use this skill whenever the user mentions Zetic, MLange, Melange, ZeticMLangeModel, ZeticMLangeLLMModel, ZeticMLangeHFModel, on-device NPU inference for mobile, or deploying ML models to Android\u002FiOS with NPU acceleration. Also trigger when users ask about running LLMs on-device with GGUF quantization, mobile NPU model deployment, or converting PyTorch\u002FONNX models for mobile inference. Covers general model inference, LLM inference (streaming token generation), and HuggingFace model loading.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fzetic-mlange\u002FSKILL.md",[],[],{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":18},"01M7AQMEK370FBPC75N2W8WA4W","youtube-downloader","Download videos, audio, playlists, and channels from YouTube and 1000+ websites using yt-dlp. Supports quality selection, format conversion, subtitle download, playlist filtering, metadata extraction, thumbnail download, and batch operations. Use when downloading YouTube videos in any quality (4K, 8K, HDR), extracting audio as MP3\u002FM4A\u002FFLAC, downloading entire playlists\u002Fchannels, getting subtitles in multiple languages, converting to specific formats, downloading live streams, archiving content, or batch processing multiple URLs. Optimized for reliability with automatic retries, rate limiting, and error handling.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fyoutube-downloader\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":108,"categories":109,"keywords":110,"publishedAt":18},"01M7AQHKQ4VQB04NH6BG4SV9Q7","wordpress-plugin-core","This skill provides comprehensive knowledge for WordPress plugin development, covering core patterns, security best practices, database interactions, hooks\u002Ffilters, Settings API, custom post types, REST API, and AJAX. This skill should be used when creating WordPress plugins, troubleshooting security issues, implementing custom post types\u002Ftaxonomies, building admin interfaces, or working with the WordPress database.\n\nUse when: Creating new WordPress plugins, implementing nonces\u002Fsanitization\u002Fescaping, working with $wpdb and prepared statements, building Settings API pages, registering custom post types or taxonomies, implementing REST API endpoints, handling AJAX requests, debugging plugin activation\u002Fdeactivation issues, preventing SQL injection\u002FXSS\u002FCSRF vulnerabilities.\n\nKeywords: wordpress plugin development, wordpress security, wordpress hooks, wordpress filters, wordpress database, wpdb prepare, sanitize_text_field, esc_html, wp_nonce, custom post type, register_post_type, settings api, rest api, admin-ajax, wordpress sql injection, wordpress xss, wordpress csrf, plugin header, activation hook, deactivation hook, wordpress coding standards, wordpress plugin architecture","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fwordpress-plugin-core\u002FSKILL.md",[],[],{"skillNo":112,"name":113,"nameZh":6,"description":114,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":115,"licenseFileUrl":116,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":18},"01M7AQH4JW8F2MJFS1C43TZ2TY","webapp-testing","Test local web applications with Playwright. Use when asked to verify frontend functionality, debug UI behavior, capture browser screenshots, or inspect browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":121,"name":122,"nameZh":6,"description":123,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":124,"categories":125,"keywords":126,"publishedAt":18},"01M7AQH0PWD6Z1NN66V15DT25M","web-performance-audit","Audit web performance using Chrome DevTools MCP. Use when asked to audit, profile, debug, or optimize page load performance, Lighthouse scores, or site speed.","https:\u002F\u002Fgithub.com\u002Fdavidanthonyn\u002Fagent-skills\u002Fblob\u002Fmain\u002Fweb-performance-audit\u002FSKILL.md",[],[]]