The Commands
Each command the help of scotch lists takes a section below, save scotch cite source, which Citing and Writing a Page sets out, and each section mise run docs:render writes from what the command line declares, meaning the command's docstring, its usage, and the type, the bound, the default, and the help of each parameter. The messages a command exits nonzero on come from src/scotch/docs/stops.toml, which mise run repo:audit holds to the messages the code prints. Beneath each section sits an example run, its output written from the index wherever the index alone sets it. The example runs write the data directory as .cache/data, where a real run prints its full path under the project's root. The Guide walks through a first match.
WritesReads
| Command | downloads/1.1 GB | index/459.9 MB | |||||
|---|---|---|---|---|---|---|---|
pgnmentor | manifest | games | left | positions | manifest | ||
fetchDownloads the files the store draws its games from. | |||||||
scotchfetchgames | scotch fetch games writes downloads/www.pgnmentor.com/ | scotch fetch games writes downloads/manifest.json | |||||
indexBuilds the index of stored games from the fetched files. | |||||||
scotchindexgames | scotch index games reads downloads/www.pgnmentor.com/ | scotch index games reads downloads/manifest.json | scotch index games writes index/games.parquet | scotch index games writes index/left.parquet | scotch index games writes index/positions.bin | scotch index games writes index/manifest.json | |
matchMatches a submitted game against the stored games. | |||||||
scotchmatchgame | scotch match game reads downloads/manifest.json | scotch match game reads index/games.parquet | scotch match game reads index/left.parquet | scotch match game reads index/positions.bin | scotch match game reads index/manifest.json | ||
scotchmatchgames | scotch match games reads downloads/manifest.json | scotch match games reads index/games.parquet | scotch match games reads index/left.parquet | scotch match games reads index/positions.bin | scotch match games reads index/manifest.json | ||
showPrints a stored game, a position, or what the store holds. | |||||||
scotchshowgame | scotch show game reads downloads/manifest.json | scotch show game reads index/games.parquet | scotch show game reads index/left.parquet | scotch show game reads index/positions.bin | scotch show game reads index/manifest.json | ||
scotchshowposition | scotch show position reads downloads/manifest.json | scotch show position reads index/games.parquet | scotch show position reads index/left.parquet | scotch show position reads index/positions.bin | scotch show position reads index/manifest.json | ||
scotchshowstore | scotch show store reads downloads/manifest.json | scotch show store reads index/games.parquet | scotch show store reads index/left.parquet | scotch show store reads index/positions.bin | scotch show store reads index/manifest.json | ||
citePrints the footnote definition citing a source. | |||||||
scotchcitesource | |||||||
- Commands
- 8
- Writes
- 6
- Reads
- 27
- Touches
- 6 of 6 files
scotch fetch games
Downloads each file sources.toml declares into the downloads folder of the data directory, in a folder named for the host of its address, and records each one in the manifest.json beside them. A file the manifest records is fetched again where the server reports it changed since, where the copy on disk no longer holds the bytes recorded, or where the server sent it with no entity tag to ask about.
Sends the requests concurrently, one thread per file up to 32, and records and prints each file in the order declared.
Prints one line per file, naming it as fetched or as unchanged, and exits nonzero naming the file and the error where the server answers with an error status, where a request fails once every retry has, where the connection breaks while the file downloads, which no retry covers, or where the file cannot be written, leaving no partial file behind.
text
scotch fetch gamesIt exits nonzero on each message below.
| Message | When | Clears It |
|---|---|---|
Could not fetch <address>: <error> | The server answers with an error status, a request fails once every retry has, the connection breaks while the file downloads, or the file cannot be written | Run the command again once the host answers, or raise SCOTCH_RETRIES or SCOTCH_TIMEOUT_S, or, where the error opens on the system's [Errno <n>], free space on the disk or make the downloads folder writable |
bash
scotch fetch gamestext
Fetched https://www.pgnmentor.com/players/Abdusattorov.zip
Fetched https://www.pgnmentor.com/players/Adams.zip
Fetched https://www.pgnmentor.com/players/Akobian.zip
…
Fetched https://www.pgnmentor.com/openings/Vienna.zipscotch index games
Reads the games of every file scotch fetch games downloaded into the downloads folder of the data directory, handing the files one at a time to a pool of processes, and writes the index of them to its index folder beside a copy of the manifest the files were read under, writing them beside that folder first and replacing it only once every file is written, so a build cut off partway leaves the earlier index readable. Each file's games are kept under the batches folder of the data directory, in a folder named for the code that reads them, so a file whose bytes and floor are unchanged is read back from there rather than parsed again, and a batch no file reads is removed. Files are parsed largest first and merged in the order sources.toml declares them, so a game several files repeat is indexed under the first, and a game rated below the floor sources.toml sets for its file's section, a game the reader records an error for, or one whose Variant tag names a variant other than standard chess is left out.
Prints the count of games read from each file beside the count left below its floor where its section sets one, one line for each problem of a game left out naming its file, its place there, and its players, and the count of games indexed. Exits nonzero where no file has been fetched, or naming each fetched file whose copy on disk no longer holds the bytes the manifest records.
text
scotch index gamesIt exits nonzero on each message below.
| Message | When | Clears It |
|---|---|---|
<count> keys are shared by different games | Two different games hash to one 64-bit key | Report the games sharing a key, since the build refuses to drop either |
No file has been fetched under <downloads> | The manifest records no file sources.toml declares | Run scotch fetch games |
These files changed on disk since their fetch, which `scotch fetch games` downloads again: | A fetched file no longer holds the bytes the manifest records | Run scotch fetch games, which downloads each file named below the line again |
bash
scotch index gamestext
…
Indexed 1,147,017 games into .cache/data/indexscotch match game
Finds the stored game sharing the longest unbroken run of positions with one game of a PGN file.
Prints the stored game as <file>:<n> beside its players, event, and date, the plies the two games share, the Forsyth–Edwards Notation of the position where they part with the move each played from it, the stored game's moves from there through its result, and the count of other stored games sharing a run as long, or a line saying no stored game shares a position with it. Stored games tied on the run rank by the mean of their players' ratings, highest first, then by the one rating a game carries, then in the order the index holds them.
Reads the index from the index folder of the data directory, which is .cache/data under the project's root unless the [tool.scotch] table of its pyproject.toml or the SCOTCH_DATA variable moves it, and warns where a fetch since the index was built recorded other bytes for the files than the ones the index was read from.
Exits nonzero naming the problem where the file cannot be read, holds no game, holds several with none chosen, or holds fewer than the one chosen, where reading the game recorded an error, such as a move illegal in the position it was played from or a FEN tag setting up a position no game reaches, where its Variant tag names a variant other than standard chess, where --json names a path opening on a hyphen other than -, or where no index has been built or the one built holds another layout.
text
scotch match game [OPTIONS] PGN| Parameter | Accepts | Default | Meaning |
|---|---|---|---|
PGN | A path | Required | The PGN file holding the game, or - for standard input. |
--game | An integer from 1 | None | The game to match, counting from 1, where the file holds several. |
--json | A path | None | The file the match is written to as JSON, or - to print the JSON alone. |
--link | A flag | Off | Prints the address of the Viewer opening the match. |
--plies | An integer from 1 | None | The most plies of the stored game's continuation to print. |
--top | An integer from 0 | 0 | The count of further stored games to list after the match. |
It exits nonzero on each message below.
| Message | When | Clears It |
|---|---|---|
Unknown option: <json> | --json names a path opening on a hyphen other than - alone | Pass the full path, such as $PWD/-match.json |
Cannot read <pgn>: <reason> | The file cannot be opened, with the reason the system gives | Name a file that exists and that the user running the command can read |
Found no game in <pgn> | The file holds no game | Pass the file holding the game, a text whose movetext follows its tag pairs |
Found several games in <pgn>, which --game chooses among | The file holds several games and --game names none | Choose one through --game, counting from 1 |
Found no game <n> in <pgn> | The file holds fewer games than --game counts | Choose a game the file holds, which scotch match games lists |
Found problems in the game in <pgn>: | Reading the game recorded an error, such as an illegal move, or its Variant tag names a variant other than standard chess | Correct the move or the tag each line below it names |
No index has been built under <index> | The data directory holds no index | Run scotch index games |
The index under <index> holds another layout | The index was built in a layout other than the one this version reads | Run scotch index games, which rebuilds the index in this layout |
bash
scotch match game docs/public/games/demo.pgn --top 3text
players/Kasparov.zip:193 Kasparov, Gary vs. Sosonko, Gennadi, Tilburg, 1981.??.??
Shares 43 positions, plies 0 to 42 of the submitted game and plies 0 to 42 of the stored game
Parts at r1b2k1r/p3q3/1p1N1p1p/2Ppn3/6pP/2QBP1B1/P3KPP1/3R4 w - - 0 22, where the submitted game played 22. c6 and the stored game played 22. Bc2
Continues 22. Bc2 Ba6+ 23. Ke1 Bc4 24. Nxc4 dxc4 25. Rd6 Re8 26. Bxe5 fxe5 27. Qxc4 Qf7 28. Qe4 g3 29. fxg3 1-0
0 other stored games share a run as long
openings/QGDOther34.zip:16393 Renet,O vs. Dizdar,G, ChIP, 2007.07.12, 21 positions
openings/QGDOther34.zip:19474 Moiseenko,A1 vs. Palac,M, 39th Olympiad Men, 2010.09.23, 20 positions
openings/QGDOther34.zip:13675 Sargissian,G vs. Dizdar,G, ADCF Masters, 2003.08.23, 20 positionsscotch match games
Matches every game of a PGN file against the index of stored games.
Prints one line per game, naming it as <file>:<n> beside the stored game closest to it as scotch match game ranks them, or saying no stored game shares a position with it. Where reading a game recorded an error, or its Variant tag names a variant other than standard chess, its line holds the problem in place of a match, and the rest of the report still prints.
Warns where the files changed since the index was built, and exits nonzero naming the problem where the file cannot be read or holds no game, where no index has been built, or where the one built holds another layout.
text
scotch match games PGN| Parameter | Accepts | Default | Meaning |
|---|---|---|---|
PGN | An existing file | Required | The PGN file holding the games. |
It exits nonzero on each message below.
| Message | When | Clears It |
|---|---|---|
Invalid value "<pgn>" for PGN. "<pgn>" does not exist. | The file does not exist, which Cyclopts reports before the command runs | Name a file that exists |
Cannot read <pgn>: <reason> | The file cannot be opened, with the reason the system gives | Name a file that exists and that the user running the command can read |
Found no game in <pgn> | The file holds no game | Pass the file holding the game, a text whose movetext follows its tag pairs |
No index has been built under <index> | The data directory holds no index | Run scotch index games |
The index under <index> holds another layout | The index was built in a layout other than the one this version reads | Run scotch index games, which rebuilds the index in this layout |
bash
scotch match games docs/public/games/demo.pgntext
demo.pgn:1 players/Kasparov.zip:193 Kasparov, Gary vs. Sosonko, Gennadi, Tilburg, 1981.??.??, 43 positionsscotch show game
Prints the stored game a <file>:<n> reference names as PGN, for any chess program to open, its tags then its mainline.
Warns where the files changed since the index was built, and exits nonzero naming the problem where the index holds no such game, where no index has been built, or where the one built holds another layout.
text
scotch show game REFERENCE| Parameter | Accepts | Default | Meaning |
|---|---|---|---|
REFERENCE | A word | Required | The stored game, as scotch match game names it. |
It exits nonzero on each message below.
| Message | When | Clears It |
|---|---|---|
No stored game is named <reference> | The index holds no game under the reference | Pass the reference scotch match game printed, such as players/Kasparov.zip:193 |
No index has been built under <index> | The data directory holds no index | Run scotch index games |
The index under <index> holds another layout | The index was built in a layout other than the one this version reads | Run scotch index games, which rebuilds the index in this layout |
bash
scotch show game players/Kasparov.zip:193text
[Event "Tilburg"]
[Site "Tilburg"]
[Date "1981.??.??"]
[Round "?"]
[White "Kasparov, Gary"]
[Black "Sosonko, Gennadi"]
[Result "1-0"]
[WhiteElo "2630"]
[BlackElo "2585"]
[ECO "D38"]
1. d4 Nf6 2. c4 e6 3. Nf3 d5 4. Nc3 Bb4 5. cxd5 exd5 6. Bg5 h6 7. Bh4 c5 8. e3 g5 9. Bg3 Ne4 10. Bb5+ Kf8 11. dxc5 Nxc3 12. bxc3 Bxc3+ 13. Ke2 Bxa1 14. Qxa1 f6 15. h4 g4 16. Nd4 Kf7 17. Bd3 Nd7 18. Qc3 Ne5 19. Nb5 Qe7 20. Nd6+ Kf8 21. Rd1 b6 22. Bc2 Ba6+ 23. Ke1 Bc4 24. Nxc4 dxc4 25. Rd6 Re8 26. Bxe5 fxe5 27. Qxc4 Qf7 28. Qe4 g3 29. fxg3 1-0scotch show position
Reports what the stored games played from one position.
Prints how many stored games reach it, each move they played from it with how many games played it and how those games ended, the games ending at the position under end, and then the games themselves, newest first, each named as <file>:<n>. A game reaching the position twice counts once, under the move it played from its first reach. A line of moves is read as PGN, so it may hold move numbers, comments, annotation marks, and a result beside its moves.
Warns where the files changed since the index was built, and exits nonzero naming the problem where a token opening on a hyphen names no option, where a Forsyth–Edwards Notation names no position or stops short of its first four fields, since a placement alone would read as white to move with no castling rights, where a line of moves holds an illegal move, a word naming no move, a ( or a { never closed, a ( before any move, a ) with none open, or more past the blank line or the result ending its moves, where no index has been built, or where the one built holds another layout.
text
scotch show position [OPTIONS] [ARGS...]| Parameter | Accepts | Default | Meaning |
|---|---|---|---|
POSITION | Any number of words | None | The Forsyth–Edwards Notation of the position or a line of moves from the start, quoted or not, the starting position where left out. |
--top | An integer from 1 | 20 | The count of games to list, the newest first. |
It exits nonzero on each message below.
| Message | When | Clears It |
|---|---|---|
Unknown option: <token> | A word of the position opens on a hyphen and names no option | Name the flag the help lists, or remove the word |
The FEN <position> stops short of its first four fields, the placement, the side to move, the castling rights, and the en passant square, which together name a position | A FEN holds fewer than four fields | Write the placement, the side to move, the castling rights, and the en passant square |
names no position: <fen> | A FEN names no position a game can reach | Correct the FEN, whose placement names eight ranks and one king of each color |
Found problems in <position>: | A line of moves holds an illegal move, a word naming no move, a bracket left open or closed with none open, or more past a blank line or on a line past its result | Correct the move or the word each line below it names |
names no move: '<word>' | A word of a line of moves reads as no move, beneath the line naming the problems | Spell the move in SAN, or remove the word |
holds more past the end of its moves | A line of moves holds text past a blank line or on a line past its result, beneath the line naming the problems | Remove the blank line or the result, or what follows it |
No index has been built under <index> | The data directory holds no index | Run scotch index games |
The index under <index> holds another layout | The index was built in a layout other than the one this version reads | Run scotch index games, which rebuilds the index in this layout |
bash
scotch show position 1. d4 Nf6 2. c4 e6 --top 3text
124,053 stored games reach this position
Nc3 56,847 1-0 19,994 1/2-1/2 20,878 0-1 15,971 * 4
Nf3 55,988 1-0 18,740 1/2-1/2 23,799 0-1 13,443 * 6
g3 10,890 1-0 3,476 1/2-1/2 4,367 0-1 3,045 * 2
Bg5 182 1-0 111 1/2-1/2 46 0-1 25 * 0
Bf4 58 1-0 24 1/2-1/2 16 0-1 18 * 0
a3 45 1-0 19 1/2-1/2 11 0-1 15 * 0
e3 23 1-0 5 1/2-1/2 8 0-1 10 * 0
g4 11 1-0 6 1/2-1/2 4 0-1 1 * 0
Qc2 4 1-0 1 1/2-1/2 3 0-1 0 * 0
Bd2 1 1-0 0 1/2-1/2 1 0-1 0 * 0
b3 1 1-0 0 1/2-1/2 1 0-1 0 * 0
d5 1 1-0 0 1/2-1/2 1 0-1 0 * 0
f3 1 1-0 0 1/2-1/2 1 0-1 0 * 0
end 1 1-0 1 1/2-1/2 0 0-1 0 * 0
Newest first:
players/Karjakin.zip:3599 Tomashevsky,E vs. Karjakin,Sergey, Chess Stars 6.0 Blitz, 2026.07.06
players/Tomashevsky.zip:2073 Tomashevsky,E vs. Sadhwani,Raunak, Chess Stars 6.0 Blitz, 2026.07.06
players/Tomashevsky.zip:2079 Gunina,V vs. Tomashevsky,E, Chess Stars 6.0 Blitz, 2026.07.06scotch show store
Reports what the store holds.
Prints each file sources.toml declares with its size and fetch date, the games and positions the index holds, whether the files have changed since the index was built from them, and the command to run next.
text
scotch show storebash
scotch show storetext
…
The index holds 1,147,017 games and 98,072,952 positions
The index was built from the files as fetched
Next: scotch match game <pgn>