Skillshub anki-connect
This skill is for interacting with Anki through AnkiConnect, and should be used whenever a user asks to interact with Anki, including to read or modify decks, notes, cards, models, media, or sync operations.
git clone https://github.com/ComeOnOliver/skillshub
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/intellectronica/agent-skills/skills" ~/.claude/skills/comeonoliver-skillshub-anki-connect-c0020c && rm -rf "$T"
skills/intellectronica/agent-skills/skills/SKILL.mdAnkiConnect
Overview
Enable reliable interaction with Anki through the AnkiConnect local HTTP API. Use this skill to translate user requests into AnkiConnect actions, craft JSON requests, run them via curl/jq (or equivalent tools), and interpret results safely.
Preconditions and Environment
- If Anki is not running, launch Anki, then wait until the AnkiConnect server responds at
(default). Verify readiness using curl, e.g.http://127.0.0.1:8765
should returncurl -sS http://127.0.0.1:8765
.Anki-Connect
Safety and Confirmation Policy (Critical)
CRITICAL — NO EXCEPTIONS
Before any destructive or modifying operation on notes or cards (adding, updating, deleting, rescheduling, suspending, unsuspending, changing deck, or changing fields/tags), request confirmation from the user. Use the AskUserQuestion tool if available; otherwise ask via chat. Only request confirmation once per logical operation, even if it requires multiple API calls (e.g., search + update + verify). Group confirmation by intent and scope (e.g., “Update 125 notes matching query X”).
Treat the following as confirmation-required by default:
- Notes:
,addNote
,addNotes
,updateNoteFields
,updateNoteTags
,updateNote
,updateNoteModel
,deleteNotes
,removeEmptyNotes
,replaceTags
,replaceTagsInAllNotes
.clearUnusedTags - Cards:
,setEaseFactors
,setSpecificValueOfCard
,suspend
,unsuspend
,forgetCards
,relearnCards
,answerCards
,setDueDate
.changeDeck - Deck or model modifications that materially change cards/notes (deck deletion, model edits). Ask even if the action is not explicitly listed above.
API Fundamentals
Request Format
Every request is JSON with:
: string action nameaction
: API version (useversion
unless user specifies otherwise)6
: object of parameters (optional)params
Response Format
Every response is JSON with:
: return valueresult
:error
on success or a string describing the errornull
Always check
error before using result.
Permissions
- Use
first when interacting from a non-trusted origin; it is the only action that accepts any origin.requestPermission - Use
to ensure compatibility; older versions may omit theversion
field in responses whenerror
≤ 4.version
curl + jq Patterns
Prefer
jq to build JSON and parse responses. Keep requests explicit and structured.
Minimal request template
jq -n --arg action "deckNames" --argjson version 6 '{action:$action, version:$version}' \ | curl -sS http://127.0.0.1:8765 -X POST -H 'Content-Type: application/json' -d @-
With params
jq -n \ --arg action "findNotes" \ --argjson version 6 \ --arg query "deck:French tag:verbs" \ '{action:$action, version:$version, params:{query:$query}}' \ | curl -sS http://127.0.0.1:8765 -X POST -H 'Content-Type: application/json' -d @-
Handling result/error
curl -sS http://127.0.0.1:8765 -X POST -H 'Content-Type: application/json' -d @- \ | jq -e 'if .error then halt_error(1) else .result end'
Batching multiple actions
Use
multi to reduce round-trips and to group actions under a single confirmation when modifying data.
jq -n --argjson version 6 --arg query "deck:French" \ '{action:"multi", version:$version, params:{actions:[ {action:"findNotes", params:{query:$query}}, {action:"notesInfo", params:{notes:[]}} ]}}' \ | curl -sS http://127.0.0.1:8765 -X POST -H 'Content-Type: application/json' -d @-
Replace the empty array with the result of the previous action when chaining; in CLI usage, split into two calls unless using a scripting language.
Core Workflow Guidance
1) Verify connectivity and version
- Call
(safe).requestPermission - Call
to confirm the API level and useversion
in requests.version: 6
2) Discover supported actions
- Use
withapiReflect
to list supported actions.scopes: ["actions"] - Use this list to map user intent to action names.
3) Resolve user request into action sequence
- Identify read-only vs destructive operations.
- For destructive/modifying operations on notes/cards, request confirmation once with the scope and count.
- Prefer
/findNotes
+findCards
/notesInfo
for previews before modification.cardsInfo
4) Execute and validate
- Execute the call(s) in order.
- Check
for each response.error - Report summarized results and any IDs returned.
Common Task Recipes (CLI-Oriented)
List decks
- Action:
deckNames
Create deck
- Action:
createDeck - Confirmation required if the deck is being created as part of a card/note modification workflow.
Search notes / cards
- Actions:
,findNotesfindCards - Use Anki search syntax (see “Search Syntax Quick Notes” below).
Preview note data
- Action:
(note IDs)notesInfo
Add notes
- Actions:
,addNoteaddNotes - Confirmation required.
- Use
orcanAddNotes
for preflight checks.canAddNotesWithErrorDetail
Update note fields or tags
- Actions:
,updateNoteFields
, or combinedupdateNoteTagsupdateNote - Confirmation required.
- Warning: Do not have the note open in the browser; updates may fail to apply.
Delete notes
- Action:
deleteNotes - Confirmation required.
Suspend/unsuspend cards
- Actions:
,suspendunsuspend - Confirmation required.
Move cards to a deck
- Action:
changeDeck - Confirmation required.
Set due date or reschedule
- Action:
setDueDate - Confirmation required.
Media upload/download
- Actions:
,storeMediaFile
,retrieveMediaFile
,getMediaFilesNames
,getMediaDirPathdeleteMediaFile - Use base64 (
), file path (data
), or URL (path
) for upload.url
Sync
- Action:
sync
Search Syntax Quick Notes (for findNotes
/findCards
)
findNotesfindCards- Separate terms by spaces; terms are ANDed by default.
- Use
, parentheses, andor
for NOT logic.- - Use
,deck:Name
,tag:tagname
,note:ModelName
.card:CardName - Use
or other field names to limit by field.front:... - Use
for regex,re:
for word-boundary searches,w:
to ignore accents.nc: - Use
,is:due
,is:new
,is:learn
,is:review
,is:suspended
to filter card states.is:buried - Use
searches for properties like interval or due date.prop: - Escape special characters with quotes or backslashes as needed.
Action Catalog (Use as a mapping reference)
Card Actions
getEaseFactorssetEaseFactorssetSpecificValueOfCardsuspendunsuspendsuspendedareSuspendedareDuegetIntervalsfindCardscardsToNotescardsModTimecardsInfoforgetCardsrelearnCardsanswerCardssetDueDate
Deck Actions
deckNamesdeckNamesAndIdsgetDeckscreateDeckchangeDeckdeleteDecksgetDeckConfigsaveDeckConfigsetDeckConfigIdcloneDeckConfigIdremoveDeckConfigIdgetDeckStats
Graphical Actions
guiBrowseguiSelectCardguiSelectedNotesguiAddCardsguiEditNoteguiAddNoteSetDataguiCurrentCardguiStartCardTimerguiShowQuestionguiShowAnswerguiAnswerCardguiUndoguiDeckOverviewguiDeckBrowserguiDeckReviewguiImportFileguiExitAnkiguiCheckDatabaseguiPlayAudio
Media Actions
storeMediaFileretrieveMediaFilegetMediaFilesNamesgetMediaDirPathdeleteMediaFile
Miscellaneous Actions
requestPermissionversionapiReflectsyncgetProfilesgetActiveProfileloadProfilemultiexportPackageimportPackagereloadCollection
Model Actions
modelNamesmodelNamesAndIdsfindModelsByIdfindModelsByNamemodelFieldNamesmodelFieldDescriptionsmodelFieldFontsmodelFieldsOnTemplatescreateModelmodelTemplatesmodelStylingupdateModelTemplatesupdateModelStylingfindAndReplaceInModelsmodelTemplateRenamemodelTemplateRepositionmodelTemplateAddmodelTemplateRemovemodelFieldRenamemodelFieldRepositionmodelFieldAddmodelFieldRemovemodelFieldSetFontmodelFieldSetFontSizemodelFieldSetDescription
Note Actions
addNoteaddNotescanAddNotescanAddNotesWithErrorDetailupdateNoteFieldsupdateNoteupdateNoteModelupdateNoteTagsgetNoteTagsaddTagsremoveTagsgetTagsclearUnusedTagsreplaceTagsreplaceTagsInAllNotesfindNotesnotesInfonotesModTimedeleteNotesremoveEmptyNotes
Statistic Actions
getNumCardsReviewedTodaygetNumCardsReviewedByDaygetCollectionStatsHTMLcardReviewsgetReviewsOfCardsgetLatestReviewIDinsertReviews
Notes and Pitfalls
- Keep Anki in the foreground on macOS or disable App Nap to prevent AnkiConnect from pausing.
- When updating a note, ensure it is not being viewed in the browser editor; updates may not apply.
paths are relative to the AnkiimportPackage
folder, not the client.collection.media
requiresdeleteDecks
to delete cards along with decks.cardsToo: true
Resources
No bundled scripts or assets are required for this skill.