Skills for Claude Code CLI such as full stack dev Cloudflare, React, Tailwind v4, and AI integrations.
Python aianthropicautomationclaude-codeclaude-skillscloudflaredevtoolsproductivityreactskillstailwindvite
feat: Add Claude rules pattern for portable project context (#3)
Jeremy Dawes61499d8e3486
diff --git a/CLAUDE.md b/CLAUDE.mdindex 36ff0e02..847cfaf1 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -181,6 +181,7 @@ This repository has three types of files:- `skills/*/references/` - Reference documentation- `skills/*/scripts/` - Helper scripts- `skills/*/assets/` - Images, diagrams+- `skills/*/rules/` - Correction rules (copied to projects)**Commands**:- `commands/*.md` - Slash command definitions@@ -396,6 +397,52 @@ After optimizing 20+ skills, these patterns work best:**Examples:** See ai-sdk-core, auto-animate, cloudflare-mcp-server+### 5. Project Rules (Portable Context)++Skills can include `rules/` directories containing correction rules that get copied into projects. These rules:++- **Bridge training cutoffs**: Correct outdated patterns Claude may suggest (e.g., Tailwind v3 → v4 syntax)+- **Are project-portable**: Committed to the project repo, work in any environment (local CLI, Claude Code online, team members)+- **Reduce user-level dependency**: Project carries its own intelligence instead of relying on user's `~/.claude/CLAUDE.md`++**How rules differ from skills:**++| Aspect | Skills | Rules |+|--------|--------|-------|+| **Location** | `~/.claude/skills/` (user-level) | `.claude/rules/` (project-level) |+| **Content** | Rich bundles (templates, scripts, references) | Single markdown files |+| **Loading** | Triggered by keywords | Always loaded for matching paths |+| **Purpose** | Teach Claude how to use a technology | Correct specific patterns |++**Rule Types:**++1. **Correction Rules** (e.g., `tailwind-v4-shadcn.md`): Bridge training cutoff gaps with current syntax+2. **Session Protocol** (e.g., `session-protocol.md`): Project-specific session management conventions++**Adding rules to a skill:**++```+skills/my-skill/+├── SKILL.md+├── rules/ # ← NEW+│ └── my-skill.md # Correction rule (matches skill name)+├── templates/+└── references/+```++**Copying rules to a project:**++Rules are copied to projects via `/plan-project` command or manually:+```bash+mkdir -p .claude/rules+cp ~/.claude/skills/tailwind-v4-shadcn/rules/tailwind-v4-shadcn.md .claude/rules/+```++**Current skills with rules:**+- `tailwind-v4-shadcn` - v3→v4 syntax corrections+- `cloudflare-worker-base` - Export patterns, wrangler.jsonc, ES modules+- `project-session-management` - Session protocol template+---## Commands & Scriptsdiff --git a/commands/plan-project.md b/commands/plan-project.mdindex ada8669f..7953dba4 100644--- a/commands/plan-project.md+++ b/commands/plan-project.md@@ -106,18 +106,38 @@ ls docs/IMPLEMENTATION_PHASES.mdls SESSION.md```+### 3.5. Create Session Protocol Rule++**Create `.claude/rules/` directory and copy session protocol:**+```bash+mkdir -p .claude/rules+```++**Copy session protocol from skill** (if project-session-management skill is installed):+```bash+cp ~/.claude/skills/project-session-management/rules/session-protocol.md .claude/rules/+```++**If skill not installed**, create the rule manually by reading the template from:+`skills/project-session-management/rules/session-protocol.md`++**Customize for this project:**+- Update "Key Files" section to list only the planning docs that were actually created+- Add any project-specific files or conventions+- This rule will be committed with the project and work across all environments (local, Claude Code online, team members)+### 4. Create Initial Git Commit (If Not Already Committed)**Check if planning docs are committed:**```bash-git status --short docs/ SESSION.md+git status --short docs/ SESSION.md .claude/rules/```**If uncommitted planning docs exist:**-Stage all planning docs:+Stage all planning docs and rules:```bash-git add docs/ SESSION.md+git add docs/ SESSION.md .claude/rules/```Check if this is initial commit:@@ -144,6 +164,7 @@ Generated planning documentation:[- ARCHITECTURE.md][- other docs...]- SESSION.md (session tracking)+- .claude/rules/session-protocol.md (session rules)Next: Start Phase 1 - [Phase 1 Name]@@ -165,6 +186,7 @@ Generated planning docs:[- API_ENDPOINTS.md][- other docs...]- SESSION.md (session tracking)+- .claude/rules/session-protocol.md (session rules)Next: Start Phase 1 - [Phase 1 Name]@@ -198,6 +220,7 @@ PLANNING DOCS CREATED:✅ IMPLEMENTATION_PHASES.md ([N] phases)✅ SESSION.md (progress tracker)+✅ .claude/rules/session-protocol.md (session rules)[✅ DATABASE_SCHEMA.md] (if created)[✅ API_ENDPOINTS.md] (if created)[✅ ARCHITECTURE.md] (if created)@@ -330,6 +353,7 @@ git push✅ project-planning skill invoked successfully✅ IMPLEMENTATION_PHASES.md created with validated phases✅ SESSION.md created with Phase 1 as current+✅ .claude/rules/session-protocol.md created (portable session rules)✅ Planning docs committed to git (if git repo exists)✅ User has clear "Next Action" to start Phase 1✅ User knows where to find all planning docsdiff --git a/skills/cloudflare-worker-base/rules/cloudflare-worker-base.md b/skills/cloudflare-worker-base/rules/cloudflare-worker-base.mdnew file mode 100644index 00000000..af6cd636--- /dev/null+++ b/skills/cloudflare-worker-base/rules/cloudflare-worker-base.md@@ -0,0 +1,140 @@+---+paths: wrangler.jsonc, wrangler.toml, src/server/**/*.ts, src/worker/**/*.ts, "**/*.worker.ts", vite.config.*+---++# Cloudflare Workers Corrections++Claude's training may reference older Workers patterns. This project uses current (2025) conventions.++## Critical Patterns++### Export Syntax+```typescript+/* ❌ Causes "Cannot read properties of undefined" */+export default { fetch: app.fetch }++/* ✅ Correct pattern */+export default app+```++### Static Assets with SPA Routing++When using `"not_found_handling": "single-page-application"`, API routes get intercepted and return `index.html` instead of JSON.++```jsonc+/* wrangler.jsonc - MUST include run_worker_first */+{+ "assets": {+ "directory": "./public/",+ "binding": "ASSETS",+ "not_found_handling": "single-page-application",+ "run_worker_first": ["/api/*"] // ← Critical: ensures Worker handles API routes+ }+}+```++### Configuration File+```bash+# ❌ Older format (still works but not recommended)+wrangler.toml++# ✅ Current format (supports comments, better DX)+wrangler.jsonc+```++### ES Module Format (Required)++```typescript+/* ❌ Service Worker format (deprecated) */+addEventListener('fetch', (event) => {+ event.respondWith(handleRequest(event.request))+})++/* ✅ ES Module format (required) */+export default {+ async fetch(request, env, ctx) {+ return new Response('Hello')+ }+}++/* ✅ Or with Hono */+import { Hono } from 'hono'+const app = new Hono()+export default app+```++### Scheduled Handlers++When adding cron triggers, must use Module Worker format:++```typescript+/* ✅ Combining fetch + scheduled */+export default {+ fetch: app.fetch,+ scheduled: async (event, env, ctx) => {+ // Cron job logic+ }+}+```++## Environment & Bindings++### Type-Safe Bindings+```typescript+type Bindings = {+ DB: D1Database+ KV: KVNamespace+ BUCKET: R2Bucket+ ASSETS: Fetcher+ MY_SECRET: string+}++const app = new Hono<{ Bindings: Bindings }>()+```++### Secrets Management+```bash+# ❌ Native Integrations (removed from dashboard June 2025)+# Set up via Cloudflare dashboard++# ✅ CLI-based approach+wrangler secret put MY_SECRET+```++## No Node.js APIs++Workers runtime is NOT Node.js:++```typescript+/* ❌ Node.js APIs don't exist */+import fs from 'fs'+import path from 'path'+process.env.MY_VAR++/* ✅ Use Web APIs and env bindings */+const response = await fetch(url)+const data = env.MY_VAR+```++## Vite Plugin++```typescript+/* vite.config.ts */+import { defineConfig } from 'vite'+import { cloudflare } from '@cloudflare/vite-plugin'++export default defineConfig({+ plugins: [cloudflare()]+})+```++## Quick Fixes++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `export default { fetch: app.fetch }` | `export default app` |+| `wrangler.toml` | `wrangler.jsonc` |+| Service Worker `addEventListener` | ES Module `export default` |+| `process.env.X` | `env.X` from handler params |+| Native Integrations dashboard | `wrangler secret put` |+| Missing `run_worker_first` | Add to assets config for API routes |diff --git a/skills/project-session-management/rules/session-protocol.md b/skills/project-session-management/rules/session-protocol.mdnew file mode 100644index 00000000..c35aec30--- /dev/null+++ b/skills/project-session-management/rules/session-protocol.md@@ -0,0 +1,72 @@+# Session Protocol++This project uses SESSION.md for progress tracking across work sessions.++## Key Files++- **SESSION.md** - Current progress, next action, known issues (project root)+- **docs/IMPLEMENTATION_PHASES.md** - Full phase specifications+<!-- CUSTOMIZE: Add other planning docs as needed -->++## Status Icons++- ⏸️ = Not started (pending)+- 🔄 = In progress+- ✅ = Complete+- 🚫 = Blocked++## Stages Within a Phase++1. **Implementation** - Writing code for tasks+2. **Verification** - Testing against phase criteria+3. **Debugging** - Fixing issues found++## When Reading SESSION.md++1. Check "Current Phase" and "Current Stage"+2. Review "Progress" checklist for completed/pending tasks+3. Read "Next Action" for specific task (file + line + action)+4. Note any "Known Issues"++## When Updating SESSION.md++1. Mark completed tasks with `[x]`+2. Update "Current Stage" if changed+3. Set concrete "Next Action": file path + line number + specific task+4. Document any new issues in "Known Issues"+5. If phase complete: Change 🔄 to ✅, collapse to summary++## Next Action Format++Always be concrete:++```markdown+<!-- ❌ Vague -->+**Next Action**: Continue working on API++<!-- ✅ Concrete -->+**Next Action**: Implement PATCH /api/tasks/:id in src/routes/tasks.ts:47, add ownership validation+```++## Git Checkpoints++After significant progress or before clearing context:++```+checkpoint: Phase [N] [Status] - [Brief Description]++Phase: [N] - [Phase Name]+Status: [Complete/In Progress/Paused]+Session: [What was accomplished]++Files Changed:+- path/to/file.ts (what changed)++Next: [Concrete next action]+```++## Session Workflow++**Ending session**: Update SESSION.md → git checkpoint → note Next Action++**Resuming**: Read SESSION.md → check Next Action → continue from that pointdiff --git a/skills/tailwind-v4-shadcn/rules/tailwind-v4-shadcn.md b/skills/tailwind-v4-shadcn/rules/tailwind-v4-shadcn.mdnew file mode 100644index 00000000..c4359509--- /dev/null+++ b/skills/tailwind-v4-shadcn/rules/tailwind-v4-shadcn.md@@ -0,0 +1,118 @@+---+paths: "**/*.css", "**/*.tsx", "**/*.jsx", tailwind.config.*, components.json, postcss.config.*+---++# Tailwind v4 + shadcn/ui Corrections++Claude's training may reference Tailwind v3 patterns. This project uses **Tailwind v4** with different syntax.++## Critical Differences from v3++### Configuration+- **No `tailwind.config.ts`** - v4 uses CSS-first config with `@theme` blocks+- **No PostCSS setup** - Use `@tailwindcss/vite` plugin instead+- **`components.json`** must have `"config": ""` (empty string)++### CSS Syntax+```css+/* ❌ v3 (Claude may suggest this) */+@tailwind base;+@tailwind components;+@tailwind utilities;++/* ✅ v4 (use this) */+@import "tailwindcss";+```++### Theme Configuration+```css+/* ❌ v3 - tailwind.config.ts */+theme: { colors: { primary: '#3b82f6' } }++/* ✅ v4 - in CSS file */+@theme inline {+ --color-primary: var(--primary);+ --color-background: var(--background);+}+```++### Animations Package+```bash+# ❌ v3 package (deprecated for v4)+pnpm add tailwindcss-animate++# ✅ v4 package+pnpm add -D tw-animate-css+```++```css+/* ✅ v4 import */+@import "tailwindcss";+@import "tw-animate-css";+```++### Plugins+```css+/* ❌ v3 - require() in config */+plugins: [require('@tailwindcss/typography')]++/* ✅ v4 - @plugin directive in CSS */+@plugin "@tailwindcss/typography";+```++### @apply Directive+```css+/* ❌ Deprecated in v4 */+.btn { @apply px-4 py-2 bg-primary; }++/* ✅ Use direct classes or CSS */+.btn { padding: 0.5rem 1rem; background-color: var(--primary); }+```++## Variable Architecture++CSS variables must follow this structure:++```css+/* 1. Define at root (NOT inside @layer base) */+:root {+ --background: hsl(0 0% 100%); /* hsl() wrapper required */+ --primary: hsl(221.2 83.2% 53.3%);+}++.dark {+ --background: hsl(222.2 84% 4.9%);+ --primary: hsl(217.2 91.2% 59.8%);+}++/* 2. Map to Tailwind utilities */+@theme inline {+ --color-background: var(--background);+ --color-primary: var(--primary);+}++/* 3. Apply base styles (NO hsl wrapper here) */+@layer base {+ body {+ background-color: var(--background);+ color: var(--foreground);+ }+}+```++## Dark Mode++- No `dark:` variants needed for semantic colors - theme switches automatically+- Just use `bg-background`, `text-foreground`, etc.+- ThemeProvider toggles `.dark` class on `<html>` element++## Quick Fixes++| If Claude suggests... | Use instead... |+|----------------------|----------------|+| `@tailwind base` | `@import "tailwindcss"` |+| `tailwind.config.ts` | `@theme inline` in CSS |+| `tailwindcss-animate` | `tw-animate-css` |+| `require('@plugin')` | `@plugin "@plugin"` |+| `@apply` | Direct CSS or utility classes |+| `hsl(var(--color))` | `var(--color)` (already has hsl) |