shiftlabs Start free
Menu CLI reference

CLI reference

The shiftlabs command deploys workflows and agents from your machine or CI, and follows their runs. It needs Node 22.18 or later and an API key.

Install

Install the shiftlabs package in your project, or run it with npx. The package also gives import { workflow } from "shiftlabs" its types.

shellterminal
npm install --save-dev shiftlabs
export SHIFTLABS_API_KEY=slk_…   # developer: deploy and run; viewer: read only
npx shiftlabs whoami
  • Node 22.18 or later. Bun runs it too.
  • SHIFTLABS_API_KEY is an API key. init needs none. The CLI reads the key only from the environment.
  • npm install shiftlabs gets 0.4.0. runs pause, runs unpause, runs retry, runs rerun, runs resume, workflows open-run, workflows send, runs cancel --undo, and runs --since, --until, --search, --tag and --key come in the SDK release after 0.4.0. See Versions.
  • --api-url, or SHIFTLABS_API_URL, sets another API origin. The default is https://api.shiftlabs.org.
  • Every command takes --json to print JSON. A failure prints a JSON error instead. See Errors.
  • The CLI never asks a question or waits for input, so it runs the same in CI and from an AI coding tool.

Commands

shiftlabs --help lists the same commands and options.

Commands
CommandWhat it does
initLists the agent templates. Writes nothing.
init <dir>Writes AGENTS.md and CLAUDE.md for coding agents into dir (. for the current directory), and lists the agent templates. See Coding agents.
init --template <name> [dir]Writes a template's shiftlabs.config.ts and workflows into dir, by default the current directory, with AGENTS.md and CLAUDE.md. See Templates.
deployDeploys every workflow and agent in shiftlabs.config.ts as one release. See Projects.
deploy <file>...Deploys workflows from .ts, .js or .py files, each current at once, with the files and packages they import. The file name is the workflow name.
releasesLists recent releases, newest first.
rollback <release>Makes an earlier release's versions and schedules current again, as a new release.
promote <release> --to <workspace>Copies a release to a linked workspace, such as production, as a new release there, or asks that workspace to approve it. See Promote a release.
run <workflow>Starts a run of the current version now. For a keyed workflow whose key has a run open, starts nothing and prints that run.
runsLists recent runs, newest first. With --since, --until, --search and --tag, finds runs, and with --workflow and --key, a keyed workflow's runs of one key. See Find runs.
runs cancel <run-id>Cancels a run: the step running now finishes, the workflow's onCancel runs if it has one, and the run ends. With --undo, its undo handlers run too. See Stop runs.
runs terminate <run-id>Stops a run at once, cutting off a step in progress. Admin keys only.
runs pause <run-id> · runs unpause <run-id>Holds a run once its running step finishes, or lets it go on. See Pause a run.
runs retry <run-id>Starts the next attempt of a step.run, step.exec or step.activity waiting to retry, at once. See Retry now.
runs rerun <run-id>Starts a new run of a run, on its own version and payload. With --current, on the workflow's current version; with --payload <json>, with that payload, checked against that version's payload schema. See Re-run a run.
runs resume <run-id>Starts a failed run again from the step it failed at, or --step <name> (with --occurrence <n> for a name used more than once), without running the steps before it. With --current, on the workflow's current version: the run's payload is checked against that version's payload schema, and the new run fails, naming the first difference, when that version's steps before the resume point differ from the run's. See Resume a failed run.
workflows pause <name>Holds the workflow's new runs until it resumes. Runs already going keep going.
workflows resume <name>Starts the held runs in the order they arrived. With --drop, cancels them instead.
workflows open-run <name> <key>Prints a keyed workflow's open run for the key: the run a start with that key answers. No open run fails with exit code 6.
workflows send <name> <event>Sends the event to a keyed workflow's open run for the key, or starts one with the data as its payload. Prints whether it sent the event or started a run.
logs <run-id>Prints a run's log lines, every line unless --limit says how many.
whoamiShows the workspace, the key's role and the plan.
typesWrites the workspace's secret and var names, never values, its agent names and each workflow's payload type as editor types. See Editor types.
export runs · export audit · export usageWrites every run, audit log entry or hour of usage to one NDJSON file. Runs take --workflow, --status, --since, --until, --tag and --payloads.
import crontab <file>Writes a project with a workflow and a schedule for each crontab entry, and prints what it holds and the lines it couldn't import. - reads standard input. Calls no API and needs no key: deploy sends the project. See Import a crontab.
Options
OptionFor
--config <file>deploy: the project file. Default shiftlabs.config.ts, then .mts, .js and .mjs.
--out <path>types: the folder to write in. Default: the folder of shiftlabs.config.ts, else the current directory. export: the file. Default: the name the API gives it, in the current directory. import crontab: a new or empty folder. Default cron-import.
--template <name>init: the template to start from.
--name <workflow>deploy: the workflow name, for a single file.
--payload <json>run: the run's JSON payload. Default {}. runs rerun: the new run's payload in place of the run's own.
--payloadsexport runs: each run's payload too. Needs a developer key.
--workflow <name>runs: only this workflow.
--status <status>runs: queued, running, sleeping, waiting, paused, completed, failed, cancelled or terminated.
--since <time>runs, export runs: runs queued at or after this time. An ISO 8601 time, milliseconds since the epoch, or a duration back from now: 30m, 24h, 7d.
--until <time>runs, export runs: runs queued before this time, as --since.
--search <text>runs: runs whose id starts with the text, or whose error, output, payload or a tag value contains it.
--tag <name>=<value>runs, export runs: only runs with this tag. Repeat it for more; a run must have them all.
--key <key>runs: with --workflow, only a keyed workflow's runs of this key. workflows send: the key whose run gets the event. Default: the data's value at the workflow's key path.
--data <json>workflows send: the event's JSON data. Default: none.
--dropworkflows resume: cancels the held runs instead of starting them. They aren't billed.
--currentruns rerun, runs resume: the workflow's current version, not the run's own.
--undoruns cancel: runs the undo handlers of the run's completed steps, newest first, before onCancel.
--limit <n>runs, logs, releases: how many. Default 20 runs, every line, 20 releases.
--to <workspace>promote: the linked workspace to promote to.
--waitpromote: waits until the linked workspace answers, then exits 7 unless the release was applied.
--systemimport crontab: a system crontab, with a user before each command.
--timezone <zone>import crontab: the IANA time zone of the entries with no CRON_TZ= or TZ= line before them. Default UTC.
--runner <pool>import crontab: the runner pool of every command. Default default.
--timeout <duration>import crontab: how long each command may run, such as "30 minutes". Default "10 minutes".
--dry-runimport crontab: prints what it would write, and writes nothing.
--jsonPrints JSON instead of text, errors included.
--api-url <url>Default $SHIFTLABS_API_URL, else https://api.shiftlabs.org.
-h, --help · -v, --versionHelp and the version.
  • deploy <file> deploys .ts and .js files as TypeScript and .py files as Python. Underscores in a file name become hyphens: nightly_report.py deploys as nightly-report.
  • A deploy with new Python packages or npm packages waits for them to build, up to 10 minutes.
  • deploy sends the files a workflow imports with it. See Files.
  • export asks again from each answer's Next-Before until it has the oldest row. Past the limit of 10 exports a minute it waits and asks again. An export that fails part-way removes its file. Exporting the audit log needs an admin key.
  • logs asks again from each page's Next-After until it has the run's last line, so a run with more than 2,000 lines prints in full, each line once and in order. Past the rate limit it waits and asks again. --limit <n> stops after n lines. With --json it prints one array; when a page fails part-way, the lines already printed stay, the error says how many, and under --json the array is left unclosed, so it doesn't read as the whole log.
  • run sends one Idempotency-Key, and on a network error, a 30-second timeout or a 5xx tries again with it, 3 attempts at most. A retry never starts a second run.
  • Developer keys deploy, release, roll back, run, cancel, pause, unpause, retry, re-run and resume runs, and pause workflows. Admin keys can also terminate runs. Viewer keys read, and can run types. promote needs an admin key that lists release.promote in its capabilities.
  • promote prints the new release in the linked workspace. When that workspace already runs the release's versions and schedules, it prints Nothing to promote and records nothing. A missing secret, var or connection there fails it with conflict, and the error names them.
  • Where the linked workspace approves promotions, promote prints that the release waits for approval there, with the request's id, and exits 0. With --wait it asks again after a second, then less often, up to every 30 seconds. A denial, a request that ran out, or a check that failed once it was approved exits 7 (conflict); with --json the error's response is the request, with its status.
  • releases marks a promoted release with the workspace and release it came from.
  • Text that others wrote prints as plain text: the other workspace's note in promote, who made each release in releases, and log messages in logs. A control character becomes a space, and a log message's later lines start with a bar (|), so none can move the terminal's cursor or start a GitHub Actions :: command. --json prints them as the API answers.

Find runs

Find a customer's runs by a tag, the last day's failures, or a run by the text of its error or payload.

shellterminal
npx shiftlabs runs --since 24h --tag customer=cus_42 --search timeout
# 2026-11-01 09:14:02  3f0c8a52-6d1e-4b7a-9a43-2e5d8c1f0b6a  failed      refund-check  Stripe: timeout  customer=cus_42
npx shiftlabs export runs --since 2026-10-01T00:00:00Z --until 2026-11-01T00:00:00Z --tag customer=cus_42
  • --since and --until bound when a run was queued: --since is included, --until isn't. A time of day without a zone, such as 2026-10-01T09:00, is your machine's local time; a date alone, such as 2026-10-01, starts at midnight UTC.
  • --search looks at a bounded number of runs per request, so it can print fewer runs than --limit, or none, while older ones still match. Run it again with a narrower --since or more tags.
  • --tag customer=cus_42 keeps runs whose customer tag is cus_42. A --tag without =, or with nothing before or after it, fails with exit code 2 before any request.
  • Each run prints its tags as name=value after its error. --json prints the API's answer, with each run's tags.
  • export runs takes --since, --until and --tag, not --search.

Stop runs

Cancel a run to end it before its next step, or terminate it to stop it at once. Pause a workflow to hold its new runs while you fix something.

shellterminal
npx shiftlabs runs cancel 3f0c8a52-6d1e-4b7a-9a43-2e5d8c1f0b6a
# run 3f0c8a52-6d1e-4b7a-9a43-2e5d8c1f0b6a cancelling: it ends before its next step
npx shiftlabs workflows pause refund-check
# refund-check paused: new runs are held until it resumes (0 held runs now)
npx shiftlabs deploy
npx shiftlabs workflows resume refund-check
# refund-check resumed: 2 held runs starting in the order they arrived
  • runs cancel lets the step running now finish, and the run ends cancelled before its next step. A run that hasn't started ends at once, and so does a waiting one without a cleanup. A started run whose workflow has onCancel runs it first, and the CLI prints its cleanup runs, then it ends cancelled. With --undo, the run's undo handlers run before onCancel. Developer keys can.
  • runs terminate stops the run at once, even in the middle of a step, and it ends terminated. Only admin keys can. terminating means the workspace keeps trying.
  • Both also stop the runs it started with step.call that haven't ended. A run that already ended fails as conflict with run already ended. See Stop a run.
  • While a workflow is paused, its new runs are held: stored, listed queued, not started. workflows resume starts them in the order they arrived; with --drop it ends them cancelled, unbilled. See Pause a workflow.
  • runs pause holds one run where it is and prints paused, or pausing while its step finishes; runs unpause lets it go on. runs retry prints the retries it started. runs rerun prints the new run's id and the version it uses. runs resume prints the new run's id, the version it uses and how many earlier steps it takes from the failed run. Developer keys can.
  • With --json, each prints the API's answer: {"runId", "status", "cleanup"}, runs retry's {"runId", "retried"}, runs rerun's {"runId", "versionHash"}, runs resume's {"runId", "from", "seeded", "versionHash"}, or the workflow's {"workflow", "paused", ...}.

Errors

With --json, a failed command prints one JSON object on stdout. Without it, the message goes to stderr, with the hint on the next line when there is one; a usage error prints only its message. The exit code is the same either way, and tells the kind of failure.

jsonstdout
{
  "error": {
    "code": "limit",
    "message": "POST /v1/workflows/refund-check/runs -> 429: quota exceeded",
    "hint": "Try again in 3600 seconds.",
    "status": 429,
    "response": {
      "error": "quota exceeded",
      "limit": "runsPerDay",
      "max": 1000
    }
  }
}
  • code and message are always there. hint says what to do next, when there is something to say.
  • status and response are there when the API answered: its HTTP status and its JSON body.
Error codes
CodeExitMeans
usage2A command, option or argument is wrong.
config3Something on your side needs fixing: the project file, a workflow file, the API URL, or a CLI too old for the API.
auth4SHIFTLABS_API_KEY is not set, or the API did not accept it.
forbidden5The key's role or scope does not allow this, or the workspace is suspended.
not_found6The workflow, run, release or other item does not exist.
conflict7Something is in the way. init and import crontab do not overwrite files.
invalid8The API refused the request, such as code that does not build, or import crontab found no entry it could import.
limit9A plan limit or a rate limit. The hint says when to try again, if the API said.
network10The API could not be reached, or did not answer in time.
server11The API failed. Try again shortly.
internal1A bug in the CLI.

Projects

shiftlabs deploy with no files reads shiftlabs.config.ts. It lists the project's workflows, agents and schedules, and deploys them as one release.

shiftlabs.config.ts
import { agent, file, project, schedule, workflowTool } from "shiftlabs";

export default project({
  workflows: {
    "lookup-invoice": "./workflows/lookup-invoice.ts",
    "nightly-report": "./workflows/nightly_report.py",
  },
  agents: {
    billing: agent({
      title: "Billing assistant",
      instructions: file("./agents/billing.md"),
      model: "@cf/zai-org/glm-4.7-flash",
      tools: [
        workflowTool("lookup-invoice", {
          description: "Look up an invoice by its id.",
          approval: "never",
        }),
      ],
    }),
  },
  schedules: {
    nightly: schedule("nightly-report", {
      cron: "0 3 * * *",
      timezone: "America/Detroit",
    }),
    "monday-summary": schedule({
      agent: "billing",
      message: "Summarize last week's refunds.",
      cron: "0 9 * * 1",
    }),
  },
});
  1. Stage

    Each workflow is deployed with ?stage=1: built and stored, not yet current. ?profile= sends the project's runnerProfile, empty when it has none.

  2. Upload code

    Each agent with code uploads that file. Every code tool in it joins the agent.

  3. Release

    One POST /v1/releases makes the workflow versions, agent definitions and schedules current together. It prints the release number and what changed.

  • If a step fails, nothing that runs changes. Staged versions and uploads that no release names are dropped after a day.
  • With nothing changed, deploy prints Nothing to release: every workflow, agent and schedule is already current., then the release that has them, if one of the last 20 does. It records no release, so CI can deploy on every push. With --json, that release is current.
  • deploy deletes nothing. Workflows and agents in the workspace that the project doesn't name stay as they are, and deploy lists them under Not in shiftlabs.config.ts, left as they are:, with how to delete a workflow: on the dashboard's Workflows screen, or with DELETE /v1/workflows/<name>, and an agent: on its page on the dashboard's Agents screen, or with DELETE /v1/agents/<name>. With --json, they are the release's unnamed. It lists only names the key can see.
  • A workflow or agent whose name is in the trash stops deploy with exit code 7 (conflict). It prints the API's message and hint, such as workflow nightly is in the trash until 2026-11-07 14:03 UTC and An admin can restore it, or delete it for good to use the name now, on the dashboard's Trash screen or with POST /v1/trash/restore or POST /v1/trash/purge. With --json, the error's response carries trash.
  • Paths are relative to the config file. The config must export default project({...}). If it imports shiftlabs, install the package first.
  • An agent's code is the path of its tools file, whose default export is tools({...}). The agent's tools takes workflowTool(...) only. See Code tools.
  • Each workflowTool(...) needs its approval: "never", "always" or { approvers, approvals }. Without one, deploy stops with exit code 3 (config) before uploading anything, naming the tool.
  • An agent's instructions: file("./x.md") sends the file's text, up to 8,000 characters.
  • A Standard JSON Schema in a workflow tool's parameters, such as a zod 4.2+ schema, is sent as its JSON Schema.
  • A key that deploys agents needs the agent.deploy capability, which developers hold.
  • schedules replaces every schedule in the workspace, including ones edited in the dashboard. schedules: {} removes them all; a project without schedules leaves them as they are. See Schedules.
  • runnerProfile is the runner image profile the project's steps ask for when they name none, kept with each workflow version deploy stages. A project without it removes the default its workflows had. One that isn't a profile name or name@version stops deploy with exit code 3 (config) before uploading anything. deploy <file>... sends none, so its versions keep the workflow's current default.

Files and packages

A workflow's file can import other files and, in TypeScript, npm packages. deploy sends them with it, as one deploy of several files. A workflow that imports nothing of its own is sent as its text, as before.

  • TypeScript: deploy follows each import, export … from, import() and require() with a relative path, such as ./money.ts, ../lib/money or ./rates.json, through the files they import. It sends .ts, .mts, .js, .mjs and .json files.
  • The files must sit in the folder of the nearest package.json, looking up from the workflow's folder, or below it. Without a package.json, they sit in the workflow's folder or below it.
  • When the code imports a package, deploy sends that package.json and the part of its package-lock.json the imports reach. The platform installs the packages the workflow imports at the versions the lockfile pins, and deploy waits while a new set installs. Node.js built-ins such as buffer, and imports of types only, need neither file. See Files and npm packages.
  • Without a package-lock.json, deploy warns and sends the files without package.json, so no package installs, and the deploy fails if the code needs one. With a pnpm-lock.yaml, bun.lock or yarn.lock, run npm install --package-lock-only to write a package-lock.json beside it.
  • An import of ./money.js that means money.ts stops the deploy. Import it as ./money.ts or ./money.
  • Python: deploy sends the modules the workflow imports from its folder and below, such as import helpers or from lib.util import double.

Editor types

shiftlabs types reads the workspace's secrets, vars, agents and workflows through the API and writes their names, never values, and each workflow's payload type to two files next to shiftlabs.config.ts. Your editor then completes secrets. and vars., and flags a misspelled name before you deploy. In an app, shiftlabs/client type-checks agent names and payloads with the same file. Run it again after adding or removing a secret or var, or deploying an agent or a workflow.

shellterminal
npx shiftlabs types
# Wrote shiftlabs-env.d.ts and shiftlabs_types.pyi: 1 secret, 2 vars, 1 agent
#   and 3 workflows.
npx tsc --noEmit
# workflows/refund.ts(4,30): error TS2551: Property 'STRIPE_KYE' does not exist
#   on type 'Readonly<Secrets>'. Did you mean 'STRIPE_KEY'?
  • shiftlabs-env.d.ts

    TypeScript. It fills the Secrets and Vars interfaces of "shiftlabs", and AgentNames and WorkflowPayloads of "shiftlabs/client". Your tsconfig.json must include it; the default include covers the whole folder.

  • shiftlabs_types.pyi

    Python. It takes effect with the shiftlabs Python package. The package reads Secrets and Vars from this file. Each name is an attribute, and ctx.secrets["NAME"] takes the names too. Annotate the context, as in async def refund_check(ctx: Context), so the editor knows what ctx is. The file also lists the agent and workflow names as AgentName and WorkflowName, which shiftlabs.client takes.

  • secrets lists only secrets with hosts, since only they have a stand-in. The command names the others. reveal() and sign() take any secret's name.
  • A var set only for some workflows is optional: string | undefined in TypeScript, str | None in Python.
  • In TypeScript, until the workspace has a secret with hosts, any secrets.NAME type-checks, and the same for vars. In Python, the file for an empty workspace has no names, so the editor flags every one.
  • A workflow's payload type comes from its payload schema. A workflow without one takes any payload. The built-in helper isn't among the agents.
  • --out <dir> writes to another folder, such as an app's that uses the client. types overwrites only files it wrote.
  • Each part needs a capability: secrets secret.view, vars var.view, workflow names and payload types workflow.view, agent names agent.view. A viewer key has all four. Without workflow.view or agent.view, that part is left empty, so any name type-checks there, and types says which capability the key lacks.
  • With --json it prints {"files", "secrets", "vars", "workflowVars", "withoutHosts", "agents", "workflows", "lacking"}. lacking lists the capabilities the key missed.

Versions

The shiftlabs package has the same version as the SDK the platform runs, so its types match how your code runs. The CLI and the API check each other's version.

  • Each request names the CLI's version in its User-Agent, such as shiftlabs-cli/0.4.0.
  • When the API runs a newer version, the command prints one line to stderr with that version and the command to update. It still runs.
  • The API refuses a CLI older than the oldest version it accepts. The command fails with 426 {"error": "cli too old"}, and the answer's hint says what to install. See Versioning.
  • A release made with shiftlabs deploy or shiftlabs rollback records the CLI's version as cliVersion. The dashboard's Releases screen shows it.
  • The package's CHANGELOG.md lists what each version changed. Before 1.0, a version can rename or reshape what earlier ones had.

Coding agents

shiftlabs init --template <name> and shiftlabs init <dir> write an AGENTS.md that coding agents such as Codex, Cursor and Claude Code read before they change the project. For a project you already have, run npx shiftlabs init . in it. The file covers the project's layout, the commands, and the rules that most often trip people up: code outside a step runs again, secrets are stand-ins, code tools have no network, and a deploy is one release. It links to these docs and their llms.txt. CLAUDE.md holds one line, @AGENTS.md, so Claude Code reads the same file.

  • init never overwrites a file. If AGENTS.md or CLAUDE.md exists, it leaves it as it was and says so. Add the line @AGENTS.md to your own CLAUDE.md.
  • If the template's shiftlabs.config.ts or a workflow file exists, init --template writes nothing.