Skip to content

sergi039/sschess

Repository files navigation

โ™Ÿ๏ธ Chess Analytics & Coaching System

AI-powered chess coaching system with memory, pattern analysis, and personalized learning paths.

๐ŸŽฏ Key Features

Basic Analysis (Chess.com) - Daily

  • ๐Ÿ“Š Automatic game updates every day via GitHub Actions
  • ๐Ÿ“ˆ Statistics: rating, win rate, time control results
  • ๐ŸŽฒ Opening analysis: repertoire, win percentages, problematic lines
  • ๐Ÿ“ Weakness identification: error patterns, time management issues
  • โšก Fast execution: < 1 minute for full cycle

Advanced Analysis (Lichess) - On Request

  • ๐Ÿ–ฅ๏ธ Computer analysis with Stockfish (accuracy, mistakes, blunders)
  • ๐ŸŽฏ Tactical patterns: forks, pins, discovered attacks
  • ๐Ÿ“š Lichess opening database: comparison with master statistics
  • ๐Ÿ“– Interactive Studies: automatic creation of training materials
  • ๐Ÿ“Š Improvement plan: personalized recommendations based on analysis

On-Demand Analysis (TypingMind Integration)

  • ๐Ÿ’ฌ AI chat commands: "Analyze my game from November 29"
  • ๐Ÿ” Smart search: by date, opponent, opening
  • ๐ŸŽฎ Interactive chess board: Lichess-style viewer embedded in chat
  • ๐Ÿค– Stockfish analysis: detailed move-by-move breakdown
  • ๐Ÿ“Š Visual analysis: Move classifications, accuracy, evaluation
  • ๐ŸŽฏ Full interactivity: Navigate moves, explore variations, all in TypingMind!

๐Ÿš€ Quick Start

1. Clone the repository

git clone https://github.com/sergi039/sschess.git chess-knowledge
cd chess-knowledge

2. Install dependencies

pip install requests python-chess
brew install stockfish  # for macOS (optional, for full analysis)

3. Configure environment

Create a .env file:

CHESS_USERNAME=sergioquesadas  # your Chess.com username
LICHESS_TOKEN=lip_YourToken    # Lichess token (optional)

4. Run analysis

# Basic analysis (fast, ~30 sec)
python scripts/main.py

# With Lichess computer analysis (slower, ~5 min)
python scripts/main.py --enable-lichess

# Analyze specific game
python scripts/analyze_game_on_demand.py "2025-11-29"

Usage Options

Basic usage (reads from .env)

python scripts/main.py

Specify username directly

python scripts/main.py --username YourChessUsername

Fetch only recent games (e.g., last 6 months)

python scripts/main.py --months 6

Skip fetching (use existing cache)

python scripts/main.py --skip-fetch

๐Ÿ“ Generated Files

Basic Reports (knowledge/) - Always Generated

  • summary.md - Overall statistics and ratings
  • openings.md - Opening repertoire analysis
  • weaknesses.md - Identified weaknesses and recommendations
  • recent_games.md - Last 20 games with details
  • typingmind_commands.md - Commands for AI chat

Advanced Reports (with --enable-lichess)

  • lichess_accuracy.md - Game accuracy and computer evaluation
  • lichess_mistakes.md - Detailed analysis of mistakes and blunders
  • lichess_tactics.md - Found tactical patterns
  • lichess_openings.md - Comparison with Lichess opening database
  • lichess_improvement.md - Personalized training plan
  • lichess_studies.md - Links to interactive lessons

Data Files (data/)

  • games_cache.json - All downloaded games
  • analysis_results.json - Basic analysis results
  • lichess_analysis_cache.json - Computer analysis cache
  • detailed_analysis_cache.json - On-demand analysis cache

๐Ÿค– GitHub Actions Automation

Setting up secrets

  1. Settings โ†’ Secrets and variables โ†’ Actions
  2. Add secrets:
    • CHESS_USERNAME - your Chess.com username
    • LICHESS_TOKEN - Lichess token (optional)
  3. Workflow runs automatically every day at 6:00 UTC

Manual run with parameters

  1. Actions โ†’ Update Chess Knowledge Base โ†’ Run workflow
  2. Parameters:
    • months - number of months to fetch
    • skip_fetch - skip fetching new games
    • enable_lichess - enable Lichess analysis โœ…

๐Ÿ’ฌ TypingMind Integration

Step 1: Configure Agent (IMPORTANT!)

  1. Go to Agents in TypingMind
  2. Create new agent or edit existing "Chess Master & Coach" agent
  3. Copy the System Prompt from ULTRA_ENHANCED_PROMPT.md
  4. Paste into agent's System Instructions
  5. Enable plugins: Web Search, Simple Calculator
  6. Save the agent

Step 2: Connect Knowledge Base

  1. In TypingMind: Data Sources โ†’ Add New
  2. Choose GitHub as source
  3. Repository: sergi039/sschess
  4. Folder: knowledge/
  5. TypingMind will sync files including:
    • chess_canvas_instructions.md (CDN links and setup)
    • Game analysis data
    • PGN files

Available chat commands

Basic statistics (always up-to-date):

  • "Show my current rating"
  • "What are my weak openings?"
  • "Show recent games"
  • "What are my main problems?"

Specific game analysis (requires scripts):

  • "Analyze my game from November 29"
  • "Find mistakes in game against [opponent]"
  • "Show computer evaluation of last game"

Improvement recommendations:

  • "What should I practice?"
  • "Which tactical patterns am I missing?"
  • "Training plan for the week"

๐Ÿ“‚ Project Structure

chess-knowledge/
โ”œโ”€โ”€ scripts/
โ”‚   โ”œโ”€โ”€ main.py                    # Main orchestrator
โ”‚   โ”œโ”€โ”€ fetch_games.py              # Chess.com game fetching
โ”‚   โ”œโ”€โ”€ analyze.py                  # Basic analysis
โ”‚   โ”œโ”€โ”€ generate_markdown.py        # Report generator
โ”‚   โ”œโ”€โ”€ lichess_analyzer.py         # Computer analysis
โ”‚   โ”œโ”€โ”€ tactical_detector.py        # Tactical pattern search
โ”‚   โ”œโ”€โ”€ opening_database.py         # Opening database handling
โ”‚   โ”œโ”€โ”€ study_generator.py          # Lichess Studies creation
โ”‚   โ”œโ”€โ”€ generate_lichess_markdown.py # Lichess reports
โ”‚   โ””โ”€โ”€ analyze_game_on_demand.py   # On-demand analysis
โ”œโ”€โ”€ knowledge/                      # Markdown files for TypingMind
โ”‚   โ”œโ”€โ”€ summary.md                  # Overall statistics
โ”‚   โ”œโ”€โ”€ openings.md                 # Openings
โ”‚   โ”œโ”€โ”€ weaknesses.md               # Weaknesses
โ”‚   โ”œโ”€โ”€ recent_games.md             # Recent games
โ”‚   โ”œโ”€โ”€ lichess_*.md                # Lichess reports (6 files)
โ”‚   โ””โ”€โ”€ typingmind_commands.md      # Command reference
โ”œโ”€โ”€ data/                           # Cached data
โ”‚   โ”œโ”€โ”€ games_cache.json            # All games
โ”‚   โ”œโ”€โ”€ analysis_results.json       # Analysis results
โ”‚   โ””โ”€โ”€ *_cache.json                # Various caches
โ””โ”€โ”€ .github/
    โ””โ”€โ”€ workflows/
        โ””โ”€โ”€ update.yml              # GitHub Actions automation

How It Works

  1. Fetching: Uses Chess.com's public API to download games

    • Incremental updates (only fetches new games)
    • Caches all games locally
    • Rate-limited to respect API guidelines
  2. Analysis: Processes games to find:

    • Opening repertoire and success rates
    • Performance by time control
    • Time management issues
    • Rating progression
    • Common patterns and weaknesses
  3. Generation: Creates readable Markdown with:

    • Tables and statistics
    • Specific recommendations
    • Visual indicators (๐ŸŸข๐ŸŸก๐Ÿ”ด)
    • Links to actual games

โš™๏ธ Technical Details

APIs Used

  • Chess.com API - game fetching (public, no token required)
  • Lichess API - computer analysis (requires token)
  • Stockfish - local engine for deep analysis

Limitations

  • Chess.com API has rate limits (0.5 sec between requests)
  • Lichess analysis limited to 5 games at a time
  • Stockfish requires local installation for full analysis

๐Ÿšง Development Roadmap

  • Basic game analysis
  • Lichess integration
  • On-demand analysis from TypingMind
  • Tactical patterns
  • Opening database
  • Graphs and visualization
  • Opponent analysis
  • Puzzle rating correlation
  • Tournament statistics

๐Ÿ“– Documentation

๐Ÿค Contributing

Issues and pull requests are welcome! Please read CONTRIBUTING.md first.

๐Ÿ“„ License

MIT

๐Ÿ‘ค Contact


๐Ÿš€ Automated chess game analysis system with AI integration

Built with Claude Code & โค๏ธ for chess improvement

About

chess.com to typingmind connector

Resources

Contributing

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages