TL;DR: .cursorrules הוא קובץ הוראות ב-root של ה-repo ש-Cursor קורא בכל קריאה ל-AI. בלעדיו, ה-AI יוצר קוד לא תחזוקתי. עם .cursorrules מקצועי - איכות שווה למפתח senior. המדריך מציג: מבנה אפקטיבי, חוקים חיוניים, תבניות מוכנות, ואכיפה.
למה .cursorrules הוא הכלי החשוב ביותר
ה-AI לא יודע איך לכתוב קוד טוב לפרויקט שלכם. הוא יודע syntax. הוא לא יודע: האם Zustand או Redux, strict typing או לא, איך מנהלים errors. .cursorrules הוא ה-system prompt שלכם.
קראו עוד: Cursor Rules Engineering
מבנה אפקטיבי
חוקיות שעובדת ב-50+ פרויקטים:
- Project Overview (3-5 שורות)
- Core Constraints (לא ניתנים להפרה)
- Architecture Patterns
- State Management
- Error Handling
- Styling
- Testing
- Anti-patterns (חשוב יותר מ-do's)
תבנית React + TypeScript
# VibeScale React .cursorrules
## Project Overview
React 19 + TypeScript + Vite + Tailwind + React Query SaaS for [domain].
Multi-tenant. Hebrew RTL. Mobile-first.
## Core Constraints
1. **MODULARITY**: NEVER exceed 200 lines per file.
2. **TYPESCRIPT**: NEVER use 'any'. Use 'unknown' + type guards.
3. **NAMING**: Components PascalCase, hooks useCamelCase.
4. **IMPORTS**: '@/...' alias. Group external/internal/types/styles.
## State Management
- **Server state**: ALWAYS TanStack Query. NEVER useEffect+fetch.
- **Global UI**: Zustand store in src/stores/.
- **Local**: useState only.
- **Forms**: react-hook-form with Zod schemas.
## Error Handling
- All API calls: try/catch OR TanStack Query.
- Error boundaries (src/components/ErrorBoundary.tsx).
- Sentry for unhandled. Never silently swallow.
## Styling
- Tailwind utility classes ONLY.
- Design tokens: bg-primary, text-on-surface, border-outline-variant.
- NEVER arbitrary values (bg-[#FF5733]) - extend theme.
- Mobile-first: base mobile, add md:/lg:.
## RTL Hebrew
- dir="rtl" on key containers.
- Logical properties: border-r (start), not border-l.
## Anti-patterns (NEVER)
- useEffect for data fetching
- inline styles
- 'any' type
- console.log in production
- async/await without try/catch
- class components
## Comments
- WHY, not WHAT. One-line max.
תבניות לסטאקים אחרים
Next.js 14 App Router:
- Server Components by default
- 'use client' only for interactivity
- Data fetching ב-Server Components או Route Handlers
- generateMetadata() ל-SEO
Python FastAPI:
- Pydantic models לכל schemas
- Type hints + mypy strict
- Dependency Injection
- Async by default
חוקים מתקדמים - Security
## Security
- NEVER secrets in client code (no VITE_ for API keys)
- NEVER innerHTML without DOMPurify
- All inputs Zod-validated before server
- Auth via httpOnly cookies, NEVER localStorage
- RLS required on every Supabase table
איך לבדוק שעובד
- בקשו פיצ'ר חדש - האם פיצל לקבצים? Types?
- בקשו תיקון באג - בדק שאר השכבות?
- בקשו refactor - שמר על סטנדרטים?
טיפ: commit .cursorrules ל-repo. כל מפתח חדש מקבל את אותם הסטנדרטים ביום הראשון.
נסו את המחולל: Cursor Rules Generator
תחזוקה לאורך זמן
.cursorrules הוא מסמך חי. עדכנו כש:
- צוות מוסיף ספרייה חדשה
- מזהים anti-pattern נפוץ ב-PRs
- ה-AI חוזר על אותה טעות פעמיים
מתחילים עם 30 שורות, אחרי 3 חודשים 80-100. אל תכתבו 500.
כלים נוספים
- Cursor Rules Generator
- Lovable to Production
- CLAUDE.md File - מקבילה ל-Claude Code
