|
| 1 | +# Cursor Rules for Kimu Video Editor |
| 2 | + |
| 3 | +project: |
| 4 | + name: "Kimu Video Editor" |
| 5 | + language: "TypeScript/React (React Router) + Python FastAPI" |
| 6 | + package_manager: pnpm |
| 7 | + |
| 8 | +conventions: |
| 9 | + - Prefer central Zod schemas in app/schemas/**; do not define inline schemas in components or routes. |
| 10 | + - Always validate external boundaries: AI responses, API inputs/outputs, localStorage, drag-and-drop payloads. |
| 11 | + - Keep UI components presentational; move parsing/validation to hooks or route loaders/actions when possible. |
| 12 | + - Use named exports and barrel files under app/schemas for discoverability. |
| 13 | + |
| 14 | +imports: |
| 15 | + zod: |
| 16 | + source: "zod" |
| 17 | + identifier: "z" |
| 18 | + schemas: |
| 19 | + source: "~/schemas" |
| 20 | + |
| 21 | +editor: |
| 22 | + formatting: |
| 23 | + - Match existing indentation and code style. |
| 24 | + - Avoid reformatting unrelated code during edits. |
| 25 | + typescript: |
| 26 | + - Prefer explicit types for exported APIs; avoid any. |
| 27 | + - Use narrow schemas and safeParse for user/LLM data. |
| 28 | + |
| 29 | +testing: |
| 30 | + - Add schema unit tests when adding complex schemas. |
| 31 | + - Validate response shapes in API route tests. |
| 32 | + |
| 33 | +commit_messages: |
| 34 | + - Use scope tags: feat(schemas), refactor(chat), fix(api), chore(tooling). |
| 35 | + |
| 36 | +typescript_guidelines: |
| 37 | + - Always enable strict type checking |
| 38 | + - Export interfaces and types from dedicated type files |
| 39 | + - Leverage a common module for shared types and utilities when possible |
| 40 | + - Use proper type imports from @types packages when available |
| 41 | + - Follow framework conventions for typing (e.g., Remix loaders/actions, React types) |
| 42 | + - DO NOT use the any type |
| 43 | + - Prefer importing types from packages before declaring your own |
| 44 | + - Avoid type casting; prefer precise types and narrowing |
| 45 | + - Prefer inferring types from Zod schemas using z.infer instead of manual type definitions |
| 46 | + - For Zod schemas, prefer .nullish().transform((val) => val ?? undefined) over .optional() for null handling; do not combine .nullish() with .default() |
| 47 | + |
| 48 | +project_structure: |
| 49 | + overview: |
| 50 | + - Frontend (Remix/React) lives under app/ |
| 51 | + - Backend (FastAPI) lives under backend/ |
| 52 | + - Centralized Zod schemas live under app/schemas/** with barrel exports in app/schemas/index.ts |
| 53 | + - Database/sql migrations under migrations/ |
| 54 | + - Shared UI primitives under app/components/ui/** |
| 55 | + - Timeline/editor components under app/components/timeline/** |
| 56 | + - Chat/AI components under app/components/chat/** |
| 57 | + - Hooks under app/hooks/** |
| 58 | + - Utilities under app/utils/** and app/lib/** |
| 59 | + |
| 60 | +code_organization_rules: |
| 61 | + - Keep feature-specific code within its respective directory (timeline, chat, media, etc.) |
| 62 | + - Place all Zod schemas under app/schemas/** (components/, apis/, domain files) and import from there (no inline schemas in components/routes) |
| 63 | + - Maintain consistent file naming: |
| 64 | + - index.ts for barrel exports |
| 65 | + - types.ts or types/index.ts for type definitions when schema inference is not applicable |
| 66 | + - Remix routes: |
| 67 | + - Validate params in loaders/actions with Zod |
| 68 | + - Validate request bodies and response payloads (APIs under app/routes/api.*) |
| 69 | + - Components: |
| 70 | + - Keep presentational; parse/validate data in hooks or route loaders |
| 71 | + - Import schemas from app/schemas/components/** |
| 72 | + - APIs: |
| 73 | + - Import request/response schemas from app/schemas/apis/** |
| 74 | + - Validate inputs (safeParse) and outputs (parse) at boundaries |
| 75 | + - Prefer z.infer<typeof Schema> to derive TS types from Zod |
0 commit comments