anki-skill
CLAUDE.md3 starsChanged 11 months agoMITView on GitHub
AnkiSkill is a Python tool for creating, parsing, and editing Anki flashcard decks (.apkg files). It's designed as a "skill" for AI assistants to work with Anki decks programmatically using JSON as an intermediate format. **scripts/create_deck.py** - Converts JSON to .apkg format - Defines three card models: BASIC_MODEL, REVERSED_MODEL, CLOZE_MODEL - Uses stable_id() to generate consistent IDs from names via SHA-256 hashing - Creates genanki Note and Deck objects, packages them into .apkg **scripts/parse_deck.py** - Extracts cards from .apkg to…
- Installs packages
In this repositoryOne other file it gives its agents.
- ankiSkill
The file
We split this CLAUDE.md into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 84
When editing decks, always parse first, modify the JSON, then recreate the .apkg
≈ “Common” is an estimate: at least 1 in 5 of the 26,980 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Overview
AnkiSkill is a Python tool for creating, parsing, and editing Anki flashcard decks (.apkg files). It's designed as a "skill" for AI assistants to work with Anki decks programmatically using JSON as an intermediate format.
Development Commands
Setup
# Install dependencies using uv
uv sync
# Or install directly with pip
pip install genankiRunning Scripts
# Create a deck from JSON
uv run create-deck input.json output.apkg
# Or: python3 scripts/create_deck.py input.json output.apkg
# Parse a deck to JSON
uv run parse-deck deck.apkg
# Or: python3 scripts/parse_deck.py deck.apkgLinting and Type Checking
# Run type checker
uv run pyright
# Run linter
uv run ruff checkArchitecture
Core Components
scripts/create_deck.py - Converts JSON to .apkg format
- Defines three card models: BASIC_MODEL, REVERSED_MODEL, CLOZE_MODEL
- Uses
stable_id()to generate consistent IDs from names via SHA-256 hashing - Creates genanki Note and Deck objects, packages them into .apkg
scripts/parse_deck.py - Extracts cards from .apkg to JSON
- Unzips .apkg file (which is a ZIP containing SQLite database)
- Reads collection.anki2/anki21 database
- Infers card type from model name ("cloze", "reverse", or "basic")
- Outputs JSON matching create_deck input format
JSON Card Format
The workflow uses this JSON structure for round-trip editing:
{
"deck_name": "Deck Name",
"cards": [
{"front": "Question", "back": "Answer"},
{"front": "Front", "back": "Back", "type": "reversed"},
{"front": "{{c1::Cloze}} text", "back": "Extra info", "type": "cloze"}
]
}Card types:
basic(default): Single front→back cardreversed: Creates two cards (front→back and back→front)cloze: Cloze deletion cards using {{c1::text}}, {{c2::text}} syntax
ID Generation
The stable_id() function in scripts/create_deck.py:11 generates deterministic IDs from names to prevent conflicts and ensure reproducible deck creation. This is crucial because genanki requires unique numeric IDs for models and decks.
Important Notes
- .apkg files are ZIP archives containing an SQLite database (collection.anki2 or collection.anki21)
- The scripts use genanki for creation but raw SQLite for parsing (since genanki doesn't provide parsing)
- Card type inference during parsing is done by matching model names (case-insensitive check for "cloze" or "reverse")
- When editing decks, always parse first, modify the JSON, then recreate the .apkg
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

