agentleFS
vibestackdevvibestackdev/vibe-stack/.cursor/rules/ai-collaboration.mdc

vibe-stack / rules

Cursor rule8 starsChanged 8 months agoMITView on GitHub

Instructions for AI agent code generation workflow

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
  1. Distinctive:

    Every code generation task MUST follow this loop:

    line 11
  2. Distinctive:

    Before writing ANY code, the AI MUST:

    line 15
  3. Distinctive:

    Read the relevant source files to verify current state — do NOT rely on memory

    line 16
  4. Distinctive:

    Do NOT write code yet

    line 19
  5. Very specific:

    Follow ALL active .cursor/rules/ constraints

    line 30
  6. Very specific:

    If unsure about auth patterns, re-read supabase-auth-security.mdc

    line 31
  7. Very specific:

    If unsure about params/layouts, re-read nextjs15-params.mdc

    line 32
  8. Very specific:

    Use unknown + Zod validation instead of any for external data

    line 33
  9. Distinctive:

    After generating code, the AI MUST self-check:

    line 38
  10. Distinctive:

    NEVER trust stored knowledge about the codebase.

    line 52
  11. Distinctive:

    Check imports and exports to ensure they match expectations

    line 54
  12. Distinctive:

    Verify that function signatures haven't changed

    line 55
  13. Distinctive:

    NEVER give the AI a task longer than 200 words

    line 100
  14. Distinctive:

    NEVER let the AI implement more than 3-4 files in one turn

    line 101
  15. Distinctive:

    NEVER let the AI skip the verification checklist

    line 102
  16. Distinctive:

    ALWAYS review the Git diff before committing

    line 103
  17. Distinctive:

    When uncertain, ask the developer — do NOT guess

    line 104

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
ai-collaboration.mdc
---
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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.