Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
feat: Add rules for 6 high-priority skills
Jez8b7cc6c2aa3d
diff --git a/skills/ai-sdk-core/rules/ai-sdk-core.md b/skills/ai-sdk-core/rules/ai-sdk-core.mdnew file mode 100644index 00000000..fea33a6b--- /dev/null+++ b/skills/ai-sdk-core/rules/ai-sdk-core.md@@ -0,0 +1,115 @@+---+paths: "**/*.ts", "**/*.tsx", package.json+---++# AI SDK v5/v6 Corrections++Claude's training may reference AI SDK v4 patterns. This project uses **AI SDK v5+**.++## Critical v4→v5 Breaking Changes++### Parameter Renames+```typescript+/* ❌ v4 (Claude may suggest this) */+maxTokens: 500+providerMetadata: { openai: { user: 'user-123' } }++/* ✅ v5 (use this) */+maxOutputTokens: 500+providerOptions: { openai: { user: 'user-123' } }+```++### Tool Definitions+```typescript+/* ❌ v4 */+tools: {+ weather: {+ parameters: z.object({ location: z.string() }),+ execute: async (args) => { /* args.location */ },+ },+}++/* ✅ v5 */+import { tool } from 'ai'+tools: {+ weather: tool({+ inputSchema: z.object({ location: z.string() }),+ execute: async ({ location }) => { /* input.location */ },+ }),+}+```++### Multi-Step Execution+```typescript+/* ❌ v4 */+maxSteps: 5++/* ✅ v5 */+import { stopWhen, stepCountIs } from 'ai'+stopWhen: stepCountIs(5)+```++### Message Types+```typescript+/* ❌ v4 */+import { CoreMessage } from 'ai'+convertToCoreMessages(messages)++/* ✅ v5 */+import { ModelMessage } from 'ai'+convertToModelMessages(messages)+```++### Package Imports+```typescript+/* ❌ v4 */+import { ... } from 'ai/rsc'+import { ... } from 'ai/react'++/* ✅ v5 */+import { ... } from '@ai-sdk/rsc'+import { ... } from '@ai-sdk/react'+```++## Cloudflare Workers Startup Fix++```typescript+/* ❌ Causes >270ms startup (exceeds 400ms limit) */+import { createWorkersAI } from 'workers-ai-provider'+const workersai = createWorkersAI({ binding: env.AI })++/* ✅ Lazy initialization inside handler */+app.post('/chat', async (c) => {+ const { createWorkersAI } = await import('workers-ai-provider')+ const workersai = createWorkersAI({ binding: c.env.AI })+})+```++## Model Names (2025)++```typescript+/* OpenAI */+openai('gpt-5') // Latest+openai('gpt-5.1') // Improved++/* Anthropic */+anthropic('claude-sonnet-4-5-20250929') // Latest Sonnet+anthropic('claude-opus-4-5-20251101') // Latest Opus++/* Google */+google('gemini-2.5-pro')+google('gemini-2.5-flash')+```++## Quick Fixes++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `maxTokens` | `maxOutputTokens` |+| `providerMetadata` | `providerOptions` |+| `parameters` (in tools) | `inputSchema` |+| `args` (in execute) | destructured input `{ location }` |+| `maxSteps: 5` | `stopWhen: stepCountIs(5)` |+| `CoreMessage` | `ModelMessage` |+| `from 'ai/rsc'` | `from '@ai-sdk/rsc'` |+| `ToolExecutionError` | `tool-error` content parts |diff --git a/skills/better-auth/rules/better-auth.md b/skills/better-auth/rules/better-auth.mdnew file mode 100644index 00000000..386facd1--- /dev/null+++ b/skills/better-auth/rules/better-auth.md@@ -0,0 +1,92 @@+---+paths: "**/*auth*.ts", "**/*auth*.tsx", src/lib/auth.ts, src/auth.ts+---++# better-auth Corrections++Claude's training may reference older better-auth patterns. This project uses **better-auth v1.4+**.++## Critical: No D1 Adapter++```typescript+/* ❌ This doesn't exist */+import { d1Adapter } from 'better-auth/adapters/d1'+database: d1Adapter(env.DB)++/* ✅ Use Drizzle instead */+import { drizzleAdapter } from 'better-auth/adapters/drizzle'+import { drizzle } from 'drizzle-orm/d1'+const db = drizzle(env.DB, { schema })+database: drizzleAdapter(db, { provider: "sqlite" })++/* ✅ Or use Kysely */+import { Kysely } from 'kysely'+import { D1Dialect } from 'kysely-d1'+database: {+ db: new Kysely({ dialect: new D1Dialect({ database: env.DB }) }),+ type: "sqlite"+}+```++## v1.4.0 Breaking Changes (Nov 2025)++```typescript+/* ❌ CommonJS no longer supported */+const { betterAuth } = require('better-auth')++/* ✅ ESM only */+import { betterAuth } from 'better-auth'+```++## TanStack Start: Cookie Plugin Required++```typescript+/* ❌ Cookies won't set properly */+export const auth = betterAuth({+ plugins: [twoFactor(), organization()],+})++/* ✅ reactStartCookies MUST be last */+import { reactStartCookies } from 'better-auth/react-start'+export const auth = betterAuth({+ plugins: [+ twoFactor(),+ organization(),+ reactStartCookies(), // MUST be LAST+ ],+})+```++## Nanostore Session Invalidation++```typescript+/* ❌ TanStack Query invalidation doesn't update session */+queryClient.invalidateQueries({ queryKey: ['user-profile'] })++/* ✅ Notify nanostore after user updates */+const { data, error } = await authClient.updateUser({ image: newAvatarUrl })+if (!error) {+ authClient.$store.notify('$sessionSignal')+}+```++## Schema Generation++```bash+# ❌ better-auth migrate doesn't work well with D1+npx better-auth migrate++# ✅ Use Drizzle Kit instead+npx drizzle-kit generate+wrangler d1 migrations apply my-db --remote+```++## Quick Fixes++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `d1Adapter(env.DB)` | `drizzleAdapter(db, { provider: "sqlite" })` |+| `require('better-auth')` | `import { betterAuth } from 'better-auth'` |+| Missing cookies in TanStack Start | Add `reactStartCookies()` as last plugin |+| `queryClient.invalidateQueries` for session | `authClient.$store.notify('$sessionSignal')` |+| `npx better-auth migrate` | `npx drizzle-kit generate` |diff --git a/skills/clerk-auth/rules/clerk-auth.md b/skills/clerk-auth/rules/clerk-auth.mdnew file mode 100644index 00000000..e5c64f68--- /dev/null+++ b/skills/clerk-auth/rules/clerk-auth.md@@ -0,0 +1,101 @@+---+paths: "**/*clerk*.ts", "**/*middleware*.ts", "**/*auth*.ts", src/app/api/**/*.ts+---++# Clerk Auth Corrections++Claude's training may reference older Clerk patterns. This project uses **Clerk v6+**.++## Next.js v6: auth() is Async++```typescript+/* ❌ v5 (synchronous) */+import { auth } from '@clerk/nextjs/server'+const { userId } = auth()++/* ✅ v6 (asynchronous) */+import { auth } from '@clerk/nextjs/server'+const { userId } = await auth()+```++## auth.protect() is Async++```typescript+/* ❌ v5 */+auth.protect()++/* ✅ v6 */+await auth.protect()+```++## API Version 2025-11-10 Changes++```typescript+/* ❌ Old field names */+{ payment_source_id: "...", payment_source: {...} }++/* ✅ New field names */+{ payment_method_id: "...", payment_method: {...} }++/* ❌ Old endpoints */+GET /v1/commerce/plans++/* ✅ New endpoints */+GET /v1/billing/plans+```++## Cloudflare Workers: authorizedParties Required++```typescript+import { verifyToken } from '@clerk/backend'++/* ❌ CSRF vulnerability */+const { data } = await verifyToken(token, {+ secretKey: c.env.CLERK_SECRET_KEY,+})++/* ✅ Always set authorizedParties */+const { data } = await verifyToken(token, {+ secretKey: c.env.CLERK_SECRET_KEY,+ authorizedParties: ['https://yourdomain.com'],+})+```++## JWT Size Limit: 1.2KB++```json+// ❌ Exceeds limit (large metadata)+{+ "bio": "{{user.public_metadata.bio}}",+ "all_metadata": "{{user.public_metadata}}"+}++// ✅ Keep claims minimal+{+ "user_id": "{{user.id}}",+ "email": "{{user.primary_email_address}}",+ "role": "{{user.public_metadata.role}}"+}+```++## Vite Dev Mode: 431 Error Fix++```json+// package.json - Increase header limit+{+ "scripts": {+ "dev": "NODE_OPTIONS='--max-http-header-size=32768' vite"+ }+}+```++## Quick Fixes++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `const { userId } = auth()` | `const { userId } = await auth()` |+| `auth.protect()` | `await auth.protect()` |+| `apiKey` | `secretKey` |+| Missing `authorizedParties` | Add `authorizedParties: ['https://yourdomain.com']` |+| `/v1/commerce/*` endpoints | `/v1/billing/*` endpoints |+| `payment_source` | `payment_method` |diff --git a/skills/drizzle-orm-d1/rules/drizzle-orm-d1.md b/skills/drizzle-orm-d1/rules/drizzle-orm-d1.mdnew file mode 100644index 00000000..6dae4550--- /dev/null+++ b/skills/drizzle-orm-d1/rules/drizzle-orm-d1.md@@ -0,0 +1,92 @@+---+paths: "**/*schema*.ts", "**/*db*.ts", drizzle.config.ts, wrangler.jsonc, wrangler.toml+---++# Drizzle ORM + D1 Corrections++Claude's training may suggest patterns that don't work with Cloudflare D1.++## Critical: No SQL Transactions++```typescript+/* ❌ D1 doesn't support SQL BEGIN/COMMIT */+await db.transaction(async (tx) => {+ await tx.insert(users).values({ ... })+ await tx.insert(posts).values({ ... })+})+// Error: D1_ERROR: Cannot use BEGIN TRANSACTION++/* ✅ Use D1 batch API instead */+await db.batch([+ db.insert(users).values({ email: '[email protected]' }),+ db.insert(posts).values({ title: 'Post', authorId: 1 }),+])+```++## Migrations: Use Wrangler, Not Drizzle Push++```bash+# ❌ drizzle-kit push doesn't work reliably with D1+npx drizzle-kit push++# ✅ Generate SQL then apply with Wrangler+npx drizzle-kit generate+npx wrangler d1 migrations apply my-database --local # Test first+npx wrangler d1 migrations apply my-database --remote # Production+```++## wrangler.jsonc: Set migrations_dir++```jsonc+{+ "d1_databases": [{+ "binding": "DB",+ "database_name": "my-database",+ "database_id": "your-database-id",+ "migrations_dir": "./migrations" // Points to Drizzle output+ }]+}+```++## Dates: Use Integer with Timestamp Mode++```typescript+/* ❌ D1 has no native DATE type */+createdAt: text('created_at')++/* ✅ Use integer with timestamp mode */+createdAt: integer('created_at', { mode: 'timestamp' }).$defaultFn(() => new Date())+```++## Foreign Keys: Use Cascading++```typescript+/* ❌ May fail during migrations */+authorId: integer('author_id').references(() => users.id)++/* ✅ Add cascading to prevent constraint failures */+authorId: integer('author_id').references(() => users.id, { onDelete: 'cascade' })+```++## Don't Import from Wrangler++```typescript+/* ❌ Fails in production */+import { ... } from 'wrangler'++/* ✅ Use drizzle-orm/d1 */+import { drizzle } from 'drizzle-orm/d1'+const db = drizzle(env.DB)+```++## Quick Fixes++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `db.transaction()` | `db.batch([...])` |+| `npx drizzle-kit push` | `npx drizzle-kit generate` + `wrangler d1 migrations apply` |+| Missing `migrations_dir` | Add to wrangler.jsonc d1_databases config |+| `text()` for dates | `integer('col', { mode: 'timestamp' })` |+| `.default(new Date())` | `.$defaultFn(() => new Date())` |+| Import from 'wrangler' | Import from 'drizzle-orm/d1' |+| `wrangler.toml` | `wrangler.jsonc` (supports comments) |diff --git a/skills/nextjs/rules/nextjs.md b/skills/nextjs/rules/nextjs.mdnew file mode 100644index 00000000..ca0336af--- /dev/null+++ b/skills/nextjs/rules/nextjs.md@@ -0,0 +1,118 @@+---+paths: "**/*.tsx", "**/*.ts", next.config.*, app/**/page.tsx, app/**/layout.tsx, app/**/route.ts+---++# Next.js 16 Corrections++Claude's training may reference Next.js 15 patterns. This project uses **Next.js 16**.++## Async Route Parameters (BREAKING)++```typescript+/* ❌ Next.js 15 (synchronous) */+export default function Page({ params, searchParams }: {+ params: { slug: string }+ searchParams: { query: string }+}) {+ const slug = params.slug // Error: params is a Promise+}++/* ✅ Next.js 16 (asynchronous) */+export default async function Page({ params, searchParams }: {+ params: Promise<{ slug: string }>+ searchParams: Promise<{ query: string }>+}) {+ const { slug } = await params+ const { query } = await searchParams+}+```++## cookies() and headers() are Async++```typescript+/* ❌ Next.js 15 */+import { cookies, headers } from 'next/headers'+const cookieStore = cookies()+const headersList = headers()++/* ✅ Next.js 16 */+const cookieStore = await cookies()+const headersList = await headers()+```++## middleware.ts → proxy.ts++```typescript+/* ❌ Deprecated in Next.js 16 */+// middleware.ts+export function middleware(request: NextRequest) { ... }++/* ✅ Use proxy.ts instead */+// proxy.ts+export function proxy(request: NextRequest) { ... }+```++## Parallel Routes: default.js Required++```+/* ❌ Will fail during soft navigation */+app/+├── @modal/+│ └── login/page.tsx++/* ✅ Add default.tsx to every parallel route */+app/+├── @modal/+│ ├── login/page.tsx+│ └── default.tsx ← Required!+```++```typescript+// app/@modal/default.tsx+export default function ModalDefault() {+ return null+}+```++## revalidateTag() Requires 2 Arguments++```typescript+/* ❌ Next.js 15 */+revalidateTag('posts')++/* ✅ Next.js 16 - second argument required */+revalidateTag('posts', 'max')++// Or with custom cache life:+revalidateTag('posts', {+ stale: 3600,+ revalidate: 86400,+})+```++## Cache Components with "use cache"++```typescript+/* ❌ Next.js 15 - implicit caching */+export async function getData() {+ return fetch('/api/data').then(r => r.json())+}++/* ✅ Next.js 16 - opt-in caching */+'use cache'+export async function getData() {+ return fetch('/api/data').then(r => r.json())+}+```++## Quick Fixes++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `params: { id: string }` | `params: Promise<{ id: string }>` + `await params` |+| `const cookieStore = cookies()` | `const cookieStore = await cookies()` |+| `middleware.ts` | `proxy.ts` |+| Missing `default.tsx` in @slots | Add `default.tsx` returning `null` |+| `revalidateTag('tag')` | `revalidateTag('tag', 'max')` |+| Implicit fetch caching | Add `'use cache'` directive |+| `experimental.ppr` | Use `"use cache"` directive instead |diff --git a/skills/tanstack-query/rules/tanstack-query.md b/skills/tanstack-query/rules/tanstack-query.mdnew file mode 100644index 00000000..df04cd75--- /dev/null+++ b/skills/tanstack-query/rules/tanstack-query.md@@ -0,0 +1,126 @@+---+paths: "**/*.tsx", "**/*.ts", "**/*query*.ts", "**/*hook*.ts"+---++# TanStack Query v5 Corrections++Claude's training may reference TanStack Query v4 patterns. This project uses **v5**.++## Object Syntax Required++```typescript+/* ❌ v4 array syntax (removed in v5) */+useQuery(['todos'], fetchTodos, { staleTime: 5000 })++/* ✅ v5 object syntax only */+useQuery({+ queryKey: ['todos'],+ queryFn: fetchTodos,+ staleTime: 5000+})+```++## Query Callbacks Removed++```typescript+/* ❌ v5 removed onSuccess/onError/onSettled from queries */+useQuery({+ queryKey: ['todos'],+ queryFn: fetchTodos,+ onSuccess: (data) => console.log(data), // Removed!+})++/* ✅ Use useEffect instead */+const { data } = useQuery({ queryKey: ['todos'], queryFn: fetchTodos })+useEffect(() => {+ if (data) console.log(data)+}, [data])++/* Note: Mutations still support callbacks */+useMutation({+ mutationFn: addTodo,+ onSuccess: () => {}, // Still works!+})+```++## isPending vs isLoading++```typescript+/* ❌ isLoading meaning changed in v5 */+if (isLoading) return <Loading />++/* ✅ Use isPending for initial load */+const { data, isPending } = useQuery(...)+if (isPending) return <Loading />+// isPending = no data yet+// isLoading = isPending && isFetching+```++## cacheTime → gcTime++```typescript+/* ❌ Renamed in v5 */+useQuery({+ queryKey: ['todos'],+ queryFn: fetchTodos,+ cacheTime: 1000 * 60 * 60, // Error!+})++/* ✅ Use gcTime */+useQuery({+ queryKey: ['todos'],+ queryFn: fetchTodos,+ gcTime: 1000 * 60 * 60,+})+```++## keepPreviousData → placeholderData++```typescript+/* ❌ Removed in v5 */+useQuery({+ queryKey: ['todos', page],+ queryFn: () => fetchTodos(page),+ keepPreviousData: true, // Error!+})++/* ✅ Use placeholderData helper */+import { keepPreviousData } from '@tanstack/react-query'++useQuery({+ queryKey: ['todos', page],+ queryFn: () => fetchTodos(page),+ placeholderData: keepPreviousData,+})+```++## Infinite Queries: initialPageParam Required++```typescript+/* ❌ v4 used undefined as first pageParam */+useInfiniteQuery({+ queryKey: ['projects'],+ queryFn: ({ pageParam = 0 }) => fetchProjects(pageParam),+ getNextPageParam: (lastPage) => lastPage.nextCursor,+})++/* ✅ v5 requires explicit initialPageParam */+useInfiniteQuery({+ queryKey: ['projects'],+ queryFn: ({ pageParam }) => fetchProjects(pageParam),+ initialPageParam: 0, // Required!+ getNextPageParam: (lastPage) => lastPage.nextCursor,+})+```++## Quick Fixes++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `useQuery(['key'], fn, opts)` | `useQuery({ queryKey, queryFn, ...opts })` |+| `onSuccess` in useQuery | `useEffect` watching data |+| `cacheTime` | `gcTime` |+| `isLoading` for initial load | `isPending` |+| `keepPreviousData: true` | `placeholderData: keepPreviousData` |+| Missing `initialPageParam` | Add `initialPageParam: 0` (or appropriate value) |+| `useErrorBoundary` | `throwOnError` |