|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Next.js 15 + React 19 + TypeScript + PWA starter template with strict TypeScript configuration and Biome for code quality. |
| 8 | + |
| 9 | +**Key Technologies:** |
| 10 | +- Next.js 15.5.4 (Pages Router) with Turbopack |
| 11 | +- React 19.2.0 |
| 12 | +- TypeScript 5.7 with strict mode enabled |
| 13 | +- Serwist (successor to next-pwa) for Progressive Web App functionality |
| 14 | +- Biome for linting and formatting |
| 15 | +- pnpm for package management |
| 16 | + |
| 17 | +## Common Commands |
| 18 | + |
| 19 | +### Development |
| 20 | +```bash |
| 21 | +pnpm dev # Start development server with Turbopack (PWA disabled in dev) |
| 22 | +pnpm type-check # Run TypeScript type checking without emitting files |
| 23 | +pnpm type-check:watch # Run TypeScript type checking in watch mode |
| 24 | +pnpm lint # Run Biome lint checks on the codebase |
| 25 | +pnpm format # Format all code with Biome |
| 26 | +pnpm check # Run Biome lint and format (auto-fix) on the codebase |
| 27 | +pnpm telemetry # Check Next.js telemetry status |
| 28 | +``` |
| 29 | + |
| 30 | +### Build & Production |
| 31 | +```bash |
| 32 | +pnpm build # Build production bundle |
| 33 | +pnpm start # Start production server (requires build first) |
| 34 | +``` |
| 35 | + |
| 36 | +### Docker |
| 37 | +```bash |
| 38 | +docker build -t next-typescript-pwa-starter . |
| 39 | +docker run --rm -it -p 3000:3000 next-typescript-pwa-starter |
| 40 | +docker-compose up |
| 41 | +``` |
| 42 | + |
| 43 | +## Architecture |
| 44 | + |
| 45 | +### Directory Structure |
| 46 | +- `pages/` - Next.js Pages Router |
| 47 | + - `_app.tsx` - Custom App component |
| 48 | + - `_document.tsx` - Custom Document component |
| 49 | + - `api/` - API routes |
| 50 | + - `index.tsx` - Home page |
| 51 | +- `components/` - React components (e.g., nav.tsx) |
| 52 | +- `styles/` - CSS/styling files |
| 53 | +- `public/` - Static assets and PWA manifest |
| 54 | +- `sw.js` - Service worker source file |
| 55 | + |
| 56 | +### PWA Configuration |
| 57 | +PWA functionality is configured using **Serwist** (next-pwa successor): |
| 58 | +- Configuration in `next.config.js` using `@serwist/next` |
| 59 | +- Service worker source: `sw.js` (root) → builds to `public/sw.js` |
| 60 | +- **Disabled** in development mode (only works in production) |
| 61 | +- Manifest file: `public/manifest.json` |
| 62 | +- PWA meta tags and manifest link in `pages/_document.tsx` |
| 63 | +- Icons located in `public/icons/` |
| 64 | + |
| 65 | +### TypeScript Configuration |
| 66 | +Strict TypeScript settings enforced: |
| 67 | +- `strict: true` with all strict flags enabled |
| 68 | +- `noUnusedLocals` and `noUnusedParameters` enabled |
| 69 | +- Path alias `@/*` maps to project root |
| 70 | +- Target: ES5, Module: ESNext |
| 71 | + |
| 72 | +### Code Quality with Biome |
| 73 | +Pre-commit hooks automatically run via Husky + lint-staged: |
| 74 | +- Configuration in `biome.json` and `.lintstagedrc.json` |
| 75 | +- Husky hook in `.husky/pre-commit` runs `pnpm lint-staged` |
| 76 | +- lint-staged runs Biome checks on staged files only |
| 77 | + |
| 78 | +Biome rules of note: |
| 79 | +- `noConsoleLog: error` - Console.log statements are errors |
| 80 | +- `noUnusedVariables: error` - Unused variables are errors |
| 81 | +- `noExplicitAny: warn` - Explicit any types trigger warnings |
| 82 | +- Auto-organizes imports |
| 83 | + |
| 84 | +### CI/CD with GitHub Actions |
| 85 | +GitHub Actions workflow (`.github/workflows/main.yml`) runs on push/PR: |
| 86 | +1. **lint-and-test** job: Runs Biome checks, type checking, and tests |
| 87 | +2. **build** job: Builds the Next.js application |
| 88 | +3. **docker** job: Builds and pushes Docker image (main branch only) |
| 89 | + |
| 90 | +## Node & Package Manager Requirements |
| 91 | +- Node >= 22.0.0 |
| 92 | +- pnpm >= 9.0.0 (packageManager: pnpm@9.15.3) |
| 93 | + |
| 94 | +## Important Notes |
| 95 | +- This project uses the **Pages Router** (Next.js 15), not the App Router |
| 96 | +- **Turbopack** is enabled by default for faster development builds (`pnpm dev --turbopack`) |
| 97 | +- PWA features only work in production builds (Serwist disabled in dev) |
| 98 | +- No test framework is configured yet (test script is a placeholder) |
| 99 | +- Console.log statements will fail Biome checks - remove before committing |
| 100 | +- Uses Serwist instead of next-pwa for better Next.js 15 compatibility |
0 commit comments