Skip to main content

05. Packages & dbt deps

What are dbt Packages?​

In dbt, a package is reusable dbt code created by another team or community project.

Packages can include:

  • macros
  • tests
  • helper SQL logic
  • reusable project utilities

The most common beginner package is dbt-utils.

Some other useful community packages include:

  • dbt-labs/dbt_utils — reusable macros and utility functions for common dbt patterns.
  • dbt-labs/codegen — generates sources, models, and tests from your database/schema metadata.
  • dbt-labs/dbt_artifacts — lets you query dbt run artifacts inside dbt models.
  • calogica/dbt_expectations — assertion-style tests inspired by great_expectations.
  • dbt-labs/dbt_date — date and time helpers for common transformations.
  • dbt-labs/dbt_iso8601 — parsing and formatting ISO 8601 date/time strings.
  • dbt-labs/metrics — reusable metric definitions and metric-related macros.
  • dbt-labs/dbt_external_tables — helpers for external table management on cloud warehouses.
  • dbt-audit-helper/dbt_audit_helper — auditing and data quality macros.

You can find the full list on dbt Hub:

https://hub.getdbt.com/


� Simple Idea​

Think of dbt packages like installing a library in Python.

ToolDependency fileInstall command
Pythonrequirements.txtpip install
Node.jspackage.jsonnpm install
dbtpackages.ymldbt deps

In dbt, you list packages in packages.yml.

Then you run:

dbt deps

dbt downloads those packages into your project.


Where to Create packages.yml​

Create packages.yml in the root of your dbt project:

my_dbt_project/
├── dbt_project.yml
├── packages.yml
├── models/
├── macros/
└── seeds/

Example:

packages:
- package: dbt-labs/dbt_utils
version: 1.1.1

Install Packages​

After adding or changing packages.yml, run:

dbt deps

This downloads the package into the dbt_packages/ folder.

my_dbt_project/
├── dbt_packages/
│ └── dbt_utils/

You usually do not edit files inside dbt_packages/.


When Should You Run dbt deps?​

Run dbt deps when:

  • You add a new package to packages.yml
  • You change a package version
  • You clone the dbt project for the first time
  • Your dbt_packages/ folder is missing

Key Takeaway​

dbt-utils is a dbt package.

Before using dbt-utils, candidates should understand:

  1. Add package details in packages.yml
  2. Run dbt deps
  3. Use the package macros/tests in dbt models or YAML files

Next, learn how to use the most common package: dbt-utils.