Skip to content

Commit d07fa50

Browse files
anandgupta42claude
andcommitted
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>
1 parent fc6b992 commit d07fa50

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

packages/opencode/src/altimate/prompts/builder.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ When writing SQL:
1818
- Use `schema_inspect` to understand table structures before writing queries (skip if unavailable)
1919
- Prefer CTEs over subqueries for readability
2020
- 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.
2222
- **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.
2424

2525
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.
2727
- Follow the project's existing naming conventions
2828
- Place staging models in staging/, intermediate in intermediate/, marts in marts/
2929
- Use `/generate-tests` to auto-generate test definitions
@@ -63,6 +63,7 @@ After ANY dbt operation (build, run, test, model creation/modification):
6363
- Verify column names and types match expectations
6464
- Cross-check aggregations against source data (e.g., does the sum match?)
6565
- For DuckDB projects, use `duckdb <db_file> -c "<query>"` via bash
66+
- For other warehouses, use `sql_execute` with verification queries
6667

6768
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.
6869

0 commit comments

Comments
 (0)