Chess Coach AI Agents
Defines a chess coaching app with AI agents that analyze positions, suggest moves, and provide strategic advice via a React frontend and Python backend.
What this file does
Defines a chess coaching app with AI agents that analyze positions, suggest moves, and provide strategic advice via a React frontend and Python backend.
When to use it
- Building a chess coaching tool with AI-powered analysis
- Integrating a React chess board with an LLM-based agent
- Creating a real-time AI assistant for game analysis
- Setting up a CopilotKit frontend with a FastAPI agent backend
Assumes this stack
Chess Coach AI Agents
Overview
This project implements a chess coaching application with AI agents that can analyze chess positions, suggest moves, and provide strategic advice. The system combines a modern React frontend with a Python-based AI agent backend.
Architecture
Frontend (React/Next.js)
- Framework: Next.js 15.3.2 with React 19
- UI Library: CopilotKit for AI integration
- Chess Board: react-chessboard for interactive chess interface
- Game Logic: chess.js for move validation and game state management
- Styling: Tailwind CSS
Backend (Python)
- Framework: LlamaIndex with OpenAI integration
- Agent: Chess assistant with FEN position understanding
- Server: FastAPI with Uvicorn
AI Agents
Chess Assistant Agent
Purpose: Provides chess analysis, move suggestions, and strategic coaching
Capabilities:
- Analyzes chess positions using FEN notation
- Suggests optimal moves based on position evaluation
- Explains chess concepts and strategies
- Provides real-time analysis
- Offers coaching advice for improvement
Technical Implementation:
- LLM: OpenAI GPT-4.1
- State Management: FEN position strings for game state
- Integration: CopilotKit for real-time UI updates
- Tools: Currently configured for chess analysis (frontend/backend tools disabled)
State Schema:
type ChessState = {
position: string; // FEN notation of current board position
}
Key Components
ChessBoard Component
- Library: react-chessboard
- Features: Drag-and-drop piece movement, move validation
- Integration: Syncs with AI agent state via FEN updates
- Validation: Uses chess.js for legal move checking
State Management
- Shared State: CopilotKit manages chess position between UI and agent
- Real-time Updates: Position changes trigger AI analysis
- Persistence: Game state maintained during session
Development Setup
Prerequisites
- Node.js 18+
- Python 3.8+
- OpenAI API Key
- uv package manager
Installation
# Install frontend dependencies
npm install
# Install Python agent dependencies
npm run install:agent
# Set environment variables
export OPENAI_API_KEY="your-api-key"
Running the Application
# Start both frontend and agent servers
npm run dev
# Or run separately
npm run dev:ui # Frontend only
npm run dev:agent # Agent only
Current Status
Implemented
- ✅ Interactive chess board with drag-and-drop
- ✅ Move validation using chess.js
- ✅ FEN position state management
- ✅ AI agent integration with CopilotKit
- ✅ Real-time position updates
- ✅ Basic chess assistant functionality
Planned Enhancements
- Advanced chess analysis tools
- Opening book integration
- Tactical puzzle generation
- Game history and replay
- Multiple difficulty levels
- Tournament mode
Technical Notes
FEN Notation
The system uses standard FEN (Forsyth-Edwards Notation) for position representation:
- Format:
rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1 - Enables precise position communication between frontend and AI
- Standard format for chess engines and analysis
Agent Communication
- Protocol: CopilotKit for seamless frontend-backend integration
- State Sync: Real-time position updates between chess board and AI
- Tool Integration: Ready for advanced chess analysis tools
File Structure
src/
├── app/
│ ├── page.tsx # Main application component
│ └── api/copilotkit/ # CopilotKit API routes
├── components/
│ ├── ChessBoard.tsx # Interactive chess board
│ └── WeatherCard.tsx # Example component (legacy)
agent/
├── agent/
│ ├── agent.py # Chess assistant agent
│ └── server.py # FastAPI server
└── pyproject.toml # Python dependencies
What's inside
Architecture overview, 2 AI agent descriptions, 3 key components, development setup, current status, technical notes, and file structure.
Change this for your project
- Replace
OPENAI_API_KEYwith your own API key - Replace
cedric-scheerlinck/chess-coachwith your repository name - Replace
WeatherCard.tsxwith your own legacy component or remove it
Where it goes
Save as AGENTS.md in your repository root. Read by Codex, Cursor and other agents that follow the AGENTS.md convention.
Worth borrowing
- Using FEN notation as a shared state format between frontend and AI agent
- Separating frontend and agent servers with a single
npm run devcommand to start both
Related Documents
Browser-only development
Guides AI assistants on an Electron + React + TypeScript desktop app for browsing and organizing AI-generated images locally.
Claude Agents — Reference & Recommendations
Catalogues 40+ Claude agents and marketing skills for building a cat adoption charity landing page, with a ready-to-paste prompt and backend API reference.
Golden DKG Prototype -- Master Plan
Defines an 8-phase implementation plan for a Rust prototype of the Golden non-interactive DKG protocol using BLS12-381 and tokio.
Swarms Examples Index
Lists 60+ example scripts for building single and multi-agent systems with the Swarms framework, organized by category and use case.