Tooling

The lttr CLI

Every lttr subcommand, its flags straight from -h, and its exit codes.

cmd/lttr previews, renders and checks a kit's samples. Run it with go run ./cmd/lttr <command> from the repo root, or go install github.com/sulv-io/lttr/cmd/lttr@latest for a standalone binary.

Terminal
$ go run ./cmd/lttr
usage: lttr <command> [flags]

commands:
  preview      render every sample to a directory with an index page
  render       write one sample's .eml to stdout
  lint         compile, render and check template files
  tags         list a template's merge tags and bindings
  serve        the studio: a live preview of the samples that reloads on save
  lsp          the language server for editors, on stdin and stdout
  kit init     start a new kit in a directory, copied from Plain
  kit check    load a kit, render its samples and check the HTML

-kit selects the kit: quiet (the default: the example templates), plain,
or a kit directory. Run "lttr <command> -h" for a command's flags.

Every command's flags come straight from its own -h; the text below is pasted from a real run, not retyped.

Choose a kit with -kit

Every command that works on templates takes -kit: quiet (the default — the nine reference templates in examples/quiet, with their Go data types), plain (the Plain starter kit and its two samples), or a kit directory on disk, loaded with no Go types or kit.Funcs. A directory kit's samples/*.md render with the literal data in samples/samples.yaml; write ./plain for a directory actually called plain, so it isn't mistaken for the built-in kit.

flag text, shared by every command
  -kit kit
        kit: quiet (the examples), plain, or a kit directory (./plain for a directory called plain) (default "quiet")

Preview every sample

Terminal
$ go run ./cmd/lttr preview -h
usage: lttr preview [-kit kit] [-out dir] [-assets url]

Renders every sample of the kit with its data and writes {NN}-{name}.html,
.txt and .eml, its template source as {NN}-{name}.md.txt, the assets under
assets/ (the kit's, or for quiet the example's logos and images),
manifest.json (the samples' metadata, for the docs site), and index.html: a
page to review them side by side at 600px and 375px, in light and dark.

flags:
  -assets url
        asset base url; relative URLs are allowed (default "assets")
  -kit kit
        kit: quiet (the examples), plain, or a kit directory (./plain for a directory called plain) (default "quiet")
  -out dir
        output dir (default "preview")
Terminal
go run ./cmd/lttr preview -kit quiet -out preview

writes, per sample ({NN}-{name} such as 01-order.out_for_delivery):

  • {NN}-{name}.html — the HTML part
  • {NN}-{name}.txt — the plain-text part
  • {NN}-{name}.eml — the full MIME message (Message.MIME, dated 2026-09-24T12:00:00Z so output is stable apart from the Message-ID and boundary)
  • {NN}-{name}.md.txt — the template's own Comark source, byte for byte

plus assets/ (the kit's assets, or for quiet the example's own logos and images), manifest.json and index.html. manifest.json is a JSON array, one object per sample, meant for tools like the docs site's own gallery to read without invoking Go:

manifest.json
[
  {
    "number": 1,
    "name": "order.out_for_delivery",
    "base": "01-order.out_for_delivery",
    "file": "01-box-on-its-way.md",
    "profile": "buyer",
    "subject": "Your produce box is on its way",
    "preheader": "Arriving at Fernhill by 5:30 pm today.",
    "from": "Loam <orders@loam.example>",
    "modules": ["statement", "progress", "receipt", "meta"],
    "warnings": []
  }
]

modules and warnings are always arrays ([], never null, even when empty). index.html is the page described in Share a one-shot preview.

make preview runs this with the Makefile's defaults: go run ./cmd/lttr preview -kit $(KIT) -out preview, where KIT defaults to quiet (KIT=plain make preview for the Plain kit, or KIT=./mykit make preview for a kit directory).

Render one sample

Terminal
$ go run ./cmd/lttr render -h
usage: lttr render [-kit kit] -t name [-to addr]

Renders the sample's data and writes the .eml to stdout.

flags:
  -kit kit
        kit: quiet (the examples), plain, or a kit directory (./plain for a directory called plain) (default "quiet")
  -t name
        template name, e.g. auth.reset
  -to address
        recipient address to use instead of the sample's
Terminal
go run ./cmd/lttr render -t order.out_for_delivery > order.eml
go run ./cmd/lttr render -kit plain -t welcome -to alex@example.com > welcome.eml

-t is required; -to must parse as an RFC 5322 address (net/mail.ParseAddress) and replaces the rendered message's To — the sample data's own recipient is used otherwise. The .eml is written straight to stdout, so redirect it or pipe it (| less, | msmtp -t, …). A bad -to fails before any rendering happens:

Terminal
$ go run ./cmd/lttr render -t outreach.partner -to "not-an-address"
lttr render: -to "not-an-address": mail: missing '@' or angle-addr

exit status 1.

Lint template files

Terminal
$ go run ./cmd/lttr lint -h
usage: lttr lint [-kit kit] [files…]

Compiles each Comark file against the kit, as the sample its "template:"
frontmatter names, renders it with the sample's data and checks the HTML
(tables, images, CSS, Outlook comments, size). Prints every error as
file:line:col: message and every warning as file:line:col: warning: message,
and exits 1 if any file has an error. With no files it lints every sample of
the kit: the nine examples for quiet, samples/*.md for any other kit.
A file that names no sample of a kit other than quiet is compiled as untyped
data only.

flags:
  -kit kit
        kit: quiet (the examples), plain, or a kit directory (./plain for a directory called plain) (default "quiet")
Terminal
go run ./cmd/lttr lint                                  # every sample of the default kit (quiet)
go run ./cmd/lttr lint -kit plain kits/plain/samples/*.md

Real output, from a copy of 03-password-reset.md with otp_code misspelt otp_cod in the template:

Terminal
$ go run ./cmd/lttr lint 03-password-reset.md
03-password-reset.md:14:15: unknown name "otp_cod" (did you mean otp_code?)
03-password-reset.md:14:1: code: missing "value"

Two errors from one typo: the merge tag doesn't resolve, and the ::code component's now-empty value attribute fails its own required rule. With files given, each one's template: frontmatter key picks which sample to compile it against; a file with no template: key at all is reported at a hardcoded 1:1 (frontmatter: missing "template", since there is no key to point at).

List merge tags and bindings

Terminal
$ go run ./cmd/lttr tags -h
usage: lttr tags [-kit kit] -t name

Lists the merge tags and bindings of a template, one per line, sorted by
position: path<TAB>go type<TAB>binding|tag<TAB>line:col. Tags of a kit's
samples, which have no Go type, are of type interface {}.

flags:
  -kit kit
        kit: quiet (the examples), plain, or a kit directory (./plain for a directory called plain) (default "quiet")
  -t name
        template name, e.g. order.out_for_delivery
Terminal
$ go run ./cmd/lttr tags -t order.out_for_delivery
destination string  tag 5:25
eta string  tag 5:44
order_id    string  tag 9:28
courier.first_name  string  tag 12:1
picked_up_at    string  tag 12:40
destination string  tag 13:8
eta string  tag 13:27
track_url   string  tag 15:31
order   quiet.Receipt   binding 21:1
deliver_to.name string  tag 26:1
…

Each line is path, the Go type it resolves to, tag or binding (a {{path}} merge tag versus a :key="path" binding), and its line:col in the source — the same shape TemplateMeta.Tags ([]TagInfo) exposes as a Go value. For a kit directory (no Go types), every tag's type prints as interface {}.

Run the studio

Terminal
$ go run ./cmd/lttr serve -h
usage: lttr serve [-kit kit] [-dir dir] [-addr host:port] [-golden dir] [-editor name] [-send-to addr,…]

Runs the lttr studio, a live preview of the kit's samples, until interrupted:
a grid of every sample and a workbench for one, with its problems as
file:line:col lines. A save reloads what it changed: for quiet the example
templates in -dir (default examples/quiet/templates); for plain, the samples
in -dir (its embedded samples, which do not change, without it); for a kit
directory, the whole kit (kit.yaml, templates, styles, samples/, or the
samples in -dir). A kit that fails to load shows its problems until it loads.

Golden status compares each render with <Name>.html and <Name>.txt in
-golden: by default testdata/golden for quiet, <dir>/testdata/golden for a
kit directory, when it exists; -golden "" turns it off.

Test sends go only to the addresses in -send-to (else LTTR_STUDIO_SEND_TO),
at most 10 a minute, marked with a "[test] " subject prefix and an
X-Lttr-Test: 1 header, through the SMTP server in LTTR_SMTP_ADDR (host:port),
with PLAIN auth when LTTR_SMTP_USER and LTTR_SMTP_PASS are set, and from
LTTR_SMTP_FROM when set. Without a list or a server, sending is off.

flags:
  -addr address
        listen address (default "localhost:7070")
  -dir dir
        template or sample source dir (see above)
  -editor editor
        editor that problem links open: vscode, cursor, zed, idea or none (default "vscode")
  -golden dir
        golden dir (see above)
  -kit kit
        kit: quiet (the examples), plain, or a kit directory (./plain for a directory called plain) (default "quiet")
  -send-to addresses
        addresses test sends may go to, comma-separated (else LTTR_STUDIO_SEND_TO); SMTP from LTTR_SMTP_ADDR, _USER, _PASS and _FROM

It prints one line when it is serving, and runs until Ctrl-C:

Output
lttr studio: serving quiet (9 samples) on http://localhost:7070

Send tests from the studio

The workbench's Send tab sends a sample's render to a real inbox. It needs an allow-list and an SMTP server, both read when serve starts:

SettingWhat it does
-send-to addr[,addr…]The addresses a test may go to: bare addresses, comma-separated. The Send tab picks from these, and the studio refuses any other.
LTTR_STUDIO_SEND_TOThe same list, read when -send-to is not given.
LTTR_SMTP_ADDRThe SMTP server's host:port, for example localhost:1025. Required to send.
LTTR_SMTP_USER, LTTR_SMTP_PASSPLAIN auth, when LTTR_SMTP_USER is set. The password never appears in the page, the answers or the log.
LTTR_SMTP_FROMThe From of every test. Without it, a test is from its template's profile.

Without a list or a server, sending is off, and the studio says which is missing. A bad address or setting is a usage error (exit 2):

Output
lttr serve: -send-to: bad address "nope": mail: missing '@' or angle-addr

Each test's subject starts with [test] and it carries the header X-Lttr-Test: 1. A studio sends at most 10 tests a minute. See Send a test.

See Studio for the grid, the workbench, the Data, Diff and Send tabs, the components page, the keyboard shortcuts, golden status and the security model. make serve runs it with the Makefile's KIT default (quiet). An app whose templates bind its own Go types runs the same studio from Go, with the studio library.

Run the language server

Terminal
$ go run ./cmd/lttr lsp -h
usage: lttr lsp [-kit kit] [-dir dir] [-golden dir] [-studio host:port] [-editor name] [-send-to addr,…]

Runs the lttr language server for an editor, on stdin and stdout, until the
editor tells it to exit. It shows each file's problems as you type, before
you save.

With -kit, every file belongs to that kit (quiet, plain or a kit directory,
with -dir and -golden as for serve), and a Markdown file outside its
samples and outside the kit directory is compiled against it. Without -kit,
a file in a kit directory (the nearest one holding kit.yaml) belongs to that
kit, and any other file to quiet, with -dir and -golden.

A kit that binds Go types is served by its app's studio program, with its
lsp subcommand. Found without -kit, such a kit and its templates, when
.lttr/schema.json describes them, get completion, hover and definition here
but no problems. Named with -kit, the kit is loaded without the schema, and
its kit.yaml shows the problem that says to run that program.

With -studio host:port, it also serves the studio there, on the same
engine, so the preview follows the editor's unsaved buffers as you type:
on -kit's kit; without -kit, on the kit directory at or above the working
directory, else on quiet. -editor and -send-to are as for serve. If the
studio cannot start (its port is in use, say), the editor shows why and
the language server runs on.

Stdout carries the protocol alone; logs, and the studio's serving line, go
to stderr.

flags:
  -dir dir
        template or sample source dir, as for serve
  -editor editor
        editor that the studio's problem links open: vscode, cursor, zed, idea or none (default "vscode")
  -golden dir
        golden dir, as for serve
  -kit kit
        kit: quiet (the examples), plain, or a kit directory (./plain for a directory called plain) (default "quiet")
  -send-to addresses
        addresses the studio's test sends may go to, as for serve
  -studio host:port
        also serve the studio on host:port, following the editor's buffers

Your editor starts it, not you: see Editor setup for VS Code, Neovim and Zed. It speaks LSP 3.17 over stdin and stdout, and gives problems with "did you mean" quick fixes, completion, hover and go to definition.

  • Without -kit, each file finds its kit: the kit directory it is in, else a .lttr/schema.json that describes it (completion, hover and definition, but no problems), else quiet. Stray Markdown, a file that is no sample of the kit, is checked only inside a kit directory: under the quiet fallback, a README gets no problems.
  • With -kit, every file belongs to that kit, and Markdown outside its samples and outside the kit directory is compiled against it as untyped data.
  • An app whose kit binds its own Go types runs its own studio program's lsp subcommand instead, with exact problems. See Choose the server. Its .lttr/schema.json applies only when lttr lsp finds the kit by walking up, without -kit. Named with -kit, the typed kit is loaded without the schema, and kit.yaml shows the problem that says to run the app's program.
  • -studio host:port also serves the studio, whose preview follows your unsaved buffers. -editor and -send-to (and LTTR_SMTP_*) are checked only with -studio, and a bad one is a usage error, exit 2. See Preview as you type.

It exits 0 when the editor sends shutdown, then exit, and 1 when the editor exits without shutdown or the connection ends.

Start and check a kit

Terminal
$ go run ./cmd/lttr kit -h
usage: lttr kit <command> [arguments]

commands:
  init <dir>                 start a new kit in dir, copied from the Plain kit
  check <dir|quiet|plain>    load a kit, render its samples and check the HTML
                             (quiet and plain are the built-in kits; use ./plain for a directory)
Terminal
$ go run ./cmd/lttr kit init -h
usage: lttr kit init [-name name] <dir>

Copies the Plain starter kit (kit.yaml, layouts, styles, blocks,
components, assets and samples) into dir, which must not exist or be empty,
and names the kit after dir (or -name): a kit name is lower-case letters,
digits and '-'. Edit the copy, then run
"lttr kit check ./dir" (the ./ keeps a directory called plain or quiet from
naming a built-in kit).

flags:
  -name name
        kit name (default: the base name of dir)
Terminal
$ go run ./cmd/lttr kit init ./emailkit
wrote 29 files to ./emailkit; check it with: lttr kit check ./emailkit
Terminal
$ go run ./cmd/lttr kit check -h
usage: lttr kit check <dir|quiet|plain>

Loads the kit, renders every samples/*.md with its literal data from
samples/samples.yaml, and checks the HTML of each: tables, images, CSS such
as display:flex, Outlook comments, size, and the color-scheme meta when the
kit is dark-capable. It reports what lint.Check reports, so two samples
with one template name are a problem too. quiet and plain name the built-in
kits (quiet renders its nine examples); any other argument is a kit
directory, loaded with no Go types, so write ./plain for a directory called
plain.

A kit that does not load prints its problems to stderr as file:line:col:
message. Sample problems print to stdout: compile and render errors as
file:line:col: message, HTML problems as file: html: problem (at byte N of
the rendered HTML), and compile warnings as file:line:col: warning:
message. The exit status is 1 if there is any problem; warnings alone
leave it 0.

A clean kit:

Terminal
$ go run ./cmd/lttr kit check quiet
kit quiet: 9 samples rendered, no problems
$ go run ./cmd/lttr kit check plain
kit plain: 2 samples rendered, no problems

Compile warnings are printed but don't fail the check. With the preheader: line taken out of samples/welcome.md, the command exits 0:

Terminal
$ go run ./cmd/lttr kit check ./emailkit
emailkit/samples/welcome.md:1:1: warning: frontmatter: no preheader
kit emailkit: 2 samples rendered, no problems (1 warning)

A kit whose own template has a mistake fails to load and never gets to render anything — here token "size.side" was misspelt token "size.sidee" in a component's html.tmpl. The reported path is prefixed with the kit directory:

Terminal
$ go run ./cmd/lttr kit check ./emailkit
emailkit/components/button/html.tmpl:1:79: token: unknown token "size.sidee" (did you mean size.side?)

exit status 1. See Build your own kit for the full walkthrough, and the README's "A kit that binds Go types" for checking a kit that needs kit.Types or kit.Funcs (which lttr kit check can't load, since those only exist in Go).

Read the exit codes

Every command returns:

CodeMeaning
0Success — including -h, -help, --help or help, at the top level or on a subcommand
1The command ran but failed — an unknown template name, an invalid -to address, a kit, compile or render error, a file that can't be read, a listener that can't bind, an editor that ends lttr lsp without shutdown
2A usage error — bare lttr with no arguments, an unrecognised command, a missing required flag (-t), an unparseable flag, or too many positional arguments

lttr preview -h prints its usage and exits 0; lttr render -bogus (a flag the command doesn't recognise) prints the flag error and usage and exits 2; lttr with no arguments at all also prints the top-level usage but exits 2, not 0 — only an explicit -h/-help/--help/help gets the success exit code.

Next steps

  • Studio for serve and the studio library, and for preview's index page.
  • Editor setup for lttr lsp in VS Code, Neovim and Zed.
  • Screenshots for make shoot, built on top of preview.
  • Goldens and testing for make golden, make check and testing your own kit's samples from Go.
Copyright © 2026