This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
- Start development server:
npm run dev - Build for production:
npm run build - Lint code:
npm run lint - Preview production build:
npm run preview
This is a React-based Minesweeper game built with Vite. The application follows a component-based architecture with clear separation of concerns:
- Entry Point:
src/main.jsxrenders the App component - Main App:
src/App.jsxcontains the root Minesweeper component - Game Logic:
src/utils/gameLogic.jscontains all pure functions for game mechanics - Components:
src/components/contains UI components with co-located CSS files
- Minesweeper.jsx: Main game container managing state and game flow
- GameHeader.jsx: Header with timer, mine counter, difficulty selector, and reset button
- GameBoard.jsx: Grid container that renders the game board using CSS Grid
- Cell.jsx: Individual cell component handling click events and visual states
The game logic is separated into pure functions in gameLogic.js:
- State Management: Uses constants for CELL_STATES, GAME_STATES, and DIFFICULTIES
- Board Operations: Functions for creating board, placing mines, revealing cells
- Game Flow: Win/lose detection, flag management, mine placement on first click
- Immutable Updates: All functions return new board states rather than mutating
Each component has a co-located CSS file following the pattern ComponentName.css. The game uses:
- CSS Grid for board layout with dynamic columns/rows
- CSS classes for cell states (
hidden,revealed,flagged,mine) - Number-specific classes (
number-1throughnumber-8) for mine count styling
The project uses modern ESLint configuration with:
- React Hooks rules
- React Refresh plugin for Vite
- Custom rule allowing unused vars with uppercase pattern (for constants)