CLI (Command Line Interface)
The CLI (Command Line Interface) allows you to perform most actions from your terminal that you would otherwise perform via the web UI.
The main benefit of using the CLI is the local workspace copy. You can clone a workspace to a folder on your machine, edit scripts in your own IDE with full type checking, manage them in Git, and push changes back. You can then execute a script and watch console output stream directly into your terminal, all without leaving your local development environment.
You can also interact with ScriptRunner Connect through an AI assistant over the CLI using the sr-connect skill.
Installation
Prerequisite: Install Node.js 22 or newer.
To run the CLI without a global installation:
npx @sr-connect/cliTo install the CLI globally for everyday use (recommended):
npm i -g @sr-connect/cli
sr-connectThe rest of this guide uses the sr-connect command.
Get started
Command structure
Commands consist of a group and a verb (for example, in script get, script is the group and get is the verb). Run a group name on its own to list its verbs, or run sr-connect to list all available groups.
| Verb | Description |
|---|---|
list | Displays all items of that kind |
get | Displays a single item |
create | Creates a new item |
update | Modifies an existing item |
delete | Deletes one item after a confirmation |
Group exceptions and aliases
Exceptions:
The
packagegroup usesaddandremove.The
loggroup uses operational verbs such aslist-console-logsandget-invocation-payload.The
scriptgroup includes execution verbs:trigger,replay-invocation, andabort-invocation.Read-only groups (
app,team,template) only support query verbs.
Short aliases: Use
lwforlocal-workspace,elforevent-listener, andenvforenvironment.
For a full list of commands and concepts, see Commands and Concepts.
Work from a local copy of a workspace
Clone a workspace into a local directory:
sr-connect local-workspace clone my-workspaceSelect the team, workspace, and environment when prompted. Specify a target directory name, or omit it to clone into the current working directory. The CLI creates a Node TypeScript project:
my-workspace/
scripts/ one .ts file per script
api/ generated code for your API connections, do not edit
<API connection path>/
index.ts
test-payloads/ your event listeners' test payloads, as JSON files
<App→Event (listenerId)>/
<payload name>.json
node/ API mocks and Jest setup for local tests
tests/ your own tests go here
apiRegistry.ts
runtimeMocks.ts
global.d.ts
jest.config.ts
tsconfig.json
.vscode/
extensions.json
ev-params.ts types for your environment parameters, never their values
README.md the workspace README
package.json PS! do not add dependencies directly, use `sr-connect package add` instead, adding dev dependencies locally is safe
tsconfig.json
tsconfig.base.json
eslint.config.js
.prettierrc
.gitignore
pnpm-workspace.yaml
workspace.json workspace metadata file, do not editManage dependencies and test scripts using standard package manager workflows:
cd my-workspace
pnpm install # installs the dependencies
pnpm typecheck # checks your scripts and tests with the TypeScript compiler
pnpm test # runs your Jest tests in node/tests against API and runtime mocksnpm or yarn, we strongly recommend pnpm v10 or newer. It blocks untrusted dependency lifecycle scripts by default, helping to protect your local workspace from supply-chain risks.Cloning performs a read-only operation and does not alter the server workspace. Sensitive parameter values and passwords are never written to disk, making the repository safe to commit.
When cloning into an existing local workspace directory, the CLI prompts before overwriting files. The following customisable configuration files and directories are preserved:
Tooling configurations:
tsconfig.json,tsconfig.base.json,eslint.config.js, .prettierrc,.gitignore,pnpm-workspace.yaml, and.vscode/extensions.json.Local testing files in
node/:apiRegistry.ts,runtimeMocks.ts,global.d.ts,jest.config.ts, andtsconfig.json.Custom
package.jsonentries (except the manageddependenciesblock). Always usesr-connect package addto register server dependencies. Adding packages underdevDependenciesis safe and preserved across clones.
For more details, see Work from a local copy.
Local workspace scoping
Commands executed inside a cloned workspace directory automatically target the team, workspace, and environment declared in workspace.json (do not edit this file). The CLI displays the active scope and requests confirmation.
Direct CLI changes affecting local files (such as saving a script or updating the README) automatically sync to your local directory without requiring an explicit re-clone. For more details, see Local sync.
Push your changes to the server
To push local scripts, test payloads, and the README to the server:
sr-connect local-workspace pushThe CLI outlines the changes before uploading and reports any TypeScript compiler errors found afterwards. TypeScript errors do not abort the push unless a bundling failure prevents the workspace from running.
Considerations when pushing:
Pushes are only accepted by environments running the
HEADversion. Released (non-HEAD) environments reject updates.Deleting a local script file does not delete the script on the server. Delete scripts using
sr-connect script delete(recommended) or pass the--delete-missingflag during push.Renaming files locally will update server scripts after a push; however, renaming explicitly via
sr-connect script updateis recommended.For very large workspaces prone to network timeouts, pass the
--asyncflag.Pushing overwrites the server copy. If changes were made concurrently via the web UI, clone to a fresh directory and inspect differences before pushing.
Development loop example
sr-connect local-workspace clone # once
# edit scripts in your IDE
pnpm typecheck && pnpm test # fast, local
sr-connect local-workspace push # push changes to server
sr-connect script trigger # run it and watch the outputEditing lock
Write operations (including push) acquire the workspace editing lock. If another user holds the lock, the CLI prompts to cancel, take over the lock, or proceed without it.
Editing locks expire automatically after 15 minutes of inactivity. Release an active lock immediately when finished by running:
sr-connect workspace-lock releaseFor more details, see Workspace locks.
Trigger a script and stream its logs
Scripts execute server-side against the saved workspace state. Ensure local changes are pushed before triggering.
sr-connect script triggerSelecting the script to execute.
Configuring a test event payload (entered in an editor, loaded from a file, or selected from the
test-payloads/directory).Choosing whether to wait for the return value (waiting limits execution time to a 20-second threshold).
Enabling live console streaming.
When console streaming is active, console.log, warning, and error outputs print to your terminal in real time. The CLI exits with a corresponding exit code upon failure, making it suitable for CI/CD pipelines and automated scripts.
Log streaming notes
Streamed entries may occasionally arrive slightly out of sequence. To inspect exact ordering, fetch stored logs using
sr-connect log list-console-logs.Pressing Ctrl+C terminates the terminal log stream, not the remote script execution.
To inspect logs from previous executions, run sr-connect log list-invocation-logs, followed by sr-connect log list-console-logs or sr-connect log list-http-logs. To replay an invocation, use sr-connect script replay-invocation. To abort an active invocation, run sr-connect script abort-invocation.
For more details, see Output and Exit codes.
The cli group and diagnostics
The cli command group provides management and diagnostic utilities for the CLI tool itself:
| Command | Description |
|---|---|
cli get-readme | Outputs the offline reference documentation |
cli check-updates | Checks for newer CLI package versions |
cli settings | Configures optional features, including API recording, workspace locking, local file synchronisation, crash reports, and agent feedback |
cli set-session | Manually sets session defaults (team, workspace, environment) |
cli clear-session | Clears stored session defaults |
cli list-api-logs | Displays locally recorded CLI API requests |
cli list-crash-reports | Displays saved diagnostic crash reports |
Session defaults:
Selected team, workspace, and environment parameters persist in the active terminal window for 12 hours. Clear them anytime with
sr-connect cli clear-session.
Local workspace precedence:
Inside a cloned directory,
workspace.jsonsettings override session defaults. Explicit command flags and environment variables take precedence over both.
API call recording:
The CLI logs outbound API calls locally for seven days with sensitive credentials redacted. View logs using
sr-connect cli list-api-logs.
Crash reports:
If an internal CLI error occurs, diagnostic reports are stored locally. Inspect them with
sr-connect cli list-crash-reportsbefore submitting.
Settings:
Run
sr-connect cli settingsto toggle API recording, workspace locking, local file synchronisation, crash reports, and agent feedback.
Exit codes:
0(Success),1(Failure),2(Usage error),3(Authentication error),4(Resource not found), and130(Cancelled).
Related information
Full reference documentation: ScriptRunner Connect CLI on npm, including Global switches and How commands work.
Command explanations: Run
sr-connect <group> <verb> --explainfor specific command documentation.
Have feedback or ideas? 📬
We're always looking for ways to improve your CLI experience. Run sr-connect feedback post from your terminal to send suggestions and feature requests directly to the team.