Lightdash CLI is a command-line interface for managing dbt (data build tool) projects and integrating them with the Lightdash business intelligence platform. It provides developers with comprehensive capabilities for compiling, validating, generating, deploying, and previewing dbt models and their associated Lightdash configurations.
npm install -g @lightdash/clilightdashInstall globally:
npm install -g @lightdash/cliAuthenticate to Lightdash:
lightdash login https://app.lightdash.cloudBasic workflow:
# Generate YAML schemas for dbt models
lightdash generate
# Compile and deploy to Lightdash
lightdash deploy
# Create preview environment for testing
lightdash previewThe Lightdash CLI is built around several key components:
Authenticate to Lightdash instances and manage project settings.
lightdash login [url]
lightdash config set-project
lightdash diagnosticsAuthentication and Configuration
Compile dbt models into Lightdash explores with full warehouse integration.
lightdash compile [options]Key options:
--project-dir <path> - dbt project directory--select <models...> - Model selection (dbt syntax)--skip-warehouse-catalog - Use YML types only--skip-dbt-compile - Use existing manifest.jsonGenerate Lightdash YAML schema files for dbt models with automatic type detection.
lightdash generate [options]
lightdash dbt run [options]Deploy compiled Lightdash projects to production or create new projects.
lightdash deploy [options]Key options:
--create [project_name] - Create new project--ignore-errors - Deploy with compilation errors--start-of-week <number> - Set first day of week (0-6)Create temporary preview projects for testing changes before deploying to production.
lightdash preview [options]
lightdash start-preview --name <name> [options]
lightdash stop-preview --name <name>Validate Lightdash projects by running validation jobs on tables, charts, and dashboards.
lightdash validate [options]Validation targets:
tables - Validate table/model definitionscharts - Validate saved chartsdashboards - Validate dashboardsDownload and upload Lightdash charts and dashboards as YAML files for version control.
lightdash download [options]
lightdash upload [options]Rename models and fields across all charts and dashboards in a project.
lightdash rename [options]Rename types:
model - Rename a dbt modelfield - Rename a field in a modellightdash refresh # Refresh project from git
lightdash generate-exposures # Generate dbt exposures YAML
lightdash lint # Validate Lightdash Code filesLIGHTDASH_API_KEY - API token for authenticationLIGHTDASH_URL - Lightdash server URLLIGHTDASH_PROJECT - Project UUIDLIGHTDASH_PROXY_AUTHORIZATION - Proxy authorization headerDBT_PROJECT_DIR - Default dbt project directory (default: .)DBT_PROFILES_DIR - Default dbt profiles directory (default: auto-detected)DBT_TARGET_PATH - Override target path for dbt compilationCI - When set to 'true', enables non-interactive modeAWS_SDK_JS_SUPPRESS_MAINTENANCE_MODE_MESSAGE - Automatically set to '1' by CLI to suppress Snowflake SDK warnings~/.config/lightdash/config.yaml)Stores authentication and context information:
user:
userUuid: string
anonymousUuid: string
organizationUuid: string
context:
serverUrl: string
project: string # project UUID
projectName: string
apiKey: string # Personal Access Token or Service Account Token
previewProject: string
previewName: stringlightdash.config.yml)Located in the dbt project directory:
spotlight:
categories:
<yamlReference>:
label: string
color: string
default_visibility: string
parameters:
<parameterName>: <parameterValue>
warehouse:
type: postgres | bigquery | snowflake | redshift | databricks | trino | clickhouseStandard dbt configuration files:
dbt_project.yml - dbt project configurationprofiles.yml - Warehouse connection profiles (in ~/.dbt/ or custom location)Commands that accept --select, --models, or --exclude options support dbt's selection syntax:
model_name - Select a single modelmodel1 model2 - Select multiple models (space-separated)tag:tagname - Select all models with a specific tag+model - Select a model and all its parentsmodel+ - Select a model and all its children+model+ - Select a model, its parents, and its childrenExamples:
# Generate YAML for a single model
lightdash generate -s customers
# Generate YAML for models with the "sales" tag
lightdash generate -s tag:sales
# Compile a model and all its dependencies
lightdash compile -s +ordersThe CLI supports an alternative model definition format called Lightdash YAML Models:
lightdash/ directorymodel/v1, model/v1beta, or modelSee lightdash.config.yml for warehouse type configuration when using Lightdash YAML models.
The CLI supports the following data warehouse platforms:
# Install CLI globally
npm install -g @lightdash/cli
# Authenticate to Lightdash
lightdash login https://app.lightdash.cloud
# Select active project
lightdash config set-project# Make changes to dbt models
# Generate YAML schemas for new/modified models
lightdash generate -s mymodel
# Create preview environment to test changes
lightdash preview --name my-feature
# Press ENTER when done to cleanup preview# Set authentication via environment variable
export LIGHTDASH_API_KEY="your-token"
# Compile and validate
lightdash compile --no-warehouse-credentials
lightdash validate --preview
# Deploy to production (on main branch)
lightdash deploy --ignore-errors# Download all charts and dashboards
lightdash download --nested
# Make changes to YAML files
# Upload changes back to Lightdash
lightdash upload --forceCommon error types:
When errors occur, the CLI provides detailed error messages and suggestions for resolution.