Skip to main content

Hybrid Anki CLI for humans and agents

Project description

anki-cli

Hybrid Anki CLI for humans and agents.

anki-cli interactive REPL showing due card counts, keyboard shortcuts, and command autocomplete

anki-cli supports both:

  • AnkiConnect backend (use a running Anki Desktop instance)
  • Direct SQLite backend (operate directly on collection files)

Current release: 0.1.4 (alpha).

Install

From PyPI (recommended):

uv tool install anki-cli
anki --version

With optional TUI extras:

uv tool install "anki-cli[tui]"

Quick Start

Inspect environment and backend:

anki status
anki version

List core entities:

anki decks
anki notetypes
anki tags

Query cards and notes:

anki cards --query "deck:Default is:due"
anki notes --query "tag:verb"
anki search --query "(tag:verb OR tag:noun) -is:suspended"

Inspect individual objects:

anki card --id 1234567890
anki note --id 1234567890
anki deck --deck "Default"
anki notetype --name "Basic"

Backend Modes

Global backend selection:

anki --backend auto ...
anki --backend ankiconnect ...
anki --backend direct ...

Collection override (direct backend):

anki --backend direct --col "/path/to/collection.anki2" status

Backend behavior:

  • auto: detects and chooses best available backend
  • ankiconnect: forwards search queries to findCards and findNotes
  • direct: compiles queries to SQL and executes directly on the collection DB

Search Query Language

Supported filters:

  • deck:NAME (supports * glob)
  • notetype:NAME
  • tag:NAME (supports * glob)
  • is:new, is:learn, is:review, is:due, is:suspended, is:buried
  • flag:N
  • prop:ivl>N, prop:due>N, prop:reps>N, prop:lapses>N (<, <=, =, >=, >)
  • nid:ID, cid:ID
  • bare text and quoted text ("specific text")

Logical syntax:

  • implicit AND from whitespace
  • explicit OR
  • unary - and NOT
  • parentheses for grouping

Examples:

anki cards --query "deck:Japanese is:due"
anki cards --query "tag:verb -is:suspended"
anki notes --query "\"specific text\""
anki cards --query "(tag:a OR tag:b) is:new"

Common Commands

Cards

anki cards --query "deck:Default"
anki card --id 123
anki card:suspend --query "is:due"
anki card:unsuspend --id 123
anki card:move --query "tag:to-move" --deck "Archive"
anki card:flag --query "is:review" --flag 3
anki card:bury --query "deck:Default"
anki card:unbury --deck "Default"
anki card:reschedule --query "tag:reset-me" --days 3
anki card:reset --query "tag:relearn"
anki card:revlog --id 123 --limit 20

Notes and tags

anki notes --query "deck:Default"
anki note --id 123
anki note:add --deck "Default" --notetype "Basic" --Front "Q" --Back "A"
anki note:edit --id 123 --Front "Updated Q" --Back "Updated A"
anki note:fields --id 123
anki note:delete --id 123 --yes
anki tag --tag "verb"
anki tag:add --query "deck:Default" --tag "important"
anki tag:remove --id 123 --tag "important"
anki tag:rename --from "old" --to "new"

Decks and notetypes

anki deck --deck "Default"
anki deck:create --name "Japanese::Vocab"
anki deck:rename --from "Old" --to "New"
anki deck:delete --deck "Temporary" --yes
anki deck:config --deck "Default"
anki deck:config:set --deck "Default" --new-per-day 20 --reviews-per-day 200

anki notetypes
anki notetype --name "Basic"
anki notetype:create --name "MyType" --field "Front" --field "Back"
anki notetype:field:add --notetype "Basic" --field "Extra"
anki notetype:field:remove --notetype "Basic" --field "Extra"
anki notetype:css --notetype "Basic" --set ".card { font-size: 18px; }"

Review

anki review
anki review:next
anki review:show
anki review:preview --id 123
anki review:answer --id 123 --rating good
anki review:undo

Interactive TUI review (requires TUI extras, direct backend):

anki review:start --deck "Japanese"

Output and Exit Codes

Global output formats:

anki --format json ...
anki --format table ...
anki --format md ...
anki --format csv ...
anki --format plain ...

Exit codes:

  • 0: success
  • 1: backend operation failed
  • 2: invalid input or confirmation required
  • 4: entity not found
  • 7: backend unavailable

AI Agent Integration

This repo ships a SKILL.md at the project root that AI agents (Cursor, Windsurf, Cline, etc.) can consume to operate anki-cli without human guidance. It covers the full command reference, JSON output structure, search query syntax, error codes, and common workflows.

To use it in Cursor, copy or symlink it into your skills directory:

# Personal skill (available across all projects)
mkdir ~/.cursor/skills/anki-cli
cp SKILL.md ~/.cursor/skills/anki-cli/SKILL.md

# Or project-local skill (shared via the repo)
mkdir .cursor/skills/anki-cli
cp SKILL.md .cursor/skills/anki-cli/SKILL.md

For other AI coding agents, point them at SKILL.md in the repo root or include it in your agent's context/system prompt.

Safety Notes

  • Use --yes for destructive operations (note:delete, deck:delete).
  • In direct mode, avoid write operations while Anki Desktop is open.
  • If Anki Desktop is running, prefer --backend ankiconnect.

Development

uv sync --group dev
uv run ruff check .
uv run ty check
uv run pytest

With optional TUI dependencies:

uv sync --group dev --extra tui
uv run pytest -m tui

License

MIT. See LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

anki_cli-0.1.5.tar.gz (432.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

anki_cli-0.1.5-py3-none-any.whl (117.6 kB view details)

Uploaded Python 3

File details

Details for the file anki_cli-0.1.5.tar.gz.

File metadata

  • Download URL: anki_cli-0.1.5.tar.gz
  • Upload date:
  • Size: 432.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for anki_cli-0.1.5.tar.gz
Algorithm Hash digest
SHA256 cfc96fae79918e04049c7765195c221ddd5acab74e3cf3a409092e83f2166deb
MD5 410cda6a5113303fa41ff22badeaf9c7
BLAKE2b-256 ab3aebc204538ee47a1df20f580e74371f347fe28ec9c6a5b9a0a09ce6ad0ced

See more details on using hashes here.

Provenance

The following attestation bundles were made for anki_cli-0.1.5.tar.gz:

Publisher: publish.yml on ubermenchh/anki-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file anki_cli-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: anki_cli-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 117.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for anki_cli-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6794ca4279988e3b5fd35facc82dd169b4dbdb57e2ee5c9368ed5de16a521887
MD5 f4b2f4ea02005b7f36ae7af54ae7e48c
BLAKE2b-256 a34b564f3ac23cfd80d6e79acbe9ded6f427536bb8b057adbdc1f6b9d11942dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for anki_cli-0.1.5-py3-none-any.whl:

Publisher: publish.yml on ubermenchh/anki-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page