This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
yarn dev- Start development server on port 8888yarn build- Build production applicationyarn start- Start production server on port 8888yarn lint- Run ESLint for code quality checks
yarn analyze- Build with bundle analyzer enabledyarn build:analyze- Alias for analyze commandyarn perf:audit- Run complete performance audit (build + start + lighthouse)yarn perf:test- Run performance tests using scripts/performance-test.jsyarn lighthouse- Run Lighthouse analysis on running server
yarn code:prompt- Run code merger tool (ts-node ./bin/codeMerger.ts)
This is a Next.js 15 application for Autobox, a simulation management platform. The application follows a modern React architecture with TypeScript, Tailwind CSS, and shadcn/ui components.
/src/app/- Next.js App Router pages and API routes/src/components/- Reusable React components/src/hooks/- Custom React hooks for state management and side effects/src/schemas/- Zod schemas for data validation/src/lib/- Utility functions and services/src/types/- TypeScript type definitions/src/styles/- Global CSS and Tailwind configuration
The application manages three main entities:
- Organizations - Top-level organizational structure
- Projects - Containers for simulations within organizations
- Simulations - Individual simulation instances with runs and metrics
API routes follow REST conventions under /src/app/api/:
/api/organizations/- Organization management/api/projects/- Project CRUD operations/api/simulations/- Simulation management/api/runs/- Simulation run lifecycle/api/templates/metrics/- Metric template management
The application includes several performance-focused features:
- Polling System:
useRunPollinghook with request deduplication for real-time updates - Optimized Images: Custom
OptimizedImagecomponent with lazy loading - Virtualization:
VirtualizedListfor large datasets - Bundle Splitting: Custom webpack configuration for optimal code splitting
- Caching: HTTP caching headers and revalidation strategies
- UI Components: shadcn/ui components built on Radix UI primitives in
/src/components/ui/ - Domain Components: Business logic components in
/src/components/ - Form Handling: Zod schemas for validation with form components
- State Management: React hooks pattern, no external state management library
The project uses shadcn/ui, a component library built on top of Radix UI primitives. Key aspects:
- Component Location: All shadcn/ui components are in
/src/components/ui/ - Styling: Uses Tailwind CSS with CSS variables for theming
- Customization: Components are copied into the project and can be freely modified
- Configuration:
components.jsoncontains shadcn/ui configuration - Available Components: Includes button, card, dialog, dropdown-menu, input, select, table, toast, and many more
- CSS Framework: Tailwind CSS with custom configuration
- Theme: Dark theme as default with system font stack
- Component Styling: Class-based styling with
clsxfor conditional classes - Icons: Lucide React icons and Radix UI icons
- shadcn/ui Integration: Uses CSS variables and Tailwind classes for consistent theming
- Strict Mode: Enabled with
noImplicitAny: true - Path Aliases:
@/*maps to./src/* - Module Resolution: Bundler mode for Next.js compatibility
- Uses Yarn as package manager (modern Yarn with PnP support)
- Environment variables:
API_URLandORG_IDfor backend configuration - Development server runs on port 8888 (both dev and production)
- PWA capabilities with service worker registration
- Performance monitoring with console timing and custom hooks
- Server Components: Extensive use of Next.js server components for data fetching
- Error Boundaries: Proper error handling with try-catch patterns
- Loading States: Dedicated loading pages and components
- Real-time Updates: Polling-based updates for simulation runs
- Performance Monitoring: Built-in timing and performance measurement
-
Avoid Redundant Comments:
- Don't add comments that simply restate what the code does
- Remove obvious comments like
// Import Reactor// Define interface - Don't comment closing braces like
} // end if
-
Write Self-Documenting Code:
- Use descriptive variable and function names that explain their purpose
- Prefer clear, readable code over comments
- Extract complex logic into well-named functions
-
When Comments Are Valuable:
- Explain WHY something is done, not WHAT is being done
- Document complex business logic or algorithms
- Add warnings about non-obvious behavior or gotchas
- Include references to external documentation or requirements
-
Examples:
// ❌ Bad: Redundant comment // Increment counter by 1 counter++; // ❌ Bad: Obvious comment // Check if user is logged in if (user.isLoggedIn) { // ✅ Good: Explains why // We need to delay by 100ms to avoid race condition with animation setTimeout(() => updateUI(), 100); // ✅ Good: Documents business logic // Price threshold based on Q4 2024 market analysis const PREMIUM_THRESHOLD = 150;
-
Function Documentation:
- Only add JSDoc comments for complex functions with non-obvious behavior
- Avoid documenting simple getters, setters, or straightforward functions
- Focus on documenting edge cases, side effects, and complex return values