spacedrep
Spaced repetition you can script. A CLI and MCP server for flashcards — so an AI agent can generate cards from what you're learning, quiz you in conversation, and manage your deck alongside you.
Import your existing Anki decks to get started. Scheduling uses FSRS (same algorithm as Anki 23.10+). Everything is JSON in, JSON out — pipe it, script it, or let an agent drive it. Why build a CLI this way.
You: Quiz me on my AWS deck.
Agent: What does S3 stand for, and what is it used for?
You: Simple Storage Service, it's object storage.
Agent: Correct. Rated good — next review in 4 days. What is the CAP theorem?
You: Something about distributed systems... I forget.
Agent: CAP: pick 2 of 3 — consistency, availability, partition tolerance. Rated again — it'll come back shortly. 12 cards left.
Install
pip install spacedrep
Optional extras: spacedrep[mcp] for the MCP server, spacedrep[optimizer] for FSRS parameter optimization (requires torch).
Features
- FSRS scheduling — same algorithm as Anki 23.10+, with parameter optimization from your review history
- Cloze deletions —
{{c1::answer}}syntax, auto-expands into multiple cards - Reversed cards — one note becomes two cards (Q→A and A→Q); edits are template-aware and re-adds dedupe on (question, deck). Basic ↔ reversed collisions are caught with a clear error — delete the existing card first to convert it
- Anki-native storage — single SQLite file using Anki's schema for full round-trip compatibility
- Rich filtering — by deck, tags, state, date ranges, FSRS properties, and more
- Agent-friendly — duplicate detection, leech detection, review preview, bury/unbury, review history
MCP Server
Add to Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"spacedrep": {
"command": "uvx",
"args": ["--from", "spacedrep[mcp]", "spacedrep-mcp"],
"env": {
"SPACEDREP_DB": "/path/to/collection.anki21"
}
}
}
}
Agent loop
get_next_card → grade → submit_review. The server bundles a few affordances for that loop:
- Loop instructions on connect — the agent gets the loop, the rating scale, and the rule that it picks the rating (not the user)
- Inline review history —
get_next_cardandget_cardinclude the last 3 reviews with theiruser_answerandfeedbacktext - Session pacing —
get_next_cardreturnsdue_remainingfor "N cards left" messaging - Sibling auto-bury —
submit_reviewburies cloze/reversed siblings for 24h and returns them assiblings_buried, so the next card isn't a sibling whose answer was just shown
CLI Quick Start
spacedrep db init # create the database
spacedrep deck import ~/Downloads/deck.apkg # or import an existing Anki deck
spacedrep card add "What is CAP theorem?" "Pick 2 of 3: consistency, availability, partition tolerance" --deck AWS
spacedrep card add-cloze "{{c1::Ottawa}} is the capital of {{c2::Canada}}" --deck Geo
spacedrep card add-reversed "Capital of France" "Paris" --deck Geo # creates 2 cards: Q→A and A→Q
spacedrep card next # get the next due card
spacedrep review submit <card_id> good # again | hard | good | easy
See spacedrep --help and spacedrep <command> --help for all options.
Cloze Deletions
Each {{c1::answer}} becomes a separate card. Hints are supported: {{c1::Ottawa::capital city}} shows [capital city] as the blank.
spacedrep card update-cloze 42 "{{c1::Ottawa}} is in {{c2::Canada}}, {{c3::North America}}"
Search and Filters
spacedrep card list --search "Lambda" --deck AWS --state review
spacedrep card list --due-before "2026-12-31" --leeches
spacedrep card bury 42 --hours 4
spacedrep deck export out.apkg
Filters work on card list and card next. See --help for the full list.
Anki Compatibility
spacedrep operates directly on Anki's native SQLite schema. Importing an .apkg replaces the working database; exporting writes it back. FSRS scheduling state survives the round-trip — cards reviewed in spacedrep show correct due dates when opened in Anki.
Media files, JavaScript templates, and nested cloze deletions are not supported.
Data Storage
Your database is a single SQLite file (collection.anki21 by default). Every card addition and review is committed immediately — if the agent disconnects or the process crashes, no work is lost.
You don't need to export after every session. The .apkg import/export tools are for moving data between spacedrep and Anki Desktop, not for saving your progress.
Metadata
Release files for spacedrep 0.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| spacedrep-0.5.0.tar.gz | 150.8 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| spacedrep-0.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 209.0 kB
Release files / spacedrep-0.5.0.tar.gz
| Download URL | spacedrep-0.5.0.tar.gz |
|---|---|
| Size | 150.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f78e25b810f1e7fa14bde5284b64018c410919d1e3280f7429a54ef1c9c83e10
|
|
BLAKE2b-256 checksum How to use checksums |
488db5b2d4b8f1f0ef4f64e8fcc78b33b0ce1c8f6ee0f88acda4fbba4ca401a3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 26, 2026.
Transparency logRelease files / spacedrep-0.5.0-py3-none-any.whl
| Download URL | spacedrep-0.5.0-py3-none-any.whl |
|---|---|
| Size | 58.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9c154ee26efe366c0c741d60dd4c951c5c302dbff88cf839a928d5b656471201
|
|
BLAKE2b-256 checksum How to use checksums |
baf4ddf7d4225ff36093ce1cdbd2b0262eca0a07dc9bd74b1650b8820f020702
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 26, 2026.
Transparency logSecurity for spacedrep 0.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for spacedrep-0.5.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 26, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.