ghost-chess/CLAUDE.md
2025-05-31 22:08:46 +09:00

53 lines
2.1 KiB
Markdown

# 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 mode
- `npm run build` - Build production application
- `npm run lint` - Run ESLint checks
- `npm start` - Start production server
## Architecture
### Core Game Logic (lib/)
- `chess-types.ts` - Core type definitions, enums (PieceType, PieceColor, GameMode), and board initialization
- `chess-rules.ts` - Game logic including move validation, check/checkmate detection, and Ghost Chess rules
- `chess-utils.ts` - Utility functions for board manipulation and calculations
### Components Structure
- `chess-game.tsx` - Main game orchestrator with state management and game loop
- `chess-board.tsx` - Board rendering and square interaction
- `chess-square.tsx` - Individual square component with piece rendering
- `game-controls.tsx` - Game control buttons and mode selection
- `game-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