CLI local runtime and configuration
The CLI gives a project a repeatable way to define, start, inspect, query, stop, and remove local Helix instances. It joins project configuration with a container runtime, local or object storage, network endpoints, and clear recovery messages. See CLI and operations for the command map and CLI command workflows for user-facing flows.
Project configuration
The project model is the source of truth for local instance identity and its normal run settings. The CLI finds helix.toml from the current directory upward, loads it with the project name and instance maps, then uses the selected local entry to drive runtime actions (crates/…/project.rs• L6-45, crates/…/config.rs• L519-697).
The configuration keeps local instance settings separate from Cloud instance links. A new local project starts with a dev instance, port 6969, the published Helix image at tag v0.0.16, and in-memory storage (crates/…/config.rs• L8-18, crates/…/config.rs• L681-695). Each local instance can also select a pull policy. This lets a run use an existing image, always refresh it, or refuse a missing image (crates/…/config.rs• L124-137, crates/…/local_runtime.rs• L341-388).
| Setting | Purpose |
|---|---|
project.name | Names the project and helps name runtime resources. |
project.queries | Sets the project query directory. It defaults to db. |
project.container_runtime | Selects Docker or Podman. Docker is the default. |
local.<name>.port | Sets the host port for the local gateway. |
local.<name>.image, tag, and pull | Select the Helix image and its refresh policy. |
local.<name>.storage | Selects memory, local disk, or S3 storage. |
local.<name>.s3 | Describes the bucket, prefix, region, endpoint, and HTTP allowance for S3 mode. |
Configuration validation prevents a project from starting with an empty name or instance set. Instance names must be at most 32 characters and use only ASCII letters, digits, -, or _; this keeps one naming rule for configuration, command input, and local state paths (crates/…/config.rs• L20-66, crates/…/config.rs• L557-645). It also requires a complete S3 block only when the instance uses S3 storage and rejects an S3 block in other storage modes. S3 endpoints must start with http:// or https:// (crates/…/config.rs• L188-243, crates/…/config.rs• L597-641). Unknown TOML fields are rejected, so stale settings fail early instead of being ignored (crates/…/config.rs• L68-90).
References: crates/…/config.rs• L8-18 crates/…/config.rs• L20-66 crates/…/config.rs• L68-186 crates/…/config.rs• L188-243 crates/…/config.rs• L519-697 crates/…/project.rs• L12-45 crates/…/local_runtime.rs• L341-388
Local runtime lifecycle
The local runtime turns one configured instance into a named container and waits for its HTTP health endpoint before reporting success. It checks the selected Docker or Podman runtime, resolves all required images before replacing a running instance, prepares storage resources, and runs Helix from the resolved image ID (crates/…/local_runtime.rs• L188-210, crates/…/local_runtime.rs• L341-365, crates/…/local_runtime.rs• L407-439). Resolving the image ID first prevents a tag change during startup from changing the image used for the run.
The normal start path runs in the background and gives the container an unless-stopped restart policy. The --foreground path attaches the terminal and removes the temporary container and disk helpers when the process exits or receives Ctrl-C (crates/…/local_runtime.rs• L407-502). The command can apply a port or storage override for one run. --persist writes the resolved settings back to helix.toml (crates/…/start.rs• L8-65).
This diagram shows the common local start path from project settings to a query-ready instance.
flowchart TD
A[Find helix.toml] --> B[Select local instance]
B --> C[Apply run overrides]
C --> D[Check container runtime]
D --> E[Resolve Helix image]
E --> F{Storage mode}
F -->|Memory| G[Start Helix container]
F -->|Disk| H[Start SeaweedFS resources]
F -->|S3| I[Prepare S3 settings]
H --> G
I --> G
G --> J[Probe /healthz]
J --> K[Report ready instance]
The runtime names the main container from the project and instance identity. Safe names keep the familiar helix-<project>-<instance> form; names that need sanitizing receive a hash suffix so different identities do not collide (crates/…/local_runtime.rs• L287-333, crates/…/local_runtime.rs• L1932-1969). Disk mode adds a SeaweedFS container, private network, and persistent data volume. S3-backed modes also get a persistent local cache volume (crates/…/local_runtime.rs• L875-910, crates/…/local_runtime.rs• L913-967). Stop removes containers and networks but keeps data volumes. Prune removes the data and cache volumes as well. S3 mode never deletes remote data (crates/…/local_runtime.rs• L504-510, crates/…/local_runtime.rs• L621-627, crates/…/local_runtime.rs• L1051-1065).
Restart preserves the existing container and checks the port that the runtime actually published before waiting for readiness. This allows the runtime's current binding to remain the source of truth after a restart (crates/…/local_runtime.rs• L512-540).
References: crates/…/local_runtime.rs• L188-210 crates/…/local_runtime.rs• L287-365 crates/…/local_runtime.rs• L407-540 crates/…/local_runtime.rs• L621-627 crates/…/local_runtime.rs• L875-967 crates/…/local_runtime.rs• L1051-1065 crates/…/local_runtime.rs• L1932-1969 crates/…/start.rs• L8-65
Endpoint and port resolution
The local gateway is exposed on the host at the configured port and maps to port 8080 inside the Helix container. The default host port is 6969, and a start-time port override changes the current run without changing the file unless --persist is used (crates/…/config.rs• L8-10, crates/…/config.rs• L124-131, crates/…/local_runtime.rs• L19-20, crates/…/local_runtime.rs• L1589-1617).
Queries to a named local instance use http://localhost:<configured-port>/v2/query by default. Query flags can replace the host and port for local targets. The CLI does not apply these local connection overrides to Cloud targets (crates/…/query.rs• L52-125). Runtime inspection can recover the published host port for status, restart, and local UI launch (crates/…/local_runtime.rs• L640-675, crates/…/local_runtime.rs• L853-863).
The CLI provides a bounded port probe for callers that need to choose a host port. When a requested port is busy, the probe searches upward for the first available port within at most 100 ports and reports an error when no port is found. The probe does not reserve the result, so a later process can still claim it before the runtime binds it (crates/…/port.rs• L7-19, crates/…/port.rs• L40-64).
The runtime waits up to 30 seconds for a successful HTTP/1.0 or HTTP/1.1 response from /healthz. A failed readiness check points the user to logs and the selected port (crates/…/local_runtime.rs• L1129-1171).
References: crates/…/config.rs• L8-10 crates/…/config.rs• L124-137 crates/…/port.rs• L7-64 crates/…/local_runtime.rs• L19-20 crates/…/local_runtime.rs• L512-540 crates/…/local_runtime.rs• L640-675 crates/…/local_runtime.rs• L853-863 crates/…/local_runtime.rs• L1129-1171 crates/…/query.rs• L52-125
Storage modes
Storage mode controls whether data survives local runtime replacement. Memory mode is simple and temporary. Disk mode uses local SeaweedFS as an S3-compatible store with a persistent data volume. S3 mode connects the container to a configured remote bucket or S3-compatible service and keeps a local cache volume (crates/…/config.rs• L124-186, crates/…/local_runtime.rs• L165-177, crates/…/local_runtime.rs• L875-910).
| Mode | Data location | Stop or restart | Prune |
|---|---|---|---|
| Memory | Container memory | Data is lost. | Removes the container. |
| Disk | Local SeaweedFS data volume | Data is preserved. | Removes the container, network, data volume, and cache volume. |
| S3 | Configured remote bucket and prefix, with a local cache | Remote data is preserved. | Does not delete remote data. |
Disk mode starts SeaweedFS on a private instance network. It creates the helix-db bucket under the db/ path and waits for a signed bucket probe before starting Helix (crates/…/local_runtime.rs• L924-967, crates/…/local_runtime.rs• L1741-1817). The data volume remains through stop and restart. Older MinIO resources are recognized for cleanup and migration warning, but their data is not mounted into the new SeaweedFS store (crates/…/local_runtime.rs• L145-156, crates/…/local_runtime.rs• L929-947).
S3 mode normalizes the prefix to a non-empty trailing-slash path. It requires an http:// or https:// endpoint when one is supplied and can pass selected host AWS credentials and region variables into the container. HTTP endpoints enable the service's HTTP allowance (crates/…/config.rs• L188-243, crates/…/local_runtime.rs• L1838-1870).
References: crates/…/config.rs• L124-186 crates/…/config.rs• L188-243 crates/…/local_runtime.rs• L145-177 crates/…/local_runtime.rs• L875-910 crates/…/local_runtime.rs• L924-967 crates/…/local_runtime.rs• L1051-1065 crates/…/local_runtime.rs• L1741-1870 crates/…/start.rs• L100-125
Explorer runtime
The Explorer is a separate local container that provides a browser UI for one running instance. Its default image is ghcr.io/helixdb/helix-explorer:v0.1.0. It uses a loopback-only host port and reaches the Helix gateway through the container host, so it does not change the instance's own endpoint (crates/…/config.rs• L11-16, crates/…/local_runtime.rs• L103-122, crates/…/local_runtime.rs• L630-723, crates/…/local_runtime.rs• L1657-1693).
The runtime marks Explorer containers with the instance identity and Explorer role. It reuses or removes only a container with matching marks; a conflicting container name is left untouched and produces a recovery hint. Explorer containers remove themselves when they stop (crates/…/local_runtime.rs• L684-735, crates/…/local_runtime.rs• L1733-1739). Docker uses host.docker.internal; Podman uses host.containers.internal (crates/…/local_runtime.rs• L1641-1655).
References: crates/…/config.rs• L11-16 crates/…/local_runtime.rs• L19-31 crates/…/local_runtime.rs• L103-122 crates/…/local_runtime.rs• L630-723 crates/…/local_runtime.rs• L1641-1693 crates/…/local_runtime.rs• L1733-1739
Filesystem paths and persisted state
The CLI uses two path scopes. Project state belongs beside the project configuration. User-wide CLI state belongs under the Helix home directory, while disposable cache data can use a separate cache directory (crates/…/paths.rs• L1-14).
| Path or source | Role |
|---|---|
| <project>/helix.toml | Persistent project and instance configuration. |
<project>/.helix/<instance> | Per-instance workspace and warning markers. |
| <project>/.env | Optional project environment values loaded by start and restart. |
HELIX_HOME | Overrides the directory for user-wide Helix state. |
~/.helix | Default user-wide Helix state directory. |
HELIX_CACHE_DIR | Overrides disposable CLI cache storage. |
HELIX_CACHE_DIR fallback | The resolved Helix home directory. |
init creates the project directory and its .helix directory. It also adds .helix/, .env, target/, and *.log to .gitignore when they are missing (crates/…/init.rs• L19-43, crates/…/init.rs• L307-330). The project loader searches upward from the current directory, so commands work from nested project folders (crates/…/project.rs• L26-45, crates/…/project.rs• L62-78).
The user home uses HOME on Unix and USERPROFILE on Windows before the operating system home lookup. An empty override is treated as unset. If no usable home exists, the CLI returns an actionable path error (crates/…/paths.rs• L19-80).
References: crates/…/paths.rs• L1-80 crates/…/project.rs• L26-59 crates/…/init.rs• L19-43 crates/…/init.rs• L307-330 crates/…/start.rs• L16-18 crates/…/restart.rs• L8-18
External tools and service endpoints
The CLI treats container runtimes, Node tools, and agent tools as host services. It checks for the required command before use and builds subprocesses through one tool map so commands work across Unix and Windows (crates/…/external_tools.rs• L14-83, crates/…/utils.rs• L8-75).
Local start needs Docker or Podman. Docker is preferred when both are installed. If the selected daemon is down, a start action tries a known platform launcher and polls for up to 120 seconds. macOS Docker startup follows the active endpoint when it proves Colima, Docker Desktop, or OrbStack; an unknown endpoint receives neutral advice instead of starting the wrong backend. Podman on macOS can start its machine, while Linux Podman has no daemon launcher (crates/…/local_runtime.rs• L188-281, crates/…/local_runtime.rs• L1402-1530). Setup warnings use a short bounded probe instead, so init and chef do not wait for a daemon (crates/…/setup.rs• L178-213, crates/…/local_runtime.rs• L212-221).
Project tooling can use npx to install Helix agent skills and the Helix docs MCP. Interactive setup can ask before installing. Missing npx or a failed tooling install produces a warning and does not undo the project scaffold (crates/…/init.rs• L146-177). The CLI also checks installed skills without running a mutating skills command, then caches that result for 24 hours (crates/…/update.rs• L195-243, crates/…/update.rs• L286-342).
Cloud and release requests use public service endpoints by default. CLOUD_AUTHORITY can change the Cloud authority, while HELIX_TEST_HTTP_BASE_URL routes Cloud and GitHub requests to an isolated test service (crates/…/service_endpoints.rs• L7-65).
References: crates/…/external_tools.rs• L12-107 crates/…/utils.rs• L8-75 crates/…/setup.rs• L96-213 crates/…/local_runtime.rs• L188-281 crates/…/local_runtime.rs• L1402-1587 crates/…/init.rs• L146-177 crates/…/update.rs• L195-243 crates/…/update.rs• L286-342 crates/…/service_endpoints.rs• L7-65
Update behavior
The CLI performs a background release check before normal command dispatch, unless an update opt-out variable is present. The check uses a 24-hour cache under the Helix home directory and ignores network failure so an unavailable release service does not block command use (crates/…/update.rs• L11-24, crates/…/update.rs• L50-187).
The explicit update command installs the latest GitHub release or the fixed v1-compatible target when --v1 is used. --force reinstalls even when the target version matches. A move from a pre-v3 CLI to v3 displays a breaking-change warning, and a successful update asks the user to restart the terminal (crates/…/update.rs• L12-110, crates/…/update.rs• L147-177).
When global Helix skills are already installed and npx is available, helix update refreshes them after the binary update. A skills refresh failure becomes a warning and does not fail the CLI update (crates/…/update.rs• L113-128).
References: crates/…/update.rs• L11-24 crates/…/update.rs• L50-187 crates/…/update.rs• L12-128 crates/…/update.rs• L147-177
Command error handling
Command errors preserve a short message and can add a file path, cause, context, or recovery hint. The top-level process renders known configuration, project, port, and CLI errors in this format and exits with status 1. Other errors use their plain report text (crates/…/errors.rs• L31-151, crates/…/main.rs• L738-755).
Local runtime failures identify the failed operation. Runtime availability errors distinguish a missing executable from a present but unusable executable. A missing Docker binary can suggest Podman when it is installed. A stopped daemon includes a launcher or a neutral check command that matches the selected runtime and active backend (crates/…/local_runtime.rs• L542-575, crates/…/local_runtime.rs• L1328-1380, crates/…/local_runtime.rs• L1540-1587). Other recovery paths include checking instance logs, checking the selected port, or using a different configured runtime.
Query connection failures name the instance and endpoint and point to helix start and helix status. Query input errors stop before network work when no input, multiple inputs, an invalid request type, or an invalid use of local-only flags is found (crates/…/query.rs• L61-124, crates/…/query.rs• L181-250).
Output verbosity changes what the user sees but not the command result. Normal mode shows key progress, quiet mode keeps errors and final results, and verbose mode adds sub-steps and timing (crates/…/output.rs• L1-9, crates/…/output.rs• L36-93).
References: crates/…/errors.rs• L31-151 crates/…/errors.rs• L239-376 crates/…/main.rs• L738-755 crates/…/local_runtime.rs• L542-575 crates/…/local_runtime.rs• L601-615 crates/…/local_runtime.rs• L1129-1142 crates/…/local_runtime.rs• L1328-1380 crates/…/local_runtime.rs• L1540-1587 crates/…/query.rs• L181-250 crates/…/output.rs• L36-93
Change checklist
When these files or sections are changed, remember to consider these:
- Update the configuration defaults, validation rules, and
start/addoverride paths together when a local setting changes. - Keep the host port shown by status, start details, restart inspection, Explorer launch, and query resolution aligned with the container's fixed internal gateway port.
- Keep image pull policy and image-ID resolution aligned with the replacement order so a failed dependency pull does not remove a working instance.
- Keep disk cleanup semantics aligned between stop, restart, prune, the SeaweedFS migration warning, and the storage warning shown at start.
- Keep
HELIX_HOMEandHELIX_CACHE_DIRbehavior aligned with every user-wide cache or persisted state file. - Keep external tool lookup and subprocess creation aligned when adding a tool, especially for Windows script names.
- Keep runtime backend detection, auto-start launchers, and unavailable-runtime hints aligned when changing Docker or Podman support.
- Keep update notices, update caches, and the explicit update command aligned when changing release or skills update behavior.
- Preserve the error conversion path when adding a new typed error so users receive context and a recovery hint.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Selected Docker or Podman is not installed | Local start cannot create the instance. | Check runtime availability and use the suggested alternate runtime or install path. |
| Runtime daemon is installed but stopped | Startup tries the detected launcher, then fails if the selected endpoint is still unavailable. | Start the selected backend and retry. |
| Docker uses an unknown or unresolved macOS endpoint | The CLI does not start a possibly wrong backend. | Check docker info and the active Docker context or host. |
| Requested local port and the next bounded candidates are busy | The instance cannot be assigned a host endpoint. | Free a port or select another port. |
| Local health endpoint does not return a 2xx response within 30 seconds | Start fails even if the container command succeeded. | Inspect logs and verify the host port. |
| SeaweedFS bucket does not become ready within 60 seconds | Disk-mode start stops before Helix starts. | Check the SeaweedFS sidecar logs and the runtime daemon. |
| S3 storage lacks a valid bucket, prefix, region, or endpoint scheme | Configuration is rejected before runtime launch. | Complete the S3 block and use an http:// or https:// endpoint. |
| Memory storage is stopped or restarted | Local data is lost with the container. | Use disk or S3 storage when data must survive a restart. |
| A container name is held by an unrelated container | The runtime refuses to replace or remove that resource. | Rename the conflicting container, then retry. |
| Project configuration is missing from the current path and its parents | Project commands cannot resolve an instance. | Run from a project tree or provide a path where supported. |
npx tooling setup fails | Skills or docs MCP are not installed, but the project remains usable. | Install Node.js/npm and run the tooling command again. |
Key files
| File | Why to read it |
|---|---|
| crates/…/config.rs | Defines project, local instance, storage, image, name, and S3 configuration rules. |
| crates/…/project.rs | Shows project discovery and per-instance workspace paths. |
| crates/…/local_runtime.rs | Describes runtime checks, image resolution, container lifecycle, readiness, storage helpers, and Explorer launch. |
| crates/…/start.rs | Connects user start options to temporary or persisted local settings. |
| crates/…/port.rs | Defines bounded host port probing. |
| crates/…/paths.rs | Defines project-independent Helix home and cache resolution. |
| crates/…/external_tools.rs | Defines host tool lookup and subprocess selection. |
| crates/…/update.rs | Defines background release and skills freshness checks. |
| crates/…/update.rs | Defines explicit CLI update and skills refresh behavior. |
| crates/…/errors.rs | Defines typed CLI error rendering and recovery context. |
| crates/…/query.rs | Shows local endpoint selection and connection failure guidance. |