CLI workflows
Bruin is a command-line application for creating, checking, running, and inspecting data pipelines. It gives an engineer one path from project setup through local validation and execution. It also provides access to data services and Bruin Cloud operations.
Command hierarchy
The CLI uses bruin as its root command. Direct commands handle one main task. Command families group related work under a shared resource or service. Most workflows use a project, pipeline, or asset path and resolve environments and connections from project configuration.
Root command
The root command provides shared application behavior and registers commands for project work, pipeline checks and runs, semantic model checks, data access, service setup, imports, backfills, authentication, and Cloud interaction. Commands that support automation can return JSON. A hidden internal family exposes structured pipeline and service information to editor and automation tools.
References: main.go• L51-94 cmd/internal.go• L40-63 cmd/semantic.go• L24-34
Command families
Command families let an engineer choose the resource first and the action second. This keeps local pipeline work and remote service work under a consistent command shape.
| Family or command group | User goal | Examples |
|---|---|---|
| Project and asset work | Create or change pipeline content | init, format, patch, docs |
| Pipeline checks and runs | Check definitions or execute tasks | validate, unit-test, run, backfill |
| Semantic model work | Check shared business definitions and quality rules | semantic validate, semantic check |
| Inspection and comparison | See rendered work or data relationships | render, render-ddl, lineage, query, data-diff |
| Local service setup | Select environments and manage connections | environments, connections, ingestr-uri |
| External system exchange | Bring service definitions into a pipeline | import, curl |
| Cloud authentication | Sign in to, inspect, or remove Cloud access | cloud login, cloud auth status, cloud logout, cloud act-as |
| Managed operations | Read and control Bruin Cloud resources | cloud |
| Tool-facing access | Expose structured pipeline state to tools | internal, mcp, ai |
The command families and operational workflows page explains these groups in more detail.
References: main.go• L65-92 cmd/cloud.go• L31-62 cmd/auth.go• L16-38 cmd/auth.go• L41-156 cmd/cloud_act_as.go• L31-53 cmd/cloud_auth.go• L26-79 cmd/login_test.go• L24-50
Tool-facing commands
The hidden internal family gives tools a machine-readable view of pipeline state. It supports parsing, variant and service discovery, connection and template schemas, controlled asset or pipeline changes, database object discovery, asset metadata, and Python dependency locking. It can also prepare local execution support by installing DuckDB drivers.
References: cmd/internal.go• L40-63 cmd/internal.go• L66-170 cmd/internal.go• L234-337 cmd/internal.go• L766-869 cmd/internal.go• L937-1341 cmd/internal.go• L1380-1435 cmd/internal.go• L1459-1565 cmd/internal.go• L1568-1622 cmd/internal.go• L1639-1709 cmd/internal.go• L1712-1728 cmd/internal.go• L1731-1804
Workflow stages
The CLI coordinates a common flow from project creation to observed execution. An engineer can start at any stage when the project and its configuration already exist.
This diagram shows how setup, local inspection, checks, execution, recovery, service review, semantic checks, and Cloud access connect.
flowchart LR
A[Create project] --> B[Develop and inspect]
B --> C[Validate]
C --> D[Run pipeline]
D --> E[Review results]
B --> F[Configure environments and connections]
F --> C
F --> D
B --> G[Validate semantic models]
G --> H[Run quality checks]
D --> I[Resume or inspect backfill]
D <--> J[Use Bruin Cloud]
Project creation
The init workflow turns a selected template into a usable Bruin project. It creates pipeline content and places .bruin.yml at the project or Git repository root. The project initialization and templates page covers the generated project in more detail.
init supports three entry modes:
- New-project mode creates a
bruinroot when the current directory is not already a Git repository. - In-place mode writes the template into the current directory.
- Merge mode adds template content to an existing pipeline without replacing its files.
Merge mode checks the destination and file conflicts before it changes the project. It keeps existing assets and configuration. It merges supported template connections into the central configuration. A conflict leaves the project unchanged, and a failed copy removes files created by that copy.
Templates can provide assets, variables, macros, connection mappings, and support files. AI-assisted setup is separate from pipeline creation. skills init installs selected skills and can ask before adding missing placeholder connections to .bruin.yml.
References: cmd/init.go• L174-205 cmd/init.go• L208-249 cmd/init.go• L259-317 cmd/init.go• L516-663 cmd/init.go• L665-855 cmd/ai_connections.go• L45-89 cmd/skills.go• L260-306 cmd/init_merge_test.go• L58-163 cmd/init_template_test.go• L22-69
Local development
Local development uses focused commands to inspect or adjust one part of a pipeline before a full run. render shows the query an asset would use after dates, variables, macros, variants, environment settings, and materialization rules are applied. render-ddl shows the schema definition that an asset would produce.
For a BigQuery Iceberg asset with no storage location of its own, render can use the selected Google Cloud connection to complete the location. This keeps local inspection aligned with the later run.
The main local choices are:
- Use
formatto keep asset definitions consistent. - Use
renderorrender-ddlto inspect generated work. - Use
queryfor direct SQL, an asset query, or a semantic query. - Use
lineageto understand declared asset relationships. - Use
unit-testto check SQL assets against expected results. - Use
data-diffto compare tables or environments before a change. - Use
patchto repair or fill asset and pipeline metadata. - Use
cleanto remove local run log artifacts.
query supports direct SQL, asset rendering, semantic model queries, and Cloud-agent execution. Local results can use plain text, JSON, or CSV. Cloud query mode sends direct SQL through a Cloud connection set and does not use local template variables or semantic query features.
Query variables support flat keys, dot-notation nested values, and JSON object or array values. They are rendered into local query templates as strings or structured values. Repeated object assignments merge their fields, while a later scalar replaces an earlier object. A selected pipeline variant keeps control of variables that it defines.
When the connection supports row streaming, query sends rows to the selected output as they arrive. Large plain results change to CSV output instead of keeping the full result in memory. Export mode writes CSV files under logs/exports and can split them by row count. The command also records each query under logs/queries; a query-log problem warns the user but does not fail the query. A failed export removes the partial files.
References: cmd/render.go• L55-100 cmd/render.go• L101-235 cmd/render.go• L267-370 cmd/render.go• L396-410 cmd/render.go• L461-518 cmd/const.go• L56-76 cmd/const.go• L142-176 cmd/const.go• L217-242 cmd/fetch.go• L56-197 cmd/fetch.go• L240-360 cmd/fetch.go• L428-589 cmd/fetch.go• L591-669 cmd/fetch.go• L2148-2242 cmd/query_stream.go• L19-75 cmd/query_stream.go• L78-101 cmd/query_stream.go• L165-225 cmd/query_stream.go• L227-312 cmd/query_stream.go• L314-401 cmd/query_stream_test.go• L50-200 cmd/query_stream_test.go• L203-355 cmd/query_log_test.go• L61-118 cmd/clean.go• L23-165 cmd/datadiff.go• L155-240 cmd/render_bigquery_test.go• L11-47
Validation and execution
Validation is the safety step before execution. validate loads the selected project or asset and reports definition and rule findings in human or JSON form. It can use the same environment, variables, variant, refresh mode, and selected paths as the run that follows.
For a directory of pipelines, an explicit variant applies that variant to each selected pipeline. Without an explicit variant, validation expands pipelines that declare variants while keeping non-variant pipelines in the same validation. Asset-only validation uses asset and cross-pipeline rules and does not support --exclude-tag.
The run workflow executes selected assets with the resolved dates, variables, environment, and variant. It can target one asset, downstream work, modified work, or a wider selection. It also applies concurrency, checks, logs, sensors, and cancellation rules. Production-like environments need confirmation unless the caller uses the force control.
Inference assets and ingestr assets without an explicit destination use the type of their write connection to resolve their destination. Their checks then use the executor for that destination, so validation and execution stay aligned with the service that receives the inferred data.
An optional connection override gives a single-asset run a different service connection without changing the asset definition. The asset and its checks use the selected connection while keeping the asset's expected secret names. A continued run keeps the connection used when the run started.
The usual sequence is:
- Render or unit-test the asset.
- Validate the pipeline with the intended environment and variant.
- Run the target or selected asset set.
- Review the result, checks, logs, and downstream effects.
An interrupted run saves state for run --continue. Streaming execution is a separate foreground mode for one streaming asset and runs only its main task until interruption. Normal batch runs skip streaming assets. Run logs and state use ignored paths and mask credentials by default.
This diagram shows the shared context between validation and execution and the recovery path for an interrupted run.
flowchart LR
A[Project or asset path] --> B[Load environment and connections]
B --> C[Materialize dates variables and variant]
C --> D[Validate selected work]
D --> E[Execute scheduled assets]
E --> F[Summary logs and checks]
E --> G[Saved run state]
G --> H[run --continue]
H --> D
The execution runtime page explains the execution path beyond the command workflow.
References: cmd/lint.go• L52-150 cmd/lint.go• L231-357 cmd/const.go• L187-215 cmd/run.go• L574-595 cmd/run.go• L597-741 cmd/run.go• L744-757 cmd/run.go• L986-1005 cmd/run.go• L1191-1393 cmd/run.go• L1429-1648 cmd/connection_override.go• L11-79 pkg/…/scheduler.go• L132-156 cmd/helpers.go• L40-75 cmd/run_stream_refresh_test.go• L13-64 cmd/run_inference_test.go• L19-51 cmd/run_test.go• L120-182 cmd/connection_override_test.go• L17-163 cmd/variable_schema_test.go• L15-62
Semantic model validation
The semantic family checks repository-level semantic models before or beside normal pipeline execution. A semantic model defines shared measures, dimensions, relationships, and quality rules. The CLI can check both the model definition and the data reached through its configured connection.
semantic validate checks model structure and compiled query definitions. semantic check runs quality rules and needs a usable connection. Both commands can select models, override a connection, select an environment, and return plain or JSON reports. The semantic layer page explains the model concepts in more detail.
References: cmd/semantic.go• L24-140 cmd/semantic.go• L173-241 cmd/semantic.go• L244-309 cmd/semantic.go• L311-387 cmd/semantic.go• L463-547 cmd/semantic_test.go• L22-69
Local backfills
A local backfill is a resumable execution over a date or time range. It divides the range into partitions, records each partition state, and starts child run operations with saved inputs. This lets a large historical load continue after failure without repeating successful partitions.
The first backfill command saves a plan and creates a backfill ID. A later --continue reuses that plan and can select failed, missing, or all recorded partitions. The workflow supports dry-run planning, text or JSON state, reverse order, retries, failure policies, bounded parallelism, and progress output. Ctrl+C stops active child runs and leaves state for recovery.
This diagram shows the relationship between the parent plan, partition state, and child runs.
flowchart LR
A[Date range and run options] --> B[Saved backfill plan]
B --> C[Partition state]
C --> D[Child run]
D --> E[Partition result and log]
E --> C
C --> F[Summary or resume command]
The backfill recovery workflows page explains the recovery path and state model. Local backfills are separate from Bruin Cloud backfills.
References: cmd/backfill.go• L29-85 cmd/backfill.go• L109-286 cmd/backfill.go• L289-333 cmd/backfill.go• L363-460 cmd/backfill_ui.go• L401-496 cmd/run.go• L744-757 cmd/helpers.go• L180-199
Database import
The import database workflow turns database structure into Bruin assets. It discovers schemas and tables from a configured connection, then writes new assets into a selected pipeline. A later import updates matching assets instead of creating duplicates.
Normal import creates source assets and can add column metadata. --ingestr creates runnable replication assets for a supported source and explicit destination. Other import families bring supported scheduled queries, tasks, dashboards, or SSIS tasks into the same asset model.
References: cmd/import.go• L44-171 cmd/import.go• L174-309 cmd/import.go• L317-486 cmd/import.go• L721-837 cmd/import_database_tui.go• L23-62 cmd/ingestr_uri.go• L16-81 cmd/import_ssis.go• L13-41 cmd/import_test.go• L1197-1314
Service interaction
Service workflows use .bruin.yml to select an environment and resolve named connections. An environment is a named configuration context. A connection is a service endpoint inside that context. environments manages contexts, while connections manages endpoints.
The CLI can add a connection from flags or an interactive wizard. query, import, data-diff, semantic checks, and run consume these names so service details stay in project configuration. ingestr-uri turns one configured connection into a temporary credential-bearing URI file and refuses to overwrite an existing path.
Service work also includes curl for rendered connection fields, Cloud-agent queries, and managed Cloud resources. The command families and operational workflows page gives the detailed command map.
References: cmd/environments.go• L16-27 cmd/environments.go• L68-118 cmd/connections.go• L22-33 cmd/connections.go• L36-211 cmd/connections.go• L300-415 cmd/connections_add_tui.go• L111-161 cmd/ingestr_uri.go• L16-81 cmd/fetch.go• L487-591
Cloud authentication
Cloud authentication supplies the credential used by Bruin Cloud commands. bruin cloud login uses an OAuth browser flow and saves the result in either a repository connection or the operating system credential store. Interactive login can ask where to save the credential. Non-interactive use must select --repo or --global, and --no-browser prints the authorization URL instead of opening a browser.
Repository login needs a Git repository and does not save a token to a Git-tracked .bruin.yml. It can create or update the repository's Cloud connection, including when the command runs from a nested directory or worktree. Global login can work outside a project. Existing credentials stay in place unless the user chooses to sign in again or passes --reauth.
cloud auth status reports the active source without printing its token. cloud logout removes either the repository or global login. It can revoke the selected token, and global logout also ends an active act-as session. Interactive logout can ask which scope to remove; non-interactive use must select --repo or --global.
Cloud access resolves in this order:
- An explicit
--api-keyorBRUIN_CLOUD_API_KEY. - An active
cloud act-assession. - A Bruin Cloud connection in the repository .bruin.yml.
- A global credential in the operating system store.
An act-as session lets the engineer run Cloud commands with one of the team's agent permissions. The session uses the person's global login to start and renew the agent token. It is tied to its team and Cloud API destination. cloud act-as --stop returns Cloud commands to the engineer's own login. An explicit API key or environment key still takes precedence over the session.
When an act-as request lacks an agent permission, interactive terminal use can offer a global reauthentication flow. JSON mode stays non-interactive and returns an actionable error instead. A Cloud permission refusal while acting as an agent identifies the active agent and tells the user to ask its owner to add the required permission rather than silently switching to the person's login. Global logout also ends the active act-as session.
References: cmd/login.go• L30-55 cmd/login.go• L171-331 cmd/login.go• L334-424 cmd/auth.go• L16-156 cmd/auth_test.go• L20-159 cmd/login_test.go• L70-172 cmd/login_test.go• L224-305 cmd/cloud_auth.go• L18-97 cmd/cloud_act_as.go• L31-221 cmd/helpers.go• L137-161 cmd/cloud_act_as_test.go• L139-180 cmd/cloud_act_as_test.go• L223-296 cmd/cloud_act_as_test.go• L328-376 cmd/cloud_act_as_test.go• L378-444
Bruin Cloud operations
The cloud family extends the CLI from local pipeline work to managed resources and remote run control. It can inspect and change teams, projects, pipelines, assets, runs, backfills, dashboards, connections, agents, scheduled agents, skills, semantic layers, data apps, and related service data.
Cloud project creation connects a Git repository to Bruin Cloud. GitHub repositories can use Bruin GitHub App access without a personal Git token. Other supported providers use a personal token. The provider can be inferred from a public provider URL or supplied explicitly for a self-hosted repository.
Cloud run review follows the service relationships. A project and pipeline identify a run. A run identifies its asset instances. An asset instance identifies its steps and checks. runs diagnose combines these levels with useful failure log lines. instances logs provides a focused path for one asset or step. runs trigger --split creates a managed Cloud backfill, which is separate from local backfill.
Scheduled-agent commands manage scheduled or explicitly triggered agent work. They also manage persistent run-state files. The separate pipeline-trigger family controls the pipeline that a scheduled agent reacts to after a successful run.
Cloud commands use plain output by default and can return JSON. A project ID is required when the account can see more than one project. A run can be named directly or resolved as the latest run for a selected project and pipeline. Split units and chunk sizes must form a valid pair before a managed backfill request is sent.
References: cmd/cloud.go• L31-62 cmd/cloud.go• L143-248 cmd/cloud.go• L334-469 cmd/cloud.go• L472-642 cmd/cloud.go• L1033-1165 cmd/cloud.go• L1218-1294 cmd/cloud.go• L1341-1668 cmd/cloud.go• L1671-1780 cmd/cloud_act_as.go• L31-53 cmd/cloud_pipeline_trigger_test.go• L17-140 cmd/cloud_test.go• L331-572 cmd/cloud_test.go• L577-705 cmd/cloud_act_as_test.go• L358-369
Data app workflows
Cloud data apps provide a managed way to build and share an interactive app backed by declared warehouse queries and HTTP requests. The cloud data-apps family separates app metadata and access settings from the local edit-and-push loop.
The guide workflow retrieves the current build guide for a coding agent. The other commands support the main lifecycle:
list,get, andsettingsshow available apps, app declarations, and team limits such as read-only queries or approved credential hosts.createmakes an empty app and can assign the agent whose connections run its queries. An app without an agent cannot run its queries.pullwrites the app HTML and manifests into a directory and records the app ID and version in .bruin-data-app.json.pushsaves the files or selected inputs back to Cloud. A directory push sends the files that exist there and uses the recorded version to detect concurrent edits.updatechanges app metadata such as its title or agent.deleteremoves the app.
This diagram shows the data app edit loop and its protection against overwriting newer Cloud content.
flowchart LR
A[Cloud data app] --> B[pull]
B --> C[HTML and JSON manifests]
C --> D[Local edits]
D --> E[push with saved version]
E --> F[New Cloud version]
E --> G[Version conflict]
G --> B
pull does not overwrite changed local files unless --force is used. Manifest formatting alone does not count as a change. push rejects invalid manifest shapes and can update only the inputs supplied. A version conflict should normally be resolved by pulling again and reapplying the local change; --force explicitly overwrites the newer Cloud version. Plain output is intended for people and JSON output is available for automation.
Data app commands use the same Cloud authentication and team selection as other runnable Cloud commands. Cloud API errors can add hints for data app version conflicts and unapproved credential domains.
References: cmd/cloud_data_apps.go• L20-55 cmd/cloud_data_apps.go• L94-201 cmd/cloud_data_apps.go• L205-399 cmd/cloud_data_apps.go• L402-480 cmd/cloud_data_apps.go• L483-615 cmd/cloud_data_apps.go• L617-708 cmd/cloud_data_apps_test.go• L76-284 cmd/cloud_data_apps_test.go• L287-337 cmd/cloud.go• L31-93 cmd/helpers.go• L136-173
Cloud team context
Cloud requests can target a team by its company prefix. An explicit --team or BRUIN_CLOUD_TEAM takes priority. The saved cloud.default_team value in the repository .bruin.yml is next. If neither is set, the API can resolve the team from the token.
An active act-as session is pinned to the team that issued its agent token. It cannot be combined with a different --team value until the session ends. It also cannot be used against a different Cloud API destination. These checks prevent a token for one team or Cloud service from being used to address another.
The cloud config set-team, get-team, and unset-team commands provide a persistent shortcut. Setting a team warns when the current token cannot list it, but the warning does not block saving. The setting updates the YAML in place and keeps unrelated environments and connections, including when configuration is also supplied through an environment source. cloud config manages local state and does not send a team header.
References: cmd/cloud.go• L64-91 cmd/cloud.go• L148-213 cmd/cloud.go• L334-469 cmd/cloud_auth.go• L82-92 cmd/cloud_act_as.go• L142-168 cmd/cloud_test.go• L152-328 cmd/cloud_act_as_test.go• L223-269
Cloud query interaction
The query command can send direct SQL through the Bruin Cloud query service when the selected connection uses Cloud routing. This mode lets local CLI workflows use a Cloud connection set while keeping the normal result, export, and query-log shape.
Cloud query mode needs a connection name, a positive connection-set ID, and a Cloud API key from the command context or a Bruin Cloud connection in .bruin.yml. It sends SQL without local template interpolation. Semantic query flags are not available in this mode, and a client-side limit can reduce the returned rows after the service response.
References: cmd/fetch.go• L494-589 cmd/fetch.go• L591-642 cmd/fetch_test.go• L249-431
Cloud agent interaction
The cloud family coordinates agent work as well as pipeline work. Engineers can manage agents, prompts, long-term memory, usage review, messages, threads, connections, connection sets, skills, and external MCP servers.
Agent connections can come from local .bruin.yml or explicit credentials. Local file-based credentials are converted to content before the Cloud request because the Cloud runner cannot read the local file. MCP updates preserve other configured integration kinds. Connection sets group services that an agent can use.
steer and stop control an active agent message. When no message ID is supplied, the CLI finds the active message in the selected thread. The IDs can come from the Cloud chat run context, but missing or non-positive IDs are rejected before a request is sent. The hidden request-connection command works only inside that context and surfaces a request for the user to add a service before the agent sends its message again.
These operations use the same Cloud authentication, team context, output modes, and resource checks as pipeline operations. A permission refusal while an act-as session is active is reported with the agent identity and the missing ability. The CLI does not switch to the person's login unless the person asks for that change. The separate cloud act-as workflow changes which agent permissions those requests use; it does not change the agent resources being managed.
References: cmd/cloud.go• L2555-3173 cmd/cloud.go• L3280-3632 cmd/cloud.go• L3841-4237 cmd/cloud.go• L4239-4883 cmd/cloud.go• L4885-5191 cmd/cloud_act_as.go• L31-221 cmd/helpers.go• L137-161 cmd/cloud_test.go• L707-1115 cmd/cloud_test.go• L1208-1270
Change checklist
When these files or sections are changed, remember to consider these:
- A new top-level command or Cloud family must remain registered at the root and be placed in the matching command-family page.
- Changes to hidden
internalcommands must preserve machine-readable output and tool-facing discovery contracts. - Changes to pipeline path discovery must remain compatible with setup, rendering, imports, validation, execution, backfills, lineage, and semantic queries.
- Changes to validation variant discovery must preserve explicit variant selection, expansion of mixed variant and non-variant pipelines, and asset-only rule limits.
- Changes to inference or ingestr destination loading must preserve destination inference from the selected write connection so checks use the correct service.
- Changes to query variable parsing must preserve flat, nested, and JSON values, merge behavior, literal scalar values, and variant precedence.
- Changes to render context must preserve environment schema prefixes, materialization rules, hook order, deferred row templates for inference assets, and BigQuery Iceberg storage settings.
- Changes to streamed query output or query logs must preserve plain, JSON, CSV, and export contracts, plus the rule that log failures do not fail queries.
- Changes to streamed export cleanup or row splitting must preserve complete CSV headers, row order, and removal of partial files after failure.
- Changes to .bruin.yml loading must preserve the difference between an explicit path, which must exist, and the default path, which setup commands may create.
- Changes to environments or connections affect local runs, queries, imports, comparisons, URI generation, semantic checks, Cloud credentials, and team lookup.
- Changes to Cloud login and logout must preserve repository versus global scope, interactive and non-interactive selection, tracked-config protection, token redaction, reauthentication behavior, revocation behavior, and act-as cleanup.
- Changes to Cloud authentication or team lookup must preserve explicit key, act-as session, repository credential, and global credential precedence, plus the distinction between local repository state and global credentials.
- Changes to act-as start, renewal, reauthentication, or stopping must preserve global-login use, team and API-destination pinning, API-key precedence, safe handling of concurrent session changes, and fallback to the person's login.
- Changes to act-as permission errors must preserve actionable agent identity and missing-permission hints without silently switching credentials.
- Changes to
cloud configmust update only the default team and must not clobber existing environments or connections. - Changes to Cloud project creation must keep GitHub App access, personal-token access, provider inference, and branch defaults aligned.
- Changes to Cloud run or instance response handling must preserve the links used for diagnosis, status updates, and log lookup.
- Changes to agent connection or MCP updates must preserve unrelated connections because some service updates replace a complete set.
- Changes to data app pull and push must preserve the local app ID and version state, changed-file protection, manifest validation, partial-input updates, and explicit force behavior.
- Changes to data app API error handling must preserve actionable hints for version conflicts and unapproved credential domains.
- Changes to shared output helpers must keep standard output machine-readable for scripts and editor tools.
- Changes to production-environment checks must preserve confirmation for writes and the no-confirmation path for checks.
- Changes to run connection overrides must preserve single-asset scope, connection-type checks, secret-name mapping, inferred destinations, and the saved connection used by
run --continue. - Changes to internal dependency locking must preserve direct file input, Python asset discovery, supported Python versions, and the correct lock action for each dependency file type.
- Changes to internal DuckDB driver setup must preserve its machine-facing registration and non-zero failure exit.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| A target path is not inside a discoverable pipeline | The CLI cannot load the project or asset | Pass a project, pipeline, or asset path that resolves to a supported pipeline |
| A run receives no variant for a variant pipeline | Run setup stops before execution | Inspect declared variants and pass one supported --variant |
| A directory validation has mixed variant pipelines and bypasses variant expansion | Some declared variants are not checked | Let validation expand variant pipelines when no single variant is selected |
| A query mixes direct SQL, asset, semantic, or Cloud-only modes | Query setup stops before execution | Select one supported query mode and its required flags |
| A query variable is not in key-value form or conflicts with a scalar parent | Query or render setup stops before execution | Use valid flat or dot-notation keys and do not nest below a scalar |
| A selected variant and query variable define the same pipeline variable | The variant value remains in force | Treat variant-owned variables as fixed for that run |
--stream is used without one streaming asset or with an incompatible run mode | The run stops before execution | Target one streaming CDC or broker asset and omit batch-only selection controls |
| A production-like environment is selected without force or confirmation | A write operation stops before changing data | Confirm the prompt or use force only for an approved operation |
| A single-asset connection override is used for a pipeline or multiple assets | The run stops before execution | Use the override only with one asset |
| A continued run uses a different override from the one saved in its state | The run refuses to continue on a different service | Continue with the saved connection or start a new run |
| A local backfill resumes with changed plan inputs | The command refuses to mix saved partition identities with new inputs | Resume the saved plan or start a new backfill |
| A streamed query output sink fails after rows are written | The command returns an error with partial output | Treat streamed output as a one-way result and use an export when a file is required |
| A streamed export fails after creating files | Partial CSV files are removed and the command fails | Check the export path and treat an unsuccessful export as having no usable output |
| A query log cannot be written or finalized | The query still runs but its log is missing and a warning is shown | Keep logs/queries writable and treat the log as observation, not query state |
| Cloud query mode lacks a connection-set ID or usable API key | The Cloud query cannot start | Provide the hidden runtime context or a valid Cloud key and connection set |
| A Cloud command has no usable API key | The Cloud request cannot start | Use an explicit key, environment key, active act-as session, repository login, or global login |
| Login or logout has no selected scope in a non-interactive terminal | The command stops without changing credentials | Pass --repo or --global explicitly |
| Repository login runs outside a Git repository | The repository credential cannot be located or saved | Run inside the repository or use --global |
| Repository login targets a Git-tracked .bruin.yml | The CLI refuses to save a token in tracked configuration | Stop tracking the file or use global login |
| An existing login is used without reauthentication | The existing credential remains and no new browser flow starts | Choose sign-in again or pass --reauth when replacement is intended |
| Token revocation fails during logout | The selected login is not removed | Fix Cloud access and retry; treat the credential as still active |
| An active act-as session is used with a different team or API destination | Cloud authentication stops before the request | Stop the session before changing team or Cloud destination |
| An act-as token expires and renewal is refused | The command reports that the agent session ended | Use the person's global login to start a new session or stop acting as the agent |
| An act-as permission refusal is handled as a reason to change credentials | A command may run with permissions the person did not request | Ask the agent owner to add the required ability or stop acting as the agent explicitly |
| A terminal act-as start lacks the required login permission | The command cannot create the agent session | Reauthenticate globally and allow acting as agents |
| A JSON act-as start lacks the required login permission | The command returns an error instead of opening a browser | Handle the error and run global reauthentication in a separate interactive step |
| A Cloud request needs a team but no team is in scope | The API rejects the request | Pass --team, set BRUIN_CLOUD_TEAM, or set a default team |
| Team setup rewrites the full config instead of updating its team field | Existing environments or connections can be lost | Keep the update limited to cloud.default_team |
A Cloud account can access several projects without --project-id | The CLI cannot identify the target project | List projects and pass the required project ID |
| A Cloud run uses an invalid split or chunk pair | The managed backfill request is rejected | Use a supported split unit and a chunk size of at least one |
| A Cloud project uses a non-GitHub provider without a Git token | Project creation is rejected | Supply a personal token and a known provider |
| An agent or thread ID is zero or negative | The CLI stops before sending an invalid request | Pass positive IDs or run inside a valid Cloud chat context |
steer has no active message to target | No steering request is sent | Send a new agent message or pass a valid running message ID |
| An MCP update omits existing kinds | Other agent integrations can be removed | Read the current set and merge the requested change |
cloud agents request-connection runs outside a Cloud chat | No connection card can be attached | Run it only with the Cloud agent and thread context |
| A data app pull would overwrite changed local files | Local edits are lost if the command proceeds | Pull without --force first and use force only when overwrite is intended |
| A data app push uses a stale saved version | Cloud rejects the save and the local version remains unchanged | Pull again, reapply the change, and push; use --force only to overwrite |
| A data app push points at a directory from another app | The command stops before sending a Cloud request | Use the directory that records the same app ID or supply the correct app files |
A data app manifest is not a JSON array or is null | The push stops before changing the app | Provide a valid JSON array for each manifest |
| A data app has no assigned agent | Its queries cannot run | Assign an agent during creation or with cloud data-apps update |
| A data app request uses a credential host outside team policy | Cloud rejects the request | Use an approved host or ask a team admin to approve the domain |
--ingestr has no supported destination or source | No runnable replication assets are created | Pass supported source and destination connections |
ingestr-uri targets an existing output path | The command refuses to write credentials | Use a new path or remove the old file first |
| A dependency lock input is not a Python asset, requirements.txt, or pyproject.toml | Dependency resolution stops before it changes files | Pass one supported input and provide its dependency configuration |
| A Python dependency lock uses an unsupported Python version | The command exits before invoking the lock tool | Select one of the supported Python versions |
| DuckDB driver installation fails | The internal command exits with code 1 | Make the driver source reachable and handle the failure before running dependent images |
Key files
| File | Why to read it |
|---|---|
| main.go | Shows the root command and user-facing command registration. |
| cmd/internal.go | Shows hidden tool-facing pipeline, service, schema, dependency-locking, and driver-preparation access. |
| cmd/internal_test.go | Shows internal command registration, asset conversion, dependency discovery, and driver-install failure contracts. |
| cmd/init.go | Shows project creation, templates, configuration merging, and merge safety. |
| cmd/render.go | Shows how asset paths become rendered SQL or DDL context for inspection. |
| cmd/render_bigquery_test.go | Shows how render completes missing BigQuery Iceberg storage settings from a connection. |
| cmd/const.go | Shows shared pipeline loading, variable overrides, hook rendering, and inferred destinations. |
| cmd/fetch.go | Shows local, semantic, and Cloud query workflows, variable input, result logging, and export behavior. |
| cmd/query_stream.go | Shows how query results reach terminal, JSON, CSV, and split export outputs while rows stream. |
| cmd/query_stream_test.go | Shows output parity, streaming fallback, export splitting, partial-file cleanup, and query-log isolation. |
| cmd/query_log_test.go | Shows the query-log format, row limits for aggregate previews, and safe handling of large or partial results. |
| cmd/semantic.go | Shows semantic model selection, validation, and quality checks. |
| cmd/lint.go | Shows project, variant, path, and asset validation, including mixed-pipeline variant handling. |
| cmd/run.go | Shows local execution, selection, variants, state continuation, streaming, reporting, inferred destinations, and connection overrides. |
| cmd/run_inference_test.go | Shows the contract that inference checks use the destination service from the write connection. |
| cmd/connection_override.go | Shows the single-asset service override and its continuation rules. |
| pkg/…/scheduler.go | Shows the run state field that keeps a continuation on its original override. |
| cmd/backfill.go and cmd/backfill_ui.go | Show resumable partition planning and recovery. |
| cmd/import.go and cmd/import_ssis.go | Show how external definitions become Bruin assets. |
| cmd/environments.go and cmd/connections.go | Show local service context and connection management. |
| cmd/helpers.go | Shows production-environment safety, Cloud error hints, act-as permission guidance, and plain or JSON result handling. |
| cmd/login.go, cmd/auth.go, and cmd/cloud_auth.go | Show Cloud sign-in, credential lookup, status, logout, and scope selection. |
| cmd/login_test.go and cmd/auth_test.go | Show repository and global login safety, precedence, non-interactive scope rules, token redaction, and logout behavior. |
| cmd/cloud_act_as.go | Shows the agent-permission session used by Cloud command authentication, including renewal and stop behavior. |
| cmd/cloud_act_as_test.go | Shows act-as start, status, stop, renewal, reauthentication, precedence, team pinning, permission hints, and logout contracts. |
| cmd/cloud.go | Shows Cloud command hierarchy, team context, project creation, run review, backfills, agents, and service configuration. |
| cmd/cloud_data_apps.go | Shows the Cloud data app guide, metadata, local pull/push lifecycle, version protection, and app deletion. |
| cmd/cloud_data_apps_test.go | Shows data app output, local file safety, manifest validation, version conflicts, and API request contracts. |
| cmd/cloud_test.go | Shows command registration, credential and team precedence, project creation, run control, agent control, and fail-fast ID checks. |
| cmd/connection_override_test.go | Shows the contract for override scope, service type, secret mapping, and continuation. |
| cmd/cloud_pipeline_trigger_test.go | Shows the separate scheduled-agent pipeline-trigger contract. |
| cmd/curl.go | Shows how configured connection fields support an external request. |