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.
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_KEYis an API key.initneeds none. The CLI reads the key only from the environment.npm install shiftlabsgets 0.4.0.runs pause,runs unpause,runs retry,runs rerun,runs resume,workflows open-run,workflows send,runs cancel --undo, andruns --since,--until,--search,--tagand--keycome in the SDK release after 0.4.0. See Versions.--api-url, orSHIFTLABS_API_URL, sets another API origin. The default ishttps://api.shiftlabs.org.- Every command takes
--jsonto 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.
| Command | What it does |
|---|---|
init | Lists 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. |
deploy | Deploys 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. |
releases | Lists 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. |
runs | Lists 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. |
whoami | Shows the workspace, the key's role and the plan. |
types | Writes 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 usage | Writes 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. |
| Option | For |
|---|---|
--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. |
--payloads | export 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. |
--drop | workflows resume: cancels the held runs instead of starting them. They aren't billed. |
--current | runs rerun, runs resume: the workflow's current version, not the run's own. |
--undo | runs 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. |
--wait | promote: waits until the linked workspace answers, then exits 7 unless the release was applied. |
--system | import 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-run | import crontab: prints what it would write, and writes nothing. |
--json | Prints JSON instead of text, errors included. |
--api-url <url> | Default $SHIFTLABS_API_URL, else https://api.shiftlabs.org. |
-h, --help · -v, --version | Help and the version. |
deploy <file>deploys.tsand.jsfiles as TypeScript and.pyfiles as Python. Underscores in a file name become hyphens:nightly_report.pydeploys asnightly-report.- A deploy with new Python packages or npm packages waits for them to build, up to 10 minutes.
deploysends the files a workflow imports with it. See Files.exportasks again from each answer'sNext-Beforeuntil 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.logsasks again from each page'sNext-Afteruntil 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 afternlines. With--jsonit prints one array; when a page fails part-way, the lines already printed stay, the error says how many, and under--jsonthe array is left unclosed, so it doesn't read as the whole log.runsends oneIdempotency-Key, and on a network error, a 30-second timeout or a5xxtries 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.promoteneeds an admin key that listsrelease.promotein its capabilities. promoteprints the new release in the linked workspace. When that workspace already runs the release's versions and schedules, it printsNothing to promoteand records nothing. A missing secret, var or connection there fails it withconflict, and the error names them.- Where the linked workspace approves promotions,
promoteprints that the release waits for approval there, with the request's id, and exits0. With--waitit 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 exits7(conflict); with--jsonthe error'sresponseis the request, with itsstatus. releasesmarks 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 inreleases, and log messages inlogs. 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.--jsonprints 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.
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
--sinceand--untilbound when a run was queued:--sinceis included,--untilisn't. A time of day without a zone, such as2026-10-01T09:00, is your machine's local time; a date alone, such as2026-10-01, starts at midnight UTC.--searchlooks 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--sinceor more tags.--tag customer=cus_42keeps runs whosecustomertag iscus_42. A--tagwithout=, or with nothing before or after it, fails with exit code2before any request.- Each run prints its tags as
name=valueafter its error.--jsonprints the API's answer, with each run'stags. export runstakes--since,--untiland--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.
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 cancellets the step running now finish, and the run endscancelledbefore 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 hasonCancelruns it first, and the CLI printsits cleanup runs, then it ends cancelled. With--undo, the run's undo handlers run beforeonCancel. Developer keys can.runs terminatestops the run at once, even in the middle of a step, and it endsterminated. Only admin keys can.terminatingmeans the workspace keeps trying.- Both also stop the runs it started with
step.callthat haven't ended. A run that already ended fails asconflictwithrun already ended. See Stop a run. - While a workflow is paused, its new runs are held: stored, listed
queued, not started.workflows resumestarts them in the order they arrived; with--dropit ends themcancelled, unbilled. See Pause a workflow. runs pauseholds one run where it is and printspaused, orpausingwhile its step finishes;runs unpauselets it go on.runs retryprints the retries it started.runs rerunprints the new run's id and the version it uses.runs resumeprints 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.
{
"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
}
}
}
codeandmessageare always there.hintsays what to do next, when there is something to say.statusandresponseare there when the API answered: its HTTP status and its JSON body.
| Code | Exit | Means |
|---|---|---|
usage | 2 | A command, option or argument is wrong. |
config | 3 | Something on your side needs fixing: the project file, a workflow file, the API URL, or a CLI too old for the API. |
auth | 4 | SHIFTLABS_API_KEY is not set, or the API did not accept it. |
forbidden | 5 | The key's role or scope does not allow this, or the workspace is suspended. |
not_found | 6 | The workflow, run, release or other item does not exist. |
conflict | 7 | Something is in the way. init and import crontab do not overwrite files. |
invalid | 8 | The API refused the request, such as code that does not build, or import crontab found no entry it could import. |
limit | 9 | A plan limit or a rate limit. The hint says when to try again, if the API said. |
network | 10 | The API could not be reached, or did not answer in time. |
server | 11 | The API failed. Try again shortly. |
internal | 1 | A 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.
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",
}),
},
});
- Stage
Each workflow is deployed with
?stage=1: built and stored, not yet current.?profile=sends the project'srunnerProfile, empty when it has none. - Upload code
Each agent with
codeuploads that file. Every code tool in it joins the agent. - Release
One
POST /v1/releasesmakes 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,
deployprintsNothing 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 iscurrent. deploydeletes nothing. Workflows and agents in the workspace that the project doesn't name stay as they are, anddeploylists them underNot in shiftlabs.config.ts, left as they are:, with how to delete a workflow: on the dashboard's Workflows screen, or withDELETE /v1/workflows/<name>, and an agent: on its page on the dashboard's Agents screen, or withDELETE /v1/agents/<name>. With--json, they are the release'sunnamed. It lists only names the key can see.- A workflow or agent whose name is in the trash stops
deploywith exit code7(conflict). It prints the API's message and hint, such asworkflow nightly is in the trash until 2026-11-07 14:03 UTCandAn 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'sresponsecarriestrash. - Paths are relative to the config file. The config must
export default project({...}). If it importsshiftlabs, install the package first. - An agent's
codeis the path of its tools file, whose default export istools({...}). The agent'stoolstakesworkflowTool(...)only. See Code tools. - Each
workflowTool(...)needs itsapproval:"never","always"or{ approvers, approvals }. Without one,deploystops with exit code3(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.deploycapability, which developers hold. schedulesreplaces every schedule in the workspace, including ones edited in the dashboard.schedules: {}removes them all; a project withoutschedulesleaves them as they are. See Schedules.runnerProfileis the runner image profile the project's steps ask for when they name none, kept with each workflow versiondeploystages. A project without it removes the default its workflows had. One that isn't a profile name orname@versionstopsdeploywith exit code3(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:
deployfollows eachimport,export … from,import()andrequire()with a relative path, such as./money.ts,../lib/moneyor./rates.json, through the files they import. It sends.ts,.mts,.js,.mjsand.jsonfiles. - The files must sit in the folder of the nearest
package.json, looking up from the workflow's folder, or below it. Without apackage.json, they sit in the workflow's folder or below it. - When the code imports a package,
deploysends thatpackage.jsonand the part of itspackage-lock.jsonthe imports reach. The platform installs the packages the workflow imports at the versions the lockfile pins, anddeploywaits while a new set installs. Node.js built-ins such asbuffer, and imports of types only, need neither file. See Files and npm packages. - Without a
package-lock.json,deploywarns and sends the files withoutpackage.json, so no package installs, and the deploy fails if the code needs one. With apnpm-lock.yaml,bun.lockoryarn.lock, runnpm install --package-lock-onlyto write apackage-lock.jsonbeside it. - An import of
./money.jsthat meansmoney.tsstops the deploy. Import it as./money.tsor./money. - Python:
deploysends the modules the workflow imports from its folder and below, such asimport helpersorfrom 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.
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.tsTypeScript. It fills the
SecretsandVarsinterfaces of"shiftlabs", andAgentNamesandWorkflowPayloadsof"shiftlabs/client". Yourtsconfig.jsonmust include it; the defaultincludecovers the whole folder.shiftlabs_types.pyiPython. It takes effect with the
shiftlabsPython package. The package readsSecretsandVarsfrom this file. Each name is an attribute, andctx.secrets["NAME"]takes the names too. Annotate the context, as inasync def refund_check(ctx: Context), so the editor knows whatctxis. The file also lists the agent and workflow names asAgentNameandWorkflowName, whichshiftlabs.clienttakes.
secretslists only secrets with hosts, since only they have a stand-in. The command names the others.reveal()andsign()take any secret's name.- A var set only for some workflows is optional:
string | undefinedin TypeScript,str | Nonein Python. - In TypeScript, until the workspace has a secret with hosts, any
secrets.NAMEtype-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.typesoverwrites only files it wrote.- Each part needs a capability: secrets
secret.view, varsvar.view, workflow names and payload typesworkflow.view, agent namesagent.view. A viewer key has all four. Withoutworkflow.vieworagent.view, that part is left empty, so any name type-checks there, andtypessays which capability the key lacks. - With
--jsonit prints{"files", "secrets", "vars", "workflowVars", "withoutHosts", "agents", "workflows", "lacking"}.lackinglists 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 asshiftlabs-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'shintsays what to install. See Versioning. - A release made with
shiftlabs deployorshiftlabs rollbackrecords the CLI's version ascliVersion. The dashboard's Releases screen shows it. - The package's
CHANGELOG.mdlists 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.
initnever overwrites a file. IfAGENTS.mdorCLAUDE.mdexists, it leaves it as it was and says so. Add the line@AGENTS.mdto your ownCLAUDE.md.- If the template's
shiftlabs.config.tsor a workflow file exists,init --templatewrites nothing.