e4 is a chess server for the terminal.
You run the server, connect over SSH, pick a nickname, and play or watch games.
- serves chess over SSH
- lets players create, join, and watch games
- supports time controls like
10|0,3|2, and15|10 - accepts SAN moves like
e4,Nf3,O-O, andQxe5+ - shows a live board, clocks, and move list in the terminal
- includes built-in themes (
classic,mono,nightowl) - adapts the board and chrome to smaller SSH terminals
Run Postgres and the server:
docker compose up --buildOr run the server against an existing Postgres database:
E4_DATABASE_URL='postgres://e4:e4@localhost:5432/e4?sslmode=disable' \
go run ./cmd/e4 serve --listen :2222 --log-level debugConnect from another terminal:
ssh -p 2222 anything@localhostThe SSH username is ignored. Player identity is tied to your SSH public key, and you choose a nickname after connecting.
Install the binary with:
go install github.com/morum/e4/cmd/e4@latestThen run:
e4 serveAfter you connect, type a nickname and press Enter.
The lobby is key-driven:
↑/↓orj/k: move through roomsEnter: join the selected room, or watch it if no seat is openw: watch the selected roomc: create a room, then enter a time control like10|0r: refresh the room listt: cycle to the next theme?: toggle helpqorctrl+c: quit
When the move input is focused, type SAN moves directly: e4, Nf3, O-O, Qxe5+.
Room controls:
Enter: submit the current move or slash commandEsc: toggle input focusl: leave the room and return to the lobbyctrl+r: resignf: flip the boardt: cycle to the next theme?: toggle helpctrl+c: quit the SSH session
Slash commands typed into the input:
:leaveor:quit: leave the room:resign: resign the game:flip: flip the board:theme <name>: switch to a specific theme
e4 serve [--listen :2222] [--host-key ./.e4_host_key] [--log-level info] [--theme classic] [--database-url postgres://...]Flags:
--listen: SSH bind address--host-key: path to the SSH private host key file--log-level:debug,info,warn, orerror--theme: default TUI theme (classic,mono, ornightowl)--database-url: Postgres connection URL. Can also be set withE4_DATABASE_URL
By default, e4 stores its generated host key in .e4_host_key.
Postgres 18+ is required for persistent player identities, games, and move history.
cmd/e4 CLI entrypoint
internal/app app wiring and configuration
internal/domain core game and lobby types
internal/service room and lobby services
internal/store/memory live in-memory room directory
internal/store/postgres persistent Postgres repositories and migrations
internal/clock chess clock state
internal/tui Bubble Tea models, widgets, and themes
internal/transport/ssh SSH transport and session handling
The code is structured so persistence, ratings, chat, bots, tournaments, and other clients can be added later without replacing the core game flow.
Requirements:
- Go
1.25+ - an SSH client
Common commands:
go test ./...
go build ./...
go run ./cmd/e4 serve --listen :2222 --log-level debugSee CONTRIBUTING.md.
e4 is released under the MIT License.
