agentleFS
MicrosoftKnown publishermicrosoft/dbt-scope/.github/copilot-instructions.md

dbt-scope

Copilot instructions3 starsChanged 5 months agoMITView on GitHub

dbt-scope is a dbt adapter that generates SCOPE scripts (not SQL) and submits them as ADLA jobs via REST API. Models written as SELECT ... FROM @data are compiled into complete SCOPE scripts with EXTRACT, CREATE TABLE, DELETE, and INSERT INTO blocks targeting Delta tables on ADLS. Materializations call helper macros that delegate to ScriptBuilder via the adapter. Most dbt DDL/introspection macros are no-ops since SCOPE has no schema catalog. The two key materializations:

  • Reads credentials

The file

Files
copilot-instructions.md

Copilot Instructions — dbt-scope

Build, test, lint

uv sync --extra dev                             # create .venv and install dev deps
.scripts/run.sh unit-test                       # fast, no credentials needed
.scripts/run.sh integration-test                # requires ADLA + az login + .env
.scripts/run.sh lint                            # ruff check + format --check
.scripts/run.sh fix                             # ruff auto-fix + format
.scripts/run.sh upload                          # build and upload the adapter to a storage account

# Single test file or test
uv run pytest tests/unit/test_script_builder.py -v
uv run pytest tests/unit/test_script_builder.py::TestScriptBuilderFullRefresh::test_generates_create_table -v

Architecture

dbt-scope is a dbt adapter that generates SCOPE scripts (not SQL) and submits them as ADLA jobs via REST API. Models written as SELECT ... FROM @data are compiled into complete SCOPE scripts with EXTRACT, CREATE TABLE, DELETE, and INSERT INTO blocks targeting Delta tables on ADLS.

Adapter layer (dbt/adapters/scope/)

FileRole
impl.pyScopeAdapter(BaseAdapter) — most introspection methods are no-ops because SCOPE has no catalog. drop_relation is a no-op for safety; rename_relation raises.
connections.pyREST client for ADLA. ScopeConnectionHandle submits jobs via PUT, polls via GET. ScopeConnectionManager.execute() passes scripts to submit_and_wait(). SELECT 1 is special-cased to verify auth only.
script_builder.pyCore engine. ScriptBuilder has static methods (build_full_refresh, build_incremental, build_checkpoint, build_drop) that assemble complete SCOPE scripts from a ScriptConfig + model SQL. All script generation is pure Python string building — not Jinja.
credentials.pyScopeCredentials — maps profiles.yml fields. Auth uses AzureCliCredential (az login).
relation.pyScopeRelation — extends BaseRelation. Adds delta_location for ABFSS paths. Identifiers are unquoted.
column.pyScopeColumn — maps agate/dbt types to SCOPE types (e.g., number → double, date → DateTime).

Macro layer (dbt/include/scope/macros/)

Materializations call helper macros that delegate to ScriptBuilder via the adapter. Most dbt DDL/introspection macros are no-ops since SCOPE has no schema catalog. The two key materializations:

  • table — calls build_full_refresh: CREATE TABLE + EXTRACT + INSERT.
  • incremental — for microbatch: DELETE partition range + EXTRACT with date filter + INSERT. For append/full-refresh: same as table.

SCOPE script conventions

  • @target = Delta table, @data = extracted SS rowset, @batch_data = user's transformed data.
  • Virtual columns _date, _serial, _source_file are added during EXTRACT.
  • The partition column (e.g., event_year_date) is excluded from EXTRACT and derived from _date.
  • Incremental mode sets @@DeltaLakeCommitCondition (configurable via delta_lake_commit_condition, default FailIfFileConflict).

Key conventions

  • Python 3.10+ — use from __future__ import annotations, list[X] / dict[X, Y] (not List/Dict).
  • Dataclasses for config/model objects. Use frozen=True for immutable types (e.g., ScopeRelation).
  • Logging — log = logging.getLogger(__name__) with %-style formatting (not f-strings) for lazy evaluation.
  • Exceptions — DbtRuntimeError for config/logic errors, DbtDatabaseError for API/job failures. Chain with from exc.
  • Ruff — line length 100, double quotes, rule set: E, W, F, I, N, UP, B, SIM, T20, RUF. print() is forbidden in library code (allowed in tests).
  • Tests — unit tests use class TestX: grouping with fixtures from conftest.py. Integration tests require .env + az login and use @pytest.mark.timeout(3600).
  • ScriptBuilder is pure Python — all SCOPE script generation is in script_builder.py using string assembly. Jinja macros only orchestrate; they don't build script text.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.