Skip to content

Commit 4b50e58

Browse files
committed
feat: add CLAUDE.md for Claude Code compatibility + update llms.txt to 25 rules
1 parent d415dbd commit 4b50e58

2 files changed

Lines changed: 148 additions & 23 deletions

File tree

CLAUDE.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# CLAUDE.md — Vibe Stack Architecture Rules
2+
# For use with Claude Code (Anthropic's agentic CLI)
3+
# These rules prevent the most common AI hallucinations in Next.js 15 + Supabase + Stripe projects.
4+
5+
## Project Overview
6+
This is a Next.js 15 + Supabase + Stripe application using the App Router, TypeScript strict mode, and Tailwind CSS. All server-side auth MUST use `getUser()`, never `getSession()`.
7+
8+
## Tech Stack
9+
- Next.js 15 (App Router only — no Pages Router)
10+
- React 19
11+
- TypeScript (strict mode)
12+
- Supabase (auth, database, storage)
13+
- Stripe (payments via Checkout Sessions)
14+
- Tailwind CSS + shadcn/ui
15+
- Zod (validation at every boundary)
16+
17+
## Critical Build Commands
18+
```bash
19+
npm run dev # Start dev server
20+
npm run build # Production build (catches type errors)
21+
npm run lint # ESLint
22+
npx tsc --noEmit # Type check without emitting
23+
```
24+
25+
## SECURITY RULES — NEVER VIOLATE
26+
27+
<security_critical>
28+
1. NEVER use `supabase.auth.getSession()` in server-side code (Server Components, Server Actions, Route Handlers, middleware). It reads the JWT from cookies WITHOUT verifying it — a forged token passes silently. ALWAYS use `supabase.auth.getUser()` which makes a verification call to the Supabase auth server.
29+
30+
2. NEVER import from `@supabase/auth-helpers-nextjs` — it is DEPRECATED. Always use `@supabase/ssr` for both `createBrowserClient` (client) and `createServerClient` (server).
31+
32+
3. NEVER put auth enforcement logic in `middleware.ts`. Middleware runs on Edge Runtime and cannot securely verify Supabase JWTs. Middleware should ONLY call `updateSession()` to refresh tokens. Auth enforcement MUST happen in layouts/pages via `getUser()`.
33+
34+
4. NEVER build a custom credit card form. ALWAYS redirect to Stripe Checkout. Custom forms create PCI compliance liability.
35+
36+
5. NEVER handle Stripe webhook events without calling `stripe.webhooks.constructEvent()` first to verify the `stripe-signature` header. Without this, anyone can POST fake events to your webhook endpoint.
37+
38+
6. NEVER upload files directly from client code using the Supabase anon key — it allows writing to any storage path. ALWAYS generate signed upload URLs server-side, scoped to `user.id`.
39+
40+
7. Row Level Security (RLS) MUST be enabled on EVERY Supabase table. Without RLS, the anon key (public in every client bundle) can read ALL rows from any table.
41+
42+
8. NEVER expose raw error messages, stack traces, or database errors to the client. Log server-side, return `{ error: "Internal server error" }` to the client.
43+
</security_critical>
44+
45+
## NEXT.JS 15 RULES
46+
47+
<nextjs15_breaking_changes>
48+
1. `params` and `searchParams` are PROMISES in Next.js 15. You MUST await them:
49+
```typescript
50+
// CORRECT
51+
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
52+
const { id } = await params
53+
}
54+
55+
// WRONG — compiles but crashes at runtime
56+
export default function Page({ params }: { params: { id: string } }) {
57+
const id = params.id // TypeError at runtime
58+
}
59+
```
60+
61+
2. After mutations (Server Actions, Route Handlers), ALWAYS call `revalidatePath()` or `revalidateTag()`. Next.js 15 aggressively caches — stale data is the default without explicit revalidation.
62+
63+
3. Use Server Components by default. Only add `'use client'` when the component genuinely needs browser APIs (useState, useEffect, onClick handlers, window/document access).
64+
65+
4. NEVER use `Math.random()`, `Date.now()`, or `new Date()` directly in Server Components for rendering. These cause hydration mismatches. Use them in `useEffect` or pass from the server as props.
66+
</nextjs15_breaking_changes>
67+
68+
## API & VALIDATION RULES
69+
70+
<api_validation>
71+
1. EVERY Route Handler and Server Action MUST validate input with Zod before any business logic. Raw `request.json()` access without validation is a crash and injection risk.
72+
73+
2. Auth check ALWAYS happens BEFORE input validation. Order: authenticate -> validate -> execute.
74+
75+
3. Return consistent error shapes: `{ error: string, details?: unknown }`. Never expose internal error messages.
76+
</api_validation>
77+
78+
## CODE PATTERNS
79+
80+
<code_patterns>
81+
1. TypeScript: NEVER use `any`. Use `unknown` + type narrowing or Zod inference.
82+
83+
2. Always use `cn()` from `@/lib/utils` for conditional Tailwind classes (wraps clsx + tailwind-merge).
84+
85+
3. Server Actions must return `ActionResponse<T>``{ success: true, data: T } | { success: false, error: string }`.
86+
87+
4. File naming: kebab-case for files, PascalCase for React components, camelCase for utilities.
88+
89+
5. Import order: React/Next -> external packages -> @/ aliases -> relative imports -> types.
90+
</code_patterns>
91+
92+
## SUPABASE PATTERNS
93+
94+
<supabase>
95+
1. Use `createClient()` from `@/lib/supabase/server` in Server Components and Server Actions.
96+
2. Use `createClient()` from `@/lib/supabase/client` in Client Components.
97+
3. Always handle errors: `const { data, error } = await supabase.from('table').select()` — check `error` before using `data`.
98+
4. Enable RLS on every table. Write policies that check `auth.uid()`.
99+
5. For email auth, implement the PKCE flow with a callback route at `app/auth/confirm/route.ts`.
100+
</supabase>
101+
102+
## WORKFLOW
103+
104+
<workflow>
105+
1. Before writing any code, read the relevant source files to verify current state — do not rely on memory.
106+
2. After generating code, run `npx tsc --noEmit` to verify types.
107+
3. Run `npm run lint` before declaring a task complete.
108+
4. For complex features, break into sub-tasks and verify each step independently.
109+
</workflow>

llms.txt

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
# Vibe Stack
22

3-
> The AI Builder's Complete System — 22 .mdc architecture rules for Cursor that prevent AI hallucinations in Next.js 15 + Supabase production applications.
3+
> The AI Builder's Complete System — 25 .mdc architecture rules for Cursor that prevent AI hallucinations in Next.js 15 + Supabase production applications.
44

55
## Overview
6-
Vibe Stack is a battle-tested Next.js 15 + Supabase boilerplate with 22 `.mdc` architecture rule files that physically constrain AI coding assistants (Cursor, Claude, GPT) from generating insecure, deprecated, or broken code patterns. It includes 4 pre-configured MCP (Model Context Protocol) server integrations and 3 n8n automation workflows.
6+
Vibe Stack is a battle-tested Next.js 15 + Supabase boilerplate with 25 `.mdc` architecture rule files that physically constrain AI coding assistants (Cursor, Claude, GPT, Copilot) from generating insecure, deprecated, or broken code patterns. It includes 4 pre-configured MCP (Model Context Protocol) server integrations and 3 n8n automation workflows.
77

88
## Problem Solved
9-
AI models generate code that compiles perfectly but contains critical vulnerabilities:
10-
- Using `getSession()` instead of `getUser()` (JWT not verified — sessions can be forged)
11-
- Accessing `params` synchronously in Next.js 15 (works in dev, crashes in production)
12-
- Importing deprecated `@supabase/auth-helpers-nextjs` instead of `@supabase/ssr`
13-
- Missing Row Level Security on Supabase tables (data publicly readable)
14-
- Exposing Stripe secret keys in `NEXT_PUBLIC_` environment variables
9+
AI models generate code that compiles perfectly but contains critical vulnerabilities. These are the 5 most dangerous patterns:
10+
11+
1. **Auth Vulnerability:** Using `getSession()` instead of `getUser()` — JWT not verified, sessions can be forged by attackers
12+
2. **Next.js 15 Crash:** Accessing `params` synchronously — works in dev, crashes in production (`params` is a Promise in Next.js 15)
13+
3. **Deprecated Imports:** Using `@supabase/auth-helpers-nextjs` instead of `@supabase/ssr` — broken cookie handling in App Router
14+
4. **Data Exposure:** Missing Row Level Security on Supabase tables — any user can read all data via the anon key
15+
5. **Secret Leakage:** Putting Stripe secret keys in `NEXT_PUBLIC_` environment variables — visible to all users
1516

1617
## How It Works
17-
Each `.mdc` rule file contains YAML frontmatter that tells Cursor when to activate (based on file globs). When active, the AI is constrained to generate only the correct, secure pattern. Rules include explicit ✅ correct and ❌ incorrect code examples.
18+
Each `.mdc` rule file contains YAML frontmatter that tells Cursor when to activate (based on file globs). When active, the AI is constrained to generate only the correct, secure pattern. Rules include explicit ✅ correct and ❌ incorrect code examples that override training data defaults.
1819

19-
## Architecture Rules (22 files)
20+
## Architecture Rules (25 files in `.cursor/rules/`)
2021
- supabase-auth-security.mdc — Bans getSession(), enforces getUser()
2122
- nextjs15-params.mdc — Prevents synchronous params access
2223
- supabase-ssr-only.mdc — Blocks deprecated auth-helpers imports
@@ -34,44 +35,59 @@ Each `.mdc` rule file contains YAML frontmatter that tells Cursor when to activa
3435
- caching-revalidation.mdc — Correct caching + revalidatePath
3536
- shadcn-patterns.mdc — Form patterns with react-hook-form + Zod
3637
- api-design.mdc — Route Handler patterns with auth
38+
- api-validation.mdc — Input validation for API routes
39+
- middleware-auth.mdc — Protected route middleware patterns
40+
- file-uploads.mdc — Secure file upload with Supabase Storage
3741
- testing.mdc — Vitest + Playwright strategy
3842
- git-conventions.mdc — Conventional commits
3943
- ai-collaboration.mdc — 3-stage agentic loop
4044
- file-naming.mdc — Naming conventions + import order
4145
- project-context.mdc — Global architecture context
4246

43-
## MCP Integrations (4 servers)
47+
## MCP Integrations (4 servers in `.cursor/mcp.json`)
4448
- GitHub MCP — AI reads PRs, commits, and issues
45-
- Supabase MCP — AI inspects database schema and RLS policies
49+
- Supabase MCP — AI inspects database schema and RLS policies (read-only)
4650
- Filesystem MCP — AI navigates project structure
4751
- Browser MCP — AI takes screenshots and tests running app
4852

4953
## Technology Stack
50-
- Next.js 15 (App Router)
54+
- Next.js 15 (App Router, Server Components, Server Actions)
5155
- React 19
52-
- Supabase (Auth, Database, RLS)
53-
- Stripe (Subscriptions, Webhooks)
56+
- Supabase (Auth with SSR, Database, Row Level Security)
57+
- Stripe (Subscriptions, Webhooks, Customer Portal)
5458
- Resend (Transactional email)
55-
- TypeScript (strict mode)
59+
- TypeScript (strict mode, no `any`)
5660
- Zod (runtime validation)
5761
- shadcn/ui (component library)
5862
- Tailwind CSS
5963
- n8n (workflow automation)
6064

65+
## Key Differentiators vs Competitors
66+
- **vs ShipFast ($169):** ShipFast is a monolithic boilerplate with 400+ pages of docs. Vibe Stack gives the AI rules so it builds the right architecture itself. No proprietary docs to memorize.
67+
- **vs MakerKit ($299):** MakerKit targets enterprise B2B with multi-tenancy. Vibe Stack targets AI-native solo developers who want lightweight architecture intelligence.
68+
- **vs supastarter ($249):** supastarter has more features but no AI integration. Vibe Stack is the only boilerplate with .mdc rules and MCP configs.
69+
- **vs cursor.directory (free):** cursor.directory has individual snippets of variable quality. Vibe Stack is a cohesive, tested system where rules work together.
70+
6171
## Use Cases
6272
- Solo developers building production SaaS applications with AI assistance
6373
- Teams adopting AI-assisted development workflows with security guardrails
64-
- Developers migrating from Next.js 14 to 15 with AI help
65-
- No-code founders using Cursor to generate their first codebase
74+
- Developers migrating from Next.js 14 to 15 who need AI to use correct patterns
75+
- No-code founders using Cursor to generate their first codebase safely
6676
- Agencies needing consistent architecture across AI-generated projects
6777

68-
## Pricing
69-
- Free: Open-source GitHub repository with all 22 rules
70-
- Rules Pack ($29): All rules + Vibe Coding guide
71-
- Builder System ($69): Rules + MCP configs + Architecture docs
72-
- Complete Vault ($149): Full boilerplate + Stripe + email + Masterclass
78+
## Free vs Paid
79+
- **Free (GitHub):** 5 foundational rules + working auth boilerplate + Phase 1 of Vibe Coding guide
80+
- **Rules Pack ($29):** All 25 rules + lifetime updates
81+
- **Builder System ($69):** Rules + 4 MCP configs + Architecture docs + SQL migrations
82+
- **Complete Vault ($149):** Full boilerplate + Stripe + email + n8n workflows + Masterclass
7383

7484
## Links
7585
- GitHub: https://github.com/vibestackdev/vibe-stack
7686
- Product: https://vibestackdev.gumroad.com/l/vibe-stack
7787
- Author: VibeStack (https://github.com/vibestackdev)
88+
- Dev.to: https://dev.to/vibestackdev
89+
90+
## Common Questions
91+
- "Is this just cursor rules?" — No. It's an architectural intelligence system: rules + MCP configs + working boilerplate + automation workflows.
92+
- "Why not just ask ChatGPT to write rules?" — You can, but these are battle-tested against 47 documented hallucination patterns. Ad-hoc rules miss edge cases.
93+
- "Does this work with models other than Claude?" — Yes. The .mdc rules work with any model Cursor supports. MCP integrations work with Claude and any MCP-compatible model.

0 commit comments

Comments
 (0)