Context
A context is a named connection profile stored locally on disk. Contexts let you switch between multiple Chronicle servers — development, staging, production — without retyping connection strings on every command.
Configuration File
Section titled “Configuration File”All contexts are stored in ~/.cratis/config.json. The CLI creates this file automatically when you create your first context. You can inspect its location with cratis context path.
Connection Resolution Order
Section titled “Connection Resolution Order”When the CLI resolves which server to connect to, it checks in this order:
--serverflag on the current commandCHRONICLE_CONNECTION_STRINGenvironment variable- Active context in
~/.cratis/config.json - Default:
chronicle://localhost:35000/?disableTls=true
Commands
Section titled “Commands”Lists all configured contexts. The active context is marked with an asterisk.
cratis context listUse --output plain for scripting — it emits tab-separated rows without decorations:
cratis context list -o plainExample output:
* dev chronicle://localhost:35000/?disableTls=true prod chronicle://prod.example.com:35000/create
Section titled “create”Creates a new named context. The first context you create automatically becomes the active context.
cratis context create <NAME> --server <CONNECTION_STRING>Options:
| Option | Short | Description |
|---|---|---|
--server | Chronicle server connection string | |
--event-store | -e | Default event store for this context (default: default) |
--namespace | -n | Default namespace for this context (default: Default) |
Example — local development server with TLS disabled:
cratis context create dev --server chronicle://localhost:35000/?disableTls=trueExample — staging server with a specific event store and namespace:
cratis context create staging \ --server chronicle://staging.example.com:35000/ \ --event-store orders \ --namespace ProductionSwitches to a named context, making it the active context for all subsequent commands.
cratis context set <NAME>The command validates that the named context exists before activating it. If the name does not match any stored context, it reports an error.
Example:
cratis context set prodDisplays the details of the currently active context: server address, event store, namespace, and credentials status.
cratis context showUse --output json for machine-readable key-value output:
cratis context show -o jsonExample output (plain):
Server: chronicle://localhost:35000/?disableTls=trueEvent store: defaultNamespace: DefaultClient ID: (not set)delete
Section titled “delete”Removes a named context from the configuration file.
cratis context delete <NAME>You cannot delete the active context or the built-in default context. Switch to a different context first, then delete the one you no longer need:
cratis context set devcratis context delete stagingrename
Section titled “rename”Renames an existing context. If you rename the active context, the CLI updates the active context reference automatically so you remain connected.
cratis context rename <OLD_NAME> <NEW_NAME>Example:
cratis context rename dev localPrints the absolute path to the configuration file. Useful for inspecting, backing up, or diffing the config:
cratis context pathExample output:
/Users/alice/.cratis/config.jsonset-value
Section titled “set-value”Sets an individual value on the current context without replacing the entire context.
cratis context set-value <KEY> <VALUE>Valid keys:
| Key | Description |
|---|---|
server | Chronicle server connection string |
event-store | Default event store name |
namespace | Default namespace name |
client-id | OAuth client ID for authenticated servers |
client-secret | OAuth client secret (masked in output) |
management-port | HTTP management port (default: 8080) |
Example — update the server URL:
cratis context set-value server chronicle://localhost:35000/?disableTls=trueExample — set credentials for an authenticated server:
cratis context set-value client-id my-appcratis context set-value client-secret s3cr3tThe client secret is stored in the config file and masked whenever the CLI displays context details.