Instruction file imported from wojciech-borek/billzilla (
.cursor/rules/shared.mdc). Copyright stays with the author.
AI Rules for Billzilla
{project-description}
Tech Stack
- Astro 5
- TypeScript 5
- React 19
- Tailwind 4
- Shadcn/ui
Project Structure
When introducing changes to the project, always follow the directory structure below:
./src- source code./src/layouts- Astro layouts./src/pages- Astro pages./src/pages/api- API endpoints./src/middleware/index.ts- Astro middleware./src/db- Supabase clients and types./src/types.ts- Shared types for backend and frontend (Entities, DTOs)./src/components- Client-side components written in Astro (static) and React (dynamic)./src/components/ui- Shadcn/ui components./src/components/group- Group-related components (create, edit, etc.)./src/components/dashboard- Dashboard-specific components./src/components/[feature]- Feature-specific components
./src/lib- Services, helpers, hooks, and schemas./src/lib/services- Business logic services./src/lib/schemas- Zod validation schemas (backend + frontend)./src/lib/hooks- Shared React hooks./src/lib/utils.ts- Utility functions
./src/assets- static internal assets./public- public assets
When modifying the directory structure, always update this section.
Coding practices
Guidelines for clean code
- Use feedback from linters to improve the code when making changes.
- Prioritize error handling and edge cases.
- Handle errors and edge cases at the beginning of functions.
- Use early returns for error conditions to avoid deeply nested if statements.
- Place the happy path last in the function for improved readability.
- Avoid unnecessary else statements; use if-return pattern instead.
- Use guard clauses to handle preconditions and invalid states early.
- Implement proper error logging and user-friendly error messages.
- Consider using custom error types or error factories for consistent error handling.
