CLI Reference#

Global Usage#

cairn [--db <path>] [command] [flags]

Run cairn with no arguments to launch the interactive TUI.

Global Flags#

FlagDescription
--db <path>Override the default database path

Commands#

cairn add#

Save a bookmark by URL. The page title and description are fetched automatically.

cairn add <url> [--tags <comma-separated>]

Arguments:

ArgumentDescription
<url>The URL to bookmark (required)

Flags:

FlagDescription
--tagsComma-separated tags, e.g. "work,go,tools" — maximum 3 tags

Exit codes:

CodeMeaning
0Saved successfully
1Already bookmarked (duplicate URL)
2Saved but page title could not be fetched
3Error (invalid arguments, database error)

Examples:

cairn add https://go.dev
cairn add https://pkg.go.dev/net/http --tags "go,stdlib"

cairn list#

List all bookmarks.

cairn list [--json] [--order asc|desc]

Flags:

FlagDefaultDescription
--jsonfalseOutput as JSON array instead of tab-separated text
--orderdescSort order: asc (oldest first) or desc (newest first)

Tab-separated output columns: ID, Title, URL, Domain, CreatedAt

Examples:

cairn list
cairn list --json
cairn list --order asc
cairn list --json | jq '.[0].title'

Search bookmarks by title, domain, and description using full-text search (FTS5) combined with fuzzy matching.

cairn search <query> [--json] [--limit N]

Arguments:

ArgumentDescription
<query>Search query (required)

Flags:

FlagDefaultDescription
--jsonfalseOutput as JSON array
--limit10Maximum number of results to return

Examples:

cairn search golang
cairn search "rust async" --limit 5
cairn search api --json | jq '.[].url'

cairn delete#

Delete a bookmark by its numeric ID.

cairn delete <id>

Arguments:

ArgumentDescription
<id>Bookmark ID (use cairn list to find IDs)

Exit codes:

CodeMeaning
0Deleted successfully
1Bookmark not found
3Error

Example:

cairn delete 42

cairn pin#

Toggle the pin (permanent) flag on a bookmark. Pinned bookmarks are never auto-archived.

cairn pin <id>

Arguments:

ArgumentDescription
<id>Bookmark ID to pin or unpin

Example:

cairn pin 42   # pins if unpinned, unpins if pinned

cairn sync#

Manage bookmark synchronisation via Dropbox. See Dropbox Sync for setup instructions.

cairn sync <subcommand>

Subcommands:

SubcommandDescription
setupConnect to Dropbox and perform initial sync
pushPush local changes to Dropbox
pullPull remote changes from Dropbox
statusShow sync configuration and pending changes
authRe-authenticate with Dropbox (refresh OAuth2 token)
unlinkDisconnect sync; local bookmarks are preserved

cairn sync setup#

Connects cairn to Dropbox and performs the initial sync. If CAIRN_DROPBOX_APP_KEY is not set via environment variable or cairn.json, the command prompts interactively:

Enter your Dropbox App Key: <key>
Enter database path (press Enter for default: /home/user/.local/share/cairn/bookmarks.db):

Values entered during the prompt are saved to cairn.json for future runs. The App Key is required for setup and auth; the database path defaults to the platform default if left blank.

You can skip the interactive prompt by supplying the App Key in advance:

export CAIRN_DROPBOX_APP_KEY=<your-app-key>
cairn sync setup

cairn sync auth#

Re-authenticates with Dropbox. Requires CAIRN_DROPBOX_APP_KEY to be set via environment variable or cairn.json (no interactive prompt).


Auto-sync (background)#

When sync is configured, most commands trigger a background sync automatically — no manual cairn sync pull or cairn sync push is needed for routine use.

TriggerDirection
Before add, list, search, delete, pinPull (background)
After add, deletePush (background)

Background syncs run as a detached subprocess with no output to the terminal. A lock file prevents concurrent syncs. If a sync is already running, the new request is silently skipped.

First-run prompt#

On the very first run (before any sync configuration exists), cairn asks whether you want to set up Dropbox sync:

No sync configured — connect to Dropbox? (y/N)
  • Answering y prints instructions to run cairn sync setup.
  • Any other response records a declined state so the prompt does not appear again.

cairn update#

Check for and apply updates to the cairn binary or the Vicinae extension. No network requests are ever made by other subcommands — updates are strictly opt-in.

cairn update [--check] [--extension]

Flags:

FlagDescription
--checkReport version status only; do not download or modify any files
--extensionTarget the Vicinae browser extension instead of the CLI binary

Flag combinations:

InvocationBehaviour
cairn updateCheck and apply CLI binary update
cairn update --checkReport CLI version status; no changes made
cairn update --extensionCheck and apply Vicinae extension update
cairn update --extension --checkReport extension version status; no changes made

Exit codes:

CodeMeaning
0Success (updated, already up to date, or --check completed)
1Error (network failure, API error, or unknown platform)
3Checksum verification failed
4Permission denied (cannot write to install directory)

Example output:

# Update available
$ cairn update
cairn: current version v0.1.0, latest v0.2.0
cairn: downloading cairn-linux-amd64...
cairn: verifying checksum...
cairn: updated to v0.2.0

# Already up to date
$ cairn update
cairn: already up to date (v0.2.0)

# Check only
$ cairn update --check
cairn: current version v0.1.0, latest v0.2.0 (update available)

# Extension not installed
$ cairn update --extension
cairn: extension not installed; run the install script with --with-extension to install it

Notes:

  • The existing binary is backed up before replacement and restored if the update fails — your installation is never left in a broken state.
  • On Windows, in-process update is not supported. Re-run the install script to update.
  • Requires write permission to the directory where cairn is installed (typically ~/.local/bin). If permission is denied, exit code 4 is returned with a descriptive error.

cairn version#

Print the application version.

cairn version

cairn config#

Print the resolved configuration (database path and whether the Dropbox app key is set).

cairn config

Output example (Dropbox key configured):

CAIRN_DB_PATH=/home/user/.local/share/cairn/bookmarks.db
CAIRN_DROPBOX_APP_KEY=(set)

Output example (no Dropbox key):

CAIRN_DB_PATH=/home/user/.local/share/cairn/bookmarks.db

The CAIRN_DROPBOX_APP_KEY line is only printed when the key is set.


cairn help#

Print the top-level help text.

cairn help
cairn --help
cairn -h

Environment Variables#

VariableDescription
CAIRN_DB_PATHOverride the default database path
CAIRN_DROPBOX_APP_KEYDropbox app key for sync setup and auth