Skip to content

Commit 677bb88

Browse files
committed
feat: shorter CLI forms for selection, global flags, JSON output, scope targets and cursors
Accept --project-dir, --no-color and --debug after the subcommand as well as before it. Treat positional arguments to compile, plan, build, test, seed, freshness, audit and check as selectors, combined with any --select values. Add --json as shorthand for --format json on lineage and query. Let sqb scope take bare model, source, seed and function names, resolved with the shared target resolver; macros, enums, constants, tests and audits keep their prefix and fail with C960 when written bare. Add --start-cursor and --end-cursor to build, plan and load, typed from the selected models' cursor type; a selection mixing timestamp and integer cursors fails with S303. The -ts and -int flags keep working.
1 parent 92cb04e commit 677bb88

61 files changed

Lines changed: 1533 additions & 113 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/sqlbuild/.agents/skills/sqlbuild/SKILL.md‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ JOIN __ref("stg_payments") p USING (order_id)
5858
than guessing how pieces connect.
5959
2. **Look at the data.** `sqb query "SELECT ..." --limit 20` runs SQL on the active target. Profile
6060
inputs (counts, nulls, key uniqueness) before writing joins.
61-
3. **Compile.** `sqb compile --select <models>` after every edit. It is offline and fast.
62-
4. **Plan.** `sqb plan --select <models>` shows exactly what a build will do and why. Read it before
61+
3. **Compile.** `sqb compile <models>` after every edit. It is offline and fast.
62+
4. **Plan.** `sqb plan <models>` shows exactly what a build will do and why. Read it before
6363
building, especially for incremental models, full refreshes and anything destructive.
64-
5. **Test.** `sqb test --select <models>` runs SQL unit tests without building.
65-
6. **Build.** `sqb build --select <models>` runs tests, builds, and runs audits in DAG order.
64+
5. **Test.** `sqb test <models>` runs SQL unit tests without building.
65+
6. **Build.** `sqb build <models>` runs tests, builds, and runs audits in DAG order.
6666
Use `--defer-to <target>` to read unselected upstream models from another target instead of
6767
rebuilding them.
6868
7. **Verify.** Prove the result is right with `sqb diff` (below), not only that it built.
@@ -79,13 +79,13 @@ the trigger applies.
7979
|---|---|
8080
| Check a refactor did not change results, or compare dev with prod | `sqb diff prod:dev --full --select <model>` |
8181
| Compare two arbitrary queries (old vs new logic, before vs after a fix, two tables) | `sqb diff --left-query "..." --right-query "..." --key <col>` |
82-
| Know what a model can see: which macros, enums and constants are visible, used, or unavailable | `sqb scope model:<name>` |
83-
| Fix "unknown macro/enum/constant", or decide where a declaration should live | `sqb scope model:<name> --explain macro:<name>` |
84-
| Preview whether moving a file breaks declaration visibility | `sqb scope model:<name> --as-path <new/path.sql>` |
82+
| Know what a model can see: which macros, enums and constants are visible, used, or unavailable | `sqb scope <name>` |
83+
| Fix "unknown macro/enum/constant", or decide where a declaration should live | `sqb scope <name> --explain macro:<name>` |
84+
| Preview whether moving a file breaks declaration visibility | `sqb scope <name> --as-path <new/path.sql>` |
8585
| Rename a model, move a model file, or rename a column | `sqb rename <old> <new>`, `sqb mv <name> <path/or/folder/>`, `sqb rename <model>.<column> <new>` (`model:`/`column:` prefixes optional) |
8686
| Find what a model depends on, or what breaks if it changes | `sqb lineage <model> --direction both` |
8787
| Trace where a column comes from, or who consumes it before renaming or dropping it | `sqb lineage <model>.<column> --direction downstream` |
88-
| See which intermediate models a SQL test will really execute | `sqb test --select <model> --inspect` |
88+
| See which intermediate models a SQL test will really execute | `sqb test <model> --inspect` |
8989
| Inspect the full graph as data | `sqb dag --json`, `sqb plan --json`, `sqb compile --json` |
9090
| Adopt an existing warehouse table's columns into a contract | `sqb contract generate --from <target> --select <model>` |
9191
| Try syntax safely in a throwaway DuckDB project | `sqb playground /tmp/sqb-sandbox` |
@@ -167,7 +167,7 @@ SQLBuild models downstream of them.
167167

168168
## Selectors
169169

170-
`--select a b` unions, `--exclude` subtracts. `+model` includes upstream, `model+` downstream.
170+
`sqb build a b` (or `--select a b`) unions, `--exclude` subtracts. `+model` includes upstream, `model+` downstream.
171171
`tag:<tag>`, `path:models/marts` (or any value containing `/`), `seed:<name>`, `source:<name>`,
172172
and quoted name globs such as `"stg_*"`. They work with plan, build, test, audit, seed, clone and
173173
diff.

‎src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/audit.md‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ Runs all attached audits without rebuilding models. Useful for verifying data qu
1111
## Usage
1212

1313
```bash
14-
sqb --project-dir <path> audit [flags]
14+
sqb audit [SELECTOR ...] [flags]
1515
```
1616

17+
Positional `SELECTOR` arguments work like `--select`, and both forms can be combined. `--project-dir <path>`, `--no-color`, and `--debug` can go before or after the command name.
18+
1719
## Flags
1820

1921
| Flag | Description |
2022
|------|-------------|
2123
| `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias) |
2224
| `--defer-to` | Resolve model references against another target |
25+
| `SELECTOR ...` | Positional selectors, the same as `--select` |
2326
| `--select`, `-s` | Select audits attached to specific models |
2427
| `--select-file` | Read selectors from a file |
2528
| `--exclude` | Exclude audits attached to specific models |
@@ -62,7 +65,7 @@ guarantee immediate cancellation of a query already running in the warehouse.
6265
sqb audit
6366

6467
# Run audits for marts only
65-
sqb audit --select path:models/marts
68+
sqb audit path:models/marts
6669

6770
# Run up to 8 audit queries concurrently
6871
sqb audit --concurrency 8

‎src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/build.md‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ Compiles, plans, and executes the selected build lifecycle, running the full sel
2525
## Usage
2626

2727
```bash
28-
sqb --project-dir <path> build [flags]
28+
sqb build [SELECTOR ...] [flags]
2929
```
3030

31+
Positional `SELECTOR` arguments work like `--select`, and both forms can be combined.
32+
3133
## Global options
3234

33-
These options apply to every `sqb` command and go before the command name, as in
34-
`sqb --debug build`:
35+
These options apply to every `sqb` command. `--project-dir`, `--no-color`, and `--debug` go
36+
before or after the command name, as in `sqb --debug build` or `sqb build --debug`. Under
37+
`sqb dbt`, put `--project-dir` before `dbt`: after it, `--project-dir` is passed to dbt as dbt's
38+
own option. `--version` works only directly after `sqb`, as in `sqb --version`:
3539

3640
| Option | Description |
3741
|--------|-------------|
@@ -56,6 +60,8 @@ These options apply to every `sqb` command and go before the command name, as in
5660
| `--fail-fast` | Stop on first failure and skip remaining nodes |
5761
| `--concurrency` | Number of worker connections (default: 1) |
5862
| `--verbose`, `-v` | Show lifecycle SQL inline after each model |
63+
| `--start-cursor` | Override the start cursor, typed from the selected incremental models' cursor type; fails with `S303` if the selection mixes timestamp and integer cursors. With no cursor model selected, an integer value is read as an integer cursor and anything else as an ISO timestamp |
64+
| `--end-cursor` | Override the end cursor, typed the same way as `--start-cursor` |
5965
| `--start-cursor-ts` | Override start cursor for timestamp incremental models (ISO format) |
6066
| `--end-cursor-ts` | Override end cursor for timestamp incremental models (ISO format) |
6167
| `--start-cursor-int` | Override start cursor for integer incremental models |
@@ -65,6 +71,7 @@ These options apply to every `sqb` command and go before the command name, as in
6571
| `--reload` | Reload managed sources (passes `is_reload=True` to loaders) |
6672
| `--selection-diagnostics` | Warn when a selected model will build on changed upstream models that are not selected; see [Selection and staleness](../concepts/planning/selection-and-staleness.md) |
6773
| `--manifest` | Generate `target/manifest.json` with plan-aware project metadata |
74+
| `SELECTOR ...` | Positional selectors, the same as `--select` |
6875
| `--select`, `-s` | Select specific models |
6976
| `--exclude` | Exclude specific models |
7077
| `--warehouse <name>` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse |
@@ -132,7 +139,7 @@ statement or step still prints its `FAIL` row.
132139
Use `--defer-to` to resolve unselected model references against another target. This lets you build a subset of models in dev while referencing production tables for everything else:
133140

134141
```bash
135-
sqb build --select fact_orders --defer-to prod
142+
sqb build fact_orders --defer-to prod
136143
```
137144

138145
No `manifest.json` is required. `--defer-to` selects only the namespace used for unselected

‎src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/check.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@ Runs Python [checks](../concepts/python-nodes/checks.md) in isolation. Checks va
1111
## Usage
1212

1313
```bash
14-
sqb --project-dir <path> check [flags]
14+
sqb check [SELECTOR ...] [flags]
1515
```
1616

17+
Positional `SELECTOR` arguments work like `--select`, and both forms can be combined. `--project-dir <path>`, `--no-color`, and `--debug` can go before or after the command name.
18+
1719
## Flags
1820

1921
| Flag | Description |
2022
|------|-------------|
23+
| `SELECTOR ...` | Positional selectors, the same as `--select` |
2124
| `--select`, `-s` | Select checks to run (by name, `check:`, `tag:`, or graph expansion) |
2225
| `--exclude` | Exclude checks from the selection |
2326
| `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias) |
@@ -35,10 +38,10 @@ Selecting a non-check node is rejected; use [`sqb build`](build.md) to run tasks
3538
sqb check
3639

3740
# Run one check and its required dependencies
38-
sqb check --select +check_orders_exported
41+
sqb check +check_orders_exported
3942

4043
# Run checks by tag
41-
sqb check --select tag:exports
44+
sqb check tag:exports
4245

4346
# Print results as JSON
4447
sqb check --json

‎src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/compile.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,11 @@ Discovers the complete project, resolves references, expands macros, validates S
2323
## Usage
2424

2525
```bash
26-
sqb --project-dir <path> compile [flags]
26+
sqb compile [SELECTOR ...] [flags]
2727
```
2828

29+
Positional `SELECTOR` arguments work like `--select`, and both forms can be combined. `--project-dir <path>`, `--no-color`, and `--debug` can go before or after the command name.
30+
2931
## Flags
3032

3133
| Flag | Description |
@@ -36,6 +38,7 @@ sqb --project-dir <path> compile [flags]
3638
| `--json` | Output the full compile report as JSON |
3739
| `--manifest` | Generate `target/manifest.json` with project metadata |
3840
| `--lineage-mode` | Column lineage mode: `fast` (default), `rich` (slower, more detail), or `none` |
41+
| `SELECTOR ...` | Positional selectors, the same as `--select` |
3942
| `--select`, `-s` | Analyze and report selected resources |
4043
| `--select-file` | Read selectors from a file, one selector per line |
4144
| `--exclude` | Remove resources from the selected scope |
@@ -58,7 +61,7 @@ Use normal selectors to limit expensive analysis and reporting while retaining c
5861
discovery and reference integrity:
5962

6063
```bash
61-
sqb compile --select fact_orders daily_revenue
64+
sqb compile fact_orders daily_revenue
6265
sqb compile --select-file selected-models.txt
6366
sqb compile --exclude deprecated_model
6467
```
@@ -284,7 +287,7 @@ sqb compile --lineage-mode none
284287
sqb compile --manifest
285288

286289
# Compile only selected models
287-
sqb compile --select fact_orders daily_revenue
290+
sqb compile fact_orders daily_revenue
288291

289292
# Disable SQL analysis
290293
sqb compile --no-sql-analysis

‎src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/freshness.md‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ Observes the current data version of each source and reports whether the data ha
2222
## Usage
2323

2424
```bash
25-
sqb --project-dir <path> freshness [flags]
25+
sqb freshness [SELECTOR ...] [flags]
2626
```
2727

28+
Positional `SELECTOR` arguments work like `--select`, and both forms can be combined. `--project-dir <path>`, `--no-color`, and `--debug` can go before or after the command name.
29+
2830
## Flags
2931

3032
| Flag | Description |
@@ -35,6 +37,7 @@ sqb --project-dir <path> freshness [flags]
3537
| `--json` | Output as JSON instead of human-readable text |
3638
| `--json-output` | Write JSON output to a file path (also prints text to stdout unless `--json` is set) |
3739
| `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias) |
40+
| `SELECTOR ...` | Positional selectors, the same as `--select` |
3841
| `--select`, `-s` | Select specific sources or models (sources upstream of selected models are included) |
3942
| `--exclude` | Exclude specific sources or models |
4043
| `--warehouse <name>` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse |
@@ -48,10 +51,10 @@ Without `--select`, all sources in the project are observed. When `--select` is
4851
sqb freshness
4952

5053
# Observe a specific source
51-
sqb freshness --select raw_orders
54+
sqb freshness raw_orders
5255

5356
# Observe sources upstream of a model
54-
sqb freshness --select fact_orders
57+
sqb freshness fact_orders
5558
```
5659

5760
## Observation without state

‎src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/lineage.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Exactly one of a positional target or `--select` is required.
4141
| `--direction` | `upstream` (default), `downstream`, or `both`. `both` is only available for model lineage. |
4242
| `--depth` | How many hops to traverse. An integer or `all` (default: `all`). |
4343
| `--format` | Output format: `tree` (default), `list`, or `json`. |
44+
| `--json` | Shorthand for `--format json`. |
4445
| `--mode` | Column lineage analysis mode: `rich` (default) or `fast`. |
4546
| `--no-sql-analysis` | Disable compile-time SQL analysis (`--no-sql-validation` is an alias). |
4647
| `--select`, `-s` | Select resources using the same selector syntax as `sqb compile`, `sqb plan` and `sqb build`, for example `path:models/marts`, `tag:finance` or `stg_*`. |
@@ -101,7 +102,7 @@ source:raw__payments -> model:stg_payments
101102
Structured output with nodes, edges, and metadata:
102103

103104
```bash
104-
sqb lineage fact_orders --format json
105+
sqb lineage fact_orders --json
105106
```
106107

107108
```json
@@ -173,7 +174,7 @@ raw__payments.amount_cents -> stg_payments.amount_cents direct
173174
### JSON
174175

175176
```bash
176-
sqb lineage fact_orders.total_cents --format json
177+
sqb lineage fact_orders.total_cents --json
177178
```
178179

179180
```json
@@ -240,7 +241,7 @@ sqb lineage --select "stg_orders~daily_activity_rollup"
240241
sqb lineage --select "+fact_orders"
241242

242243
# JSON output for programmatic consumption
243-
sqb lineage fact_orders --format json --direction upstream
244+
sqb lineage fact_orders --json --direction upstream
244245
```
245246

246247
## Depth limiting

‎src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/load.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ sqb --project-dir <path> load [flags]
2222
| `--exclude` | Exclude specific sources or loaders |
2323
| `--reload` | Pass `is_reload=True` to loader functions |
2424
| `--concurrency` | Number of worker connections (default: from settings or 1) |
25+
| `--start-cursor` | Override the start cursor; an integer value sets `start_cursor_int`, anything else is read as an ISO timestamp and sets `start_cursor_ts` |
26+
| `--end-cursor` | Override the end cursor, typed the same way as `--start-cursor` |
2527
| `--start-cursor-ts` | Override start cursor for timestamp-based loaders (ISO format) |
2628
| `--end-cursor-ts` | Override end cursor for timestamp-based loaders (ISO format) |
2729
| `--start-cursor-int` | Override start cursor for integer-based loaders |
@@ -47,7 +49,7 @@ sqb load --concurrency 4
4749
sqb load --reload
4850

4951
# Override cursor bounds
50-
sqb load --start-cursor-ts "2026-05-01T00:00:00"
52+
sqb load --start-cursor "2026-05-01T00:00:00"
5153
```
5254

5355
## Execution order

‎src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/plan.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@ Shows the execution plan without making any changes. Useful for inspecting chang
1919
## Usage
2020

2121
```bash
22-
sqb --project-dir <path> plan [flags]
22+
sqb plan [SELECTOR ...] [flags]
2323
```
2424

25+
Positional `SELECTOR` arguments work like `--select`, and both forms can be combined. `--project-dir <path>`, `--no-color`, and `--debug` can go before or after the command name.
26+
2527
## Flags
2628

2729
| Flag | Description |
@@ -34,10 +36,13 @@ sqb --project-dir <path> plan [flags]
3436
| `--json` | Output the plan as JSON |
3537
| `--selection-diagnostics` | Warn when a selected model will build on changed upstream models that are not selected; see [Selection and staleness](../concepts/planning/selection-and-staleness.md) |
3638
| `--full-refresh` | Plan a full rebuild for selected models unless a model sets `full_refresh false`; `full_refresh true` forces a model without this flag |
39+
| `--start-cursor` | Override the start cursor, typed from the selected incremental models' cursor type; fails with `S303` if the selection mixes timestamp and integer cursors. With no cursor model selected, an integer value is read as an integer cursor and anything else as an ISO timestamp |
40+
| `--end-cursor` | Override the end cursor, typed the same way as `--start-cursor` |
3741
| `--start-cursor-ts` | Override start cursor for timestamp incremental models (ISO format) |
3842
| `--end-cursor-ts` | Override end cursor for timestamp incremental models (ISO format) |
3943
| `--start-cursor-int` | Override start cursor for integer incremental models |
4044
| `--end-cursor-int` | Override end cursor for integer incremental models |
45+
| `SELECTOR ...` | Positional selectors, the same as `--select` |
4146
| `--select`, `-s` | Select specific models |
4247
| `--exclude` | Exclude specific models |
4348
| `--warehouse <name>` | Snowflake warehouse for this invocation; overrides the target's `build` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse |

‎src/sqlbuild/.agents/skills/sqlbuild/references/docs/cli/query.md‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
77
Online: https://sqlbuild.com/docs/cli/query/
88

9+
## Contents
10+
11+
- Usage
12+
- Flags
13+
- Output formats
14+
- Errors
15+
- Examples
16+
917
Execute ad hoc SQL against the active project connection. Useful for inspecting data, debugging models, or running one-off queries without leaving the SQLBuild CLI.
1018

1119
## Usage
@@ -29,6 +37,7 @@ File paths are resolved from the current working directory.
2937
| `sql` | SQL to execute (positional argument) |
3038
| `--file` | Read SQL from a file instead of the command line |
3139
| `--format` | Output format: `long` (default), `table`, `json`, or `csv` |
40+
| `--json` | Shorthand for `--format json` |
3241
| `--limit` | Maximum rows to return (default: 20) |
3342
| `--no-limit` | Disable the row limit |
3443
| `--warehouse <name>` | Snowflake warehouse for this invocation; overrides the target's `query` [warehouse group](../concepts/project-configuration.md#command-group-warehouses) and the connection warehouse |
@@ -101,7 +110,7 @@ sqb query "SELECT * FROM dev.fact_orders"
101110
sqb query "SELECT * FROM dev.dim_customers" --format table --limit 50
102111

103112
# Export to JSON
104-
sqb query "SELECT * FROM dev.daily_revenue" --format json --no-limit
113+
sqb query "SELECT * FROM dev.daily_revenue" --json --no-limit
105114

106115
# Run SQL from a file
107116
sqb query --file debug_query.sql

0 commit comments

Comments
 (0)