Read cards from and write new cards to a local Anki installation
Read and query existing Anki cards, or add new cards directly to your local Anki collection.
For Write Operations:
Optional Configuration:
# Custom collection path (auto-detected if not set)
export ANKI_COLLECTION_PATH="/path/to/collection.anki2"
Query and export cards from your Anki collection using Anki search syntax.
# Export all cards with tag "german" as JSON
skill: anki read-cards --query "tag:german" --format json --output cards.json
# Export due cards as CSV
skill: anki read-cards --query "is:due" --format csv --output due.csv
# Show cards from a specific deck as markdown
skill: anki read-cards --query "deck:Vocabulary" --format markdown
# Query all cards (returns as text summary)
skill: anki read-cards --query ""
Formats:
json - Structured data with all fields and metadatacsv - Tabular format (Front, Back, Tags, Deck)markdown - Human-readable formatted listtext - Simple text summary (default)List all decks in your collection with card counts.
skill: anki list-decks
Show detailed information about a specific deck.
skill: anki describe-deck --deck "German Vocabulary"
List all note types in your collection with their field structures.
skill: anki list-note-types
Output shows:
Example output:
Found 3 note type(s):
Basic (Standard)
Fields: Front, Back
Cloze (Cloze)
Fields: Text, Extra
FSI German Drills (Standard)
Fields: Prompt1, Prompt2, Answer
Show which note types are used in a specific deck with sample card data.
skill: anki describe-deck-note-types --deck "DEU FSI German Basic Course Drills"
Output shows:
Use cases:
Add new cards to your Anki collection. Requires Anki to be closed.
Supports multiple note types: Basic, Cloze, and custom note types.
Basic Examples:
# Add Basic cards from CSV file (default note type)
skill: anki add-cards --input cards.csv --deck "Vocabulary"
# Add Basic cards from JSON file
skill: anki add-cards --input cards.json --deck "German"
# Add a single Basic card via arguments
skill: anki add-cards --deck "Quick" --front "Hello" --back "Hallo" --tags "german,greetings"
Cloze Card Examples:
# Add Cloze cards from JSON
skill: anki add-cards --input cloze.json --deck "Geography" --note-type "Cloze"
Cloze JSON Format:
[
{
"fields": {
"Text": "{{c1::Berlin}} is the capital of {{c2::Germany}}",
"Extra": "European capitals"
},
"tags": ["geography", "europe"]
}
]
Cloze CSV Format:
Text,Extra,Tags
"{{c1::Tokyo}} is the capital of Japan","Asian capitals","geography,asia"
"{{c1::Paris}} is in {{c2::France}}","European cities","geography,europe"
Custom Note Type Examples (e.g., FSI German Drills):
# Add cards with custom 3-field note type
skill: anki add-cards --input fsi.json --deck "DEU FSI" --note-type "FSI German Drills"
Custom Note Type JSON Format:
[
{
"fields": {
"Prompt1": "_____ ist dort.",
"Prompt2": "D- Flughafen",
"Answer": "Der Flughafen ist dort."
},
"tags": ["fsi", "drill"]
}
]
Flexible Format (case-insensitive field matching):
[
{
"prompt1": "_____ ist dort.",
"prompt2": "D- Flughafen",
"answer": "Der Flughafen ist dort.",
"tags": ["fsi", "drill"]
}
]
Legacy Basic Format (backward compatible):
[
{
"front": "Word",
"back": "Translation",
"tags": ["tag1", "tag2"]
}
]
CSV Format (Basic):
Front,Back,Tags
"Word","Translation","tag1,tag2"
The skill supports any note type in your collection:
Basic (default)
{"front": "...", "back": "..."} or {"fields": {"Front": "...", "Back": "..."}}Cloze
{"fields": {"Text": "{{c1::word}}", "Extra": "hint"}}Any custom note type in your collection is supported. Use discovery commands to find them:
# List all note types with their fields
skill: anki list-note-types
# See which note types are used in a specific deck
skill: anki describe-deck-note-types --deck "Your Deck"
1. Explicit Fields (recommended for non-Basic types):
{"fields": {"Field1": "value", "Field2": "value"}, "tags": [...]}
2. Legacy Front/Back (Basic only):
{"front": "value", "back": "value", "tags": [...]}
3. Case-Insensitive Matching:
{"field1": "value", "field2": "value", "tags": [...]}
Field names are matched case-insensitively to note type fields.
anki>=25.9.2)~/Library/Application Support/Anki2/User 1/collection.anki2 (macOS)--collection argument or ANKI_COLLECTION_PATH environment variable--note-type for other typesCommon Errors:
Collection is locked - Anki is currently running. Close it and try again.Deck not found - Specified deck doesn't exist. Use list-decks to see available decks.Collection not found - Cannot locate Anki collection. Specify path with --collection.Note type 'X' not found - Specified note type doesn't exist. Use list-note-types to see available types.Problem: Field 'X' not found in note type
Solution:
list-note-types to see exact field names (case-sensitive for explicit format)describe-deck-note-types --deck "Your Deck" to see fields with examplesfields formatProblem: Could not map any input fields
Solution:
fields format:{"fields": {"ExactFieldName": "value"}, "tags": [...]}
Problem: Note type does not have Front/Back fields
Solution:
{"front": "...", "back": "..."} only works with Basic note type{"fields": {"Text": "...", "Extra": "..."}, "tags": [...]}
Problem: Cloze cards not working
Solution:
--note-type "Cloze"{{c1::text}}, {{c2::text}}, etc.{"fields": {"Text": "{{c1::Berlin}} is capital", "Extra": "Geography"}}col.add_note, col.find_notes)