Back to AI Tools & Agents

anki-connect

Ankiflashcardsspaced repetitionAnkiConnectproductivitylearningautomationAI integration
273📄 CC0-1.0🕒 2026-04-25Source ↗

Install this skill

npx skills add intellectronica/agent-skills

Works across Claude Code, Cursor, Codex, Copilot & Antigravity

The AnkiConnect skill bridges your agent with the Anki flashcard application via a local HTTP interface. It enables programmatic control over your study deck metadata, card content, and review status. By translating natural language into structured JSON payloads, the agent can search for specific notes, update existing card fields, or bulk-import new information. Safety is prioritized by requiring explicit user approval for any destructive or modifying actions, such as card suspension or field edits. This skill is intended for automating spaced repetition workflows, keeping study materials in sync with external knowledge bases, or managing large volumes of cards efficiently through a command-line pipeline. Use standard JSON-RPC patterns to communicate with the AnkiConnect server running on your local machine.

When to Use This Skill

  • Synchronizing newly captured notes from a markdown file into Anki
  • Suspended cards in a specific tag category to prioritize new material
  • Bulk-updating field content for thousands of existing cards at once
  • Automating the creation of cloze-deletion cards from technical documentation

How to Invoke This Skill

Example prompts that trigger this skill in Claude Code, Cursor, or Antigravity:

  • Update my Anki deck with these new cards
  • Find all cards tagged with 'biology' and suspend them
  • Check if my Japanese deck has any duplicate notes for this term
  • Change the deck for all cards currently in the 'General' folder
  • List all available decks in my local Anki installation

Pro Tips

  • 💡Always review the 'Safety and Confirmation Policy' section carefully, especially for destructive operations, to prevent unintended data loss.
  • 💡Familiarize yourself with common AnkiConnect API actions (e.g., `addNote`, `findNotes`, `updateNoteFields`) to efficiently formulate prompts.
  • 💡When troubleshooting, verify Anki is running and AnkiConnect is accessible at `http://127.0.0.1:8765` before issuing complex commands.

What this skill does

  • Execute bulk operations on cards and notes using API-based automation
  • Query deck contents using native Anki search syntax filters
  • Programmatically append, modify, or delete flashcard data
  • Check availability and verify note duplication before adding content
  • Batch multiple API actions into a single HTTP transaction

When not to use it

  • Manual, one-off card adjustments where a GUI edit is faster
  • Managing card synchronization across devices without AnkiConnect configured
  • Scenarios requiring high-frequency UI interactions that lack API endpoints

Example workflow

  1. Launch Anki and ensure the AnkiConnect add-on is active
  2. Call deckNames to identify the destination deck
  3. Use findNotes with a search query to locate relevant card IDs
  4. Request user confirmation to proceed with the pending modification
  5. Execute the updateNoteFields action via curl with the verified payloads

Prerequisites

  • Anki desktop application installed
  • AnkiConnect add-on installed in Anki
  • Local network access to port 8765

Pitfalls & limitations

  • !Performing mass modifications without user confirmation leads to accidental data loss
  • !Malformed JSON requests to the API often return silent errors or non-descriptive messages
  • !Misinterpreting Anki's internal search syntax can return unexpected notes in bulk edits

FAQ

Do I need to keep Anki open?
Yes, Anki must be running and the AnkiConnect server must be active on port 8765 for the agent to communicate with your decks.
How do I handle errors during batch requests?
Always inspect the error field in the JSON response; if a batch request fails, investigate the specific action that triggered the error before retrying.
Is my data safe when using this skill?
The skill mandates user confirmation for any destructive actions like deleting or updating cards, ensuring you remain in control of your data.

How it compares

Unlike manual editing, this skill allows for algorithmic management and batch processing of large card sets, reducing human error during repetitive updates.

Source & trust

273 stars📄 CC0-1.0🕒 Updated 2026-04-25
📄 Full skill instructions — original source: intellectronica/agent-skills
# AnkiConnect

## 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 http://127.0.0.1:8765 (default). Verify readiness using curl, e.g. curl -sS http://127.0.0.1:8765 should return 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:

- action: string action name
- version: API version (use 6 unless user specifies otherwise)
- params: object of parameters (optional)

### Response Format

Every response is JSON with:

- result: return value
- error: null on success or a string describing the error

Always check error before using result.

### Permissions

- Use requestPermission first when interacting from a non-trusted origin; it is the only action that accepts any origin.
- Use version to ensure compatibility; older versions may omit the error field in responses when version ≤ 4.

## 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 requestPermission (safe).
- Call version to confirm the API level and use version: 6 in requests.

### 2) Discover supported actions

- Use apiReflect with scopes: ["actions"] to list supported 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/cardsInfo for previews before modification.

### 4) Execute and validate

- Execute the call(s) in order.
- Check error for each response.
- 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: findNotes, findCards
- Use Anki search syntax (see “Search Syntax Quick Notes” below).

### Preview note data

- Action: notesInfo (note IDs)

### Add notes

- Actions: addNote, addNotes
- Confirmation required.
- Use canAddNotes or canAddNotesWithErrorDetail for preflight checks.

### Update note fields or tags

- Actions: updateNoteFields, updateNoteTags, or combined updateNote
- 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: suspend, unsuspend
- 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, getMediaDirPath, deleteMediaFile
- Use base64 (data), file path (path), or URL (url) for upload.

### Sync

- Action: sync

## Search Syntax Quick Notes (for findNotes/findCards)

- Separate terms by spaces; terms are ANDed by default.
- Use or, parentheses, and - for NOT logic.
- Use deck:Name, tag:tagname, note:ModelName, card:CardName.
- Use front:... or other field names to limit by field.
- Use re: for regex, w: for word-boundary searches, nc: to ignore accents.
- Use is:due, is:new, is:learn, is:review, is:suspended, is:buried to filter card states.
- Use prop: searches for properties like interval or due date.
- Escape special characters with quotes or backslashes as needed.

## Action Catalog (Use as a mapping reference)

### Card Actions

- getEaseFactors
- setEaseFactors
- setSpecificValueOfCard
- suspend
- unsuspend
- suspended
- areSuspended
- areDue
- getIntervals
- findCards
- cardsToNotes
- cardsModTime
- cardsInfo
- forgetCards
- relearnCards
- answerCards
- setDueDate

### Deck Actions

- deckNames
- deckNamesAndIds
- getDecks
- createDeck
- changeDeck
- deleteDecks
- getDeckConfig
- saveDeckConfig
- setDeckConfigId
- cloneDeckConfigId
- removeDeckConfigId
- getDeckStats

### Graphical Actions

- guiBrowse
- guiSelectCard
- guiSelectedNotes
- guiAddCards
- guiEditNote
- guiAddNoteSetData
- guiCurrentCard
- guiStartCardTimer
- guiShowQuestion
- guiShowAnswer
- guiAnswerCard
- guiUndo
- guiDeckOverview
- guiDeckBrowser
- guiDeckReview
- guiImportFile
- guiExitAnki
- guiCheckDatabase
- guiPlayAudio

### Media Actions

- storeMediaFile
- retrieveMediaFile
- getMediaFilesNames
- getMediaDirPath
- deleteMediaFile

### Miscellaneous Actions

- requestPermission
- version
- apiReflect
- sync
- getProfiles
- getActiveProfile
- loadProfile
- multi
- exportPackage
- importPackage
- reloadCollection

### Model Actions

- modelNames
- modelNamesAndIds
- findModelsById
- findModelsByName
- modelFieldNames
- modelFieldDescriptions
- modelFieldFonts
- modelFieldsOnTemplates
- createModel
- modelTemplates
- modelStyling
- updateModelTemplates
- updateModelStyling
- findAndReplaceInModels
- modelTemplateRename
- modelTemplateReposition
- modelTemplateAdd
- modelTemplateRemove
- modelFieldRename
- modelFieldReposition
- modelFieldAdd
- modelFieldRemove
- modelFieldSetFont
- modelFieldSetFontSize
- modelFieldSetDescription

### Note Actions

- addNote
- addNotes
- canAddNotes
- canAddNotesWithErrorDetail
- updateNoteFields
- updateNote
- updateNoteModel
- updateNoteTags
- getNoteTags
- addTags
- removeTags
- getTags
- clearUnusedTags
- replaceTags
- replaceTagsInAllNotes
- findNotes
- notesInfo
- notesModTime
- deleteNotes
- removeEmptyNotes

### Statistic Actions

- getNumCardsReviewedToday
- getNumCardsReviewedByDay
- getCollectionStatsHTML
- cardReviews
- getReviewsOfCards
- getLatestReviewID
- insertReviews

## 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.
- importPackage paths are relative to the Anki collection.media folder, not the client.
- deleteDecks requires cardsToo: true to delete cards along with decks.

## Resources

No bundled scripts or assets are required for this skill.

How to Use This Skill Unit

Option A: Project-Specific (Recommended)

  1. Click "Download" above
  2. In your project, create the directory: .agent/skills/anki-connect/
  3. Save the file as SKILL.md
  4. The agent will automatically discover the skill based on its description.

Option B: Global Installation (All Agents)

Save the file to these locations to make it available across all projects:

  • Claude Code: ~/.claude/skills/intellectronica/agent-skills/anki-connect/SKILL.md
  • Cursor: ~/.cursor/skills/intellectronica/agent-skills/anki-connect/SKILL.md
  • Antigravity: ~/.gemini/antigravity/skills/intellectronica/agent-skills/anki-connect/SKILL.md

🚀 Install with CLI:
npx skills add intellectronica/agent-skills

Read the Master Guide: Mastering Agent Skills

Recommended Rules

View more rules

Recommended Workflows

View more workflows

Recommended MCP Servers

View more MCP servers

Take It Further

Maximize your productivity with these powerful resources

📋

Define Your Standards

Set up coding standards to ensure this workflow produces consistent, high-quality results.

Browse Rules Library
📖

Master Workflows

Learn how to create custom workflows, use Turbo Mode, and build your automation library.

Complete Guide

How to use this Skill in Claude Code & Cursor

For Claude Code (CLI)

To use this skill in Claude Code, copy the rule content into your project's custom instructions or follow our Add-Skill CLI guide. This ensures Claude follows your standards during every code generation.

For Cursor & Windsurf

For Cursor or Windsurf, individual skills are best used in the "Rules for AI" section. This specific unit helps the agent avoid ai tools & agents issues, leading to cleaner, more efficient code.

Why the skill format matters: the standardized Agent Skills format lets your AI agent load detailed instructions only when they are relevant, keeping your prompt clean while improving results.

Source & attribution

This skill is categorized under AI Tools & Agents and is published by intellectronica, maintained in intellectronica/agent-skills.

← Browse All Agent Skills
Sponsored AI assistant. Recommendations may be paid.