Automating Anki Deck Creation with LLMs

Creating high-quality Anki flashcards manually can be time-consuming, especially when dealing with large amounts of content. I’ve developed a workflow that leverages Large Language Models (LLMs) to automate much of this process, making it significantly more efficient while maintaining quality control. The key to this approach is providing clear, detailed prompts that guide the LLM’s output. An example of a part of the prompt I use to define the rules that LLMs should follow to create, complete or fix my cards:

French-Italian Idioms CSV File Rules

This document outlines the structure and formatting rules for the french_idioms_italian.csv file.

File Format

  • Fields are separated by semicolons (;)
  • String values containing semicolons, spaces, or special characters are enclosed in double quotes (")
  • File uses UTF-8 encoding to support special characters

Columns The CSV contains the following columns in order:

  1. French Expression - The complete French idiom
  2. French Definition - The meaning of the idiom in French
  3. Italian Translation - The equivalent idiom in Italian
  4. Example1 - A complete sentence using the idiom with the full expression visible (not masked)
  5. PartialCloze1 - A sentence where only the beginning of the idiom is masked with [...]
  6. Example2 - A second complete sentence using the idiom with the full expression visible (not masked)
  7. PartialCloze2 - A sentence where only the ending of the idiom is masked with [...]
  8. FullCloze - A sentence where the entire idiom is masked with [...]
  9. Register - The formality level of the idiom (Neutre, Informel, Familier)

Cloze Test Rules

  • [...] is used as the placeholder for masked portions of text
  • PartialCloze1: Masks the beginning of the expression, keeping the ending visible
  • PartialCloze2: Masks the ending of the expression, keeping the beginning visible
  • FullCloze: Masks the entire expression
  • All cloze examples must maintain grammatical correctness and natural flow
  • Example sentences should provide sufficient context to infer the missing expression
  • Use completely different sentences for different fields (Example1, Example2, PartialCloze1, PartialCloze2, > FullCloze) to provide varied contexts

I use placeholders ("[…]") and not cloze card types because I think it’s not possible to create cloze cards AND front/back cards in the same note.

I use CSV files as intermediate files to interact with the content of the decks. I’ve tried to use an MCP server (that I wrote using Claude Code, the MCP TypeScript SDK and the Anki Connect API specification) to connect LLMs to Anki Connect API and it works well, but it’s slow if you interact with thousands of notes. I prefer using LLM to create a Python script that loads the complete CSV file into the deck using the Anki Connect API.

I use LLMs also to reflect on card types: how to structure them? Which fields should be shown in front? Which ones in back? How to style them? Unfortunately, at the moment, Anki Connect does not allow creating or editing card types, so I had to create/edit the card types by hand.

It’s obviously an iterative process, but using LLM to create Anki decks is, by far, more productive than doing it by hand. I start, for example, by listing French expressions in a new CSV file:

1
2
3
French Expression
prendre le taureau par les cornes
chercher une aiguille dans une botte de foin

and then I ask an LLM to add a new column, French Definition for example, following the rules I listed above. When I’ve verified a sample of the results, I add the other columns, one by one. And at the end I use the Python script written by the LLM to create a new deck.