This file provides guidance to AI assistants when working with code in this repository.
This is the Databricks CLI, a command-line interface for interacting with Databricks workspaces and managing Declarative Automation Bundles (DABs), formerly known as Databricks Asset Bundles. The project is written in Go and follows a modular architecture.
When moving code from one place to another, please don't unnecessarily change the code or omit parts.
make build- Build the CLI binarymake test- Run unit tests for all packagesgo test ./acceptance -run TestAccept/bundle/<path>/<to>/<folder> -tail -test.v- run a single acceptance testmake integration- Run integration tests (requires environment variables)make cover- Generate test coverage reports
make lint- Run linter on changed files only (uses lintdiff.py)make lintfull- Run full linter with fixes (golangci-lint)make ws- Run whitespace lintermake fmt- Format code (Go, Python, YAML)make checks- Run quick checks (tidy, whitespace, links)
make schema- Generate bundle JSON schemamake docs- Generate bundle documentationmake generate- Generate CLI code from OpenAPI spec (requires universe repo)
Use git rm to remove and git mv to rename files instead of directly modifying files on FS.
If asked to rebase, always prefix each git command with appropriate settings so that it never launches interactive editor:
GIT_EDITOR=true GIT_SEQUENCE_EDITOR=true VISUAL=true GIT_PAGER=cat git fetch origin main &&
GIT_EDITOR=true GIT_SEQUENCE_EDITOR=true VISUAL=true GIT_PAGER=cat git rebase origin/maincmd/ - CLI command structure using Cobra framework
cmd/cmd.go- Main command setup and subcommand registrationcmd/bundle/- Bundle-related commands (deploy, validate, etc.)cmd/workspace/- Workspace API commands (auto-generated)cmd/account/- Account-level API commands (auto-generated)
bundle/ - Core bundle functionality for Declarative Automation Bundles
bundle/bundle.go- Main Bundle struct and lifecycle managementbundle/config/- Configuration loading, validation, and schemabundle/deploy/- Deployment logic (Terraform and direct modes)bundle/mutator/- Configuration transformation pipelinebundle/phases/- High-level deployment phases
libs/ - Shared libraries and utilities
libs/dyn/- Dynamic configuration value manipulationlibs/filer/- File system abstraction (local, DBFS, workspace)libs/auth/- Databricks authentication handlinglibs/sync/- File synchronization between local and remote
Bundles: Configuration-driven deployments of Databricks resources (jobs, pipelines, etc.). The bundle system uses a mutator pattern where each transformation is a separate, testable component.
Mutators: Transform bundle configuration through a pipeline. Located in bundle/config/mutator/ and bundle/mutator/. Each mutator implements the Mutator interface.
Direct vs Terraform Deployment: The CLI supports two deployment modes controlled by DATABRICKS_BUNDLE_ENGINE environment variable:
terraform(default) - Uses Terraform for resource managementdirect- Direct API calls without Terraform
- Use
make test-updateto regenerate acceptance test outputs after changes - The CLI binary supports both
databricksandpipelinescommand modes based on executable name - Comments should explain "why", not "what" — reviewers consistently reject comments that merely restate the code
- Do NOT add dependencies without checking license compatibility.
- Do NOT use
os.Exit()outside ofmain.go. - Do NOT remove or skip failing tests to fix CI — fix the underlying issue.
- Do NOT leave debug print statements (
fmt.Println,log.Printffor debugging) in committed code — always scrub before committing.
- Wrap errors with context:
fmt.Errorf("failed to deploy %s: %w", name, err) - Use
logdiag.LogDiag/logdiag.LogErrorfor logging diagnostics. - Return early on errors; avoid deeply nested if-else chains.
- Use
diag.Errorf/diag.Warningfto create diagnostics with severity.