A comprehensive chess library and toolset written in Go that helps you manage, analyze, and study your chess games.
- Automatic Import: Download and import games from Chess.com and Lichess with a single command
- Smart Tracking: Automatically fetches only new games since your last import
- SQLite Database: Store and query thousands of games efficiently
- PGN Support: Import, export, and manage PGN files
- Analyze PGN files using Stockfish or other UCI-compatible engines
- Calculate centipawn loss for each move
- Identify and annotate inaccuracies, mistakes, and blunders
- Generate summary statistics for each player and game
- Full chess move generation and validation
- FEN (Forsyth-Edwards Notation) support
- Legal move detection and position evaluation
cmd/: Main applicationsgochess/: The chess analysis tool executable
internal/: Private application codepgn/: PGN parsing and annotationengine/: UCI engine communicationanalysis/: Game analysis logic
pkg/: Library code that may be used by external applications
- Go 1.23 or later
- (Optional) Stockfish chess engine for analysis features
go install github.com/kyleboon/gochess/cmd/gochess@latestOr build from source:
git clone https://github.com/kyleboon/gochess.git
cd gochess
go build ./cmd/gochessSet up your configuration with usernames for automatic game import:
gochess config initThis will interactively prompt you for:
- Database location (default:
~/.gochess/games.db) - Chess.com username (optional)
- Lichess username and API token (optional)
Once configured, importing your games is as simple as:
gochess importThis command will:
- Fetch new games from all configured sources (Chess.com and/or Lichess)
- Only download games since your last import (incremental updates)
- Store them in your local database
- Track the import time for future runs
Run it daily, weekly, or whenever you want to update your game collection!
List games in your database:
# List recent games
gochess db list
# Filter by player
gochess db list --white "YourUsername"
# Show a specific game
gochess db show --id 123
# Export games to PGN
gochess db export --output games.pgnGet statistics:
# Overall statistics
gochess db stats
# Stats for a specific player
gochess db stats --player "YourUsername"# Show current configuration
gochess config show
# Add a user
gochess config add-user --platform lichess --username your-username
# Remove a user
gochess config remove-user --platform chesscom# Force full re-import (ignore last import time)
gochess import --full
# Show detailed errors during import
gochess import --verboseYou can still use the platform-specific commands for more control:
# Chess.com: Download specific month
gochess chesscom download --username player --year 2024 --month 12
# Chess.com: Download all history
gochess chesscom download --username player --all-history --import-db
# Lichess: Download with date range
gochess lichess download --username player --since 2024-01-01 --import-db
# Lichess: Download with filters
gochess lichess download --username player --perf-type blitz --rated true# Import PGN files directly
gochess db import --pgn games.pgn
# Clear database
gochess db clear
# List with pagination
gochess db list --limit 50 --offset 100The configuration is stored at ~/.gochess/config.yaml:
database_path: /Users/you/.gochess/games.db
chesscom:
username: your-chesscom-username
lichess:
username: your-lichess-username
api_token: your-optional-api-token
last_import:
chesscom:your-chesscom-username: 2024-12-09T10:30:00Z
lichess:your-lichess-username: 2024-12-09T10:31:15ZYou can edit this file manually or use the gochess config commands.
TBD