vibe-stack / rules
Cursor rule8 starsChanged 8 months agoMITView on GitHub
Instructions for AI agent code generation workflow
Where files are headingNew Cursor rule files have more rules about planning and tracking tasks, and fewer about code style.
Of the Cursor rule files we read, the 1,533 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository31 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .cursor/rules/api-design.mdcCursor rule
- .cursor/rules/api-validation.mdcCursor rule
- .cursor/rules/caching-revalidation.mdcCursor rule
- .cursor/rules/context-management.mdcCursor rule
- .cursor/rules/database-design.mdcCursor rule
- .cursor/rules/env-management.mdcCursor rule
- .cursor/rules/error-handling.mdcCursor rule
- .cursor/rules/file-naming.mdcCursor rule
- .cursor/rules/file-uploads.mdcCursor rule
- .cursor/rules/git-conventions.mdcCursor rule
- .cursor/rules/hydration-safety.mdcCursor rule
- .cursor/rules/middleware-auth.mdcCursor rule
- .cursor/rules/nextjs15-params.mdcCursor rule
- .cursor/rules/performance.mdcCursor rule
- .cursor/rules/project-context.mdcCursor rule
- .cursor/rules/react19-patterns.mdcCursor rule
- .cursor/rules/security.mdcCursor rule
- .cursor/rules/server-actions.mdcCursor rule
- .cursor/rules/server-vs-client-components.mdcCursor rule
- .cursor/rules/shadcn-patterns.mdcCursor rule
- .cursor/rules/stripe-payments.mdcCursor rule
- .cursor/rules/stripe-webhooks.mdcCursor rule
- .cursor/rules/supabase-auth-security.mdcCursor rule
- .cursor/rules/supabase-rls.mdcCursor rule
- .cursor/rules/supabase-ssr-only.mdcCursor rule
- .cursor/rules/testing.mdcCursor rule
- .cursor/rules/typescript-strict.mdcCursor rule
- .cursor/rules/verify-before-use.mdcCursor rule
- llms.txtllms.txt
The file
Show its rules and text
We split this ai-collaboration.mdc into the rules it gives an agent
17 rules. About 0 are common, 13 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈13
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Every code generation task MUST follow this loop:
- Distinctive: line 15
Before writing ANY code, the AI MUST:
- Distinctive: line 16
Read the relevant source files to verify current state — do NOT rely on memory
- Distinctive: line 19
Do NOT write code yet
- Very specific: line 30
Follow ALL active .cursor/rules/ constraints
- Very specific: line 31
If unsure about auth patterns, re-read supabase-auth-security.mdc
- Very specific: line 32
If unsure about params/layouts, re-read nextjs15-params.mdc
- Very specific: line 33
Use unknown + Zod validation instead of any for external data
- Distinctive: line 38
After generating code, the AI MUST self-check:
- Distinctive: line 52
NEVER trust stored knowledge about the codebase.
- Distinctive: line 54
Check imports and exports to ensure they match expectations
- Distinctive: line 55
Verify that function signatures haven't changed
- Distinctive: line 100
NEVER give the AI a task longer than 200 words
- Distinctive: line 101
NEVER let the AI implement more than 3-4 files in one turn
- Distinctive: line 102
NEVER let the AI skip the verification checklist
- Distinctive: line 103
ALWAYS review the Git diff before committing
- Distinctive: line 104
When uncertain, ask the developer — do NOT guess
≈ “Common” is an estimate: at least 1 in 5 of the 3,030 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
---
description: Instructions for AI agent code generation workflow
globs: ["*"]
alwaysApply: true
---
# AI Collaboration Guidelines
## The 3-Stage Agentic Loop
Every code generation task MUST follow this loop:
### Stage 1: PLAN (gather context first)
Before writing ANY code, the AI MUST:
1. Read the relevant source files to verify current state — do NOT rely on memory
2. Identify which `.cursor/rules/` files apply to this task
3. List the files to modify and explain why
4. Do NOT write code yet
Prompt template:
```
Analyze the current codebase and plan how to implement [feature].
List the files you'll modify and why. Don't write code yet.
```
### Stage 2: IMPLEMENT (follow constraints)
When generating code:
- Follow ALL active `.cursor/rules/` constraints
- If unsure about auth patterns, re-read `supabase-auth-security.mdc`
- If unsure about params/layouts, re-read `nextjs15-params.mdc`
- Use `unknown` + Zod validation instead of `any` for external data
- Return `ActionResponse<T>` from all Server Actions (see below)
### Stage 3: VERIFY (confirm before declaring done)
After generating code, the AI MUST self-check:
- [ ] No `getSession()` on the server (MUST be `getUser()`)
- [ ] No synchronous `params` or `searchParams` access
- [ ] No `@supabase/auth-helpers-nextjs` imports
- [ ] No `any` types — use `unknown` + type narrowing
- [ ] Every API route has Zod validation
- [ ] Every error is caught and returns `{ error: string }`
- [ ] New tables have RLS enabled
- [ ] `loading.tsx` and `error.tsx` exist for data-fetching pages
Report issues BEFORE the developer runs the code.
## Skeptical Retrieval Rule
NEVER trust stored knowledge about the codebase. Before modifying a file:
1. Re-read the file to verify its current contents
2. Check imports and exports to ensure they match expectations
3. Verify that function signatures haven't changed
This prevents generating code that references stale function signatures,
deleted files, or renamed exports.
## Standard Patterns
### ActionResponse Type (use for all Server Actions)
```typescript
type ActionResponse<T = void> =
| { success: true; data: T }
| { success: false; error: string }
```
### Standard Server Action Structure
```typescript
'use server'
import { createClient } from '@/lib/supabase/server'
import { z } from 'zod'
const Schema = z.object({ /* ... */ })
export async function myAction(input: unknown): Promise<ActionResponse<MyType>> {
// 1. Auth
const supabase = await createClient()
const { data: { user } } = await supabase.auth.getUser()
if (!user) return { success: false, error: 'Unauthorized' }
// 2. Validate
const result = Schema.safeParse(input)
if (!result.success) return { success: false, error: 'Invalid input' }
// 3. Execute
try {
const { data, error } = await supabase.from('table').insert(result.data).select().single()
if (error) throw error
return { success: true, data }
} catch {
return { success: false, error: 'Operation failed' }
}
}
```
## Task Constraints
- NEVER give the AI a task longer than 200 words
- NEVER let the AI implement more than 3-4 files in one turn
- NEVER let the AI skip the verification checklist
- ALWAYS review the Git diff before committing
- When uncertain, ask the developer — do NOT guess
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

