Skip to content

About

High-performance CLI gateway for reMarkable Cloud Sync v3, document search, vector stroke decoding, and page rendering in Go

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

remarkable is a high-performance CLI gateway to reMarkable Cloud Sync v3, providing document inspection, full-text page search, hyperlink inspection, vector stroke extraction, and stationery compositing.

What It Does

  • Unified cloud gateway: Interacts directly with reMarkable Cloud Sync v3 over Wi-Fi without USB cables or device modifications.
  • Document hierarchy navigation: Lists documents and collections, inspects page-level stroke presence, and renders virtual folder trees.
  • Full-text search & link inspection: Searches text inside PDF documents and lists the page targets, URIs, anchor text, and positions of the hyperlinks on any page.
  • Vector stroke extraction: Decodes v6 binary .rm stroke files with Paper Pro 24-bit BGRA color decoding and variable shader translucency.
  • Native handwriting import: Copies native v6 .rm files to explicitly mapped, empty pages of an existing cloud document while preserving their bytes and its PDF background.
  • Complete native backups: Archives every document attachment with its original name and bytes, plus source revision and SHA-256 evidence.
  • Separate PDF uploads: Creates a cloud document from a local multi-page PDF, preserving its bytes and links and saving recovery identity before committing. With --initialize-pages, it also creates the native page of every PDF page, so handwriting import and settings transfer can follow without opening the document on the tablet.
  • Migration settings transfer: Copies document tags, mapped page tags, and view settings to a separate document while preserving its PDF and handwriting.
  • High-resolution page rendering: Composites background stationery with vector handwriting layers into crisp 200 DPI PNGs in painter's order.
  • Content-addressed disk caching: Caches blobs and manifests by SHA-256 hash so repeat renders reuse unchanged downloads.
  • Dual-mode output: Formats aligned ASCII tables and trees for humans, and compact token-conservative TSV for scripts and AI agents (AGENT=1).

How It Works

  • Authenticates against reMarkable Cloud Sync v3 using a persistent device token.
  • Discovers documents and collections in cloud storage, resolving them by UUID or title.
  • Retrieves content-addressed blobs for document manifests, content schemas, background templates, and vector stroke files.
  • Converts vector stroke lines to SVG or composites them over stationery templates into standard PNG images.
  • Imports mapped native stroke files after validating the destination's initialized pages and checking for handwriting conflicts, then downloads uploaded data to verify bytes and page associations.
  • Exports a complete native document snapshot to a ZIP at an explicit output path, preserving existing local files and leaving the source document unchanged.
  • Uploads a valid local PDF under an explicit title in the root or an existing folder, rejecting a duplicate title in that folder and reporting the new document UUID. On request it also creates every page's native page, so strokes can be imported without opening the document on the tablet first.
  • Transfers source tags and view settings through an explicit page map, showing conflicts and freshly verifying both documents' preserved native files.

How it Really Works

  • Cloud commands keep a content-addressed download cache in the directory chosen by --cache-dir, then REMARKABLE_CACHE_DIR, then $XDG_CACHE_HOME/remarkable-cli (default ~/.cache/remarkable-cli). The manifests and files they download through it, including document metadata, background PDFs, and .rm stroke files, are stored under blobs/ and named by their SHA-256 hash, so repeat runs read unchanged files from local disk instead of downloading them again. The cache holds no credentials and is never pruned, so it grows with every document the CLI reads; deleting it only forces fresh downloads, and --no-cache neither reads nor writes it.
  • Document lookups by UUID scan the root manifest in O(n) time and fetch the matching document's manifest and metadata. Name and path lookups load metadata across the library.
  • Deleted and trashed items, including their descendants, are excluded from listing and resolution.
  • doc list orders items by parent folder path, then name, then ID. Names compare ignoring case under Unicode full case folding, as --query and doc search ignore case, so alpha precedes Zed and Straße precedes Strasse 2; names that fold alike, such as Notes and notes, fall back to their UTF-8 bytes, then IDs. A folder's items come before its subfolders' items, and folders sharing a name never interleave. Items whose parent chain never reaches the root, such as those with a missing parent or parent cycle, come last, ordered by parent ID. doc tree orders siblings the same way and reports the number of items it omits because their parent chain cannot reach the root. Use doc list to see their IDs. Repeated runs retain the same order, and --limit returns the same leading items.
  • Highlighter and shader strokes are grouped and rendered underneath pen ink with square linecaps to keep black handwriting sharp and legible.
  • When AGENT=1 is set in the environment, tree glyphs, borders, and column alignment spaces are omitted in favor of flat key-values and raw tab-separated lines.
  • Diagnostic logs and API request counters write to stderr, while requested page content (SVG, raw text, or binary strokes) streams directly to stdout for clean shell redirection.
  • A failed command writes its error message to stderr once, prefixed with [ERROR] , or with ERR: when AGENT=1 is set. Trailing whitespace is removed; control characters in cloud response bodies are escaped. Invocation errors print the command's usage screen before the message: an unknown flag, a wrong number of arguments, a missing required flag, an unparseable flag value such as --page abc or --initialize-pages=maybe, or a value rejected without reading files or contacting the cloud, such as an unsupported --format, a negative --page, an empty doc render or doc archive --output, an empty --mapping, a pairing code that is not 8 characters, a non-UUID doc import or doc settings transfer argument, or an empty or whitespace-only doc search query. Failures after the command starts, such as an unreadable file or an unreachable cloud, print no usage screen.
  • A name, or one segment of a folder path, that matches several live documents or folders fails instead of picking one, and exits 1. After the error message, stderr lists every match with its ID, its FOLDER path from the root (/ for an item at the root), and REACHABLE: a table in human mode, tab-separated lines under a header with AGENT=1. Reachable matches come first, then matches sort by folder path and ID, so the list is identical on every run. REACHABLE is no for a match that no path reaches, because an ancestor is missing from the listing, a document, or part of a parent loop; its FOLDER then holds only the live folders below that ancestor, or - when there are none. Pass the UUID of the intended document instead; doc list --folder <ID> lists the documents inside a matching folder.
  • The exit status tells failures apart, so a script can retry when the cloud is unreachable, re-pair when credentials are rejected, or report a missing document without reading the error text; see Exit Status.
  • When the cloud rejects the saved credentials or a pairing code, or the credentials file is missing or holds no token, the error message ends with : run 'remarkable auth pair <code>' with a new code from https://my.remarkable.com/device/desktop/connect. A rejected pairing code leaves the credentials file unchanged; pairing with an accepted code overwrites it.
  • Native archives download every attachment directly from the cloud, verify its hash and byte length, and check that the root hash and generation remain unchanged. A concurrent cloud change causes an error, including a change to another document. Complete ZIP bytes are published only after verification; existing output paths are preserved even if created during the export.

Installation

Download the prebuilt binary for your platform from the latest release, replacing X.X.X with the version shown on that page.

# macOS (Apple Silicon)
curl -sSL https://github.com/alexgorbatchev/remarkable-cli/releases/latest/download/remarkable_X.X.X_darwin_arm64.tar.gz | tar -xz -C ~/.local/bin

Setup

  • Pairing Code - Required for initial device registration. Run remarkable auth pair <code> to generate and save a device token.
  • Credentials use rmapi's devicetoken: ... and usertoken: ... lines. The path comes from --config, then REMARKABLE_CONFIG, then an existing $XDG_CONFIG_HOME/remarkable-cli/credentials (XDG base defaults to ~/.config), then ~/.rmapi. Without an override or an existing XDG file, pairing saves to ~/.rmapi. JSON credentials are rejected; the former XDG config.json filename is no longer selected automatically. Use remarkable auth status; the former root status shortcut has been removed.

Quick Start

# Check cloud connection and document count
remarkable auth status

# Find the pages for October 1, skipping Oct 10 through Oct 19
remarkable doc search "2026 - Daily" "Oct 1" --word

# Render a specific page directly to PNG
remarkable doc render 0e40ea7e-2ee9-4f96-80cc-a7e11f28c53a --page 457 -o oct1-notes.png

Sample Output:

[OK]    Rendered page 457 to oct1-notes.png

Options & Flags

This section covers selected commands. For every command and option, including authentication, tree browsing, upload recovery, stroke inspection, help, and shell completion, run remarkable skill and read the references it indexes with remarkable skill reference cat <topic>. Document arguments accept a UUID, an exact display name, or a slash-separated folder/document path. Search results and --page use 0-based indexes; add one to report a tablet page position.

Flag Short Default Description
--config <path> -c resolved path Override credentials path; otherwise REMARKABLE_CONFIG, an existing XDG remarkable-cli/credentials, then ~/.rmapi (see Setup)
--cache-dir <dir> ~/.cache/remarkable-cli Path to the cache of downloaded manifests, PDFs, and strokes; safe to delete
--no-cache false Disable local disk caching and force network downloads
--debug false Log outgoing reMarkable API requests and latencies
--version -v false Print raw version string
--help -h false Print command line help

remarkable doc list

Flag Short Default Description
--folder <id> none Filter items by parent collection ID
--type <type> none Filter items by type (DocumentType, CollectionType)
--query <str> -q none Filter items matching title substring
--limit <n> 0 Return the first n matching items in listing order (0 for all)

remarkable doc inspect

Flag Short Default Description
--pages false Include page-by-page stroke presence and byte sizes

A document whose page list, or with --pages whose list of files, cannot be read fails with the cause, so a Pages count of 0 and a page marked empty describe a document that was read. Pages counts the document's native pages: folders, and PDFs uploaded with doc upload without --initialize-pages that have not yet been opened on the tablet, report 0.

remarkable doc search

Argument Description
<id-or-name> Document UUID, exact display name, or folder path
<query> Text string to search across document pages
Flag Short Default Description
--word false Match the query only as whole words, so Oct 1 skips Oct 10 through Oct 19

The query matches each page's PDF text case-insensitively under Unicode simple case folding, so οδος matches ΟΔΟΣ. Before matching, every whitespace run in the page text and in the query, including PDF line breaks, counts as one space, and whitespace at either end of the query is ignored, so whole words copied from a snippet match that snippet's page. An empty or whitespace-only query is rejected before any cloud request. Without --word, the query matches anywhere, including inside longer words and numbers. With --word, a match counts only when no letter, decimal digit, or combining mark directly precedes or follows it: Oct 1 matches Oct 1, and Oct 1 at the end of a page, but not Oct 12. Each matching page reports only its first counted match, with a snippet holding the matched text plus up to 20 characters (Unicode code points) before it and 40 after, whitespace runs collapsed to single spaces and trimmed from both ends. A page whose text cannot be extracted fails the search instead of dropping out of the results, so no matches means every page was read.

remarkable doc links

Flag Short Default Description
--page <n> 0 0-based page index to extract hyperlinks from; negative values are rejected

Each link prints its 0-based index, its target page, its URI, the page text under it, and its rectangle, in the order the page lists its links: a table with LINK #, TARGET PAGE, URI, TEXT, and RECT columns in human mode, and headerless index<TAB>target<TAB>URI<TAB>text<TAB>rect lines with AGENT=1. A link to a page of the same document shows its 0-based target page and the URI #page=N, where N is the target plus one. A link that opens a URI shows - as its target and the URI the PDF stores; when the PDF declares a base URI (/URI /Base), that base is prepended as plain text to a URI that contains no : or starts with one. Any other link, such as one that opens another PDF or a local file, shows - and an empty URI: a blank cell in human mode, an empty third field with AGENT=1.

TEXT is the PDF text inside the link's rectangle, in the page's text order, with each run of white space, line breaks included, collapsed to one space and trimmed from both ends. A character whose box overlaps the rectangle counts in full, so a rectangle that cuts through a word yields part of it. A link over handwriting, an image, or empty space has empty text: a blank cell in human mode, an empty fourth field with AGENT=1.

RECT is the area that activates the link, as left,bottom,right,top in PDF points (1/72 inch unless the page sets /UserUnit), taken from the link's /Rect as written: y grows upwards, the corners are ordered so that left is at most right and bottom at most top, and neither the page's media box or crop box origin nor its rotation is applied. On a page whose media box starts at [0 0], 0,0 is the bottom-left corner of the unrotated page. Each number is the shortest decimal that reads back as the same single-precision value, such as 98.6, and never uses exponent notation; a coordinate written with a decimal point (a PDF real) beyond the single-precision range (about 3.4e38) prints as +Inf or -Inf. A link without a /Rect, or with one that is not an array of four elements, prints 0,0,0,0, the same as a rectangle written as zeros. Inside a four-element /Rect, an element that is not a number reads as 0, and so does an integer, written without a decimal point, above 4294967295 or, when written with a + or - sign, outside -2147483648 to 2147483647; the corners are ordered after that, so [1 2 3 /Foo] prints 1,0,3,2.

A PDF stores a URI as raw bytes, which can hold tabs, line breaks, terminal escape sequences, or bytes that are not valid UTF-8. To keep each link on one row and keep such bytes away from the terminal, both modes print as %XX, with uppercase hex digits, each byte of a space, of invalid UTF-8, or of a character outside the letter, mark, number, punctuation, and symbol categories (for example controls, non-ASCII spaces, and invisible format characters such as direction overrides), as classified by the Unicode version Go ships: a tab prints as %09, a line feed as %0A. Every other character, including % and non-ASCII letters, prints unchanged, so a URI that needs no encoding appears exactly as PDFium returns it: the stored URI, with the /URI /Base prefix when that rule applies.

Link text can hold the same kinds of characters, such as ESC, apart from the white space already collapsed. Both modes print each character of the text that is neither the ASCII space nor in the categories above as the Go escape sequence Go's strconv.QuoteRune writes for it, with lowercase hex digits: for example \x1b for ESC, \a for BEL, \u202e for a right-to-left override, and \U000e0001 above U+FFFF. Each byte of invalid UTF-8 prints as \xNN, and a backslash as \\. Every other character, including % and quotation marks, prints unchanged, so every backslash in the printed text starts an escape that Go's strconv.UnquoteChar decodes.

A PDF page without links succeeds with no rows: human mode prints a No hyperlinks found on page N notice, and agent mode prints nothing. A page whose links cannot be read fails instead of reporting none. A document without a background PDF, such as a handwritten notebook, fails with an error saying it has no background PDF.

remarkable doc cat

Flag Short Default Description
--page <n> 0 0-based page index to extract; negative values are rejected
--format <fmt> svg Stream format (svg, text, rm, pdf)

remarkable doc render

Flag Short Default Description
--page <n> 0 0-based page index to render; negative values are rejected
--dpi <n> 200 Rendering resolution DPI
--output <path> -o none Destination output path for the PNG image (required)

remarkable doc sync

Flag Short Default Description
--output-dir <dir> -o . Destination directory for exported pages
--format <fmt> png Page format (png, svg, rm)
--dpi <n> 200 Rendering resolution DPI for PNGs
--force -f false Overwrite existing local page files

remarkable doc import <destination-uuid>

Flag Short Default Description
--mapping <path> — none Required nonempty path to a JSON file mapping native stroke paths to 0-based destination page indexes

Use local v6 .rm files, including metadata-only files. Extract archives before importing. Paths are relative to the mapping file's directory or absolute. For example, save this as mapping.json beside the stroke files:

[
  {"source": "page-000.rm", "page": 0},
  {"source": "page-457.rm", "page": 457}
]
remarkable doc import 0e40ea7e-2ee9-4f96-80cc-a7e11f28c53a --mapping mapping.json

The destination must have initialized native page IDs: upload it with doc upload --initialize-pages, or open it on the tablet and let it sync. Import preserves source files, layers, coordinates, and native bytes, including annotations on future dates. It preserves the destination's PDF background and page structure and updates its modification timestamp. Existing handwriting, text, annotations, and unsupported native destination blocks cause a page-specific conflict; metadata-only destination files can be replaced. Every mapping is checked before any upload.

Uploads are staged before a generation-checked root commit broadcasts the update. The operation downloads data directly from the cloud to compare bytes and page associations. Successful output reports verified. Errors report staged, commit-unknown, or committed, plus confirmed uploads; they return a nonzero exit status. Staged blobs remain unreferenced if the root commit fails. Inspect the destination after an uncertain commit or failed post-commit verification. The operation has a five-minute timeout.

For tablet verification, use a disposable destination and confirm that imported handwriting can be selected, moved, and erased.

remarkable doc settings transfer <source-uuid> <destination-uuid>

Flag Short Default Description
--mapping <path> — none Required nonempty path to a JSON array with 0-based source_page and destination_page indexes
--replace-viewport — false Permit differing destination view settings and show every difference; tag conflicts remain errors

Save a separate settings mapping as settings-map.json:

[
  {"source_page": 0, "destination_page": 1},
  {"source_page": 457, "destination_page": 458}
]
remarkable doc settings transfer 33333333-3333-4333-8333-333333333333 44444444-4444-4444-8444-444444444444 --mapping settings-map.json

Both documents need initialized native page IDs. Map every tagged source page; untagged pages may be omitted, and [] is valid when the source has no page tags. Missing tagged pages, duplicate indexes, out-of-range indexes, incompatible structures or fields, and equal source/destination identities cause errors before uploads. Page tags retain their complete payloads and timestamps, with native page IDs remapped. Destination document tags and mapped-page tags must be empty or identical to the source values. Different nonempty tags cause explicit conflicts; unmapped destination page tags stay intact. Identical tag comparisons include payload and order. Numbers in tags and viewport settings compare by exact numeric value, so 9, 9.0, and 9e0 are equal. Writes preserve the source numeric tokens; identical transfers preserve the destination content bytes.

The operation copies zoomMode, viewBackgroundFilter, and the six fields customZoomCenterX, customZoomCenterY, customZoomOrientation, customZoomPageHeight, customZoomPageWidth, and customZoomScale. Any value or presence difference is reported and rejected by default. Review the old/new values, then use --replace-viewport to authorize these differences. A missing source field removes that destination field; omission of the background filter has different firmware behavior from off. Unknown destination fields, other view settings, native page IDs/order, redirections, PDF bytes, strokes, and metadata are preserved. Existing stroke-only doc import continues preserving destination content.

Both snapshots use one root revision. A concurrent root change causes an error, including changes to unrelated documents. Only destination content is submitted for update. After the generation-checked commit, every source and destination file is downloaded fresh and checked for the expected bytes and preserved associations. Identical transfers perform fresh verification without uploads. Successful output reports verified, both document UUIDs and hashes, the intended root hash, preflight generation, confirmed uploads, and viewport differences. In AGENT=1, differences include explicit presence and JSON values in TSV columns; absent values are marked false and absent.

Errors return nonzero with available progress: staged has no confirmed commit, commit-unknown has an uncertain commit outcome, and committed has a confirmed commit with incomplete verification. Default conflicts show their old/new viewport values before returning an error. Inspect both cloud documents before retrying uncertain or committed operations; the command does not retry automatically. A stdout failure can occur after a verified cloud change. The operation has a five-minute timeout, and its verification output contains no credentials.

remarkable doc archive <id-or-name>

Flag Short Default Description
--output <path> -o none Required ZIP output path; existing files are preserved
remarkable doc archive "2026 - Daily" --output daily-native.zip

The ZIP contains files/<original-native-name> for every document-manifest entry, including raw .content, .metadata, PDF, .pagedata, .rm, and unknown attachments when present. Raw content preserves both native page schemas, native page IDs, PDF redirections, inserted/deleted page records, tags, viewport settings, and metadata-only stroke bytes without rendering or rebuilding them. Extract files/ to access the native files.

evidence/document.docSchema contains the original manifest bytes. evidence/snapshot.json records archive format version 1, document UUID, native document-manifest hash, root hash/generation/schema version, the raw manifest SHA-256, and each file's native name, cloud hash, downloaded SHA-256, and byte length. The native document-manifest hash uses the cloud's ordered file-hash scheme; it differs from the raw manifest SHA-256. Success prints this identity and per-file evidence to stdout in both output modes, with state: verified and TSV file rows in agent mode. Compare it with a fresh archive to check source preservation; the evidence records the source state checked at export time.

Export uses a five-minute timeout and writes a private 0600 ZIP through a temporary file beside the destination. Its parent directory must exist and support hard links for publication without replacement. A failed download, checksum mismatch, concurrent cloud change, or existing output path returns a nonzero exit status and removes the temporary archive. An stdout write failure occurs after publication; inspect the completed ZIP at the printed or requested output path before retrying. The operation exports documents with a native document manifest and requires their .content and .metadata entries. It performs no document uploads or edits; credentials may renew through the normal cloud client.

remarkable doc upload <pdf>

Flag Short Default Description
--title <title> none Required nonblank display title, without control characters
--folder <UUID> root Existing live destination folder UUID
--evidence <path> none Required new private JSON recovery file; parent directory must exist
--initialize-pages false Create a native page for every PDF page (up to 816 pages) so doc import and doc settings transfer work immediately
remarkable doc upload planner.pdf --title "Planner migration" --evidence upload.json --initialize-pages
remarkable doc upload-check upload.json

Upload creates a separate document with a fresh UUID; it preserves the PDF bytes and links and all existing documents. An exact, case-sensitive title collision with any live item in the destination folder causes an error. Choose a distinct title to create another document. The actual PDF page count is stored. Without --initialize-pages, native page IDs stay uninitialized and output reports native_pages: pending-tablet-initialization: open the document on the tablet, let it sync, then use doc inspect <UUID> --pages to establish native page IDs before importing strokes.

With --initialize-pages, output reports native_pages: initialized. The document is created with one native page per PDF page, each with a fresh UUID, the PDF page it shows, the Blank template, and the page order the tablet assigns a PDF of that length. doc inspect <UUID> --pages, doc import, and doc settings transfer accept it right away, and the tablet receives the complete document, imported handwriting included, on its next sync. The page order is reproduced from tablet-initialized PDFs of up to 816 pages; a longer PDF is rejected before anything is uploaded. Cloud byte verification does not establish tablet editability.

The five-minute operation freshly checks folder/title policy and commits against that same root generation. Output exposes staged, commit-unknown, committed, and verified, with the UUID, intended document/root hashes, preflight generation, page count, and confirmed attachments. JSON evidence records those fields plus intended attachment names, SHA-256 values, and byte lengths, and with --initialize-pages the native page IDs in PDF order and the author UUID used by their timestamp records. It is created with 0600 permissions before staging and durably refreshed before the commit request; existing evidence is preserved. Neither output nor evidence includes credentials.

After a timeout, retain evidence and run doc upload-check <evidence> before retrying. This read-only command freshly confirms the recorded UUID, document hash, and attachment bytes against an unchanged root snapshot without creating anything or modifying evidence; for initialized pages it also confirms that the cloud document lists the recorded page IDs in order and uses the recorded author UUID. A changed or missing document, differing bytes or page IDs, or concurrent cloud change returns a nonzero exit status and requires inspection. Tablet initialization, imports, and later edits can change the document hash. Every creation retry chooses another UUID and new page IDs. An evidence or stdout failure after commit can occur even though the document exists; use the recovery check.

remarkable stroke export

Flag Short Default Description
--output <path> -o stdout Destination file for exported SVG
--width <pt> 447.874 Viewport width in points
--height <pt> 595.275 Viewport height in points

Set both width and height to positive values to override the renderer's canvas dimensions.

Exit Status

Status Meaning
0 Success
1 An invocation error such as an unknown flag, a name that matches several documents or folders (pass the UUID instead), or any failure no other status covers
3 A document or folder named by an argument, the document recorded in doc upload-check evidence, or a local file or directory does not exist, or --page is beyond the document
4 Credentials are missing, hold no token, or were rejected by the cloud (HTTP 401 or 403); pair again with remarkable auth pair <code>
5 The cloud, or a proxy on the way to it, could not be reached, timed out, sent a response that failed partway (cut off, or its compression could not be decoded), or failed with a server error (HTTP 5xx, 408, or 429); retry later. A refused TLS handshake or certificate, including one with an HTTPS proxy, is a configuration problem and exits 1
6 doc import, doc upload, or doc settings transfer failed after sending its root commit (commit-unknown or committed), so the cloud may already hold the change; inspect the documents, or run doc upload-check, before retrying

The CLI never exits with status 2, which the Go runtime reserves for a crash (an unrecovered panic). When one failure has several causes, status 6 takes precedence, then 4, 5, and 3. A write that fails before its root commit, reported as staged, exits with the status of its cause.

License

MIT License (c) 2026 Alex Gorbatchev

About

High-performance CLI gateway for reMarkable Cloud Sync v3, document search, vector stroke decoding, and page rendering in Go

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages