Interact with Anki flashcard decks via the AnkiConnect add-on. Use this skill whenever the user mentions Anki, flashcards, spaced repetition, creating cards, reviewing decks, or wants to turn any content (especially medical guidelines, PDFs, lecture notes) into flashcards. Also trigger when the user asks to browse, search, edit, delete, or organize Anki decks/cards, or wants to be quizzed. This skill covers ALL Anki interactions — deck management, card creation (Basic, Basic+Reversed, Cloze), searching, editing, deleting, and deck organization. Even if the user just says "make me some flashcards" or "add this to Anki", use this skill.
Manage Anki flashcards through Python scripts that talk to AnkiConnect on http://127.0.0.1:8765.
2055492159): Tools → Add-ons → Get Add-ons → paste code → restart AnkiAll scripts live in scripts/ relative to this skill's directory. They use only Python stdlib (urllib.request, json).
| Script | Purpose |
|---|---|
anki_api.py | Shared AnkiConnect client — all other scripts import this |
create_cards.py | Create one or more cards (Basic, Basic+Reversed, Cloze) |
search_cards.py |
| Search cards using Anki query syntax |
edit_card.py | Update fields or tags on an existing note |
delete_cards.py | Delete notes by ID (with confirmation) |
manage_decks.py | List, create, or delete decks |
move_cards.py | Move cards between decks |
get_note_types.py | List available note types and their fields |
python3 <SKILL_DIR>/scripts/manage_decks.py --list
If this fails, tell the user to open Anki and check AnkiConnect is installed.
Before creating cards, discover what note types and fields the user has:
python3 <SKILL_DIR>/scripts/get_note_types.py
The default model names are Basic, Basic (and reversed card), and Cloze, but the user may have custom ones. Adapt field names accordingly.
Read references/card-quality.md before creating any cards — it has rules for writing atomic, high-quality medical flashcards.
Always present proposed cards to the user for approval before creating them.
Basic card:
python3 <SKILL_DIR>/scripts/create_cards.py \
--deck "Medical::Cardiology" \
--type basic \
--front "What is the first-line treatment for stable angina?" \
--back "Beta-blockers (e.g., metoprolol) — Class I, LOE A (ESC 2023)" \
--tags "cardiology,angina,treatment,ESC-2023"
Basic + Reversed:
python3 <SKILL_DIR>/scripts/create_cards.py \
--deck "Medical::Cardiology" \
--type basic-reversed \
--front "Troponin I" \
--back "Cardiac biomarker; rises 3-6h post-MI, peaks 12-24h, normalizes 7-10d" \
--tags "cardiology,biomarkers,MI"
Cloze:
python3 <SKILL_DIR>/scripts/create_cards.py \
--deck "Medical::Cardiology" \
--type cloze \
--text "CHADS₂-VASc: {{c1::CHF}}, {{c2::HTN}}, {{c3::Age ≥75 (2pts)}}, {{c4::DM}}, {{c5::Stroke/TIA (2pts)}}, {{c6::Vascular dz}}, {{c7::Age 65-74}}, {{c8::Sex (female)}}" \
--tags "cardiology,afib,scoring"
Batch creation from JSON (preferred for multiple cards):
python3 <SKILL_DIR>/scripts/create_cards.py --from-json cards.json
JSON format:
{
"cards": [
{
"deck": "Medical::Cardiology",
"type": "basic",
"front": "Question",
"back": "Answer",
"tags": ["tag1", "tag2"]
},
{
"deck": "Medical::Cardiology",
"type": "cloze",
"text": "The {{c1::left ventricle}} pumps to the {{c2::systemic circulation}}",
"tags": ["anatomy"]
}
]
}
# By deck
python3 <SKILL_DIR>/scripts/search_cards.py -q "deck:Medical::Cardiology"
# By tag
python3 <SKILL_DIR>/scripts/search_cards.py -q "tag:angina"
# Full-text
python3 <SKILL_DIR>/scripts/search_cards.py -q "troponin"
# Combined
python3 <SKILL_DIR>/scripts/search_cards.py -q "deck:Medical tag:treatment metoprolol"
# Raw JSON output
python3 <SKILL_DIR>/scripts/search_cards.py -q "tag:ESC-2023" --json
# Update a field
python3 <SKILL_DIR>/scripts/edit_card.py --note-id 1234567890 --field Front --value "Updated question"
# Add tags
python3 <SKILL_DIR>/scripts/edit_card.py --note-id 1234567890 --add-tags "reviewed,2024"
# Remove tags
python3 <SKILL_DIR>/scripts/edit_card.py --note-id 1234567890 --remove-tags "draft"
python3 <SKILL_DIR>/scripts/delete_cards.py --note-ids 1234567890 1234567891
Always confirm with the user before deleting. The script also prompts interactively.
# List all decks
python3 <SKILL_DIR>/scripts/manage_decks.py --list
# Create (use :: for hierarchy)
python3 <SKILL_DIR>/scripts/manage_decks.py --create "Medical::Endocrinology::Diabetes"
# Delete empty deck
python3 <SKILL_DIR>/scripts/manage_decks.py --delete "OldDeck"
# By card IDs
python3 <SKILL_DIR>/scripts/move_cards.py --card-ids 123 456 --to-deck "Medical::Cardiology"
# By search query (moves ALL matching cards)
python3 <SKILL_DIR>/scripts/move_cards.py --query "tag:renal" --to-deck "Medical::Nephrology"
When the user provides a guideline (PDF, pasted text, or URL content):
references/card-quality.md for flashcard quality rules:: deck hierarchy (e.g., Medical::Cardiology::HeartFailure)--from-jsonSuggest this hierarchy (adapt to existing decks):
Medical::
├── Cardiology::
│ ├── HeartFailure
│ ├── ACS
│ └── Arrhythmias
├── Pulmonology::
│ ├── Asthma
│ └── COPD
└── Endocrinology::
├── Diabetes
└── Thyroid
Always run --list first to match the user's existing structure.
| Variable | Default | Purpose |
|---|---|---|
ANKICONNECT_URL | http://127.0.0.1:8765 | Override AnkiConnect URL |