---
description: "Governance rules, tech stack constraints, and file size limits"
globs:
  - "**/*.ts"
  - "**/*.tsx"
  - "**/*.js"
  - "**/*.jsx"
  - "**/*.sql"
alwaysApply: true
---
## 🧬 STACK DNA

### Tech Stack
- Next.js
- TypeScript
- Supabase
- Tailwind CSS

### Project Configuration
| Attribute | Value |
|-----------|-------|
| Tenancy | SINGLE |
| Monetization | FREE |
| Compliance | NONE |
| Design Vibe | CORPORATE |


### 🛡️ GUARDIAN RULES (Mandatory)
🛡️ **THE 400-LINE RULE (STRICT):** No file may exceed 400 lines. If approaching this limit, you MUST propose a refactor into smaller modules.
🛡️ **TSX LIMIT:** React components (.tsx) should not exceed 250 lines. Extract sub-components proactively.
🛡️ **TYPE SAFETY:** Avoid "any". Use strict TypeScript types. Infer from Zod schemas when possible.
👤 All queries are user-scoped (filter by user_id or RLS)
⚡ Enable RLS on ALL new tables immediately
⚡ Use @supabase/ssr patterns for server-side auth
🚨 **IMPACT_GUARD:** Before deleting ANY file, you MUST:
   1. Search codebase for all imports/references (use grep_search or equivalent)
   2. Update or remove ALL references first
   3. Only delete after confirming ZERO references remain
   4. Commit changes atomically (references + deletion in same commit)
✅ **BUILD_INTEGRITY:** After ANY structural change (new files, moved modules, refactors):
   1. Run type-check (e.g., `tsc --noEmit` or framework equivalent)
   2. Verify build success before declaring task complete
   3. If errors detected, fix immediately—do NOT leave broken builds