Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
WIP: cloudflare-full-stack-scaffold skill - 40% complete
Jezbbdd8fa13024
diff --git a/skills/cloudflare-full-stack-scaffold/IMPLEMENTATION_STATUS.md b/skills/cloudflare-full-stack-scaffold/IMPLEMENTATION_STATUS.mdnew file mode 100644index 00000000..988aa1a2--- /dev/null+++ b/skills/cloudflare-full-stack-scaffold/IMPLEMENTATION_STATUS.md@@ -0,0 +1,391 @@+# cloudflare-full-stack-scaffold Implementation Status++**Date**: 2025-10-23+**Status**: 40% Complete (4 of 10 phases done)+**Context**: 133k/200k tokens used - needs context clear to complete++---++## ✅ Completed (4/10 phases)++### 1. Helper Scripts ✅+**Files Created**:+- `scripts/enable-auth.sh` - Uncomments Clerk auth patterns, prompts for API keys+- `scripts/enable-ai-chat.sh` - Uncomments AI chat UI, prompts for AI provider keys++**Status**: Complete and executable (chmod +x applied)++---++### 2. Backend Middleware ✅+**Files Created**:+- `backend/middleware/cors.ts` - Dev/prod CORS, copied from cloudflare-full-stack-integration skill+- `backend/middleware/auth.ts` - JWT auth with COMMENTED Clerk patterns (uncommented by enable-auth.sh)++**Status**: Complete with proper comment markers for scripts++---++### 3. Backend Routes (PARTIAL - 2/8 done) ⚠️+**Files Created**:+- `backend/routes/api.ts` - Basic routes (echo, status, data, search) ✅+- `backend/routes/d1.ts` - Full CRUD on users table ✅++**Files Still Needed** (6 files):+- `backend/routes/kv.ts`+- `backend/routes/r2.ts`+- `backend/routes/ai.ts`+- `backend/routes/ai-sdk.ts`+- `backend/routes/vectorize.ts`+- `backend/routes/queues.ts`++---++### 4. Skill Metadata ✅+**Files Exist**:+- `SKILL.md` - Complete with all promised features documented+- `README.md` - Complete with auto-trigger keywords+- `references/` - All 5 reference docs complete++**Status**: All documentation is complete++---++## ⏸️ In Progress (1/10 phases)++### Backend Routes (2 of 8 complete)+- ✅ api.ts+- ✅ d1.ts+- ❌ kv.ts (NEXT TO DO)+- ❌ r2.ts+- ❌ ai.ts+- ❌ ai-sdk.ts (IMPORTANT - shows multiple providers)+- ❌ vectorize.ts+- ❌ queues.ts++---++## ❌ Not Started (6/10 phases)++### 5. Backend Database Helpers+**File Needed**:+- `backend/db/queries.ts` - Typed D1 query helpers for users table++**Pattern**: See cloudflare-d1 skill or reference existing d1.ts for style++---++### 6. Frontend Library+**File Needed**:+- `src/lib/api-client.ts` - Fetch wrapper with COMMENTED Clerk auth++**Pattern**: Copy from `skills/cloudflare-full-stack-integration/templates/frontend/lib/api-client.ts`+**Important**: Add `/* CLERK AUTH START */` and `/* CLERK AUTH END */` comment markers around auth code++---++### 7. Frontend Components+**Files Needed** (4 files):+- `src/components/ThemeProvider.tsx` - Dark mode (copy from tailwind-v4-shadcn skill pattern)+- `src/components/ProtectedRoute.tsx` - COMMENTED auth gate (add comment markers)+- `src/components/ChatInterface.tsx` - COMMENTED AI chat UI (add comment markers)+- `src/components/ui/.gitkeep` - Placeholder for shadcn components++**Pattern**:+- ThemeProvider: Standard dark/light/system with localStorage+- ProtectedRoute: From cloudflare-full-stack-integration skill with `/* CLERK AUTH START */` markers+- ChatInterface: Use AI SDK `useChat` hook with `/* AI CHAT START */` markers++---++### 8. Frontend Pages+**Files Needed** (3 files):+- `src/pages/Home.tsx` - Landing page with API examples, dark mode toggle+- `src/pages/Dashboard.tsx` - Example page showing D1/KV/API calls+- `src/pages/Chat.tsx` - COMMENTED chat page (uses ChatInterface component)++**Pattern**: Simple functional components, use api-client for data fetching++---++### 9. Integration Updates+**Files to Update** (2 files):+- `src/App.tsx` - Add React Router, ThemeProvider, COMMENTED ClerkProvider+- `backend/src/index.ts` - Import all routes, apply CORS middleware++**Pattern**:+```typescript+// backend/src/index.ts+import { corsDevMiddleware } from './middleware/cors'+import apiRoutes from './routes/api'+import d1Routes from './routes/d1'+// ... import all 8 routes++app.use('/api/*', corsDevMiddleware) // CRITICAL: Before routes+app.route('/api', apiRoutes)+app.route('/api/d1', d1Routes)+// ... route all 8+```++---++### 10. Config Files+**Files Needed** (3 files):+- `components.json` - shadcn/ui config+- `.env.example` - Frontend env vars (VITE_CLERK_PUBLISHABLE_KEY commented)+- `backend/tsconfig.json` - Backend-specific TS config++---++## File Inventory++### Exists (37 files)+```+skills/cloudflare-full-stack-scaffold/+├── SKILL.md ✅+├── README.md ✅+├── IMPLEMENTATION_STATUS.md ✅ (this file)+│+├── scripts/+│ ├── setup-project.sh ✅+│ ├── init-services.sh ✅+│ ├── enable-auth.sh ✅+│ └── enable-ai-chat.sh ✅+│+├── references/+│ ├── quick-start-guide.md ✅+│ ├── ai-sdk-guide.md ✅+│ ├── service-configuration.md ✅+│ ├── customization-guide.md ✅+│ └── enabling-auth.md ✅+│+└── scaffold/+ ├── package.json ✅+ ├── tsconfig.json ✅+ ├── vite.config.ts ✅+ ├── wrangler.jsonc ✅+ ├── .gitignore ✅+ ├── .dev.vars.example ✅+ ├── index.html ✅+ ├── README.md ✅+ ├── CHANGELOG.md ✅+ ├── CLAUDE.md ✅+ ├── SCRATCHPAD.md ✅+ ├── INSTALL.md ✅+ ├── schema.sql ✅+ │+ ├── docs/+ │ ├── ARCHITECTURE.md ✅+ │ ├── DATABASE_SCHEMA.md ✅+ │ ├── API_ENDPOINTS.md ✅+ │ ├── IMPLEMENTATION_PHASES.md ✅+ │ ├── UI_COMPONENTS.md ✅+ │ └── TESTING.md ✅+ │+ ├── migrations/+ │ └── 0001_initial.sql ✅+ │+ ├── src/+ │ ├── main.tsx ✅+ │ ├── App.tsx ✅ (needs update)+ │ ├── index.css ✅+ │ ├── vite-env.d.ts ✅+ │ ├── lib/+ │ │ └── utils.ts ✅+ │ ├── components/ (directories exist but empty)+ │ └── pages/ (directory exists but empty)+ │+ └── backend/+ ├── src/+ │ └── index.ts ✅ (needs update)+ ├── middleware/+ │ ├── cors.ts ✅+ │ └── auth.ts ✅+ ├── routes/+ │ ├── api.ts ✅+ │ └── d1.ts ✅+ └── db/ (directory exists but empty)+```++### Still Needed (27 files)+```+Backend Routes (6 files):+├── backend/routes/kv.ts+├── backend/routes/r2.ts+├── backend/routes/ai.ts+├── backend/routes/ai-sdk.ts+├── backend/routes/vectorize.ts+└── backend/routes/queues.ts++Backend Database (1 file):+└── backend/db/queries.ts++Frontend Library (1 file):+└── src/lib/api-client.ts++Frontend Components (4 files):+├── src/components/ThemeProvider.tsx+├── src/components/ProtectedRoute.tsx (COMMENTED)+├── src/components/ChatInterface.tsx (COMMENTED)+└── src/components/ui/.gitkeep++Frontend Pages (3 files):+├── src/pages/Home.tsx+├── src/pages/Dashboard.tsx+└── src/pages/Chat.tsx (COMMENTED)++Integration Updates (2 files):+├── src/App.tsx (update existing)+└── backend/src/index.ts (update existing)++Config Files (3 files):+├── components.json+├── .env.example+└── backend/tsconfig.json++README Updates (1 file):+└── scaffold/README.md (add features list)++Total: 27 files remaining+```++---++## Implementation Patterns++### Comment Markers for Scripts++**For Clerk Auth** (enable-auth.sh):+```typescript+/* CLERK AUTH START+import { useSession } from '@clerk/clerk-react'+// ... auth code here ...+CLERK AUTH END */+```++**For AI Chat** (enable-ai-chat.sh):+```typescript+/* AI CHAT START+import { useChat } from '@ai-sdk/react'+// ... chat code here ...+AI CHAT END */+```++**For OpenAI** (enable-ai-chat.sh):+```typescript+/* OPENAI START+import { openai } from '@ai-sdk/openai'+// ... OpenAI code here ...+OPENAI END */+```++**For Anthropic** (enable-ai-chat.sh):+```typescript+/* ANTHROPIC START+import { anthropic } from '@ai-sdk/anthropic'+// ... Anthropic code here ...+ANTHROPIC END */+```++---++## Reference Files for Copy-Paste++**Templates from cloudflare-full-stack-integration skill**:+- Frontend api-client: `skills/cloudflare-full-stack-integration/templates/frontend/lib/api-client.ts`+- ProtectedRoute: `skills/cloudflare-full-stack-integration/templates/frontend/components/ProtectedRoute.tsx`+- Backend middleware: Already copied ✅++**Templates from other skills**:+- KV patterns: `skills/cloudflare-kv/`+- R2 patterns: `skills/cloudflare-r2/`+- Workers AI: `skills/cloudflare-workers-ai/`+- Vectorize: `skills/cloudflare-vectorize/`+- Queues: `skills/cloudflare-queues/`++**ThemeProvider pattern**: Standard React context with dark/light/system modes++---++## Next Steps (In Order)++### Phase 1: Finish Backend Routes (6 files)+1. `backend/routes/kv.ts` - GET/POST/DELETE with TTL examples+2. `backend/routes/r2.ts` - Upload/download/presigned URLs+3. `backend/routes/ai.ts` - Direct Workers AI binding (text, embeddings, images)+4. `backend/routes/ai-sdk.ts` - AI SDK with Workers AI + COMMENTED OpenAI/Anthropic+5. `backend/routes/vectorize.ts` - Insert/query embeddings, RAG pattern+6. `backend/routes/queues.ts` - Producer/consumer examples++### Phase 2: Backend Database (1 file)+7. `backend/db/queries.ts` - Typed helpers for users table++### Phase 3: Frontend Library (1 file)+8. `src/lib/api-client.ts` - Copy from integration skill, add comment markers++### Phase 4: Frontend Components (4 files)+9. `src/components/ThemeProvider.tsx`+10. `src/components/ProtectedRoute.tsx` (COMMENTED)+11. `src/components/ChatInterface.tsx` (COMMENTED)+12. `src/components/ui/.gitkeep`++### Phase 5: Frontend Pages (3 files)+13. `src/pages/Home.tsx`+14. `src/pages/Dashboard.tsx`+15. `src/pages/Chat.tsx` (COMMENTED)++### Phase 6: Integration (2 files)+16. Update `src/App.tsx` - React Router + ThemeProvider + COMMENTED ClerkProvider+17. Update `backend/src/index.ts` - Import all routes + apply CORS++### Phase 7: Config (3 files)+18. `components.json`+19. `.env.example`+20. `backend/tsconfig.json`++### Phase 8: Testing+21. Copy scaffold to test directory+22. Run `npm install`+23. Run `npm run dev`+24. Test all routes work+25. Test enable-auth.sh script+26. Test enable-ai-chat.sh script++---++## Estimated Completion++**Remaining work**: 27 files+**With fresh context**: 2-3 hours+**Token estimate**: ~60-80k tokens++---++## Critical Success Criteria++1. ✅ **Scripts work** - enable-auth.sh and enable-ai-chat.sh uncomment correctly+2. ⏸️ **All routes work** - 8 service routes with working examples+3. ⏸️ **Frontend-backend connected** - API client works, CORS configured+4. ⏸️ **Dark mode works** - ThemeProvider functional+5. ⏸️ **npm run dev works** - No errors on first run+6. ⏸️ **Copy-paste ready** - Users can copy scaffold and start building++---++## Resume Instructions++**When resuming with fresh context**:++1. Read this file (IMPLEMENTATION_STATUS.md)+2. Start with Phase 1: Backend routes (kv.ts next)+3. Use reference files listed above for patterns+4. Add proper comment markers for scripts+5. Test each file as you go+6. Update this file with progress++**Quick context**: We're building a complete Cloudflare full-stack scaffold that users can copy and run immediately. It includes all Cloudflare services, optional Clerk auth, optional AI chat, and scripts to enable features. We're 40% done - basic structure, middleware, and 2/8 backend routes complete.++---++**Status**: Ready for context clear and resume+**Next file to create**: `backend/routes/kv.ts`diff --git a/skills/cloudflare-full-stack-scaffold/scaffold/backend/middleware/auth.ts b/skills/cloudflare-full-stack-scaffold/scaffold/backend/middleware/auth.tsnew file mode 100644index 00000000..07f856b3--- /dev/null+++ b/skills/cloudflare-full-stack-scaffold/scaffold/backend/middleware/auth.ts@@ -0,0 +1,140 @@+/**+ * Auth Middleware for Cloudflare Workers + Hono+ *+ * This file contains Clerk authentication patterns (COMMENTED out by default).+ * Enable auth by running: ./scripts/enable-auth.sh+ *+ * @package hono version 4.10.2++ * @package @clerk/backend version 2.19.0+ (when auth enabled)+ */++import { createMiddleware } from 'hono/factory'+import { HTTPException } from 'hono/http-exception'++/* CLERK AUTH START+import { jwt } from 'hono/jwt'+import type { JwtVariables } from 'hono/jwt'++type Variables = JwtVariables & {+ userId: string+ sessionClaims: any+}++/**+ * Simple JWT Middleware using Hono's built-in jwt()+ *+ * This is the SIMPLEST approach. Use Clerk's signing secret directly.+ *+ * Usage:+ * app.use('/api/protected/*', jwtAuthMiddleware(env.CLERK_SECRET_KEY))+ * app.get('/api/protected/data', (c) => {+ * const payload = c.get('jwtPayload')+ * const userId = payload.sub // User ID from Clerk+ * return c.json({ userId })+ * })+ */+export function jwtAuthMiddleware(secret: string) {+ return jwt({+ secret,+ cookie: 'clerk-session',+ })+}++/**+ * Advanced Auth Middleware with @clerk/backend+ *+ * Provides session verification and user metadata access.+ *+ * Usage:+ * import { createClerkClient } from '@clerk/backend'+ * const clerkClient = createClerkClient({ secretKey: env.CLERK_SECRET_KEY })+ * app.use('/api/protected/*', clerkAuthMiddleware(clerkClient))+ */+export function clerkAuthMiddleware(clerkClient: any) {+ return createMiddleware(async (c, next) => {+ const authHeader = c.req.header('Authorization')+ if (!authHeader?.startsWith('Bearer ')) {+ throw new HTTPException(401, {+ message: 'Missing or invalid Authorization header',+ })+ }++ const token = authHeader.replace('Bearer ', '')++ try {+ const session = await clerkClient.sessions.verifySession(token)+ c.set('userId', session.userId)+ c.set('sessionClaims', session)+ await next()+ } catch (error) {+ console.error('Auth verification failed:', error)+ throw new HTTPException(401, { message: 'Invalid or expired token' })+ }+ })+}++/**+ * Optional Auth Middleware+ *+ * Allows both authenticated and unauthenticated requests.+ * If authenticated: c.get('userId') will be set+ * If not authenticated: c.get('userId') will be undefined+ */+export function optionalAuthMiddleware(secret: string) {+ return createMiddleware(async (c, next) => {+ const authHeader = c.req.header('Authorization')++ if (!authHeader?.startsWith('Bearer ')) {+ return next()+ }++ const token = authHeader.replace('Bearer ', '')++ try {+ const { jwt: jwtMiddleware } = await import('hono/jwt')+ const verify = jwtMiddleware({ secret })+ await verify(c, next)+ } catch (error) {+ console.warn('Optional auth failed:', error)+ }++ await next()+ })+}++/**+ * Common Auth Errors and Fixes+ *+ * ❌ Error: "Missing or invalid Authorization header"+ * Fix: Make sure frontend sends: Authorization: Bearer <token>+ *+ * ❌ Error: "Invalid signature"+ * Fix: Check that CLERK_SECRET_KEY is correct+ *+ * ❌ Error: "Token expired"+ * Fix: Frontend needs to refresh the token (Clerk handles this)+ *+ * ❌ Error: 401 on first request after sign in+ * Fix: Frontend race condition - check isLoaded before making API calls+ */+CLERK AUTH END */++/**+ * Example: How to use auth middleware+ *+ * 1. Enable auth: ./scripts/enable-auth.sh+ * 2. Apply to protected routes:+ *+ * import { jwtAuthMiddleware } from './middleware/auth'+ * app.use('/api/protected/*', jwtAuthMiddleware(env.CLERK_SECRET_KEY))+ *+ * 3. Access user in route handler:+ *+ * app.get('/api/protected/profile', (c) => {+ * const payload = c.get('jwtPayload')+ * const userId = payload.sub+ * return c.json({ userId })+ * })+ *+ * See cloudflare-full-stack-integration skill for complete patterns.+ */diff --git a/skills/cloudflare-full-stack-scaffold/scaffold/backend/middleware/cors.ts b/skills/cloudflare-full-stack-scaffold/scaffold/backend/middleware/cors.tsnew file mode 100644index 00000000..4b4d0efa--- /dev/null+++ b/skills/cloudflare-full-stack-scaffold/scaffold/backend/middleware/cors.ts@@ -0,0 +1,62 @@+/**+ * CORS Middleware for Cloudflare Workers + Hono+ *+ * Prevents the common error:+ * "Access to fetch at '...' from origin '...' has been blocked by CORS policy"+ *+ * CRITICAL: This middleware MUST be applied BEFORE route handlers+ *+ * ❌ WRONG:+ * app.post('/api/data', handler)+ * app.use('/api/*', cors())+ *+ * ✅ CORRECT:+ * app.use('/api/*', cors())+ * app.post('/api/data', handler)+ *+ * @package hono version 4.10.2++ */++import { cors } from 'hono/cors'+import type { MiddlewareHandler } from 'hono'++/**+ * Development CORS - Allows all origins+ *+ * Use this for local development. It allows requests from any origin,+ * which is fine for dev but NOT for production.+ */+export const corsDevMiddleware: MiddlewareHandler = cors({+ origin: '*', // Allow all origins+ allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],+ allowHeaders: ['Content-Type', 'Authorization'],+ credentials: true,+ maxAge: 600, // Cache preflight for 10 minutes+})++/**+ * Production CORS - Restricted to your domain(s)+ *+ * Replace 'https://example.com' with your actual production domain.+ * You can also use an array: ['https://example.com', 'https://app.example.com']+ */+export const corsProdMiddleware: MiddlewareHandler = cors({+ origin: 'https://example.com', // ← REPLACE with your domain+ allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],+ allowHeaders: ['Content-Type', 'Authorization'],+ exposeHeaders: ['Content-Length'],+ credentials: true,+ maxAge: 86400, // Cache preflight for 24 hours+})++/**+ * Dynamic CORS - Choose based on environment+ *+ * Automatically uses dev CORS for local and prod CORS for production.+ */+export function corsMiddleware(env: any): MiddlewareHandler {+ // Check if running in production+ const isProduction = env.ENVIRONMENT === 'production'++ return isProduction ? corsProdMiddleware : corsDevMiddleware+}diff --git a/skills/cloudflare-full-stack-scaffold/scaffold/backend/routes/api.ts b/skills/cloudflare-full-stack-scaffold/scaffold/backend/routes/api.tsnew file mode 100644index 00000000..f22b6659--- /dev/null+++ b/skills/cloudflare-full-stack-scaffold/scaffold/backend/routes/api.ts@@ -0,0 +1,71 @@+/**+ * Basic API Routes+ *+ * Simple examples without database dependencies.+ * Use these patterns for your own API routes.+ */++import { Hono } from 'hono'++const api = new Hono()++// Echo endpoint - Returns what you send+api.post('/echo', async (c) => {+ const body = await c.req.json()+ return c.json({+ echo: body,+ timestamp: Date.now(),+ })+})++// Status endpoint - Returns server info+api.get('/status', (c) => {+ return c.json({+ status: 'ok',+ version: '1.0.0',+ timestamp: Date.now(),+ environment: c.env.ENVIRONMENT || 'development',+ })+})++// Example POST with validation+api.post('/data', async (c) => {+ try {+ const body = await c.req.json()++ // Simple validation+ if (!body.name) {+ return c.json({ error: 'Name is required' }, 400)+ }++ // Process data+ return c.json({+ success: true,+ data: {+ id: crypto.randomUUID(),+ name: body.name,+ createdAt: new Date().toISOString(),+ },+ })+ } catch (error) {+ return c.json({ error: 'Invalid JSON' }, 400)+ }+})++// Example query parameters+api.get('/search', (c) => {+ const query = c.req.query('q')+ const limit = parseInt(c.req.query('limit') || '10')++ return c.json({+ query,+ limit,+ results: [+ // Mock results+ { id: 1, title: `Result for: ${query}` },+ { id: 2, title: `Another result for: ${query}` },+ ].slice(0, limit),+ })+})++export default apidiff --git a/skills/cloudflare-full-stack-scaffold/scaffold/backend/routes/d1.ts b/skills/cloudflare-full-stack-scaffold/scaffold/backend/routes/d1.tsnew file mode 100644index 00000000..0fcc81df--- /dev/null+++ b/skills/cloudflare-full-stack-scaffold/scaffold/backend/routes/d1.ts@@ -0,0 +1,111 @@+/**+ * D1 Database Routes+ *+ * CRUD operations on the users table.+ * See schema.sql for table definitions.+ */++import { Hono } from 'hono'++type Bindings = {+ DB: D1Database+}++const d1 = new Hono<{ Bindings: Bindings }>()++// Get all users+d1.get('/users', async (c) => {+ const { results } = await c.env.DB.prepare(+ 'SELECT * FROM users ORDER BY created_at DESC LIMIT 100'+ ).all()++ return c.json({ users: results })+})++// Get user by ID+d1.get('/users/:id', async (c) => {+ const id = c.req.param('id')++ const user = await c.env.DB.prepare(+ 'SELECT * FROM users WHERE id = ?'+ )+ .bind(id)+ .first()++ if (!user) {+ return c.json({ error: 'User not found' }, 404)+ }++ return c.json({ user })+})++// Create user+d1.post('/users', async (c) => {+ const body = await c.req.json()++ if (!body.email) {+ return c.json({ error: 'Email is required' }, 400)+ }++ const id = crypto.randomUUID()+ const now = Math.floor(Date.now() / 1000)++ try {+ await c.env.DB.prepare(+ 'INSERT INTO users (id, email, name, created_at, updated_at) VALUES (?, ?, ?, ?, ?)'+ )+ .bind(id, body.email, body.name || null, now, now)+ .run()++ const user = await c.env.DB.prepare('SELECT * FROM users WHERE id = ?')+ .bind(id)+ .first()++ return c.json({ user }, 201)+ } catch (error: any) {+ if (error.message?.includes('UNIQUE constraint')) {+ return c.json({ error: 'Email already exists' }, 409)+ }+ throw error+ }+})++// Update user+d1.put('/users/:id', async (c) => {+ const id = c.req.param('id')+ const body = await c.req.json()+ const now = Math.floor(Date.now() / 1000)++ const result = await c.env.DB.prepare(+ 'UPDATE users SET name = ?, updated_at = ? WHERE id = ?'+ )+ .bind(body.name, now, id)+ .run()++ if (result.meta.changes === 0) {+ return c.json({ error: 'User not found' }, 404)+ }++ const user = await c.env.DB.prepare('SELECT * FROM users WHERE id = ?')+ .bind(id)+ .first()++ return c.json({ user })+})++// Delete user+d1.delete('/users/:id', async (c) => {+ const id = c.req.param('id')++ const result = await c.env.DB.prepare('DELETE FROM users WHERE id = ?')+ .bind(id)+ .run()++ if (result.meta.changes === 0) {+ return c.json({ error: 'User not found' }, 404)+ }++ return c.json({ success: true })+})++export default d1diff --git a/skills/cloudflare-full-stack-scaffold/scripts/enable-ai-chat.sh b/skills/cloudflare-full-stack-scaffold/scripts/enable-ai-chat.shnew file mode 100755index 00000000..aa0e67df--- /dev/null+++ b/skills/cloudflare-full-stack-scaffold/scripts/enable-ai-chat.sh@@ -0,0 +1,130 @@+#!/bin/bash+# Enable AI Chat Interface+# This script uncomments all AI SDK UI patterns for chat++set -e++echo "💬 Enabling AI Chat Interface..."+echo ""++# Check if we're in a project directory+if [ ! -f "package.json" ]; then+ echo "❌ Error: package.json not found"+ echo "Run this script from your project root directory"+ exit 1+fi++# 1. Uncomment ChatInterface component+echo "1. Enabling ChatInterface component..."+if [ -f "src/components/ChatInterface.tsx" ]; then+ sed -i 's/\/\* AI CHAT START//' src/components/ChatInterface.tsx+ sed -i 's/AI CHAT END \*\///' src/components/ChatInterface.tsx+ echo " ✓ ChatInterface.tsx enabled"+else+ echo " ⚠️ src/components/ChatInterface.tsx not found (will be created)"+fi++# 2. Uncomment Chat page+echo "2. Enabling Chat page..."+if [ -f "src/pages/Chat.tsx" ]; then+ sed -i 's/\/\* AI CHAT START//' src/pages/Chat.tsx+ sed -i 's/AI CHAT END \*\///' src/pages/Chat.tsx+ echo " ✓ Chat.tsx page enabled"+else+ echo " ⚠️ src/pages/Chat.tsx not found (will be created)"+fi++# 3. Uncomment Chat route in App.tsx+echo "3. Enabling Chat route in App.tsx..."+if [ -f "src/App.tsx" ]; then+ sed -i 's/\/\* AI CHAT START//' src/App.tsx+ sed -i 's/AI CHAT END \*\///' src/App.tsx+ echo " ✓ Chat route enabled in App.tsx"+else+ echo " ⚠️ src/App.tsx not found"+fi++# 4. Uncomment AI SDK routes in backend+echo "4. Enabling AI SDK routes..."+if [ -f "backend/routes/ai-sdk.ts" ]; then+ # Uncomment OpenAI examples+ sed -i 's/\/\* OPENAI START//' backend/routes/ai-sdk.ts+ sed -i 's/OPENAI END \*\///' backend/routes/ai-sdk.ts+ # Uncomment Anthropic examples+ sed -i 's/\/\* ANTHROPIC START//' backend/routes/ai-sdk.ts+ sed -i 's/ANTHROPIC END \*\///' backend/routes/ai-sdk.ts+ echo " ✓ AI SDK routes enabled"+else+ echo " ⚠️ backend/routes/ai-sdk.ts not found (will be created)"+fi++echo ""+echo "📝 Setting up environment variables..."++# 5. Create .dev.vars if it doesn't exist+if [ ! -f ".dev.vars" ]; then+ if [ -f ".dev.vars.example" ]; then+ cp .dev.vars.example .dev.vars+ echo " ✓ Created .dev.vars from .dev.vars.example"+ else+ touch .dev.vars+ echo " ✓ Created .dev.vars"+ fi+fi++echo ""+echo "🤖 AI Provider API Keys Setup (Optional)"+echo ""+echo "You can use Workers AI (free, no key needed) or add external providers:"+echo ""++# Prompt for OpenAI API key (optional)+read -p "Enter OpenAI API Key (optional, press Enter to skip): " OPENAI_KEY+if [ ! -z "$OPENAI_KEY" ]; then+ if grep -q "OPENAI_API_KEY" .dev.vars; then+ sed -i "s|^.*OPENAI_API_KEY=.*|OPENAI_API_KEY=$OPENAI_KEY|" .dev.vars+ else+ echo "OPENAI_API_KEY=$OPENAI_KEY" >> .dev.vars+ fi+ echo " ✓ Added OPENAI_API_KEY to .dev.vars"+fi++# Prompt for Anthropic API key (optional)+read -p "Enter Anthropic API Key (optional, press Enter to skip): " ANTHROPIC_KEY+if [ ! -z "$ANTHROPIC_KEY" ]; then+ if grep -q "ANTHROPIC_API_KEY" .dev.vars; then+ sed -i "s|^.*ANTHROPIC_API_KEY=.*|ANTHROPIC_API_KEY=$ANTHROPIC_KEY|" .dev.vars+ else+ echo "ANTHROPIC_API_KEY=$ANTHROPIC_KEY" >> .dev.vars+ fi+ echo " ✓ Added ANTHROPIC_API_KEY to .dev.vars"+fi++# Prompt for Google API key (optional)+read -p "Enter Google AI API Key (optional, press Enter to skip): " GOOGLE_KEY+if [ ! -z "$GOOGLE_KEY" ]; then+ if grep -q "GOOGLE_GENERATIVE_AI_API_KEY" .dev.vars; then+ sed -i "s|^.*GOOGLE_GENERATIVE_AI_API_KEY=.*|GOOGLE_GENERATIVE_AI_API_KEY=$GOOGLE_KEY|" .dev.vars+ else+ echo "GOOGLE_GENERATIVE_AI_API_KEY=$GOOGLE_KEY" >> .dev.vars+ fi+ echo " ✓ Added GOOGLE_GENERATIVE_AI_API_KEY to .dev.vars"+fi++echo ""+echo "✅ AI Chat interface enabled!"+echo ""+echo "Next steps:"+echo " 1. Restart your dev server:"+echo " npm run dev"+echo ""+echo " 2. Visit the chat page:"+echo " http://localhost:5173/chat"+echo ""+echo " 3. Choose your AI provider:"+echo " - Workers AI (free, no setup)"+echo " - OpenAI GPT-4o (requires API key)"+echo " - Anthropic Claude (requires API key)"+echo " - Google Gemini (requires API key)"+echo ""+echo "See references/ai-sdk-guide.md for more information"diff --git a/skills/cloudflare-full-stack-scaffold/scripts/enable-auth.sh b/skills/cloudflare-full-stack-scaffold/scripts/enable-auth.shnew file mode 100755index 00000000..787c8e20--- /dev/null+++ b/skills/cloudflare-full-stack-scaffold/scripts/enable-auth.sh@@ -0,0 +1,126 @@+#!/bin/bash+# Enable Clerk Authentication+# This script uncomments all Clerk auth patterns in the scaffold++set -e++echo "🔐 Enabling Clerk Authentication..."+echo ""++# Check if we're in a project directory (has package.json)+if [ ! -f "package.json" ]; then+ echo "❌ Error: package.json not found"+ echo "Run this script from your project root directory"+ exit 1+fi++# 1. Uncomment api-client auth patterns+echo "1. Enabling auth in api-client.ts..."+if [ -f "src/lib/api-client.ts" ]; then+ # This will be implemented by removing /* */ comment blocks+ sed -i 's/\/\* CLERK AUTH START//' src/lib/api-client.ts+ sed -i 's/CLERK AUTH END \*\///' src/lib/api-client.ts+ echo " ✓ api-client.ts auth enabled"+else+ echo " ⚠️ src/lib/api-client.ts not found (will be created)"+fi++# 2. Uncomment ProtectedRoute component+echo "2. Enabling ProtectedRoute component..."+if [ -f "src/components/ProtectedRoute.tsx" ]; then+ sed -i 's/\/\* CLERK AUTH START//' src/components/ProtectedRoute.tsx+ sed -i 's/CLERK AUTH END \*\///' src/components/ProtectedRoute.tsx+ echo " ✓ ProtectedRoute.tsx enabled"+else+ echo " ⚠️ src/components/ProtectedRoute.tsx not found (will be created)"+fi++# 3. Uncomment backend auth middleware+echo "3. Enabling backend auth middleware..."+if [ -f "backend/middleware/auth.ts" ]; then+ sed -i 's/\/\* CLERK AUTH START//' backend/middleware/auth.ts+ sed -i 's/CLERK AUTH END \*\///' backend/middleware/auth.ts+ echo " ✓ auth.ts middleware enabled"+else+ echo " ⚠️ backend/middleware/auth.ts not found (will be created)"+fi++# 4. Uncomment ClerkProvider in App.tsx+echo "4. Enabling ClerkProvider in App.tsx..."+if [ -f "src/App.tsx" ]; then+ sed -i 's/\/\* CLERK AUTH START//' src/App.tsx+ sed -i 's/CLERK AUTH END \*\///' src/App.tsx+ echo " ✓ ClerkProvider enabled in App.tsx"+else+ echo " ⚠️ src/App.tsx not found"+fi++echo ""+echo "📝 Setting up environment variables..."++# 5. Create .env if it doesn't exist+if [ ! -f ".env" ]; then+ if [ -f ".env.example" ]; then+ cp .env.example .env+ echo " ✓ Created .env from .env.example"+ else+ touch .env+ echo " ✓ Created .env"+ fi+fi++# 6. Create .dev.vars if it doesn't exist+if [ ! -f ".dev.vars" ]; then+ if [ -f ".dev.vars.example" ]; then+ cp .dev.vars.example .dev.vars+ echo " ✓ Created .dev.vars from .dev.vars.example"+ else+ touch .dev.vars+ echo " ✓ Created .dev.vars"+ fi+fi++echo ""+echo "🔑 Clerk API Keys Setup"+echo ""+echo "Get your keys from: https://dashboard.clerk.com"+echo ""++# Prompt for Clerk publishable key+read -p "Enter your Clerk Publishable Key (pk_test_xxx): " CLERK_PUB_KEY+if [ ! -z "$CLERK_PUB_KEY" ]; then+ # Add to .env (frontend)+ if grep -q "VITE_CLERK_PUBLISHABLE_KEY" .env; then+ sed -i "s|^.*VITE_CLERK_PUBLISHABLE_KEY=.*|VITE_CLERK_PUBLISHABLE_KEY=$CLERK_PUB_KEY|" .env+ else+ echo "VITE_CLERK_PUBLISHABLE_KEY=$CLERK_PUB_KEY" >> .env+ fi+ echo " ✓ Added VITE_CLERK_PUBLISHABLE_KEY to .env"+fi++# Prompt for Clerk secret key+read -p "Enter your Clerk Secret Key (sk_test_xxx): " CLERK_SECRET_KEY+if [ ! -z "$CLERK_SECRET_KEY" ]; then+ # Add to .dev.vars (backend)+ if grep -q "CLERK_SECRET_KEY" .dev.vars; then+ sed -i "s|^.*CLERK_SECRET_KEY=.*|CLERK_SECRET_KEY=$CLERK_SECRET_KEY|" .dev.vars+ else+ echo "CLERK_SECRET_KEY=$CLERK_SECRET_KEY" >> .dev.vars+ fi+ echo " ✓ Added CLERK_SECRET_KEY to .dev.vars"+fi++echo ""+echo "✅ Clerk authentication enabled!"+echo ""+echo "Next steps:"+echo " 1. Create a JWT template in Clerk Dashboard"+echo " Name: cloudflare-worker"+echo " Claims: email, firstName, lastName, userId"+echo ""+echo " 2. Restart your dev server:"+echo " npm run dev"+echo ""+echo " 3. Test authentication by visiting your app"+echo ""+echo "See references/enabling-auth.md for detailed setup instructions"