@ligr/cli
v0.6.2
Published
Beta. The ligr command line. ligr graphic scaffolds, validates, pushes and publishes LIGR graphics over the REST API.
Readme
@ligr/cli
Beta. Code graphics are in beta. You create the theme with
npx @ligr/cli graphic theme create. The protocol, the manifest and the REST routes can change between minor versions. See https://docs.ligr.live/graphics-sdk/#beta-status.
ligr is the LIGR command line. ligr graphic works with code and Rive graphics. It scaffolds a graphic,
validates it, and pushes and publishes it over the LIGR REST API.
The browser runtime is a separate package: @ligrsystems/graphics-sdk.
The protocol, the manifest and the bundle rules are documented at https://docs.ligr.live/graphics-sdk/.
LIGR loads HTML, CSS and JavaScript. Start with the plain HTML template, or use any toolchain that produces a static bundle. Framework integrations are optional. They use the same protocol, manifest and publishing commands.
Install
npm i -g @ligr/cliThe package installs the ligr command. To run the CLI once without an install, use npx @ligr/cli graphic <command>.
Use Node 22 and npm. The CLI supports Node 20 or later; optional template toolchains can require newer versions.
@ligr/cli is a public npm package. The SDK downloads from public GitHub Releases.
Neither download needs an npm account or GitHub authentication.
The scaffold pins both packages to the release archives of the CLI version that wrote it. Keep your lockfile in Git.
Each template installs the CLI locally. Run it with npx @ligr/cli graphic after npm install.
ligr-graphic is the old name. npx ligr-graphic <command> still runs ligr graphic <command> and prints a deprecation notice.
Replace ligr-graphic <command> with ligr graphic <command>.
Quick start
You need a write API key. Set LIGR_API_KEY in your shell.
npx @ligr/cli graphic init my-graphic
cd my-graphic
npm install
npm run build
npx @ligr/cli graphic theme create --name "My Theme" --sports football
npx @ligr/cli graphic create --name "Scorebug" --sports football
npx @ligr/cli graphic push
npx @ligr/cli graphic publish --theme-versioninit writes a scorebug. theme create creates a theme your organization owns and writes
its id into ligr.json. create registers the graphic in the theme and adds the graphic id. push builds, uploads the changed files and records the bundle. publish creates a graphic version and
a theme version pinned to it. Test the pushed draft in the dashboard code viewer
before you publish.
From 0.6.2, push sends the size of each file. The API refuses a file over the limit for its type
before the upload starts: Rive 64 MB, image 25 MB, font 20 MB, video 50 MB, code and other files 5 MB.
Update to 0.6.2 or later. A later API release requires the size, and older versions will stop working then. See https://docs.ligr.live/graphics-sdk/test/. Inspect the published version, then activate it at the right moment:
npx @ligr/cli graphic theme inspect --theme <themeId> --version <publishedVersion>
npx @ligr/cli graphic theme activate --theme <themeId> --version <publishedVersion>To publish several graphics first, run publish without --theme-version for each one. Then publish one theme version
that pins the latest published version of every graphic:
npx @ligr/cli graphic theme publish --theme <themeId> --dry-run
npx @ligr/cli graphic theme publish --theme <themeId> [--activate]Activation selects the version for newly loaded overlays. Reload existing overlay pages or browser sources to load it. To roll back, activate an earlier published version and reload those sources.
Commands
Every command that talks to LIGR needs an API key. Pass --api-key <key> or set LIGR_API_KEY. theme create,
theme delete, theme activate, theme publish, create, push and publish need a write key.
theme list, theme inspect and status work with a read key.
Environment
| Variable | Flag | Purpose |
| --- | --- | --- |
| LIGR_API_KEY | --api-key <key> | The API key |
| LIGR_API_URL | --base-url <url> | The REST base URL, including /rest/v2. Default: https://api.ligr.live/rest/v2 |
The flag wins over the variable. For rive commands, apiUrl in rive.json wins over LIGR_API_URL.
To use another LIGR environment, set the full base URL of that environment:
export LIGR_API_KEY=<key for that environment>
export LIGR_API_URL=https://<api host>/rest/v2
npx @ligr/cli graphic theme listAn API key works only in the environment that issued it.
--dir <path> names the graphic folder. Default: the current folder. The folder holds graphic.json, the manifest,
and ligr.json, the ids. --theme <id> and --graphic <id> override ligr.json.
npx @ligr/cli graphic init [dir] [--template vanilla|react]
Copy a template into dir. Default template: vanilla. The command refuses a folder that holds files.
| Template | Content |
| --- | --- |
| vanilla | index.html with the SDK, no build tool. The build copies the files to dist/ |
| react | Vite, React and TypeScript. vite.config.ts sets base: './' |
Both hold graphic.json, a README, an AGENTS.md and a Claude Code skill with the same rules.
The React template is an optional example. Custom toolchains must produce HTML and use relative bundle paths.
npx @ligr/cli graphic theme create --name <name> --sports football[,tennis] [--variables <file.json>]
Create a theme your organization owns. The theme appears on the Themes page of the dashboard and in the competition
theme picker like any other theme. In a folder that holds graphic.json and no theme id yet, the command writes the
theme id into ligr.json. --variables names a JSON file with an array of { id, name, type, defaultValue },
where type is string, number or boolean. An organization can own up to five themes.
| Call | Purpose |
| --- | --- |
| POST /themes | Body { name, sports, variables? }. 409 THEME_LIMIT_REACHED past the cap |
npx @ligr/cli graphic theme list
Print the themes your organization owns: id, name, sports and the active version. Public themes and themes LIGR linked to your organization are not in the list, because the theme routes cannot write to them.
npx @ligr/cli graphic theme delete --theme <themeId> --yes
Delete a theme you own and every graphic in it. The command refuses to run without --yes. A theme a competition
still uses answers 409 THEME_IN_USE with one competition per details[] line. Remove the theme instance from
those competitions in the dashboard first.
npx @ligr/cli graphic theme inspect --theme <themeId> --version <version>
Read a published theme version. Prints JSON with version and graphics: [{ graphicId, version }].
This uses GET /themes/{themeId}/versions/{version} and needs a read key.
npx @ligr/cli graphic theme activate --theme <themeId> --version <version>
Activate an existing published theme version. This also supports rollback to an earlier version without republishing graphics.
It sends PUT /themes/{themeId}/active-version with { version } and prints the returned activeVersion.
This needs a write key. Reload existing overlay pages or browser sources to load the selected version.
Choose an appropriate broadcast moment for that reload.
npx @ligr/cli graphic theme publish --theme <themeId> [--activate] [--dry-run]
Publish a theme version without a new graphic version. Every graphic takes its latest published version. A graphic with no published version is not in the theme version. The command prints the new version, each pinned graphic version, and whether the new version is active.
| Call | When | Purpose |
| --- | --- | --- |
| POST /themes/{themeId}/versions | Always, except --dry-run | Body { activate }. Publish the theme version |
| GET /themes/{themeId}/versions/{version} | After the publish | Read the pinned graphic versions |
| GET /themes/{themeId} | --dry-run | Read the published graphic versions. The command writes nothing |
This needs a write key. --activate selects the new version for newly loaded overlays, and the command prints a reminder
to reload existing sources. Without --activate the command prints the theme activate command for the new version.
npx @ligr/cli graphic create --theme <themeId> --name <name> [--sports football,tennis]
Register the graphic. Writes ligr.json with { themeId, graphicId }.
| Call | Purpose |
| --- | --- |
| POST /themes/{themeId}/code-graphics | Body { name, sports? }. sports defaults to the sports of the theme |
npx @ligr/cli graphic push [--dir .] [--dist dist] [--skip-build]
Build and send the bundle. The command runs the build script of package.json with pnpm, yarn or npm, by lock file.
--skip-build sends the folder as it is. --dist names the build output folder. Default dist, or dist in
ligr.json.
Before the first call the command checks graphic.json and the files with the same rules as the API. A problem stops
the push with one line per problem.
| Step | Call | Purpose |
| --- | --- | --- |
| 1 | GET /themes/{themeId}/code-graphics/{graphicId} | Read the stored assets with their hash |
| 2 | POST …/uploads | Request an upload URL for every file whose hash changed. Skipped when nothing changed |
| 3 | PUT <url> | Send each changed file body with its Content-Type |
| 4 | PUT …/bundle | Body { uploadSessionId, files, stateMachine }. files is the complete file set. stateMachine is graphic.json |
The hash is sha256:<hex> of the file body. A file that is not in the build folder is deleted from the graphic.
npx @ligr/cli graphic publish [--theme-version] [--activate]
Publish the working copy.
| Call | When | Purpose |
| --- | --- | --- |
| POST …/code-graphics/{graphicId}/versions | Always | Create the graphic version |
| POST /themes/{themeId}/versions | --theme-version or --activate | Body { graphics: [{ graphicId, version }], activate }. Pin the new version |
--activate selects the active theme version for newly loaded overlays. The command prints a reminder to reload existing sources.
Reload existing overlay pages or browser sources at an appropriate broadcast moment to load the selected version.
npx @ligr/cli graphic status
GET /themes/{themeId}/code-graphics/{graphicId}. Prints the working version, the published versions, the sports,
the lock and every asset.
npx @ligr/cli graphic validate [--dir .] [--dist dist]
Check graphic.json and the build output locally. No network. The command prints one line per problem, with the same
wording as the API details[], and exits with 1. It applies the manifest rules, the file name rules and the size
limits: 5 MiB per file, 10 MiB per bundle.
npx @ligr/cli graphic rive <group> …
The rive group edits a native Rive graphic through the REST operation routes. Each subcommand sends one
operation. The server validates the whole configuration on every write.
rive.json holds the project: { "themeId": number, "graphicId": string, "apiUrl"?: string }. rive import
writes it. Pass --theme and --graphic to work without it.
Every write sends ifUnchangedSince with the timestamp of the last read. A changed draft answers
409 TARGET_CHANGED. The CLI reads the draft again and retries once. A second conflict fails the command.
A 409 LOCKED prints the name of the editor who holds the lock.
| Command | Action |
| --- | --- |
| rive import <file> --theme <id> --name <name> | Upload a .riv, .rev or project ZIP and create the graphic |
| rive replace <file> | Replace the Rive asset of the working draft. It prints the bindings that the new file does not have, which the replace removed |
| rive inspect [<file>] [--job <id>] | Show the draft, one import job, or a prepared file |
| rive list | List the Rive graphics of a theme |
| rive delete --yes | Delete the working draft |
| rive duplicate --name <name> | Copy the working draft |
| rive publish [--theme-version] [--activate] | Publish a graphic version, and a theme version |
| rive download --kind runtime\|original | Save the runtime file or the original source |
| rive control list\|add\|set\|rm | Edit the control variables |
| rive bind list\|set\|default\|expose\|unexpose\|transform\|source\|list-add\|list-rm\|list-order | Edit the data bindings |
| rive input list\|set | Edit the state-machine inputs |
| rive asset list\|set\|file\|expose\|unexpose\|rm | Edit the configured assets |
| rive expr list\|add\|set\|rm | Edit the user expressions |
| rive schema add\|rm | Select or deselect a data schema |
| rive settings set | Change the renderer, the layout, the name and the sports |
| rive settings select --artboard <n> --state-machine <n> | Finish an import that asked for a choice |
| rive pull | Write the working configuration into rive.json |
| rive push [--dry-run] [--force] [--watch] [--debounce <ms>] | Send one operation for each change in rive.json. --watch repeats on every save |
| rive asset file <assetId> <path> | Supply the missing image of an unresolved asset |
| rive asset expose <id> --name <n> --entity <type> [--default-file <path>] | Expose an asset to the match operator, optionally with a default image |
| rive eval [--scenario <name>] [--var k=v] [--step <n>] | Check every binding. Exit 0 only when all resolve |
| rive preview [--scenario <name>] [--open] | Print short-lived signed URLs that play the draft |
| rive var list\|add\|set\|rm | Edit the theme variables |
| rive data-schema list\|create\|set\|rm | Edit the data schemas (data source templates) of the theme |
rive var and rive data-schema edit theme-scoped resources. They need --theme or a rive.json
with a themeId, but no --graphic. They take no lock.
Add --retain-source to rive import to keep the editable source. Read
https://docs.ligr.live/rive-graphics/source-files/ before you retain a source.
rive push sends one operation for each change. It is not atomic. If one operation fails, the CLI prints
the count it applied and the operation that failed. Run rive pull, then push again.
rive push removes a control variable or a user expression only when nothing refers to it. A referenced
value answers 422 UNKNOWN_REFERENCE. Add --force to remove it and blank every reference to it.
rive push --watch runs the push once, then again on every save of rive.json, debounced by
--debounce milliseconds (default 300). Press Ctrl+C to stop.
rive replace, rive bind set and rive push print a warning when an enum binding reads a theme
variable ($t) that has options the Rive enum does not list. On air, the graphic ignores those options.
rive eval checks every data binding's expression and reference against the working draft. It exits 0
only when every binding and user expression resolves, so a pipeline can gate on it.
rive pull and rive push do not manage manual list elements. Use rive bind list-add, rive bind list-rm
and rive bind list-order for those.
npx @ligr/cli graphic mcp
mcp runs a local MCP server on stdio. An agent, for example Claude Code, Claude Desktop or Codex, uses it to do every
Rive Graphics Builder (the builder) action on a graphic. The server sends REST calls only. Logs go to stderr. stdout carries the protocol.
Each tool takes an action argument.
| Tool | Actions | Edit session |
| --- | --- | --- |
| list_rive_graphics | list | Not needed |
| get_graphic_state | read: every field the other tools change, the lock, the session and builderUrl | Not needed |
| edit_session | begin, end with keep or discard | end closes it |
| bindings | set, clear, batch, expose, unexpose, transform, clear_transform, set_source | Needed |
| list_items | add, remove, reorder | Needed |
| control_variables | upsert, delete | Needed |
| user_expressions | upsert, rename, delete | Needed |
| settings | set: name, sports, x, y, scale, renderer, rendererRelease, deferInitialShow, layer, preview sport | Needed |
| data_sources | list, create, update for the theme templates ($x). select, deselect for the graphic | select and deselect only |
| theme_variables | list, create, update ($t) | Not needed |
| files | import, replace, status, select, repair, cancel, revisions, download | replace only |
| images | supply_missing, thumbnail | Needed |
| publish | graphic, graphic_and_theme | Needed |
| check | evaluate, preview_urls | Not needed |
To delete a theme variable or a data source, use the dashboard or the CLI. These deletes change every graphic of the theme.
Graphic writes act on the graphic of the open edit session. The server holds one session and sends a heartbeat every
20 seconds. An open builder goes read-only and shows each change live. If a person takes the graphic back,
the next write fails with SESSION_INVALID. Begin a new session to continue. When the client stops the server, the server
ends the open session with keep.
end with discard restores the draft as it was at begin. publish, files replace and images thumbnail
inside a session move the restore point. After one of them, discard restores the draft as it was after the last one.
Theme writes (theme_variables, and data_sources create and update) need no edit session. They fail with
409 TARGET_CHANGED when someone else changed the theme or the template.
Every graphic write returns builderUrl, the builder page of the graphic in the dashboard. The server takes the dashboard
from LIGR_API_URL: api.ligr.live gives https://ligr.live. For any other API, set LIGR_DASHBOARD_URL.
Without it, the server does not start.
files import and replace wait up to 60 seconds (waitSeconds, at most 240). When the file needs a choice, the
answer names it: preparing, choose-entry, choose-artboard, or failed, with an offer to repair. Continue with select, repair or
status and the jobId. The server keeps the jobs it started until it stops.
publish publishes a graphic version. With graphic_and_theme, it also publishes a theme version that pins it.
publish never activates a theme version. A person activates the theme version in the dashboard.
user_expressions rename does not change the expressions that read the old name. The answer lists them in
staleReferences. Update dataBinding rows with bindings and userExpression rows with user_expressions. input and
asset rows are deprecated bindings with no tool: ask the person to change them in the builder. A write still accepts a
reference that was already unknown, so each stale row can be fixed on its own. A new unknown name fails with
422 UNKNOWN_REFERENCE.
The API checks each expression when it saves it. An invalid expression fails with 422 INVALID_EXPRESSION or
422 UNKNOWN_REFERENCE and one line per problem.
A binding takes an id or a view model path. Use [] for any list index, for example rows[].name.
A path that matches more than one binding fails and lists the ids.
Local files
files, images and data_sources read and write local files. The server uses files only inside one folder:
- If
LIGR_MCP_ROOTis set, that folder is the one. The value must be an absolute path to a folder. A blankLIGR_MCP_ROOTrefuses every file action. - If
LIGR_MCP_ROOTis not set, the folder is the one where the server started. The server refuses every file action when that folder is/, the home folder, or a folder that holds the home folder. Claude Desktop often starts a server in one of these folders. SetLIGR_MCP_ROOTin theenvblock of the server.
Every path must be absolute. The server refuses files with more than one hard link, and paths with . or .. segments.
A read follows a symbolic link only when the real file is inside the folder.
The server refuses a download target that is a symbolic link.
| Files | Types | Largest file |
| --- | --- | --- |
| Rive files (files import, replace, download) | .riv, .rev, .zip | 128 MB |
| Data source samples (data_sources create, update) | .csv, .xlsx | 5 MB |
| Images (images supply_missing) | .png, .jpg, .jpeg, .webp | 25 MB |
| Thumbnails (images thumbnail) | .png, .jpg, .jpeg, .webp | 5 MB |
files download does not replace an existing file unless you pass overwrite: true.
The field names of a data source come from its sample file. The agent can choose the header row, so it can read any row of the sample. Keep files that you do not want an agent to read out of this folder.
Setup
Use an API key with the themes:write scope only. The server reads LIGR_API_KEY, LIGR_API_URL, LIGR_DASHBOARD_URL
and LIGR_MCP_ROOT.
The MCP client starts the server with npx @ligr/cli graphic mcp. npx uses an installed @ligr/cli, or downloads it.
Claude Code:
claude mcp add ligr-graphics \
--env LIGR_API_KEY=<key> \
--env LIGR_API_URL=https://api.ligr.live/rest/v2 \
--env LIGR_MCP_ROOT=<absolute path to a folder> \
-- npx @ligr/cli graphic mcpClaude Desktop, in claude_desktop_config.json:
{
"mcpServers": {
"ligr-graphics": {
"command": "npx",
"args": ["@ligr/cli", "graphic", "mcp"],
"env": {
"LIGR_API_KEY": "<key>",
"LIGR_API_URL": "https://api.ligr.live/rest/v2",
"LIGR_MCP_ROOT": "<absolute path to a folder>"
}
}
}
}In a project that installs the CLI locally, npx @ligr/cli graphic mcp runs the local copy.
JSON output
Add --json to any command. The command then prints one JSON document and no human lines.
Use it in scripts.
npx @ligr/cli graphic rive list --theme 203 --json | jq -r '.[].graphicId'Errors
A failed REST call prints <status> <code> <message>, one line per details[], and (held by <name>) for a
409 LOCKED. Wait, then retry a locked graphic. Do not delete it.
Files
| File | Purpose |
| --- | --- |
| graphic.json | The manifest. The API stores it as stateMachine. See https://docs.ligr.live/graphics-sdk/manifest/ |
| ligr.json | { "themeId": number, "graphicId": string, "dist"?: string }. Written by create |
| rive.json | { "themeId": number, "graphicId": string, "apiUrl"?: string, "config"?: object }. Written by rive import and rive pull |
Development
Both packages live in the LIGR monorepo, under packages/graphics-sdk and packages/graphics-cli.
pnpm --filter @ligrsystems/graphics-sdk build
pnpm --filter @ligr/cli build
pnpm --filter @ligr/cli type:check
pnpm --filter @ligr/cli testThe test suite runs the bin, scaffolds and builds both templates, and drives a fake API. The scaffold test installs the template dependencies, so it needs the registry or a warm pnpm store.
Releasing
Both packages ship as versioned tarballs in GitHub Releases:
ligrsystems-graphics-sdk-<version>.tgz and ligr-cli-<version>.tgz. The CLI is also on npm as @ligr/cli.
The private source repository builds and verifies the packages before uploading them to the public distribution repository.
- Bump both package versions together. Update the template URLs and installation examples to that version.
- Run the package checks and packed-template tests.
- Merge the pull request into
masterto run thepublish-graphics-sdkworkflow. - Verify both archives and
SHA256SUMSin the published release before testing the public installation commands.
Each release contains both packages. Published asset URLs stay pinned to their version; upgrades require updating the dependency URLs and lockfile. Maintainers can rerun the workflow from the Actions tab.
License
MIT
