You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: address code review findings on builder prompt
- Scope "Explore first" to relevant models in same layer/domain instead
of reading ALL models (performance concern for large projects)
- Make reserved word quoting dialect-aware: double quotes for ANSI SQL,
backticks for BigQuery/MySQL, brackets for SQL Server
- Add incremental model exception for temporal function guidance
- Add warehouse-agnostic fallback for output validation (not just DuckDB)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: packages/opencode/src/altimate/prompts/builder.txt
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -18,12 +18,12 @@ When writing SQL:
18
18
- Use `schema_inspect` to understand table structures before writing queries (skip if unavailable)
19
19
- Prefer CTEs over subqueries for readability
20
20
- Include column descriptions in dbt YAML files
21
-
- **Avoid non-deterministic functions** (`current_date`, `now()`, `current_timestamp`, `getdate()`) in models operating on fixed/historical datasets. Use date columns from source data instead. Only use temporal functions when the task explicitly requires "as of today" logic.
21
+
- **Avoid non-deterministic functions** (`current_date`, `now()`, `current_timestamp`, `getdate()`) in models operating on fixed/historical datasets. Use date columns from source data instead. Only use temporal functions when the task explicitly requires "as of today" logic. Incremental models that filter new records are an exception — use dbt's `is_incremental()` guard pattern.
22
22
- **Read before writing**: Always read existing model files thoroughly before creating new ones. Understand the existing schema, column names, and data flow. Modify existing models when the task requires changes — do not duplicate logic in new files.
23
-
- **Quote reserved words**: If a column name is a SQL reserved word (e.g., `offset`, `order`, `group`, `user`, `type`, `date`, `time`, `key`, `value`, `index`, `range`, `comment`, `rank`, `count`), always wrap it in double quotes in SQL: `"offset"`, `"order"`, etc.
23
+
- **Quote reserved words**: If a column name is a SQL reserved word (e.g., `offset`, `order`, `group`, `user`, `type`, `date`, `time`, `key`, `value`, `index`, `range`, `comment`, `rank`), use the warehouse's identifier quoting convention: double quotes for ANSI SQL (Snowflake, PostgreSQL, DuckDB), backticks for BigQuery/MySQL, brackets for SQL Server.
24
24
25
25
When creating dbt models:
26
-
- **Explore first**: Read ALL existing models in the project before writing anything. Understand the DAG, naming conventions, and column contracts already in place.
26
+
- **Explore first**: Read relevant existing models in the same layer/domain before writing anything. Understand the DAG, naming conventions, and column contracts from nearby models.
27
27
- Follow the project's existing naming conventions
28
28
- Place staging models in staging/, intermediate in intermediate/, marts in marts/
29
29
- Use `/generate-tests` to auto-generate test definitions
@@ -63,6 +63,7 @@ After ANY dbt operation (build, run, test, model creation/modification):
63
63
- Verify column names and types match expectations
64
64
- Cross-check aggregations against source data (e.g., does the sum match?)
65
65
- For DuckDB projects, use `duckdb <db_file> -c "<query>"` via bash
66
+
- For other warehouses, use `sql_execute` with verification queries
66
67
67
68
Do NOT consider a dbt task complete until you have verified the output data is correct, not just that the SQL compiles. A model that runs but produces wrong results is NOT done.
0 commit comments