Sandbox
@andre-salvati/databricks-template

Databricks PySpark ETL template for Claude Code

This repo is a starter template for building Databricks ETL pipelines in Python. It combines medallion architecture, Databricks Asset Bundles, Databricks SDK scripts, tests, and data quality checks so you can ship a project with a working workflow instead of starting from scratch. It also includes Claude Code files, a `CLAUDE.md`, and `specs/` docs that describe how the project is meant to be built and deployed. The result is a reusable scaffold for local development, CI/CD, and Databricks deployment.

83 stars32 forksPythonUpdated 1mo ago
Claude Code: 5 Essentials for Data Engineering
Dustin Vannoy24k views • 8 months ago

Videos about this repo

Who it's for

Builders who are starting a Databricks ETL project and want a ready-made scaffold for Claude Code and CI/CD.

What it delivers

You can start a Databricks pipeline with the project structure, deployment flow, and test setup already in place.

What it does

Medallion pipeline structure

Organizes the project around bronze, silver, and gold layers for Databricks ETL.

Databricks Asset Bundles deployment

Uses `databricks.yml` and bundle-based deployment for dev, staging, and prod.

Claude Code workflow files

Ships `CLAUDE.md` and `.claude/` settings, skills, and hooks for agent-led development.

Test suite scaffold

Includes `tests/` for unit, integration, and load tests with pytest.

Data quality checks

Uses Databricks DQX rules and quarantine handling for bad data.

Databricks SDK scripts

Provides `scripts/` helpers for workspace, account, job, and SQL tasks.

CI/CD and guardrails

Includes GitHub Actions, pre-commit, Makefile tasks, and production deploy safeguards.

Databricks dashboard example

Adds a gold-layer dashboard definition in `resources/orders_dashboard.lvdash.json`.

How to get it

  1. 1Set up the Python environment and run unit tests on your local machine.
    make sync && make unit-test
  2. 2Initialize the workspace. Create an external location in Databricks and update the…
    make init
  3. 3Deploy and execute on the dev workspace.
    make deploy env=dev

README

Databricks PySpark ETL Template — production-ready pipelines, built agentically with Claude Code

Databricks PySpark CI/CD Claude Code License Stars

🚀 Overview

Stop spending weeks on boilerplate. This PySpark project template for Databricks gives you medallion architecture, Python packaging, unit + integration + load tests, CI/CD, DQX data quality, service-principal-based production deploys, and much more — all wired together and ready to ship. Whether you're starting a new Databricks ETL project or looking for a reference implementation of production-ready PySpark pipelines, fork this and go.

If this saves you time, a star helps others find it. Let's connect on LinkedIn.

🧪 Technologies

  • Databricks Free Edition (Serverless)
  • Databricks Runtime 18.0 LTS
  • Databricks Unity Catalog
  • Databricks Declarative Automation Bundles (former Asset Bundles)
  • Databricks CLI
  • Databricks Python SDK
  • Databricks DQX
  • Databricks AI Dev Kit
  • Databricks Dashboards
  • Claude Code
  • PySpark 4.1
  • Spark Declarative Pipelines (SDP)
  • Python 3.12
  • GitHub Actions
  • Pytest

📦 Features

This project template demonstrates how to:

  • use agentic development (with Databricks AI Dev Kit and Claude Code) in data projects. The template ships with a CLAUDE.md and a specs/ folder documenting the project's conventions.
  • structure PySpark code inside classes/packages, deploy it as a Python wheel (instead of notebooks), and manage the project with uv.
  • package and deploy code with Declarative Automation Bundles to different environments (dev, staging, prod). Use GitHub Actions to automate CI/CD pipeline.
  • utilize Databricks Lakeflow Jobs to execute a DAG - Yes, you don't need Airflow to manage your DAGs here!!!. Generate job definitions to run with environment-specific conditions using Databricks SDK.
  • isolate "dev" environments / catalogs to avoid concurrency issues between developer tests.
  • separate deploy-time config (environment variables, CI secrets) from runtime config (job parameters overridable from the Databricks UI), keeping jobs flexible without coupling them to the build process.
  • utilize job tags to track issues, costs, and ownership.
  • use the medallion architecture to organize your data.
  • use a Lakeflow Spark Declarative Pipeline to run the same ETL logic side-by-side with the PySpark job, demonstrating both paradigms from one codebase.
  • apply Delta liquid clustering and incremental load to build more efficient pipelines.
  • run unit tests on transformations with the pytest package. Set up VS Code to run tests on your local machine.
  • run integration tests by setting the input data and validating the output data.
  • run load tests to exercise both the initial bulk load and incremental daily updates, validating that the pipeline handles production-scale data.
  • use Databricks AI/BI Dashboards to visualize the gold layer.
  • utilize the coverage package to generate test coverage reports.
  • use structured logging giving you full observability during incidents without a code change.
  • lint and format code with ruff and pre-commit.
  • use a Makefile to automate repetitive tasks.
  • utilize Databricks DQX to enforce data quality rules, such as null checks, uniqueness, thresholds, and schema validation, and filter bad data into quarantine tables.
  • utilize service principals to run production code.
  • utilize the Databricks SDK for Python to manage catalogs, schemas, workspaces, and accounts. Refer to the scripts folder for examples.
  • utilize Databricks Unity Catalog to manage permissions and get data lineage.
  • enforce production guardrails out of the box — identity-locked CI deploys, a health-check task, wheel version pinning, per-task timeouts, schema-drift guards, queued runs, and on-call alerting.
  • use a Claude 'project-costs' skill to track project cloud spend in USD across AWS (Cost Explorer) and Databricks — see an example.
  • use a Claude 'sql-diagram' skill to diagram any SQL query with sqlglot — see an example.
  • use a Claude 'data-divergence' skill to investigate why two datasets that should agree don't — see an example.
  • utilize serverless job clusters on Databricks Free Edition to deploy your pipelines.

📐 Specs

Deep technical detail lives in specs/ (the README stays a landing page):

  • Architecture — wheel/CLI surface, jobs DAG, job generation, CI/CD, job-level params, deploy-time env vars, logging, production guardrails, folder structure.
  • Data model — catalog/schema isolation, medallion data flow (diagram), table schemas, product-name freeze semantics, the dashboard, liquid clustering, DQX/quarantine, lineage.
  • Workflow — the development lifecycle (plan → branch → PR), PR description standard, production-table impact check, the prod rollback playbook, and the unit / integration / load test plan.
  • Tooling — MCP servers (Databricks, AWS billing/docs, context7), the Databricks CLI, and the bundled skills.

🧠 Resources

Agentic development:

Debates on the use of notebooks vs. Python packaging:

Sessions on Databricks Declarative Automation Bundles, CI/CD, and Software Development Life Cycle at Data + AI Summit 2025:

Other resources:

Instructions

  1. (Optional) Install Databricks AI Dev Kit and Claude Code.

  2. Create a Databricks Free Edition workspace.

  3. Install and configure the Databricks CLI on your local machine. Check the current version in databricks.yml. Follow the instructions here.

  4. Set up the Python environment and run unit tests on your local machine.

     make sync && make unit-test
     
    
  5. Initialize the workspace. Create an external location in Databricks and update the storage-root parameter in the Makefile. This step will create the catalogs, schemas, service principal, and the required grants. For more details, see Overview of external locations. Then run:

     make init
    
  6. Generate a secret for the service principal. In Databricks, go to: Workspace -> Settings -> Identity and access -> Service principals -> Secrets. Generate a new secret for your service principal and update the corresponding profiles in your .databrickscfg file. Your configuration should look similar to this:

     [dev]
     host          = https://xxxx.cloud.databricks.com/
     token         = bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
                     
     [staging]
     host          = https://xxxx.cloud.databricks.com/
     client_id     = yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
     client_secret = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    
     [prod]
     host          = https://xxxx.cloud.databricks.com/
     client_id     = yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy
     client_secret = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
    
  7. Deploy and execute on the dev workspace.

     make deploy env=dev
    
  8. Configure CI/CD automation with the service principal ID and secret. Configure GitHub Actions repository secrets: DATABRICKS_HOST, DATABRICKS_CLIENT_ID, DATABRICKS_CLIENT_SECRET, and TEMPLATE_ALERT_EMAILS (comma-separated on-call addresses).

  9. (Optional) You can also execute unit tests from your preferred IDE. Here's a screenshot from VS Code with Microsoft's Python extension installed.

License

Licensed under the Apache License 2.0. See LICENSE and NOTICE.

Star History

Star History ChartStar History Chart

Generated from the GitHub API by make star-history — see scripts/star_history.py.

Files in the repo

Repository payload18 top-level entries
  • .claude
  • .github
  • assets
  • resources
  • scripts
  • specs
  • src
  • tests
  • .gitignore
  • .pre-commit-config.yaml
  • CLAUDE.md
  • databricks.yml
  • LICENSE
  • Makefile
  • NOTICE
  • pyproject.toml
  • README.md
  • uv.lock

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More templates

CopilotKit/
OpenBot

Open-source AI coworkers that each get a computer of their own: a browser, files and tools, with every action decided before it happens and recorded after. Bring any AG-UI agent.

4.6k
Donchitos/
Claude-Code-Game-Studios

Turn Claude Code into a full game dev studio — 49 AI agents, 72 workflow skills, and a complete coordination system mirroring real studio hierarchy.

25k

A self-organizing Obsidian vault that gives AI coding agents persistent memory. Claude Code, Codex CLI, Gemini CLI.

4.6k
idavidov13/
agentic-playwright

Production-grade Playwright + TypeScript Scaffold for Agentic Testing. Harness for all major AI coding agents baked in.

163
gavishap/
omnia-vault

Omnia Vault - the all-in-one project brain: an Obsidian LLM wiki, Graphify code graphs, a living plan that triages new videos against itself, and a Claude Code ⇄ Codex relay. Everything your project knows, in one clonable vault.

60

🎬 Tạo video "so sánh kiến thức" ngắn tự động — HyperFrames + AI voice, 1 template nhiều chủ đề.

169