Switch language to العربية

Rules

AI coding rules and patterns for quick wins. Define constraints, anti-patterns, and best practices.

What are Rules?

Rules are explicit constraints and patterns that guide AI coding behavior. They prevent common mistakes and enforce project conventions.

Cursor

.cursorrules

Claude Code

CLAUDE.md

Cline

.clinerules

Cursor Rules

Rules for Cursor IDE AI assistant.

.cursorrulesmarkdown
# .cursorrules

You are an expert in TypeScript, Node.js, Next.js 15 App Router, React 19,
Shadcn UI, Radix UI, and Tailwind CSS 4.

## Code Style and Structure

- Write concise, technical TypeScript code with accurate examples
- Use functional and declarative programming patterns
- Prefer iteration and modularization over code duplication
- Use descriptive variable names with auxiliary verbs (isLoading, hasError)
- Structure files: exported component, subcomponents, helpers, types

## Naming Conventions

- Use lowercase with dashes for directories (components/auth-wizard)
- Favor named exports for components

## TypeScript Usage

- Use TypeScript for all code; prefer interfaces over types
- Avoid enums; use const objects with `as const` assertion
- Use functional components with TypeScript interfaces

## Syntax and Formatting

- Use the "function" keyword for pure functions
- Avoid unnecessary curly braces in conditionals
- Use declarative JSX

## UI and Styling

- Use Shadcn UI, Radix, and Tailwind for components and styling
- Implement responsive design with Tailwind CSS; mobile-first approach

## Performance Optimization

- Minimize "use client", "useEffect", and "setState"
- Favor React Server Components (RSC)
- Wrap client components in Suspense with fallback
- Use dynamic loading for non-critical components

Claude Code Rules

Rules section in CLAUDE.md for Claude Code.

CLAUDE.mdmarkdown
# CLAUDE.md Rules Section

## Anti-Patterns to Avoid

- NEVER import `@prisma/client` in client components
- NEVER use `use client` unless absolutely necessary
- NEVER create new files unless explicitly required
- NEVER add comments to code you didn't write
- NEVER use Edge runtime (deprecated in Next.js 16)

## Required Patterns

- ALWAYS await dynamic APIs: params, searchParams, cookies, headers
- ALWAYS use `pnpm` as package manager
- ALWAYS follow mirror-pattern for new routes
- ALWAYS use Server Components by default

## Component Rules

- UI components: src/components/ui/
- Atoms (2+ primitives): src/components/atom/
- Feature components: src/components/root/{feature}/
- Page content: content.tsx in component folder

Cline Rules

Rules for Cline VSCode extension.

.clinerulesmarkdown
# .clinerules

## Project Context
This is a Next.js 15+ monorepo using:
- React 19 with Server Components
- Prisma 6 for database
- NextAuth v5 for authentication
- Tailwind CSS 4 with OKLCH colors

## Key Constraints
1. Node.js runtime only (no Edge)
2. All dynamic APIs must be awaited
3. Prefer Server Actions over API routes
4. Use pnpm exclusively

## File Patterns
- Routes: app/[lang]/(root)/[feature]/page.tsx
- Components: components/root/[feature]/content.tsx
- Server actions: components/root/[feature]/actions.ts

Rule Categories

Anti-Patterns

What NOT to do. Explicit prohibitions prevent costly mistakes.

Required Patterns

What MUST be done. Enforce consistency across the codebase.

Style Guidelines

Naming, formatting, and code organization preferences.

Project Context

Stack details, constraints, and architectural decisions.