Project lifecycle commands
Project lifecycle commands take a DAC project from an empty directory to a checked and publishable dashboard. They create project structure, inspect discovered dashboards, catch definition and data errors, produce static artifacts, and keep the CLI and its authoring aids current.
Lifecycle model
The lifecycle moves from source creation to safe inspection and then to publication. The commands share the same project directory and dashboard model, so a change found by one stage can affect every later stage.
This diagram shows the main path for a DAC project and the maintenance paths that support it.
flowchart LR
A[dac init] --> B[Dashboard and semantic source]
B --> C[dac ls]
B --> D[dac validate]
D --> E[dac check]
E --> F[dac build]
G[dac skills] -. authoring guidance .-> B
H[dac upgrade] -. CLI and skill refresh .-> G
Project creation
dac init creates a usable DAC starting point in a new or existing directory. It supplies project configuration, sample data, dashboard examples, and the bundled dashboard authoring skill, then initializes Git so Bruin can find the project root.
The command offers four starting shapes:
| Template | Starting point |
|---|---|
starter | SQL dashboard, semantic dashboard, and semantic model |
sql | SQL-backed YAML dashboard |
semantic | Semantic YAML dashboard and model |
tsx | Semantic TSX dashboard and model |
The command stops before writing when scaffold files would replace existing files unless --force is set. This protects an existing project from an accidental re-scaffold. The generated Codex authoring path links to the Claude skill so both agents use one copy.
References: cmd/init.go• L27-51 cmd/init.go• L57-133 cmd/init.go• L168-228 cmd/init_test.go• L13-58 cmd/init_test.go• L101-162
Project inspection
dac ls gives a compact view of the dashboards that DAC can discover in a directory. It validates the discovered definitions before listing them, so the result represents dashboards that are usable by the rest of the CLI rather than files that merely exist.
The listing summarizes each dashboard by:
- Name
- Widget count
- Filter count
- Default connection name
An empty directory is reported without an error. A dashboard definition that fails validation prevents the listing from being produced.
References: cmd/ls.go• L14-60 cmd/common.go• L61-70 cmd/common.go• L86-95
Definition validation
dac validate checks dashboard definitions and their semantic references without running data queries by default. It is the fast source-level gate for structure, schema use, widget layout, filters, query references, and semantic model links.
The optional --with-database mode adds a safe database check. It dry-runs one resolved widget query at a time against configured connections and rejects empty, multiple, or potentially mutating SQL before it reaches the database. Supported read-only statement forms are SELECT, WITH, VALUES, SHOW, DESCRIBE, and EXPLAIN. For TSX dashboards, load-time query calls are checked while their result data stays empty during validation.
Validation also reports when an installed authoring skill is older than the bundled skill. This notice is passive and does not change the project.
Validation returns a failure when any discovered dashboard is invalid. A directory with no dashboard files is reported as empty rather than as a validation failure.
References: cmd/validate.go• L24-139 cmd/validate.go• L143-166 cmd/validate.go• L198-245 cmd/skills.go• L266-305
Query verification
dac check is the execution gate after definition validation. It validates each dashboard, resolves its widget work with default filters, and runs real data queries so the command can confirm that connections, generated SQL, and returned result shapes work together.
The result reports query errors, row and column counts, and elapsed time for each data widget. Text and divider widgets are treated as static content because they do not need a data query. Queries that use the same connection run in sequence, while independent connections can be checked at the same time.
Use dac validate --with-database when the goal is database-side query acceptance without fetching rows. Use dac check when the goal is to verify live results before deployment or a database change.
References: cmd/check.go• L29-145 cmd/check.go• L149-176 cmd/check.go• L178-189
Static publication
dac build turns one named dashboard into a self-contained static web artifact. It resolves the dashboard and its data at build time, applies a template and optional filter values, and writes output that can be served by static hosting without a DAC server or live database access.
The build stage accepts these project-level choices:
- Dashboard name to publish
- Dashboard directory
- Output directory
- Template name or theme YAML file
- Filter overrides in JSON form
Semantic dashboard widgets are resolved to query results before the artifact is written. Treat the output as a point-in-time snapshot; later source or database changes require a new build.
References: cmd/build.go• L12-65
Authoring support
dac skills manages local instructions for coding agents that create or change DAC dashboards. The bundled create-dashboard skill is version 14 and describes the shared dashboard model, project layout, and validate/check workflow, so it connects source authoring to lifecycle checks without changing runtime dashboard behavior.
The command supports three user-facing actions:
| Action | Project effect |
|---|---|
skills list | Shows bundled skills and their agent targets |
skills install | Adds selected skills to a project without replacing existing files by default |
skills update | Replaces installed skills with the versions bundled in the current CLI |
The Claude target is the shared skill file. The Codex target links to that same skill directory, which keeps both agents on one copy. Installing or updating a skill requires an agent session restart before the new guidance is used.
An installed skill is compared with the bundled version by its frontmatter version. Passive update notices report stale installed skills without changing them. The automatic refresh used during upgrade rewrites stale installed skills, while current or absent installs produce no notice or change.
References: cmd/skills.go• L16-35 cmd/skills.go• L44-119 cmd/skills.go• L122-263 cmd/skills.go• L266-419 cmd/skills_test.go• L11-157 cmd/skills_test.go• L159-324
CLI maintenance
dac upgrade replaces the current CLI by running the official installer. It stays on the current release channel by default, supports an explicit stable or edge channel, and can install a named version tag into the current or chosen binary directory.
After the new binary is installed, it refreshes only stale skills that are already installed in the current project. It does not add new skills or create project directories, and a skill refresh failure does not make the CLI upgrade fail. Use dac skills update when skill replacement must be a separate, explicit action.
The update command name is an alias for upgrade. The installer skips a separate Bruin CLI install because DAC users can manage that tool independently.
References: cmd/upgrade.go• L14-42 cmd/upgrade.go• L44-107 cmd/upgrade.go• L110-136 cmd/skills.go• L317-357
Shared CLI behavior
The lifecycle commands use one top-level CLI contract. Global options establish the project configuration and environment, while command-local options select the dashboard directory or change the command result.
Command context
The dac application registers lifecycle commands beside the server, data access, import, and export commands. Each real subcommand receives shared telemetry hooks, while help and version requests do not run a command hook.
The global options are:
| Option | Purpose |
|---|---|
--config or -c | Select a .bruin.yml configuration file instead of discovery |
--environment or -e | Select the target data environment |
--debug | Enable debug logging |
These options shape the command context but do not replace the command's own dashboard or output options.
References: cmd/root.go• L19-25 cmd/root.go• L28-63
Directory selection
Most lifecycle commands use --dir or -d to select the directory that holds dashboard definitions. The default is the current directory. Commands that accept a positional directory allow either form, but not both, which keeps the source of the project path clear.
init is different: its optional positional path is the directory to create or seed. skills uses its own --dir meaning because it targets the project that receives agent instructions. build also uses the selected directory as the source while writing its result to a separate output directory.
References: cmd/common.go• L12-18 cmd/common.go• L73-84 cmd/init.go• L27-51 cmd/skills.go• L37-42 cmd/build.go• L23-39
Configuration and environment
Commands that need project or database settings discover .bruin.yml from the selected directory unless --config supplies a path. The chosen environment then travels with the data operation, which keeps validation, checking, and building aligned with the same connection context.
Commands that only inspect definitions can work without a configuration file when they do not need database access. Commands that perform database work require a resolvable configuration and fail with a configuration error when it cannot be loaded.
References: cmd/common.go• L20-59 cmd/build.go• L41-64 cmd/validate.go• L47-62 cmd/check.go• L40-45
Command output and status
The commands use human-readable standard output for their main result and return an error when the requested lifecycle gate fails. Notices about skill staleness and upgrade progress use standard error so they do not mix with command result data.
This separation matters when a command is used in automation. A successful exit means the command completed its own gate, but it does not mean that a later lifecycle stage has also passed.
References: cmd/root.go• L19-25 cmd/validate.go• L40-41 cmd/validate.go• L127-139 cmd/check.go• L136-145 cmd/skills.go• L300-357 cmd/upgrade.go• L68-107
The CLI platform page explains the wider command architecture. See Query and connection commands for direct data access and Dashboard CLI operations for local serving and external dashboard exchange.
Change checklist
When these files or sections are changed, remember to consider these:
- Keep
--dir, positional directory handling, configuration discovery, and semantic model placement aligned so each lifecycle stage reads the same project. - Keep
validate --with-database's single-statement, read-only SQL safeguards separate fromcheck's real query execution contract. - Keep dashboard query resolution consistent between
check,build, and the local server so a passing source does not produce a different result at publication time. - Keep init template contents, generated README examples, Git initialization, and the bundled skill targets aligned when the project scaffold changes.
- Keep bundled skill content, version parsing, target links, and refresh behavior aligned between
skills update, passive notices, and the post-upgrade refresh. - Keep upgrade channel and installer argument handling aligned with the published installer contract.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
init finds scaffold files and --force is not set | Project creation stops before overwriting them | Review the target or use --force only when replacement is intended |
Git is not available during init | The project is not initialized because Bruin cannot use the Git root for discovery | Install Git or initialize the target as a Git repository before using the project |
| A dashboard has structural or semantic errors | ls, validate, and later gates cannot treat it as usable | Run dac validate after source changes |
validate --with-database receives empty, multiple, or non-read-only SQL | The database dry run is rejected without query execution | Use one SELECT, WITH, VALUES, SHOW, DESCRIBE, or EXPLAIN statement for validation and use check for real execution |
A live widget query fails during check | The check exits with errors and cannot serve as a passing data gate | Confirm the selected environment, connection, SQL, and returned result shape |
build receives invalid filter JSON | The static artifact is not built | Pass a valid JSON object for filter overrides |
| A skill install would replace an existing customized file | Installation stops unless replacement is explicit | Back up or review the local skill, then choose --force or skills update deliberately |
| An installed skill has an older version | Passive notices report it, while automatic refresh or explicit update can replace it | Review the notice and use dac skills update when replacement is intended |
| The upgrade installer or channel is invalid | The CLI binary is not replaced | Use a supported channel and ensure the installer and target directory are available |
Key files
| File | Why to read it |
|---|---|
| cmd/root.go | Defines the top-level CLI, global options, command registration, and shared telemetry boundary. |
| cmd/common.go | Defines dashboard directory selection, configuration discovery, and shared dashboard loading. |
| cmd/init.go | Shows the project creation contract and the available scaffold shapes. |
| cmd/ls.go | Shows the validated dashboard summary used for project inspection. |
| cmd/validate.go | Defines the source validation gate and the safe database dry-run boundary. |
| cmd/check.go | Defines the live query verification gate and its result summary. |
| cmd/build.go | Defines the static publication entry point and its source, template, filter, and output choices. |
| cmd/skills.go | Defines bundled agent guidance, installation targets, version refresh, and project notices. |
| cmd/…/SKILL.md | Explains the authoring model and the guidance that lifecycle skill commands install or refresh. |
| cmd/upgrade.go | Defines CLI replacement and the handoff to skill refresh after installation. |