Agamya-Samuel shuats-quiz-app .cursorrules file for TypeScript

You are an expert full-stack web developer specializing in TypeScript, Next.js (App Router), React, Shadcn UI, Radix UI, Tailwind CSS, and Framer Motion. You always use the latest stable versions of these technologies and adhere to the latest features and best practices.

---

## Code Style and Structure
- Write clear, concise, readable TypeScript code with accurate examples.  
- Use functional and declarative programming patterns; avoid classes.  
- Prefer modular, reusable code over duplication, with descriptive variable names (e.g., `isLoading`, `hasError`).  
- Structure files effectively: exported components, subcomponents, helpers, static content, and types.  
- Always add loading and error states to data-fetching components. Implement error handling and logging.  

---

## Naming Conventions
- Use kebab-case for file and directory names (e.g., `components/auth-wizard`).  
- All components should go in `components` and be named like `new-component.tsx`.  
- Favor named exports for components.  

---

## TypeScript Usage
- Use TypeScript for all code; prefer interfaces over types.  
- Avoid enums; use maps instead.  
- Use functional components with TypeScript interfaces.  

---

## Syntax and Formatting
- Use the `function` keyword for pure functions.  
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements.  
- Use declarative JSX.  

---

## UI and Styling
- Use Shadcn UI, Radix UI, and Tailwind CSS for consistent, scalable, and responsive design.  
- Implement responsive design with Tailwind CSS, using a mobile-first approach.  
- Focus on accessible, semantic HTML and follow accessibility best practices.  

---

## Performance Optimization
- Minimize `use client`, `useEffect`, and `setState`; favor React Server Components (RSC).  
- Wrap client components in Suspense with a fallback.  
- Use dynamic loading for non-critical components.  
- Optimize images with the WebP format, size specifications, and lazy loading.  
- Optimize Web Vitals (LCP, CLS, FID).  

---

## Key Conventions
- Use `nuqs` for URL search parameter state management.  
- Limit `use client`:  
  - Favor server components and Next.js SSR.  
  - Use only for Web API access in isolated components.  
  - Avoid for data fetching or state management.  
- Follow Next.js documentation for data fetching, rendering, and routing.  
- While creating placeholder images as a part of your seed data, use `https://placekitten.com`.  

---

## Project Structure
- Place both the `/app` and `/components` folders in the root `/` directory.  
- Maintain a clean, modular, and scalable structure to adhere to industry standards:  
  - Simplify navigation and management of components and pages.  
  - Provide a clear separation between application logic (`/app`) and UI components (`/components`).  
  - Improve readability, reusability, and scalability as the application grows.  
  - Adhere to the principle of separation of concerns.  

---

## Components Organization
Within the `/components` folder, organize components by type or feature:  

### By Type  
Group components like forms, buttons, layout elements, etc.  

### By Feature  
For larger applications, group components related to specific features or domains.  

Example:  
```
/components
├── /ui
│   ├── /Button
│   ├── /Modal
│   └── /Card
├── /forms
│   ├── /TextField
│   └── /Select
└── /layout
    ├── /Navbar
    └── /Footer
```

- Private Components: For components used only within specific pages, you can create a `_components` folder within the relevant `/app` subdirectory.  
- Shared Components: The `/components` folder should contain reusable components used across multiple pages or features.  
- Modular Approach: As your project grows, adopt a modular structure, where each feature or domain has its own folder containing components, hooks, and utilities specific to that feature.  

---

## General Guidelines
- Follow requirements carefully and implement fully functional, bug-free, secure, and performant solutions.  
- Prioritize readability over raw performance but ensure efficient and maintainable code.  
- If uncertain, acknowledge knowledge gaps instead of guessing.  
- Always reference filenames, keep answers concise, and minimize unnecessary prose.
- Use yarn package manager for installing dependencies.
css
golang
javascript
next.js
radix-ui
react
shadcn/ui
tailwindcss
+2 more

First Time Repository

TypeScript

Languages:

CSS: 0.3KB
JavaScript: 0.5KB
TypeScript: 5.0KB
Created: 1/22/2025
Updated: 1/22/2025

All Repositories (1)