2.1 KiB
2.1 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
This is a Next.js chess application that implements both classic chess and a variant called "Ghost Chess". The app features a complete chess interface with piece movement, game state management, and different game modes.
Key Commands
npm run dev- Start development server with Turbo modenpm run build- Build production applicationnpm run lint- Run ESLint checksnpm start- Start production server
Architecture
Core Game Logic (lib/)
chess-types.ts- Core type definitions, enums (PieceType, PieceColor, GameMode), and board initializationchess-rules.ts- Game logic including move validation, check/checkmate detection, and Ghost Chess ruleschess-utils.ts- Utility functions for board manipulation and calculations
Components Structure
chess-game.tsx- Main game orchestrator with state management and game loopchess-board.tsx- Board rendering and square interactionchess-square.tsx- Individual square component with piece renderinggame-controls.tsx- Game control buttons and mode selectiongame-info.tsx- Game status, move history, and captured pieces display
Game Modes
- Classic Chess: Standard chess rules with check, checkmate, and stalemate
- Ghost Chess: Special variant with forced captures and different win conditions (capture all pieces)
Key Features
- Full chess piece movement and validation
- Castling and pawn promotion (auto-promotes to queen)
- Visual move highlighting for valid moves
- Move history tracking with algebraic notation
- Captured pieces tracking
- Game state management (check, checkmate, stalemate, ongoing)
Technology Stack
- Next.js 15 with App Router
- React 19 with TypeScript
- Tailwind CSS for styling
- Radix UI components (tabs, slots)
- Lucide React for icons
File Organization
- Uses
@/*path alias for imports - Components follow React functional component patterns with hooks
- Game state managed through useState with proper effect handling
- Board represented as 8x8 array of ChessPiece | null