napkin-sketchdocs 1.0.0 GitHub

The napkin-sketch command line: cheatsheet#

On this page

API hub · Reference · Quickstart · Cheatsheet

Reminders for the four commands: their flags, exit codes, the JSON report and the calls from other languages.

Commands#

CommandDoes
napkin-sketch draw <script | ->Draw a napkin script to svg, png, pdf, skbk or jsx files.
napkin-sketch check <script | ->Read and run a script, report what is wrong, write nothing.
napkin-sketch render <book.skbk>Write a sketch book as svg, png, pdf, skbk or jsx files, or its figure as animation frames.
napkin-sketch verbsList napkin script's verbs and the shape library.

Flags#

FlagdrawcheckrenderverbsDoes
--to <formats>yesyesThe formats to write: svg, png, pdf, skbk, jsx, comma-separated.
--out <dir>yesyesThe folder to write into, made when it is missing.
--name <stem>yesyesThe name the files are written under.
--base <dir>yesyesyesThe folder linked files are read inside.
--asset <name>=<file>yesyesAn image the script places by name; repeatable.
--use <name>=<book.skbk>yesyesA book the script copies in with use; repeatable.
--font <family>=<file>yesyesA font file text in that family is drawn from: its outlines in a PNG and a PDF, its advances in every format; repeatable, a family's faces each once.
--composition-style <style.json>yesRestyle every page by its layers' names with a composition style once it is drawn; a rule that matched nothing is a warning.
--seed <n>yesyesThe seed for the hand-drawn pass.
--scale <n>yesyesPNG pixels a page pixel.
--crop auto|none|<x,y,w,h>yesyesWhat every file is cut to.
--limit <n>yesyesThe most instructions a run may execute.
--prompt <request>yesExperimental: ask the AI helper for a script that draws this, and draw it; the script is kept as <name>.napkin.
--helper <command>yesExperimental: the AI helper command --prompt runs: $NAPKIN_SCRIPT_HELPER unless given, else Claude Code.
--page <n>yesOnly this page of the book, counting from 1.
--animate <type>yesDraw the page's figure through a measured cycle, a frame a page: walk, run, ideal, knocked-down.
--frames <n>yesHow many frames --animate spreads the cycle across: 2 to 60, the cycle's own length unless given.
--facing left|rightyesWhich way the --animate figure travels, when its feet do not say.
--category <name>yesOnly this category of verbs.
--jsonyesyesyesyesOne line of JSON on standard output, and nothing else.
--strictyesyesyesAnything reported at all is a failure, and nothing is written.
--quietyesyesyesPrint errors and nothing else.

Exit codes#

CodeMeaning
0It drew, the script checked clean, or the book was written.
1The arguments were wrong: an unknown option, a bad value, no script. Nothing is written.
2The script had errors, render was given a file that is not a book, or --animate found no figure on its page; with --strict, anything reported at all. What could be drawn is written, unless --strict.
3A file could not be read or written. A linked file that could not be read is drawn as its placeholder and the files are written; for anything else, nothing is.
4draw --prompt got no script back: the AI helper is not installed, is not signed in, or failed. Nothing is written.

The JSON report#

FieldHolds
ok, exitCodeok is true exactly when exitCode is 0
files{ path, format, page } for each file written
diagnostics{ level, code, message, line, column }; index for JSON scripts
warningsWhat a format left out or drew as a stand-in
statsinstructions, marks, anchors, points, pages; null when nothing ran
error{ kind: 'usage' | 'io' | 'input', message } when a command stopped
version, languageThe package version, and the language version it reads

One line each#

WantRun
SVG and PNG into a foldernapkin-sketch draw card.napkin --to svg,png --out out
A retina PNG cut to the inknapkin-sketch draw card.napkin --to png --scale 2 --crop auto
A script from a pipe, JSON backnapkin-sketch draw - --json < card.napkin
An image the script placesnapkin-sketch draw card.napkin --asset logo=art/logo.png
A book the script copies innapkin-sketch draw card.napkin --use badge=badge.skbk
Links read from another foldernapkin-sketch draw card.napkin --base brand
A check that fails on warningsnapkin-sketch check card.napkin --strict
Page 2 of a saved booknapkin-sketch render deck.skbk --page 2 --to png
A figure's walk, a file a frame, no AInapkin-sketch render hero.skbk --animate walk
Every verb's grammar as JSONnapkin-sketch verbs --json

From other languages#

CallerThe call
sh, bashnapkin-sketch draw card.napkin --to svg,png --out out; echo $?
Windows batchcall napkin-sketch draw card.napkin --to "svg,pdf" --out out
PowerShellnapkin-sketch draw card.napkin --to svg,png --out out; $LASTEXITCODE
NodespawnSync('napkin-sketch', ['draw', '-', '--json'], { input, encoding: 'utf8', shell: process.platform === 'win32' })
Pythonsubprocess.run([shutil.which("napkin-sketch"), "draw", "-", "--json"], input=script, capture_output=True, encoding="utf-8")
Cpopen("napkin-sketch draw card.napkin --json --to svg --out out", "r")

Common mistakes#

WrongRightWhy
napkin-sketch draw ... in a .batcall napkin-sketch draw ...npm installs a .cmd; without call the batch file never comes back.
image "art/logo.png" in the scriptimage "logo" and --asset logo=art/logo.pngA script reads no files: a path is unknown-asset.
Parsing the human report--json, and branch on exitCode and codeMessages are for people and may change.