@softr/cli
v0.2.3
Published
The Softr command line: build, test and publish Softr workflows from local files, manage Softr Databases; more Softr APIs to come
Readme
@softr/cli
softr is the Softr command line: it works with your Softr workspace from files on your machine, by hand or through a
coding agent, and nothing runs locally. Its root commands cover the account and the workspace; each area of Softr is a
scope with a noun:
softr workflows: build, test and publish Softr workflows from local files.softr db: manage Softr Databases.
More scopes follow.
Status: versions below 1.0 may change between releases; a single-binary build is planned.
Install and run
npm install -g @softr/cli # then: softr --help
npx @softr/cli --help # without installing
npm run dev -- --help # from a checkoutNode 22 or newer. npm update -g @softr/cli updates a global install; npx fetches the latest release on
its own.
Log in
Log in through the browser (recommended) or with a personal API token. The CLI checks the token with Softr before it
stores it in ~/.softr/credentials.json.
softr login # asks: browser or personal API token
softr login --no-browser # prints the login URL to open elsewhere
pbpaste | softr login --token # a personal API token from stdin; without a pipe, it asks with the input hidden
softr whoami # who the stored token belongs to and what it grants
softr logoutA personal API token needs the scopes of the commands you use: workflows:* for softr workflows, databases.* for
softr db. SOFTR_TOKEN overrides the stored token for scripts and CI.
The CLI targets Softr production. For development, SOFTR_WORKFLOWS_API_URL, SOFTR_STUDIO_API_URL,
SOFTR_STUDIO_URL and SOFTR_TABLES_API_URL point it at other Softr services. SOFTR_BUILDER_API_URL adds the
studio's node catalog, so workflows spec shows the studio's labels and descriptions and searches them too.
Global commands
| Command | What it does |
| ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| login / whoami / logout | Log in, show who the stored token belongs to and what it grants, forget the token. |
| workspaces | The workspaces the token reaches, with your role and the scopes the token grants in each. Commands that take --workspace default to SOFTR_WORKSPACE_ID, else to your only or default workspace. |
| integrations [--workspace <id>] [--type <TYPE>] | The workspace's connected integrations: id, name, type and account. Credentials are never shown. |
Every command accepts --json.
Project folder
One directory holds exactly one workflow or one database, with a softr-*.jsonc file that you own and commit, and a
dot directory where the CLI keeps its state and caches. A project folder groups related ones side by side, so you and
your agent can look up one from the other, for example the table and field ids a workflow reads:
my-project/
lead-scoring/
softr-workflows.jsonc # the workflow
actions/score.py # a Run custom code node
.softr-workflows/ # CLI state (gitignore it)
weekly-digest/
softr-workflows.jsonc
.softr-workflows/
crm/
softr-db.jsonc # names the database
.softr-db/schema.json # its tables and fields, kept current by the CLI (gitignore it).gitignore for the folder: .softr-workflows/ and .softr-db/.
Workflows
The softr workflows commands; softr workflows --help lists them.
Workflow directory
lead-scoring/
softr-workflows.jsonc # the workflow (comments allowed)
actions/
enrich-record.js # body of the CUSTOM_CODE node "enrich-record"
score.py
.softr-workflows/ # CLI state: remote version/draft, cached sample outputssoftr-workflows.jsonc
The file has the shape of the workflows API write model (title, workspaceId, triggers, actions, paths,
configuration) plus the server id. Two CLI conventions apply:
- File references. Any string value of the form
"@@/relative/path"is replaced by that file's content onpush. The path is relative to the config file and must stay inside the workflow directory, also after symlinks are resolved; a reference that leads out of it stops the command.pulluses it for everyCUSTOM_CODEnode'sinputs.code. - Readable node ids. Ids such as
enrich-recordare fine; the service only requires uniqueness and no:::. Placeholders then read{outputs.enrich-record:::$.body}. - Schema.
$schemapoints at.softr-workflows/schema.json: the path condition grammar, and for every node the input schema the workflows service serves for its type and version (types, allowed values, placeholders).init,pull,add,replace,upgradeandschema --writewrite it again; a node added by hand has free inputs until then. Drafts may hold nulls. The service remains the authority at publish. Inputs may hold keys the service does not read, because the studio keeps its own state there;push,verifyandeditwarn about such a key when the server copy of the node does not have it yet, which is usually a typo.
Validation stays in the service: push saves a draft; publish refuses while the readiness report lists validation
problems.
Code files
The service stores the body of a function and runs it with a single variable, inputData, holding the node's
"Data to use in the code" map (inputs.inputData in the config), and with fetch in scope, authenticated by the
integrations attached to the node (inputs.integrations, each with an alias). Locally the body lives inside a real
function so that editors, linters and agents see valid code. On the current version, CUSTOM_CODE 1.3.0:
export default async function (inputData) {
// The CRM is attached to the node (inputs.integrations): the call to its API host is authenticated by itself.
const response = await fetch(`https://api.crm.example/contacts?email=${inputData.email}`);
const { items } = await response.json();
return { known: items.length > 0 };
}def main(inputData):
response = fetch(f"https://api.crm.example/contacts?email={inputData['email']}")
return {"known": len(response.json()["items"]) > 0}The integration option of fetch, { integration: 'crm' }, names an attached integration by its alias; it is needed
when the URL alone does not pick one (a REST API integration can need this) or when two attached integrations share a
host. An integration's credentials go only to its own API: any other URL gets none (the headers of a REST API
integration carry a placeholder value there).
The generated header follows the version of the node, so a node still on an older version gets that runtime's rules; this README always shows the latest.
pull writes a generated header above the function: the rules of the runtime and one typed line per inputData
entry. The types come from the saved test outputs of the referenced nodes (trusted), then from their declared output
metadata (marked as not seen in test data), and are unknown with a hint when the upstream node was never tested.
JavaScript gets a JSDoc @typedef with @property lines, so editors type-check inputData; Python gets the same as
comments. The header is regenerated on every pull and is never uploaded.
push uploads only that function body. Anything outside it (imports, helpers, constants) is rejected with a
message. From CUSTOM_CODE 1.2.0 on, both languages call HTTP APIs with fetch and the JavaScript function is async; a
node still on 1.0.0 or 1.1.0 keeps its synchronous runtime without fetch, and its header says so until you run
upgrade on it. JavaScript has no imports; Python imports from an allowlist of standard modules inside
main. The return value becomes the node output at $.body. Never write workflow placeholders such as
{outputs.x:::$.y} inside code; map them in inputData instead. See the
Run Custom Code docs.
Commands
| Command | What it does |
| -------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| workflows list [--workspace <id>] [--app <id>] | List the workflows you can access, one table per workspace, with their trigger types; --json gives each trigger's id too (triggers), the triggerId app code fires a workflow by. --app keeps only those pinned to that application. A workspace whose listing fails is reported at the end and skipped. |
| workflows pull [<workflowId>] [--dir <path>] [--force] | Download a workflow into a directory (new ./<title-slug>/ by default). Without an id, list what you can pull. |
| workflows push [--dir <path>] [--dry-run] [--force] | Inline @@ references and code files, save as a new draft. Sends nothing when the files match the last sync, and refuses when the server copy changed since then (--force overrides both). Warns about placeholders that no saved test data backs. |
| workflows init <title> [--workspace <id>] [--pin-to-app <id>] [--trigger <TYPE>] [--dir <path>] | Create a workflow on the server with one trigger (default WEBHOOK) and the local directory for it; --pin-to-app (default SOFTR_PINNED_APP_ID) pins it to an application of the same workspace, so the app lists it. |
| workflows pin [--app <id>] [--id <workflowId>] [--dir <path>] / unpin | Pin an existing workflow to an application of its workspace, or remove it from the app. The app defaults to SOFTR_PINNED_APP_ID, the workflow to the one in the directory. |
| workflows upgrade [<nodeId>...] [--dir <path>] | Move nodes on an older version of their type up where the CLI knows how (CUSTOM_CODE moves to the newest version the service runs: from 1.0.0 and 1.1.0 the integrations list is added, the code file keeps its body and gets the new header) and list the others. Every command that touches a workflow lists nodes below the newest version in a note. |
| workflows add <TYPE> [--id <id>] [--after <nodeId>] [--in-loop <loopId>] [--to <actionId>] [--lang JAVASCRIPT\|PYTHON] [--title <t>] | Append an action of any type the service runs after a node (default: the only node without a successor) and the path to it, or append a trigger (--to connects it). The node gets the newest version and every input of its schema, set to the service's default or null. Custom code gets actions/<id>.js\|py with an empty function. Comments in the config survive. |
| workflows replace <nodeId> <TYPE> | Give a node another type of the same kind, on its newest version: id, title and paths stay, inputs start from the new type's defaults. |
| workflows remove <nodeId> | Remove a node and the paths to and from it; a loop goes with its body. Code files stay on disk. |
| workflows edit <nodeId> [--set <path>=<json>] [--set-text <path>=<text>] [--unset <path>] [--rename <path>=<key>] | Change keys of one node in place, by a path such as inputs.filter.conditions[0].rightSide: set a JSON value or a text as it is (a placeholder), remove a key or a list item, rename a key. Options repeat and apply in order, all or none; comments and layout stay. Names input keys the node's schema does not know. |
| workflows spec [<TYPE>] [--search <text>] [--kind trigger\|action] [--node-version <v>] | The node types the workflows service runs, with their integration and newest version; with a type: the inputs of a version from its schema (types, allowed values, defaults), how the service treats it, and an example node where the CLI has one. |
| workflows schema [<TYPE> [--node-version <v>]] [--write] [--dir <path>] | Print the JSON schema of softr-workflows.jsonc with the input schemas of the workflow's nodes, or write it into the workflow directory. init, pull, add, replace and upgrade write it and $schema in the config points at it, so editors validate and complete the file. With a type: only the JSON schema of one node of that type and version (default the newest), for a client or agent that needs nothing else from spec. |
| workflows status | Local edits vs the last sync, the server's version and draft, the live version. |
| workflows publish [--force] / unpublish | Enable the latest version (the service validates the whole workflow) or disable the workflow. publish fetches the server copy first and refuses unpushed local edits and a server copy that changed since the last sync; then it lists nodes that are untested, failed, tested before the last save, or tested against outdated upstream data: a terminal asks for confirmation, a script or agent needs --force. |
| workflows publish --stop-ongoing-runs / unpublish --stop-ongoing-runs | Stop the waiting runs (a wait step, a retry, a user interaction, the serial queue) of the replaced versions (publish) or of all versions (unpublish) and report how many. Without it they continue. |
| workflows test <nodeId> [--mock] [--iteration <n>] [--sample <n>] | Run one node in the workflows service and save its sample output. Triggers propose samples; --sample picks one (default the first). |
| workflows test --all | Run the trigger and then every action in execution order, predecessors first across parallel paths and loop bodies. Branches, filters and loops are skipped. Failures are reported at the end; the exit code is 1 when any test failed. |
| workflows outputs | One line per node: tested, failed, untested, with the field count. |
| workflows outputs <nodeId> | The node's referenceable variables with types and examples, ready to paste. |
| workflows outputs --refresh | Fetch the saved samples from the service and regenerate the code headers. |
| workflows verify [--test-missing] | One readiness report: code files parse, local files match the server, the service accepts the definition for publishing, every node tested on current data, every placeholder backed by test data. --test-missing first runs the tests that are missing, in execution order. Exit code 1 while something needs attention. |
| workflows placeholder <nodeId> [keys...] | Build the token for a node's output field from keys (* for every element, digits for an index, or one dotted path), checked against the saved test data: type and example when it exists, the keys that do exist when it does not. A loop id gives the current item. |
After a pull, the workflow directory remembers its target in .softr-workflows/state.json.
Every test and outputs --refresh updates .softr-workflows/outputs.json and rewrites the code headers, so the
types of inputData follow the latest test data. Tests run against the server's copy of the workflow. test compares
the local files with that copy and names the nodes whose edits are not pushed yet, so a green result is never mistaken
for a verdict on local code.
verify, status and the publish guard read the service's readiness report
(GET /v1/workflows/{id}/readiness): the publish validation as a dry run with every message, and per node the test
state, staleness against the last save, outdated references and placeholders no saved sample backs.
.softr-workflows/state.json keeps the server version and draft of the last sync and a content hash of what was
synced. That is how push knows there is nothing to send, how it notices that the server copy moved on, and how
test tells edited from unedited without any server-side support.
Node types
Every node type the workflows service runs: spec lists them, spec --search airtable narrows the list, and
spec <TYPE> shows the inputs of its newest version (--node-version for an older one), with the defaults the service
applies. add, replace and init --trigger write a new node on the newest version with every input of its schema,
set to the default or null. Inputs picked from a connected account (bases, tables, channels) need their ids; the
studio lists those for you, the CLI does not.
A typical session
softr workflows init "Lead scoring" # server + ./lead-scoring/
cd lead-scoring
softr workflows add CUSTOM_CODE --id score --lang python # actions/score.py + node + path
# edit actions/score.py, set inputs.inputData in softr-workflows.jsonc
softr workflows push
softr workflows test --all # trigger first (send it one request), then score
softr workflows outputs score # variables the next node can use
softr workflows publishDatabases
The softr db commands manage Softr Databases through the
Softr Database API; softr db --help lists them. Its
rate limits apply per token.
Database directory
softr db create <name> and softr db get <id or name> write ./<name-slug>/softr-db.jsonc with the database id,
and .softr-db/schema.json next to it with the database, its tables and their fields (ids, names, types, options).
Inside that directory, or with --dir <path>, the commands work on that database without its id, and db get refreshes
the cache. A database id passed as an argument or in SOFTR_DATABASE_ID comes first. The commands that change the
schema refresh the cache too; the CLI rewrites it at any time, so never edit it.
crm/
softr-db.jsonc # { "databaseId": "…" }
.softr-db/schema.json # the cache of the tables and fields
.softr-db/views/<tableId>.json # the views of a table, once views list read them| Command | What it does |
| --------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| db list | The databases the token reaches, across all workspaces, with their workspace and number of tables. |
| db get [<database>] [--dir <path>] | One database with its tables, by id or exact name. Outside a database directory it creates ./<name-slug>/; inside one it refreshes the cache, and a different database is an error. |
| db create <name> [--description <text>] [--workspace <id>] [--dir <path>] | Create an empty database and its directory. The workspace defaults to SOFTR_WORKSPACE_ID, else to your only or default workspace among those where the token grants databases.schema:write. |
| db update [<databaseId>] [--name <name>] [--description <text>] [--dir <path>] | Change the name, the description or both. |
| db delete [<databaseId>] [--force] [--dir <path>] | Delete a database. One that still has tables needs --force, which also deletes the tables and all their records. The directory keeps its softr-db.jsonc; the cache goes. |
| db tables list / get <table> | The tables of the database; one table with its fields (ids, types, primary/required/read-only). |
| db tables create <name> [--field <name:TYPE>]... [--fields <json>] [--primary-field <name>] | Create a table with at least one field: --field for types without options, --fields (a JSON array, @<file> or -) for any; the first one names a record. |
| db tables update <table> [--name] [--description] / delete <table> [--force] | Rename or describe a table; delete it (--force when it still has records). |
| db fields get <table> <field> | One field with its options. |
| db fields add <table> <name> --type <TYPE> [--options <json>] [--multiple] | Add a field. The types and their options: field reference. |
| db fields update <table> <field> [--name] [--type] [--options <json>] [--[no-]multiple] | Change a field; what is not passed stays as it is, --options replaces the options as a whole. |
| db fields delete <table> <field> | Delete a field and its values in every record. |
| db views list <table> | The views of a table (the API reads views only). |
| db records list <table> [--view <view>] [--limit <n>] [--offset <n>] [--all] | Records through a view, the table's default view unless --view; one page or --all in pages of 200. |
| db records search <table> [--filter <json>] [--sort <field[:desc]>]... | Records by a filter (operators); without --filter, every record. |
| db records get <table> <recordId> | One record. |
| db records create <table> --fields <json> / update <table> <recordId> --fields <json> | Create a record, or change some of its fields. --fields is inline JSON, @<file> or -. |
| db records delete <table> <recordId> | Delete a record. |
| db records upload <table> <recordId> <field> <file> [--name <fileName>] | Add a local file to an attachment field, stored under the local file name unless --name. |
Tables and fields take an id or an exact name; a name two items share is an error that lists their ids. The table,
field and view commands take the database from --database <id>, else SOFTR_DATABASE_ID, else the database
directory, and keep its cache current; a delete always resolves the name on the server, never from the cache.
Records are keyed by field name in the output and take field names in --fields, filters and --sort; the CLI maps
them to ids, which the API needs. --field-ids keys the output by id. Records are never written to disk.
Agent skills
Three skills in the Agent Skills format, published in softr-io/softr-io-skills:
softr-cli: install and update the CLI, log in, the root commands and the environment variables. Every other Softr skill builds on it.softr-workflows: thesoftr workflowsscope, with the code-file rules in itsreferences/custom-code.md.softr-db: thesoftr dbscope, the database directory and the schema commands.
Install them as a plugin in Claude Code, which keeps them updated, or with npx skills add softr-io/softr-io-skills
in every other agent. The exact steps are on docs.softr.io/softr-cli.
Development
npm ci
npm run check # typecheck, prettier, tests, build
node dist/cli.mjs --helpThe build is one self-contained ESM file (dist/cli.mjs), which keeps a later bun build --compile possible: no
native addons, no runtime reads relative to __dirname. A release is a version bump merged to master.
Further reading
- Triggers: https://docs.softr.io/workflows/trigger-types
- Advanced concepts (Branch, Loop, Run Custom Code, Call API): https://docs.softr.io/workflows/advanced-concepts
- For agents: the docs index https://docs.softr.io/llms.txt; every page is also served as Markdown by appending
.mdto its URL, which is whatspecand the skill link to.
