Anki CLI Skill
Capability
Complete command-line control over Anki flashcard application via AnkiConnect API. Supports all major operations: creating cards, managing decks/models, searching, tagging, suspending, reviewing, and automation.
Installation Prerequisites
- Install Anki from https://apps.ankiweb.net/
- Install AnkiConnect plugin from https://ankiweb.net/shared/info/2055492159
- Install this CLI:
pip install -e . in the anki-cli directory
Quick Start
# Check connection
anki-cli version
# List decks
anki-cli deck-list
# Add a flashcard
anki-cli add-note -d "English" -m Basic Front:Hello Back:你好 -t vocabulary
# Search for cards
anki-cli find-notes "deck:English"
# Start reviewing a deck
anki-cli gui-review "English"
All Available Commands
System & Connection
| Command |
Description |
anki-cli version |
Get AnkiConnect API version |
anki-cli sync |
Sync with AnkiWeb |
anki-cli profiles |
List all profiles |
anki-cli check-database |
Check database for corruption |
Deck Management
| Command |
Description |
anki-cli deck-list |
List all decks |
anki-cli deck-ids |
List decks with IDs |
anki-cli deck-stats DECK |
Get deck statistics |
anki-cli create-deck NAME |
Create a new deck |
anki-cli delete-deck DECKS... |
Delete decks |
Note Model Management
| Command |
Description |
anki-cli model-list |
List all note models |
anki-cli model-fields MODEL |
Get model field names |
anki-cli create-model NAME FIELDS... |
Create a new model |
Search & Browse
| Command |
Description |
anki-cli find-cards QUERY |
Search for cards |
anki-cli find-notes QUERY |
Search for notes |
anki-cli cards-info CARD_ID |
Get card information |
anki-cli notes-info NOTE_IDS... |
Get note information |
anki-cli gui-browser QUERY |
Open Browser with search |
Note Operations
| Command |
Description |
anki-cli add-note -d DECK [fields...] |
Add a new note |
anki-cli add-notes -d DECK -f FILE |
Add multiple notes from file |
anki-cli update-note NOTE_ID [fields...] |
Update note fields |
anki-cli get-note-tags NOTE_ID |
Get tags for a note |
anki-cli add-tags NOTES... TAGS |
Add tags to notes |
anki-cli remove-tags NOTES... TAGS |
Remove tags from notes |
anki-cli clear-tags |
Clear unused tags |
anki-cli replace-tags NOTES OLD NEW |
Replace tags |
anki-cli delete-notes NOTES... |
Delete notes |
Card State Management
| Command |
Description |
anki-cli suspend NOTES... |
Suspend notes from reviews |
anki-cli unsuspend NOTES... |
Resume suspended notes |
anki-cli are-suspended NOTES... |
Check if notes are suspended |
anki-cli are-due CARDS... |
Check if cards are due |
anki-cli set-due-date CARDS... DAYS |
Set card due date |
anki-cli forget CARDS... |
Reset cards to new state |
anki-cli relearn CARDS... |
Set cards to relearning |
anki-cli answer CARD_ID EASE |
Answer a card (ease 1-4) |
GUI Operations
| Command |
Description |
anki-cli gui-add |
Open Add Cards dialog |
anki-cli gui-edit NOTE_ID |
Open Edit Note dialog |
anki-cli gui-current |
Get current review card |
anki-cli gui-question |
Show question of current card |
anki-cli gui-answer |
Show answer of current card |
anki-cli gui-timer |
Start review timer |
anki-cli gui-deck-browser |
Open Deck Browser |
anki-cli gui-deck-overview DECK |
Open Deck Overview |
anki-cli gui-review DECK |
Start reviewing a deck |
anki-cli gui-undo |
Undo last action |
anki-cli gui-exit |
Close Anki |
Statistics
| Command |
Description |
anki-cli today-stats |
Get today's review count |
anki-cli reviews-by-day |
Get reviews by day |
anki-cli collection-stats |
Get collection statistics |
Media Operations
| Command |
Description |
anki-cli media-list |
List media files |
anki-cli media-store FILENAME DATA |
Store media file (base64) |
Import/Export
| Command |
Description |
anki-cli export DECK PATH |
Export deck as .apkg |
anki-cli import PATH |
Import .apkg file |
anki-cli multi FILE |
Execute multiple actions |
Anki Search Syntax
Basic Searches
deck:English - Cards in English deck
tag:vocabulary - Cards with vocabulary tag
note:Basic - Notes using Basic model
front:hello - Search in front field
Card States
is:new - New cards
is:due - Due cards (ready for review)
is:suspended - Suspended cards
is:buried - Buried cards
is:learn - Learning cards
is:review - Review cards
is:filtered - Cards in filtered decks
Properties (prop:)
prop:due<=1 - Due within 1 day
prop:interval>7 - Interval greater than 7 days
prop:lapses>2 - More than 2 lapses
prop:reps<5 - Less than 5 repetitions
Time-based
added:1 - Added today
added:7 - Added in last 7 days
edited:1 - Edited today
rated:1 - Reviewed today
Combining Terms
deck:English is:due - Due cards in English deck
tag:vocabulary -is:suspended - Non-suspended vocabulary cards
(deck:English or deck:French) is:new - New cards in either deck
Usage Examples
Create flashcards programmatically
# Single card
anki-cli add-note -d "Biology" -m "Basic" -t "chapter1" Front:"What is mitosis?" Back:"Cell division process"
# Multiple cards from file (notes.txt format: Front<TAB>Back)
anki-cli add-notes -d "Biology" -m "Basic" -t "chapter1" notes.txt
Manage a study session
# Check what's due
anki-cli find-notes "deck:Biology is:due"
# Start review session
anki-cli gui-review "Biology"
# Get current card info
anki-cli gui-current
# Answer with ease rating (1-4)
anki-cli answer <card_id> 3
Bulk tag operations
# Find all notes in a deck and tag them
notes=$(anki-cli find-notes "deck:OldDeck" | grep -E "^\s+-" | awk '{print $2}')
anki-cli add-tags $notes "archived"
# Replace a tag across all notes
anki-cli replace-tags $notes "old-tag" "new-tag"
Automated card management
# Suspend cards not reviewed in 90 days
anki-cli suspend $(anki-cli find-cards "rated:90 -prop:due<=90")
# Reset cards that failed
anki-cli forget $(anki-cli find-cards "prop:lapses>3") --delete-data
Deck statistics
# Get overview of all decks
anki-cli deck-list
for deck in $(anki-cli deck-list | grep "^\s*-" | awk '{print $2}'); do
anki-cli deck-stats "$deck"
done
AI Agent Integration Patterns
Pattern 1: Create cards from content
# Extract terms and create cards
extract_terms() { ... } # Your extraction logic
for term in $(extract_terms); do
anki-cli add-note -d "Glossary" -m "Basic" \
Front:"$term" Back:"$(define $term)" -t "auto-generated"
done
Pattern 2: Daily review automation
# Check if cards are due
due_count=$(anki-cli find-notes "is:due" | wc -l)
if [ $due_count -gt 0 ]; then
anki-cli gui-review "Default"
fi
Pattern 3: Spaced repetition for learning
# Find cards to review based on interval
anki-cli find-cards "prop:due<=0 is:review"
Error Handling
All commands return:
- Success: Result data on stdout, exit code 0
- Failure: Error message on stderr, non-zero exit code
Common errors:
- Connection: "Cannot connect to AnkiConnect" - Ensure Anki + AnkiConnect running
- Not found: "Deck/Model/Note not found" - Verify names/IDs exist
- Invalid syntax: Check search query syntax
Related Resources