Skip to content

Global options and shared behavior ​

Global options are accepted on registered command paths. Put them before the command for clarity. Their presence in the parser does not promise every action produces the same output: interactive chat, raw-token output, local history and connector tool results have their own behavior. Command pages list inherited parent options separately.

Options ​

OptionDescriptionDefault
-v, --versionShow the current version—
--jsonOutput results in JSON format for scripting—
--ui <mode>Conversation presentation: auto, managed TUI, or plain lines Accepted values: auto, tui, plain."auto"
--api-url <url>Override the API base URL for this command—
--env-file <path>Load environment variables from a trusted file—
--no-splashSkip the startup splash screenSetting without flag: true; with flag: false
-h, --helpShow command help and exit—

Configuration and scope ​

The API URL resolves from --api-url, then CHAINABIT_BASE_URL, then saved configuration. The normal default is https://api.chainabit.com/api/v1. --env-file loads only the explicitly selected trusted file; it is not a request to search for secrets. Credentials resolve from CHAINABIT_TOKEN before saved credentials.

A saved sign-in belongs to the API address it was created on. If --api-url or CHAINABIT_BASE_URL points to a different host, the saved credentials are not sent there; sign in on that host, or supply a token with CHAINABIT_TOKEN, which works with any API address. API addresses must use https; plain http is accepted only for localhost, loopback addresses such as 127.0.0.1, and ::1. auth login saves the API address it signed in against, and that address becomes the default for later commands until the next login or an override. Signing in or out clears the saved default workspace, so run workspace use again afterwards.

Workspace context resolves from an applicable command-specific override, then CHAINABIT_WORKSPACE_ID, then local configuration. Commands using an explicit positional workspace ID use that ID for their operation. ai --workspace is consumed by approvals and sharing/invitation commands; it is not a universal override for every child. workspace use saves a local choice, while workspace set-default changes the account default.

The CLI may retain configuration locally. Treat its configuration directory and any environment file as sensitive, and make them available only to your user account. A token does not grant new scopes when exchanged or select ownership automatically.

Output and exit behavior ​

--json chooses action-specific machine output; it is not a shared response schema. Lists usually print arrays, search and trigger listing preserve {data, meta}, token output contains a secret, and local show/reset/prune print JSON even without the option. ai rejects JSON for interactive chat; use chao --message for one-shot output.

Successful help/version output exits 0. Failures exit with the codes in Exit codes; cancelling a confirmation can still exit 0 without applying the action. Shared JSON errors go to stderr as an object containing error, with optional API code and statusCode, and exitCode; parser/top-level errors can remain human text. Connector execution can print a failed tool result on stdout before exiting 1. Chat interruption can detach with exit 130. Always inspect the operation result and run status.

Text received from the API or from a marketplace is shown with terminal control characters removed. --json output is unchanged.

--ui accepts auto, tui and plain, defaulting to auto. Managed TUI requires interactive stdin/stdout and cursor support. Plain mode uses line input. --no-splash changes presentation, not authentication, authority or billing.

Exit codes ​

The CLI exits with a code that names the class of failure, so a script can react without parsing messages.

CodeMeaning
0Success, including help and version output.
1Unclassified failure.
2Usage: the parser or the server rejected a flag or argument.
3Authentication: no credential is available, or the server answered HTTP 401.
4Permission: the server answered HTTP 403, or an API key policy refused the request.
5Quota: credits, a spending limit, a quota or a rate limit stopped the request.
6Network: the connection or name lookup failed, a deadline passed, or a redirect was refused.
130Interrupted.

Authentication and permissions ​

Use a signed-in session or a token whose scopes permit the operation. The server checks resource access and account or workspace authority; selecting a workspace does not grant membership or override those checks. For an authentication or permission refusal, check the resolved identity and the destination access before retrying.

Command groups ​

A command group prints help when no subcommand is selected and has no action of its own, so help does not require login. Review the subcommand before running it: reading, mutation, sharing, installation and credit-consuming work have different effects. A parent's options may be accepted syntactically, but each subcommand uses only the context described on its own page.

Safety and billing ​

Most commands do not request AI inference and have no fixed credit price. Commands that start AI work consume wallet credits, and their pages say so. --json is an output format, not a dry run, a spending limit or a confirmation.

Idempotent mutation helpers keep one operation identity through their automatic retries; a separate invocation creates a new identity, and the CLI has no idempotency flag. A timeout is not proof that a mutation failed. Inspect the resource before repeating a destructive or paid operation.

Examples ​

Examples are literal CLI invocations. Replace example IDs and paths with your own records; sample UUIDs are illustrative, not seeded resources. Review the effect of destructive, sharing or paid operations before running them.

bash
chainabit --version
chainabit --json workspace list

Built with purpose. chainabit.com