Skip to content

Commit 5690e7d

Browse files
suryaiyer95claude
andcommitted
feat: add altimate-dbt CLI package for dbt project operations
New `packages/dbt-tools/` TypeScript package wrapping `@altimateai/dbt-integration` to provide one-shot dbt CLI operations (compile, build, test, execute, introspect). - 16 commands: init, doctor, info, compile, compile-query, build, run, test, build-project, execute, columns, columns-source, column-values, children, parents, deps, add-packages - Config at `~/.altimate-code/dbt.json`, auto-detected via `altimate-dbt init` - Prerequisite validation (`doctor`) checks Python, dbt-core, and project health - Structured JSON output to stdout, logs to stderr, `--format text` for humans - Graceful error handling with actionable `error` + `fix` fields - Patch `python-bridge@1.1.0` to fix `bluebird.promisifyAll` crash - Build with `bun build --target node` for Node.js runtime (Bun IPC bug workaround) - 11 tests covering config round-trip, CLI dispatch, error paths - `/dbt-cli` skill teaching AI agents when and how to invoke each command Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f5466e7 commit 5690e7d

22 files changed

Lines changed: 1034 additions & 3 deletions

.opencode/skills/dbt-cli/SKILL.md

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
---
2+
name: dbt-cli
3+
description: Compile, build, test, and introspect dbt projects by running dbt operations against a real project. Use when the user needs to compile Jinja, materialize models, run tests, execute SQL against the warehouse, inspect columns, or navigate the DAG.
4+
---
5+
6+
# dbt Project Operations
7+
8+
## Requirements
9+
**Agent:** builder or migrator (build/run/test modify warehouse state), any (compile/info/columns/children/parents are read-only)
10+
**Tools used:** bash (runs `altimate-dbt` commands), read, glob, write, edit
11+
12+
> **When to use this vs other skills:**
13+
> - Use `/dbt-cli` when you need to **execute dbt operations** — compile Jinja, materialize models, run tests, query the warehouse, or navigate the DAG
14+
> - Use `/model-scaffold` when **creating new model files** from scratch
15+
> - Use `/generate-tests` when **adding schema.yml test definitions**
16+
> - Use `/impact-analysis` when analyzing **downstream impact of SQL changes** via lineage
17+
> - Use `/dbt-docs` when **documenting models** in schema.yml
18+
19+
## How to Run Commands
20+
21+
The CLI command is `altimate-dbt`. All commands output JSON to stdout; logs go to stderr.
22+
23+
```bash
24+
altimate-dbt <command> [args...]
25+
altimate-dbt <command> [args...] --format text # Human-readable output
26+
```
27+
28+
## First-Time Setup
29+
30+
Before any command works, initialize the dbt project:
31+
32+
```bash
33+
altimate-dbt init # Auto-detect: walks up from cwd looking for dbt_project.yml
34+
altimate-dbt init --project-root /path # Explicit project root
35+
altimate-dbt init --python-path /path # Override Python interpreter
36+
```
37+
38+
This writes `~/.altimate-code/dbt.json`. Run `altimate-dbt doctor` to verify everything is healthy.
39+
40+
If `altimate-dbt` is not found, the binary lives at `packages/dbt-tools/bin/altimate-dbt` in the altimate-code repo. Build with `bun run --cwd packages/dbt-tools build` if `dist/` is missing.
41+
42+
## Commands
43+
44+
### Health & Info
45+
```bash
46+
altimate-dbt doctor # → { passed: true, checks: [{check: "python", status: "ok"}, ...] }
47+
altimate-dbt info # → { projectRoot, projectName, adapterType }
48+
```
49+
50+
### Compile (Jinja → SQL)
51+
```bash
52+
altimate-dbt compile --model <model_name>
53+
altimate-dbt compile-query --query "SELECT * FROM {{ ref('stg_orders') }}" [--model <context>]
54+
```
55+
56+
### Build, Run & Test
57+
```bash
58+
altimate-dbt build --model <name> [--downstream] # compile + run + test
59+
altimate-dbt run --model <name> [--downstream] # materialize only
60+
altimate-dbt test --model <name> # run tests only
61+
altimate-dbt build-project # full project build
62+
```
63+
64+
### Execute SQL Against Warehouse
65+
```bash
66+
altimate-dbt execute --query "SELECT count(*) FROM {{ ref('orders') }}" --limit 100
67+
```
68+
69+
### Schema & DAG Introspection
70+
```bash
71+
altimate-dbt columns --model <name> # column names and types
72+
altimate-dbt columns-source --source <src> --table <tbl> # source table columns
73+
altimate-dbt column-values --model <name> --column <col> # sample values for a column
74+
altimate-dbt children --model <name> # downstream models
75+
altimate-dbt parents --model <name> # upstream models
76+
```
77+
78+
### Package Management
79+
```bash
80+
altimate-dbt deps # install packages.yml
81+
altimate-dbt add-packages --packages dbt-utils,dbt-expectations
82+
```
83+
84+
## When to Invoke This Skill
85+
86+
**Invoke when the user:**
87+
- Says "compile", "build", "run", "test" in the context of a dbt project
88+
- Asks "what columns does this model have?"
89+
- Wants to see the rendered SQL behind a Jinja model
90+
- Asks about upstream/downstream dependencies
91+
- Wants to run a SQL query that uses `{{ ref() }}` or `{{ source() }}`
92+
- Needs to check if their dbt project is set up correctly
93+
- Asks to install dbt packages
94+
95+
**Do NOT invoke when the user:**
96+
- Wants to create a new model file from scratch (use `/model-scaffold`)
97+
- Wants to add tests to schema.yml (use `/generate-tests`)
98+
- Wants to analyze lineage impact of SQL changes (use `/impact-analysis`)
99+
- Is writing raw SQL without Jinja (use `/query-optimize` instead)
100+
101+
## Workflow Patterns
102+
103+
### Write → Validate → Ship
104+
1. **Write** the model SQL with `write` or `edit`
105+
2. **Compile** to catch Jinja errors: `altimate-dbt compile --model <name>`
106+
3. **Check lineage**: `altimate-dbt parents --model <name>` and `altimate-dbt children --model <name>`
107+
4. **Build** to materialize: `altimate-dbt build --model <name> --downstream`
108+
5. **Spot-check**: `altimate-dbt execute --query "SELECT * FROM {{ ref('<name>') }}" --limit 10`
109+
110+
### Explore a Project
111+
1. `altimate-dbt info` — project name, adapter, root path
112+
2. `glob` for `models/**/*.sql` — list all models
113+
3. `altimate-dbt columns --model <name>` — what does it produce?
114+
4. `altimate-dbt parents --model <name>` / `altimate-dbt children --model <name>` — walk the DAG
115+
5. `altimate-dbt compile --model <name>` — see the rendered SQL
116+
117+
### Debug a Failing Model
118+
1. `altimate-dbt doctor` — check prerequisites
119+
2. `altimate-dbt compile --model <name>` — isolate Jinja vs SQL errors
120+
3. Read the model file to understand the logic
121+
4. `altimate-dbt execute --query "<diagnostic_sql>" --limit 5` — probe the data
122+
5. Fix, then `altimate-dbt build --model <name>` to verify
123+
124+
### Column Discovery
125+
1. `altimate-dbt columns --model <name>` — get column list
126+
2. `altimate-dbt column-values --model <name> --column status` — discover real values
127+
3. Use column info to generate schema.yml tests or docs
128+
129+
## Error Handling
130+
131+
All errors return JSON with `error` and `fix` fields:
132+
```json
133+
{ "error": "dbt-core is not installed", "fix": "Install it: python3 -m pip install dbt-core" }
134+
```
135+
136+
Run `altimate-dbt doctor` as the first diagnostic step for any failure.

0 commit comments

Comments
 (0)