0
# CLI Commands
1
2
dbt provides a comprehensive command-line interface with commands for project lifecycle management, data transformation, testing, and documentation. All commands are accessible via the `dbt` console script.
3
4
## Core Commands
5
6
### build
7
8
Runs all seeds, models, snapshots, and tests in DAG order - the comprehensive execution command.
9
10
```bash { .api }
11
dbt build [options]
12
13
Options:
14
--exclude TEXT Exclude resources by name or selector
15
--full-refresh Drop and recreate incremental models
16
--select TEXT Select resources by name or selector
17
--threads INTEGER Number of threads to use
18
--profiles-dir PATH Directory containing profiles.yml
19
--project-dir PATH Directory containing dbt_project.yml
20
--target TEXT Target profile to use
21
--vars TEXT Supply variables as YAML string
22
```
23
24
### run
25
26
Compiles SQL and executes models against the target database.
27
28
```bash { .api }
29
dbt run [options]
30
31
Options:
32
--exclude TEXT Exclude models by name or selector
33
--full-refresh Drop and recreate incremental models
34
--select TEXT Select models by name or selector
35
--threads INTEGER Number of threads to use
36
--profiles-dir PATH Directory containing profiles.yml
37
--project-dir PATH Directory containing dbt_project.yml
38
--target TEXT Target profile to use
39
--vars TEXT Supply variables as YAML string
40
```
41
42
### test
43
44
Runs tests on deployed models to validate data quality.
45
46
```bash { .api }
47
dbt test [options]
48
49
Options:
50
--exclude TEXT Exclude tests by name or selector
51
--select TEXT Select tests by name or selector
52
--resource-type TEXT Run only specified resource types
53
--store-failures Store test failures in database tables
54
--threads INTEGER Number of threads to use
55
--profiles-dir PATH Directory containing profiles.yml
56
--project-dir PATH Directory containing dbt_project.yml
57
--target TEXT Target profile to use
58
--vars TEXT Supply variables as YAML string
59
```
60
61
### compile
62
63
Generates executable SQL from source, model, test, and analysis files without execution.
64
65
```bash { .api }
66
dbt compile [options]
67
68
Options:
69
--exclude TEXT Exclude resources by name or selector
70
--select TEXT Select resources by name or selector
71
--full-refresh Treat incremental models as table models
72
--threads INTEGER Number of threads to use
73
--profiles-dir PATH Directory containing profiles.yml
74
--project-dir PATH Directory containing dbt_project.yml
75
--target TEXT Target profile to use
76
--vars TEXT Supply variables as YAML string
77
```
78
79
## Project Management Commands
80
81
### init
82
83
Initializes a new dbt project with starter files and directory structure.
84
85
```bash { .api }
86
dbt init [project_name] [options]
87
88
Arguments:
89
project_name Name of project to create (optional)
90
91
Options:
92
--profiles-dir PATH Directory for profiles.yml
93
--project-dir PATH Directory to create project in
94
--skip-profile-setup Skip interactive profile setup
95
```
96
97
### deps
98
99
Installs dbt packages specified in packages.yml or dependencies.yml.
100
101
```bash { .api }
102
dbt deps [options]
103
104
Options:
105
--profiles-dir PATH Directory containing profiles.yml
106
--project-dir PATH Directory containing dbt_project.yml
107
--source TEXT Package source (hub, git, local)
108
--lock Generate package-lock.yml file
109
--upgrade Upgrade packages to latest versions
110
--add-package TEXT Add package in format name@version
111
```
112
113
### clean
114
115
Deletes all folders in the clean-targets list (usually target/ and dbt_packages/).
116
117
```bash { .api }
118
dbt clean [options]
119
120
Options:
121
--profiles-dir PATH Directory containing profiles.yml
122
--project-dir PATH Directory containing dbt_project.yml
123
--clean-project-files-only Clean only project files, not profiles
124
```
125
126
### parse
127
128
Parses the project and provides performance information about parsing time.
129
130
```bash { .api }
131
dbt parse [options]
132
133
Options:
134
--profiles-dir PATH Directory containing profiles.yml
135
--project-dir PATH Directory containing dbt_project.yml
136
--target TEXT Target profile to use
137
--threads INTEGER Number of threads to use
138
--vars TEXT Supply variables as YAML string
139
```
140
141
## Data Management Commands
142
143
### seed
144
145
Loads CSV files from the data/ directory into the data warehouse.
146
147
```bash { .api }
148
dbt seed [options]
149
150
Options:
151
--exclude TEXT Exclude seeds by name or selector
152
--select TEXT Select seeds by name or selector
153
--full-refresh Drop and recreate seed tables
154
--show Show sample of loaded data
155
--threads INTEGER Number of threads to use
156
--profiles-dir PATH Directory containing profiles.yml
157
--project-dir PATH Directory containing dbt_project.yml
158
--target TEXT Target profile to use
159
--vars TEXT Supply variables as YAML string
160
```
161
162
### snapshot
163
164
Executes snapshots defined in the project to capture changing data over time.
165
166
```bash { .api }
167
dbt snapshot [options]
168
169
Options:
170
--exclude TEXT Exclude snapshots by name or selector
171
--select TEXT Select snapshots by name or selector
172
--threads INTEGER Number of threads to use
173
--profiles-dir PATH Directory containing profiles.yml
174
--project-dir PATH Directory containing dbt_project.yml
175
--target TEXT Target profile to use
176
--vars TEXT Supply variables as YAML string
177
```
178
179
### clone
180
181
Creates clones of selected nodes based on their location in the state manifest.
182
183
```bash { .api }
184
dbt clone [options]
185
186
Options:
187
--exclude TEXT Exclude resources by name or selector
188
--select TEXT Select resources by name or selector
189
--full-refresh Force full refresh of cloned models
190
--threads INTEGER Number of threads to use
191
--profiles-dir PATH Directory containing profiles.yml
192
--project-dir PATH Directory containing dbt_project.yml
193
--target TEXT Target profile to use
194
--vars TEXT Supply variables as YAML string
195
```
196
197
## Documentation Commands
198
199
### docs generate
200
201
Generates the documentation website for the project including model lineage and descriptions.
202
203
```bash { .api }
204
dbt docs generate [options]
205
206
Options:
207
--exclude TEXT Exclude resources from documentation
208
--select TEXT Select resources for documentation
209
--compile-docs Compile docs blocks in models
210
--empty-catalog Skip catalog generation (faster)
211
--static Generate static files only
212
--threads INTEGER Number of threads to use
213
--profiles-dir PATH Directory containing profiles.yml
214
--project-dir PATH Directory containing dbt_project.yml
215
--target TEXT Target profile to use
216
--vars TEXT Supply variables as YAML string
217
```
218
219
### docs serve
220
221
Serves the documentation website locally on a web server.
222
223
```bash { .api }
224
dbt docs serve [options]
225
226
Options:
227
--browser Open browser automatically
228
--host TEXT Host address to bind (default: localhost)
229
--port INTEGER Port to serve on (default: 8080)
230
--profiles-dir PATH Directory containing profiles.yml
231
--project-dir PATH Directory containing dbt_project.yml
232
```
233
234
## Utility Commands
235
236
### list / ls
237
238
Lists resources in the project based on selection criteria.
239
240
```bash { .api }
241
dbt list [options]
242
dbt ls [options] # alias
243
244
Options:
245
--exclude TEXT Exclude resources by name or selector
246
--select TEXT Select resources by name or selector
247
--resource-type TEXT Filter by resource type
248
--output TEXT Output format (name, json, path)
249
--output-keys TEXT Keys to include in output
250
--profiles-dir PATH Directory containing profiles.yml
251
--project-dir PATH Directory containing dbt_project.yml
252
--target TEXT Target profile to use
253
--vars TEXT Supply variables as YAML string
254
```
255
256
### show
257
258
Generates executable SQL for a resource or inline query and returns a preview of results without materialization.
259
260
```bash { .api }
261
dbt show [options]
262
263
Options:
264
--exclude TEXT Exclude resources by name or selector
265
--select TEXT Select resources by name or selector
266
--inline TEXT Inline SQL query to execute
267
--limit INTEGER Limit number of rows returned
268
--threads INTEGER Number of threads to use
269
--profiles-dir PATH Directory containing profiles.yml
270
--project-dir PATH Directory containing dbt_project.yml
271
--target TEXT Target profile to use
272
--vars TEXT Supply variables as YAML string
273
```
274
275
### debug
276
277
Shows information about the dbt environment and tests database connection.
278
279
```bash { .api }
280
dbt debug [options]
281
282
Options:
283
--connection Test database connection only
284
--config-dir PATH Config directory path
285
--profiles-dir PATH Directory containing profiles.yml
286
--project-dir PATH Directory containing dbt_project.yml
287
--vars TEXT Supply variables as YAML string
288
```
289
290
### retry
291
292
Retries nodes that failed in the previous run based on run_results.json.
293
294
```bash { .api }
295
dbt retry [options]
296
297
Options:
298
--profiles-dir PATH Directory containing profiles.yml
299
--project-dir PATH Directory containing dbt_project.yml
300
--threads INTEGER Number of threads to use
301
--full-refresh Force full refresh of retried models
302
--target TEXT Target profile to use
303
--vars TEXT Supply variables as YAML string
304
```
305
306
### run-operation
307
308
Executes a named macro with optional arguments.
309
310
```bash { .api }
311
dbt run-operation <macro_name> [options]
312
313
Arguments:
314
macro_name Name of macro to execute
315
316
Options:
317
--args TEXT Arguments to pass to macro as YAML
318
--profiles-dir PATH Directory containing profiles.yml
319
--project-dir PATH Directory containing dbt_project.yml
320
--threads INTEGER Number of threads to use
321
--target TEXT Target profile to use
322
--vars TEXT Supply variables as YAML string
323
```
324
325
## Source Commands
326
327
### source freshness
328
329
Checks the freshness of project sources against defined freshness criteria.
330
331
```bash { .api }
332
dbt source freshness [options]
333
334
Options:
335
--exclude TEXT Exclude sources by name or selector
336
--select TEXT Select sources by name or selector
337
--output-path PATH Path to write freshness results
338
--threads INTEGER Number of threads to use
339
--profiles-dir PATH Directory containing profiles.yml
340
--project-dir PATH Directory containing dbt_project.yml
341
--target TEXT Target profile to use
342
--vars TEXT Supply variables as YAML string
343
```
344
345
## Global Options
346
347
All commands support these global options:
348
349
```bash { .api }
350
Global Options:
351
--debug Enable debug logging
352
--log-level TEXT Log level (debug, info, warn, error)
353
--log-path PATH Path for log files
354
--no-write-json Skip writing run_results.json
355
--quiet Suppress non-error output
356
--warn-error Treat warnings as errors
357
--use-colors / --no-use-colors Enable/disable colored output
358
--version Show version information
359
--help Show help message
360
```
361
362
## Usage Examples
363
364
```bash
365
# Complete project build
366
dbt build --threads 4
367
368
# Run specific models
369
dbt run --select my_model+
370
371
# Run all changed models
372
dbt run --select state:modified+
373
374
# Test data quality
375
dbt test --store-failures
376
377
# Generate and serve docs
378
dbt docs generate
379
dbt docs serve --port 8080
380
381
# Debug connection issues
382
dbt debug --connection
383
```