> ## Documentation Index
> Fetch the complete documentation index at: https://docs.meetsilicon.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Syncing dbt projects

> Sync your dbt project to Silicon by deploying with the CLI or refreshing from a Git connection

> [!NOTE]
>
> Silicon supports dbt v1.4.0 and above. If you are using an older version of dbt, you will need to upgrade to sync your project to Silicon.

## Syncing your dbt project to Silicon

There are two approaches to syncing dbt into Silicon. Each one has several methods, covered in [CLI deploy methods](#cli-deploy-methods) and [Git connection methods](#git-connection-methods).

| | CLI deploy | Git connection |
| - | - | - |
| How it works | You compile the dbt project with `silicon deploy` and push the resulting manifest to Silicon | Silicon pulls the connected branch, compiles it server-side, and refreshes the project |
| dbt code source | Local working copy or CI checkout | Connected branch in GitHub, GitLab, Azure DevOps, Bitbucket, or dbt Cloud |
| Uncommitted changes | Included when you deploy from a laptop | Not included |
| Connection settings used | Local or CI `profiles.yml` | UI Connection Settings |
| Remote git connection required? | No | Yes |
| Multiple dbt sources | Not supported | Supported |
| Methods | From a laptop, from CI | **Refresh dbt** button, `silicon refresh` from CI, refresh API, `silicon deploy` from a laptop or CI |

> [!TIP]
>
> **New to Silicon?** Start with CLI deploy to see your project quickly, then switch to a Git connection for production, or connect Git from the start if your repository is ready. The [setup path picker](https://docs.meetsilicon.com/get-started/quickstart.md#find-your-setup-path) lists the steps for your setup.

### Which method should I use?

| If you need... | Use |
| - | - |
| Quick local testing / debugging | CLI (`silicon deploy`) |
| Production deployment | Git connection + UI/API refresh |
| Multiple dbt sources | Git connection (required) |
| CI/CD without duplicating credentials | Git connection + `silicon refresh` |
| Include uncommitted changes | CLI only |

For a property-by-property comparison of every method, see [Detailed comparison](#detailed-comparison).

### Common workflows

#### Just getting started

Use [`silicon deploy` from your laptop](#cli-deploy-methods) for the fastest first look, or connect Git from the start if your repository is ready. Move a CLI-deployed project to one of the automated workflows below as soon as it's stable.

#### Production team (git-connected)

For projects with Silicon connected to GitHub, GitLab, Azure DevOps, Bitbucket, or dbt Cloud:

* **PR workflow** -> `silicon start-preview` + `silicon validate` in CI
* **Post-merge to `main`** -> `silicon refresh` from CI, or the refresh API
* **Manual refresh** -> the **Refresh dbt** button, for ad-hoc syncs

#### No git connection

For projects loaded through the CLI only, without a remote git connection:

* **Production sync** -> `silicon deploy` from CI
* **Previews** -> `silicon start-preview` in CI

Not sure whether to use `silicon deploy` or `silicon refresh`? Read about the [differences between the two commands](https://docs.meetsilicon.com/workflow/cli/reference.md#silicon-deploy-vs-silicon-refresh) in the CLI reference.

> [!NOTE]
>
> When you create a project, **Connect via CLI** sets it up for CLI deploy, and **Connect manually** lets you pick a dbt connection type such as GitHub or GitLab for a Git connection. You can change the dbt connection type later in **Project settings**.

For ready-to-use workflow templates, see the [`silicon/cli-actions`](https://github.com/meetsilicon/cli-actions) repo.

## CLI deploy methods

`silicon deploy` compiles the dbt project wherever the CLI runs and replaces the project's Explores with the result. It ignores the project's UI Connection Settings and uses the local or CI `profiles.yml` instead. For command details, see [`silicon deploy`](https://docs.meetsilicon.com/workflow/cli/deploy).

> [accordion] silicon deploy from a developer's laptop
>
> Compiles the dbt project locally and pushes the resulting `manifest.json` to Silicon.
>
> | Property | Value |
> | - | - |
> | dbt code source | Local working copy (uncommitted changes included) |
> | Compile location | Laptop |
> | `profiles.yml` source | Local (`~/.dbt/profiles.yml` by default, or `--profiles-dir`) |
> | Target | Default in that `profiles.yml`, overridden by `--target` |
> | UI Connection Settings respected? | No |
> | Auth | `silicon login` session or `SILICON_API_KEY` env var |
> | Prerequisites | Silicon CLI installed; dbt installed; warehouse creds reachable locally |
> | Remote git connection required? | No |
>
> **Use cases:** initial project setup, debugging, one-off manual deploys.
>
> **Trade-offs:** bypasses PR review; relies on per-developer `profiles.yml`; high footgun risk if a developer's prod target accidentally points at a non-prod warehouse.
>
> > [!WARNING]
> >
> > Don't use `silicon deploy` from your local environment as the primary way you update Silicon. Small mistakes can lead to production issues.

> [accordion] silicon deploy from CI
>
> Same as deploying from a laptop, but runs inside a CI workflow (GitHub Actions, GitLab CI, Azure Pipelines, Bitbucket Pipelines, etc.) with credentials stored as CI secrets.
>
> | Property | Value |
> | - | - |
> | dbt code source | CI runner's checkout of the repo |
> | Compile location | CI runner |
> | `profiles.yml` source | Provided by the workflow -- either committed as an `env_var()` template, or written to disk from a CI secret at runtime |
> | Target | Default in the CI `profiles.yml`, overridden by `--target` |
> | UI Connection Settings respected? | No |
> | Auth | `SILICON_API_KEY` from CI secrets |
> | Prerequisites | Silicon CLI + dbt installed in the workflow; warehouse creds available to CI; valid `profiles.yml` produced at runtime |
> | Remote git connection required? | No |
> | Workflow template | [`deploy.yml`](https://github.com/meetsilicon/cli-actions) in `silicon/cli-actions` (GitHub Actions example) |
>
> **Use cases:** automated production deploys gated by PR merge; PR preview workflows (`silicon start-preview` + `silicon validate`).
>
> **Trade-offs:** requires duplicating warehouse credentials into CI on top of what's already in Silicon; needs dbt available in the runner.
>
> > [!WARNING]
> >
> > Never commit a `profiles.yml` with plaintext credentials. Either use an `env_var()` template committed to the repo, or write the file to disk at runtime from a CI secret.
>
> To set this up, see [continuous deployment example workflows](https://docs.meetsilicon.com/workflow/set-up-ci-cd.md#deploy-changes-to-silicon).

## Git connection methods

The project is connected to a remote git source (GitHub, GitLab, Azure DevOps, Bitbucket, or dbt Cloud) in Project Settings. Every method triggers the same server-side refresh: Silicon pulls the connected branch, compiles it using the UI Connection Settings, and updates the project. The methods differ only in how you trigger that refresh.

You can also run [`silicon deploy`](#cli-deploy-methods) against a git-connected project. It compiles locally or in CI instead of pulling the connected branch, and its result stays in place until the next refresh. Don't use it on projects with [multiple dbt sources](#connecting-multiple-dbt-sources).

Push and merge your changes to the branch your Silicon project is connected to before you trigger a refresh.

> [accordion] "Refresh dbt" button in the Silicon UI
>
> Silicon fetches the dbt code from the configured remote, compiles it server-side, and updates the project.
>
> | Property | Value |
> | - | - |
> | dbt code source | Silicon pulls from the remote git source configured in Project Settings (GitHub, GitLab, Azure DevOps, Bitbucket, dbt Cloud) |
> | Compile location | Silicon servers |
> | `profiles.yml` source | Silicon synthesises one from Project Settings -> Connection Settings |
> | Target | UI Project Settings -> Connection Settings -> Target name |
> | UI Connection Settings respected? | Yes |
> | Auth | Logged-in user in the UI |
> | Prerequisites | Project must have a remote git source connected |
> | Remote git connection required? | Yes |
>
> **Use cases:** ad-hoc refresh after a merge; quick UI-driven sync without leaving the browser.
>
> **Trade-offs:** manual; relies on a human remembering to click it.
>
> The button is on the **Query from tables** page.
>
> If you've changed the underlying data (for example, adding a new column in your `model.sql` file or changing the SQL logic of a dimension), run `dbt run -m yourmodel` before you click **Refresh dbt**.

> [accordion] silicon refresh from CI
>
> Calls the same endpoint as the "Refresh dbt" button, but programmatically from CI (GitHub Actions, GitLab CI, Azure Pipelines, Bitbucket Pipelines, etc.). Silicon does the work server-side using the project's UI Connection Settings.
>
> | Property | Value |
> | - | - |
> | dbt code source | Silicon pulls from the remote git source (configured in Project Settings) |
> | Compile location | Silicon servers |
> | `profiles.yml` source | Synthesised by Silicon from UI Connection Settings |
> | Target | UI Project Settings -> Connection Settings -> Target name |
> | UI Connection Settings respected? | Yes |
> | Auth | `SILICON_API_KEY` from CI secrets |
> | Prerequisites | Project must have a remote git source connected; Silicon CLI installed in the workflow |
> | Remote git connection required? | Yes |
> | Workflow template | [`refresh.yml`](https://github.com/meetsilicon/cli-actions) in `silicon/cli-actions` (GitHub Actions example) |
>
> **Use cases:** automated post-merge sync to production when the project is already git-connected.
>
> **Trade-offs:** can't push uncommitted changes (only what's in the connected branch); won't catch issues pre-merge -- pair with a separate `silicon validate` PR workflow if you want that.

> [accordion] Refresh API from CI
>
> Same as `silicon refresh` from CI, but bypasses the Silicon CLI entirely -- just a `curl` to the API. Works from any CI system (GitHub Actions, GitLab CI, Azure Pipelines, Bitbucket Pipelines, etc.).
>
> | Property | Value |
> | - | - |
> | dbt code source | Silicon pulls from the remote git source (configured in Project Settings) |
> | Compile location | Silicon servers |
> | `profiles.yml` source | Synthesised by Silicon from UI Connection Settings |
> | Target | UI Project Settings -> Connection Settings -> Target name |
> | UI Connection Settings respected? | Yes |
> | Auth | `SILICON_API_KEY` from CI secrets |
> | Prerequisites | Project must have a remote git source connected |
> | Remote git connection required? | Yes |
> | Silicon CLI required? | No |
> | Endpoint | `POST /api/v1/projects/{projectUuid}/refresh` |
>
> **Use cases:** the simplest possible automated refresh -- no dependencies to install. Useful for teams who don't want a Node toolchain in CI.
>
> **Trade-offs:** same as `silicon refresh` from CI. The refresh is async (returns a `jobUuid`); for stronger guarantees, poll `GET /api/v1/jobs/{jobUuid}` to confirm completion before exiting the workflow.

## Detailed comparison

> [accordion] Compare every sync method
>
> | | `silicon deploy` -- laptop | `silicon deploy` -- CI | "Refresh dbt" -- UI button | `silicon refresh` -- CI | `POST /refresh` API -- CI |
> | - | - | - | - | - | - |
> | Approach | CLI deploy | CLI deploy | Git connection | Git connection | Git connection |
> | Automated? | No | Yes | No | Yes | Yes |
> | Pushes uncommitted local changes? | Yes | No | No | No | No |
> | Needs dbt + warehouse creds in CI? | N/A | Yes | No | No | No |
> | Needs Silicon CLI installed? | Yes | Yes | No | Yes | No |
> | Respects UI Target name? | No | No | Yes | Yes | Yes |
> | Works without a remote git connection? | Yes | Yes | No | No | No |
> | Catches breaking changes pre-merge? | With `--select` + `validate` | If used in a PR workflow | No | No | No |
> | Best for | Initial setup, debugging | PR previews; CI deploys with no remote git connection | Ad-hoc UI refresh | Post-merge sync (recommended) | Post-merge sync, minimal-CI shops |

## Things to know

`silicon deploy` does not use the UI **Target name** setting. It uses the local `profiles.yml` default, or whatever `--target` overrides it with. Only the Git connection methods respect the UI Target name.

`silicon refresh` requires a remote git connection. It fails with a `ParameterError` if the project's `dbtConnection.type` is `NONE`.

Refresh is async. `silicon refresh` and the refresh API both return a `jobUuid` and the work continues server-side. If your CI needs to know the refresh succeeded, poll `GET /api/v1/jobs/{jobUuid}` before exiting the workflow.

> [!WARNING]
>
> **Never commit `profiles.yml` with credentials.** For `silicon deploy` from CI, use either a secret-written-to-file approach or an `env_var()` template. Never check in plaintext credentials.

`silicon refresh` and the refresh API are underused. Most CI examples lead with `silicon deploy`, which is the heaviest option in CI because it duplicates dbt and warehouse credentials into the runner. The refresh-based methods are simpler and often a better fit when the project is git-connected.

> [!WARNING]
>
> **Projects with [multiple dbt sources](#connecting-multiple-dbt-sources) must not use `silicon deploy`.** CLI deploy methods replace the project's Explores with only the local repo's models. Use a Git connection method instead.

## Connecting multiple dbt sources

> [!NOTE]
>
> **Availability.** Multiple dbt sources is enabled by default, so the **dbt sources** panel is already visible in Project Settings.

A single Silicon project can connect to more than one dbt project. Each connected dbt project is called a **dbt source**:

* The dbt connection you set up when you first created the Silicon project is the **primary source**.
* Any dbt projects you add on top of it are **additional sources**.

All sources are compiled together into one set of Explores, so tables from different dbt repos appear side-by-side in the same Silicon project and can reference each other via `ref()` and joins.

### When to use this

* A monorepo you've split into multiple dbt projects and want to expose as one analytics surface.
* Multiple teams that each own their own dbt project, but share the same warehouse and want a single place to explore the data.
* Shared/common dbt packages you want to pull into a project alongside team-specific models.

> [!NOTE]
>
> All sources share the Silicon project's warehouse connection. On a project with [multiple warehouse connections](https://docs.meetsilicon.com/workspace-admin/multiple-warehouse-connections.md), you can run an additional source on another connection.

### Adding and managing sources

Go to **Project settings -> dbt connection**. When the feature is enabled for your org, you'll see a **dbt sources** panel that lists the primary source plus any additional ones. Each row shows the source's display name and its git identity (`repository - branch - subfolder`), or the connection type for non-git sources.

From the panel you can:

* **Add an additional source**: connect a GitHub repository, give the source a display name, and fill in its repo/branch/subfolder/credentials and any environment variables. Environment variables are validated when the source is saved. Other connection types aren't supported for additional sources.
* **Edit an additional source**: change its display name, connection details, or environment variables.
* **Remove an additional source**: additional sources can be removed at any time.
* **Edit the primary source**: the primary source is edited via the normal dbt connection form. It cannot be removed.

> [!NOTE]
>
> If a source's saved credentials can't be loaded, its row in the sources panel shows a warning icon. Other sources keep working normally. Only operations that need that specific source's connection will fail.

Each additional source has:

* A **display name**: how it appears in the sources panel and in collision errors.
* Its own **dbt connection**: GitHub only. The primary source can use any of Silicon's supported connection types (GitHub, GitLab, Azure DevOps, Bitbucket, dbt Cloud), but additional sources are limited to GitHub, each with its own repo, branch, subfolder, credentials, and environment variables.
* A **precedence**: the order in which sources are merged. Collisions fail the deploy rather than being resolved by precedence (see below). Precedence determines which source is reported as holding the existing definition and which as the duplicate.

### How compilation and merging works

On refresh, Silicon compiles every source and merges the resulting manifests into a single set of Explores.

**Precedence.** Sources are ordered by precedence. The primary source is always `0` (highest priority). Additional sources are appended after it in the order they were added. Precedence orders the merge for `ref()` and lookup resolution.

**Name collisions.** If the same model name exists in more than one source, **compilation fails** with an error that names each collision and which sources define it (in the form `<section> "<key>" is defined in both "<source A>" and "<source B>"`, listing up to 10 entries and ending with "Rename or remove the duplicate(s) before deploying."). Rename or remove the duplicates in one of the sources before deploying. Only identical dbt built-in macros and docs are merged silently.

> [!WARNING]
>
> **The CLI's `--combine-manifest` flag is a different mechanism.** It merges an external manifest into the manifest the CLI just generated, and unlike the additional-sources merge it does not fail on collisions -- see [`silicon deploy`](https://docs.meetsilicon.com/workflow/cli/reference#silicon-deploy) in the CLI reference.

**What's merged vs. deduplicated.**

* **Models**: must be uniquely named across sources -- a name collision fails the deploy. Once unique, models can be joined across sources and can reference each other with [cross-project refs](#cross-project-refs-between-sources).
* **Metrics, docs, dbt sources, macros**: unioned across all repos.
* **Identical dbt built-in macros and docs**: merged silently across repos and never reported as collisions.

**Environment variables** are scoped to their source's connection and validated when that source is saved.

### Cross-project refs between sources

Experimental

A model in one source can reference a model in another connected source. Use dbt's two-argument `ref`, the same syntax as dbt Mesh and dbt-loom:

```sql theme={null}
select * from {{ ref('upstream_project', 'model_name') }}
```

The first argument is the `name` from the upstream project's `dbt_project.yml`. You don't need dbt-loom or any other package installed in Silicon.

To set up cross-project refs:

1. Contact [Silicon support](mailto:support@meetsilicon.com) to enable the `cross-source-dbt-refs` feature flag for your organization. It's off by default. [What Experimental means](https://docs.meetsilicon.com/support/feature-maturity-levels.md).
2. Connect every upstream repository as a dbt source of the same Silicon project, as described in [Adding and managing sources](#adding-and-managing-sources).
3. Use the [dbt selector](#dbt-selector) of each source to choose which of its models become Explores. A source whose selector matches none of its models still resolves refs from other sources, but you cannot join to its models.
4. Refresh the project.

#### How Silicon compiles the sources

Silicon prepares each source once. Before it compiles, it reads each source's project `name` from `dbt_project.yml`, its two-argument refs written as plain strings, and any `projects:` list in its `dependencies.yml`. It then compiles the sources in dependency order, so a ref to a model in another connected source resolves on the first compile of that source. The sources then merge as described in [How compilation and merging works](#how-compilation-and-merging-works). Chains of refs across several sources work, and so do diamond-shaped dependencies.

Some refs are not visible before compile, for example a ref whose project name comes from a macro, a `{% set %}` variable, or `var()`. These refs still resolve. Silicon compiles that source again after its upstream source has compiled, so the refresh takes longer. Deeper chains also take longer to refresh.

#### Declaring upstream projects

You can list the projects that a source depends on under `projects:` in its `dependencies.yml`. This is optional. It is the dbt Mesh convention, and dbt Core ignores the key.

```yaml theme={null}
projects:
  - name: upstream_project
```

Silicon checks declared upstream projects before it compiles any source. If the declarations form a cycle, the refresh fails immediately with an error that names the projects, for example:

```text theme={null}
Declared dbt upstreams form a cycle: "a" -> "b" -> "a". Fix dependencies.yml in one of the repositories.
```

If a source declares a project that no connected source provides, the refresh fails immediately with an error that names the source, for example:

```text theme={null}
dbt source "a" declares upstream project "p" in dependencies.yml, but no connected dbt source provides project "p".
```

#### Requirements

The two dbt projects must have different `name` values in their `dbt_project.yml` files.

dbt's [model access](https://docs.getdbt.com/docs/mesh/govern/model-access) settings decide which models you can reference:

* You cannot reference a `private` model from another project.
* You can reference a `protected` model. `restrict-access: true` in the consuming project has no effect on cross-project refs.
* You can always reference a `public` model.

Versioned models work. Pin a version with `v`, for example `{{ ref('upstream_project', 'model_name', v=2) }}`, or leave it out to get the latest version.

#### Limits

* The project's dbt version must be 1.6 or newer.
* The two sources must use the same warehouse connection. On a project with [multiple warehouse connections](https://docs.meetsilicon.com/workspace-admin/multiple-warehouse-connections.md), sources on different connections cannot reference each other.
* Silicon reads upstream projects only from connected dbt sources. It does not read an upstream project from anywhere else, for example a manifest published to S3 or to dbt Cloud, so a model that references such a project cannot compile.
* If you run one Silicon project per repository, connect the upstream repository as an additional source of each Silicon project that references it.
* A CLI preview includes the models of other sources only when the parent project has a merged manifest. A project with multiple warehouse connections has no merged manifest. See [Preview projects](#preview-projects).

#### Joins to a model in another source

The downstream model can declare a [join](https://docs.meetsilicon.com/semantic-layer/joins.md) to the upstream model by its model name. The upstream model appears as an Explore, and as a table you can join, only when its source's [dbt selector](#dbt-selector) includes it.

#### Local development and the CLI

dbt-loom keeps working locally with your `dbt_loom.config.yml`. `silicon compile`, `silicon preview`, and `silicon deploy` work from one repository, with no extra setup.

The CLI compiles only the local repository's models. `silicon deploy` uploads only those models, as described in [How refreshes work](#how-refreshes-work). `silicon preview` adds the other sources' models from the parent project's merged manifest, as described in [Preview projects](#preview-projects). When the models of another source are not available, the CLI skips a join to a model from that source and prints a warning.

#### Warnings

A model can use the single-argument form, `ref('model_name')`. If that name exists only in another connected source, the ref resolves to the model in that source. The refresh then records a warning in the project's [compilation history](https://docs.meetsilicon.com/workspace-admin/project-compilation-history.md), with the two-argument form to use, for example:

```text theme={null}
Model "orders" in dbt source "b" uses ref('orders'), which resolved to external model model.a.orders from another dbt source. Use ref('a', 'orders') to make the cross-source reference explicit.
```

Use the two-argument form for all cross-project refs.

#### Errors

If a ref names a dbt project that no connected source provides, the refresh fails with:

```text theme={null}
Cannot resolve dbt source "<source>": ref "<project>.<model>" was not found. No connected dbt source provides project "<project>".
```

This error also appears when the upstream source is on a different warehouse connection.

If the upstream project is connected but has no model with that name, for example after a typo in the ref, the refresh fails with:

```text theme={null}
Cannot resolve cross-source dbt refs: Source "<source>": <project>.<model>: source "<upstream source>" provides project "<project>" but has no model "<model>"
```

If two sources use the same dbt project name and a cross-project ref needs that name, the refresh fails with:

```text theme={null}
dbt sources "<a>" and "<b>" both use the dbt project name "<project>". A model cannot reference another dbt project that has its own name. Change the name: value in one repository's dbt_project.yml.
```

If two sources reference each other, directly or through other sources, or a source depends on an upstream source that failed, the refresh fails with:

```text theme={null}
Cannot resolve cross-source dbt refs: the pending sources depend on each other or on an upstream source that failed. Source "<a>": <b>.<model>; Source "<b>": <a>.<model>
```

If the project's dbt version is 1.4 or 1.5, the refresh fails with:

```text theme={null}
Cross-source dbt refs require dbt 1.6 or newer.
```

When the feature flag is off, a cross-project ref fails with dbt's usual error, followed by this hint:

```text theme={null}
This model references a model in another dbt project. Connect that project as a dbt source and enable cross-source dbt refs for your organization.
```

### How refreshes work

Every refresh -- [Git connection methods](#git-connection-methods), plus **Test & deploy** in Project Settings -- re-fetches and compiles all sources and merges them into one Explore set. If any single source fails (clone, manifest parsing, credentials, model-name collision), the whole refresh fails with an error naming that source. There are no partial deploys.

> [!WARNING]
>
> **Do not use `silicon deploy` against a multi-source project.** The CLI compiles the local repo and writes those Explores directly, without merging in the other sources -- a CLI deploy will replace the project's Explores with only the local repo's models until the next server-side refresh. Teams using multiple dbt sources should sync via a [Git connection method](#git-connection-methods) and must not run `silicon deploy` in CI against a multi-source project.

### Preview projects

A preview of a multi-source project contains models from every source, not just the repo you are working in. How that happens depends on where the preview is created.

**From the Silicon UI.** The preview inherits the parent's additional sources, then compiles all of them server-side and stores the merged result. Branch and manifest overrides you set when creating the preview apply to the primary source only; additional sources are always compiled from the branch saved on their own connection.

**From the CLI** (`silicon preview` and `silicon start-preview`). The CLI compiles your local repo, then fetches the parent project's merged manifest from Silicon and combines the two before uploading. Your locally compiled models win on conflicts, so you get your working changes on top of everything else in the project. This is automatic -- you don't need to pass `--combine-manifest`.

> [!WARNING]
>
> **The CLI's automatic combine is fail-open.** If the parent's merged manifest can't be fetched, the CLI prints a warning and continues with your local models alone, which produces a preview missing the other sources' models rather than an error. Read the CLI output if a preview looks short of models. The most common causes are:
>
> * The parent project has not completed a server-side refresh since additional sources were added, so it has no merged manifest yet. Run **Test & deploy** on the parent first.
> * Your local repo isn't recognised as one of the parent's sources, in which case the CLI says `the local dbt project is not a source of this Silicon project`.
> * You passed `--no-combine`, which skips the fetch.

Passing `--combine-manifest <path-or-url>` explicitly overrides the automatic fetch, and is still the right option when you want a specific manifest rather than the parent's. It takes a single file, so in a project with more than two sources that file must already contain the full merged set.

[Cross-project refs](#cross-project-refs-between-sources) work in a preview the same way as in its parent. A preview created from the UI resolves them on the server. A CLI preview gets the upstream models from the parent's merged manifest. If the CLI skips that combine, it also skips joins to models from other sources and prints a warning.

### Write-back behavior

Silicon has two write-back paths, and they behave differently in a multi-source project.

#### AI agent write-back

Fully supported across all git-backed sources. AI agents that open PRs with dbt changes work in a multi-source project. Before making changes, the agent resolves which source to target, in this order:

1. A source you explicitly specified.
2. The source a resumed thread is already bound to.
3. The only source, if the project has just one.
4. A source named in your prompt.

If it can't decide, it doesn't guess. It asks you to pick from the candidate sources. The chosen source is remembered for the whole thread, so follow-up messages keep editing the same repo and updating the same PR.

> [!NOTE]
>
> Only git-backed sources (GitHub, GitLab, and other git connection types) can be targeted by agent write-back. If the primary source is not git-backed, the agent will skip it in favor of git-backed additional sources.

#### Explore write-back

Supported for the **primary source only**. Writing custom metrics and dimensions back as a PR from the Explore view always opens the PR against the primary source's repo. This means:

* For models that come from the **primary source**, Explore write-back works normally.
* For models that come from an **additional source**, Explore write-back will fail because the model's YAML file isn't in the primary repo.

> [!WARNING]
>
> To edit models in additional sources, use AI agent write-back or edit the source's dbt project directly.

## dbt project settings

For more information about dbt connection types (Github, Gitlab, Bitbucket, etc.) and the fields required for each type, [read the dbt project section in our connection guide](https://docs.meetsilicon.com/integrations/connect-project.md#2-import-a-dbt-project).

Below are details about the universal fields for all connected dbt projects.

### dbt selector

> [!NOTE]
>
> This setting is found under Advanced configuration options

You can filter out models in your dbt project that you don't want to see in Silicon. This is useful if you have a large dbt project and you want to speed up the sync process. Unlike [Tables configuration](https://docs.meetsilicon.com/semantic-layer/tables.md#choosing-which-tables-appear-in-silicon), this selector is applied to the dbt models, so it will skip the entire compilation process for the models that you don't want to see in Silicon. For a side-by-side comparison of the two settings, see [Tables configuration vs. dbt selector](https://docs.meetsilicon.com/semantic-layer/tables.md#tables-configuration-vs-dbt-selector).

To do this, you can add a **dbt selector** to your project settings. This is a JSON object that contains the models you want to include in Silicon.

For example, if you only want to include the `my_model` and all models with the `silicon` tag in Silicon, you can add the following to your dbt project settings:

```console theme={null}
my_model tag:silicon
```

To combine conditions, separate them with a comma. For example, `package:analytics,tag:silicon` includes only models in the `analytics` package that also have the `silicon` tag.

We support all dbt selectors. [Read more about selectors in the dbt docs](https://docs.getdbt.com/reference/node-selection/syntax#combining-state-and-result-selectors).

In a project with [multiple dbt sources](#connecting-multiple-dbt-sources), each source has its own selector. Other sources can still use [cross-project refs](#cross-project-refs-between-sources) to a model outside its source's selector, but that model produces no Explore and you cannot join to it. This lets you connect a repository only so that other sources can reference its models: give it a selector that matches none of its models, such as `tag:reference_only`.

## dbt targets

### What is a dbt target?

A **dbt target** is an environment configuration in your dbt project that defines where and how dbt should run. In dbt Core, targets are defined in your `profiles.yml` file and typically include settings like:

* Database connection details
* Schema/dataset names
* Warehouse specifications
* Other environment-specific configurations

Most teams have multiple targets for different environments:

* `dev` - for development work
* `prod` - for production deployments
* `staging` - for testing before production

Each target can have different connection settings which are stored in your profiles.yml file.
The example `profiles.yml` file below shows different connection settings for the dev and prod targets. Note that on line 3 `target: dev` indicates that the dev target is the default target for this project.

```yaml theme={null}
# example profiles.yml file
jaffle_shop:
  target: dev
  outputs:
    dev:
      type: postgres
      host: localhost
      user: alice
      password: <password>
      port: 5432
      dbname: jaffle_shop
      schema: dbt_alice
      threads: 4

    prod:  # additional prod target
      type: postgres
      host: prod.db.example.com
      user: alice
      password: <prod_password>
      port: 5432
      dbname: jaffle_shop
      schema: analytics
      threads: 8
```

### Configuring your target in Silicon

**Target** contains information about your dbt connection to your warehouse.
By default, we set this to be the same value as you have as the default in your `profiles.yml` file when you run `silicon deploy` (if that's how you created or recently deployed your project). If you want to update this, you can enter the target of your choice in the project settings (for example `prod` or `analytics`).

[Read more about dbt targets in the dbt docs.](https://docs.getdbt.com/reference/dbt-jinja-functions/target)

### How targets work with dbt macros

When Silicon connects to your dbt project, it compiles a `profiles.yml` file based on the connection settings you configure in the Silicon UI or the connection settings from your profiles.yml if you deployed your project from the CLI using `silicon deploy`. This means that any dbt macros in your project that use target settings will be executed by Silicon and resolved according to those settings.

#### Why use targets in macros?

You might want dbt to behave differently depending on the target/environment you're running in. Common use cases include:

* Using different schema naming conventions in dev vs. production
* Configuring different warehouse sizes (small for dev, large for prod)
* Adjusting query performance settings per environment
* Loading different amounts of data (sample data in dev, full data in prod)
* Applying different data retention policies

Let's look at a common example: customizing schema names based on your target.

#### Example: Schema naming based on target

By default, dbt appends your custom schema names to your target schema. For example, if your target schema is `analytics` and you configure a model with `schema='staging'`, dbt creates it in `analytics_staging`.

This default behavior is useful in development because it prevents developers from overwriting each other's work - each developer can have their own target schema like `dbt_jane` or `dbt_john`, resulting in separated schemas like `dbt_jane_staging` and `dbt_john_staging`.

However, in production, you typically want cleaner schema names. Instead of `analytics_staging`, you just want `staging`. This is where customizing the `generate_schema_name` macro based on the target becomes helpful.

**Default behavior:**

```sql theme={null}
{% macro generate_schema_name(custom_schema_name, node) -%}
    {%- set default_schema = target.schema -%}
    {%- if custom_schema_name is none -%}
        {{ default_schema }}
    {%- else -%}
        {{ default_schema }}_{{ custom_schema_name | trim }}
    {%- endif -%}
{%- endmacro %}
```

**Modified behavior for production:**

```sql theme={null}
{% macro generate_schema_name(custom_schema_name, node) -%}
    {%- set default_schema = target.schema -%}
    {%- if custom_schema_name is none -%}
        {{ default_schema }}
    {%- elif target.name == 'prod' -%}
        {{ custom_schema_name | trim }}
    {%- else -%}
        {{ default_schema }}_{{ custom_schema_name | trim }}
    {%- endif -%}
{%- endmacro %}
```

This macro says: "If we're in production (`target.name == 'prod'`), use just the custom schema name. Otherwise, use the default behavior of prefixing it."

**How this works in Silicon:**

If your Silicon connection settings specify:

* **Target name:** `prod`
* **Dataset/Schema:** `analytics`

And you have a model configured with:

```sql theme={null}
{{ config(schema='staging') }}
```

Then Silicon will create/query this model in the `staging` schema - not `analytics_staging` - because `target.name == 'prod'`.

This gives you clean, professional schema names in production (`staging`, `marts`, `reporting`) while maintaining developer isolation in development environments (`dbt_jane_staging`, `dbt_john_staging`).

> [!TIP]
>
> The `generate_schema_name` macro is a default dbt macro and its behavior can be overridden by adding a macro to dbt with the same name. If this macro is not showing up in your dbt project, it means that your project is using the default macro. It is a good idea to check your project for custom macros which can alter your project's configurations.

**Example: Warehouse configuration**

Similarly, if you have a macro that dynamically configures settings:

```sql theme={null}
{% macro get_warehouse() %}
  {% if target.name == 'prod' %}
    {{ return('LARGE_WAREHOUSE') }}
  {% elif target.name == 'dev' %}
    {{ return('SMALL_WAREHOUSE') }}
  {% endif %}
{% endmacro %}
```

And use it in your models:

```sql theme={null}
{{ config(snowflake_warehouse=get_warehouse()) }}
```

Silicon will use the configuration that corresponds to the target name you've configured in your Silicon connection settings.

### Differences between dbt Core and dbt Cloud

In dbt Core, teams commonly use targets to manage different environments. In dbt Cloud, targets are replaced by environments, and custom logic such as `if target.name = dev then...` is commonly swapped out using env vars to become 'if env\_var = development then...' or similar.

## dbt environment variables

### What are environment variables?

Environment variables allow you to set dynamic values that your dbt macros can reference. This is particularly useful if your dbt project uses environment variables to control behavior (common in dbt Cloud setups).

### Configuring environment variables in Silicon

> [!NOTE]
>
> This setting is found under Advanced configuration options

If your dbt project uses [environment variables in your dbt `profiles.yml` file](https://docs.getdbt.com/reference/dbt-jinja-functions/env%5Fvar), you can add these to Silicon in your project settings. For each environment variable, you'll need to add the `key` + `value` pair for the item.

You'll normally find these values in a file called `.env` in your dbt project directory.

For example, you might have something like:

```yaml theme={null}
profile:
  target: prod
  outputs:
    prod:
      type: postgres
      host: 127.0.0.1
      user: "{{ env_var('DBT_USER') }}"
      ....
```

Then a `.env` file like:

```yaml theme={null}
export DBT_USER="myspecialuser"
```

So, in Silicon, you'd add a new environment variable and put `key` as `DBT_USER` and `value` as `myspecialuser`.

### Reserved and blocked variable names

When you create or update a project, Silicon validates each environment variable key and rejects values that could change how dbt or its child processes execute. Names must contain only letters, numbers, and underscores, and cannot start with a number.

The following keys are blocked:

* `GIT_ASKPASS`, `GIT_SSH`, `GIT_SSH_COMMAND`, and any name starting with `GIT_CONFIG_`
* `LD_AUDIT`, `LD_LIBRARY_PATH`, `LD_PRELOAD`, and any name starting with `DYLD_`
* `NODE_OPTIONS`, `NODE_PATH`
* `PATH`, `SHELL`
* `PERL5OPT`, `PYTHONHOME`, `PYTHONPATH`, `RUBYOPT`
* `SSH_ASKPASS`
* Any name starting with `SILICON_DBT_PROFILE_VAR_` (reserved for internal use)

If you have an existing project that already uses one of these keys, project compilation will continue to work -- the check only runs when you save changes to your connection settings. Rename the variable in your dbt project and save the updated settings to clear the validation error.

### How environment variables work with dbt macros

When Silicon compiles your dbt project, any environment variables you configure will be available to your dbt macros through the `env_var()` function.

For example, if you have a macro that checks an environment variable:

```sql theme={null}
{% macro get_schema() %}
  {% if env_var('DBT_ENV') == 'production' %}
    {{ return('prod_analytics') }}
  {% else %}
    {{ return('dev_analytics') }}
  {% endif %}
{% endmacro %}
```

You would set `DBT_ENV=production` as an environment variable in your Silicon connection settings to ensure the macro resolves to `prod_analytics`.

**Key points about environment variables:**

* They're available to all macros in your dbt project via the `env_var()` function
* They're particularly important if your dbt project was built for dbt Cloud, which relies heavily on environment variables
* Make sure to set any environment variables your macros depend on in Silicon to match your production dbt environment

## Key takeaways

* Silicon compiles your dbt project using the target name and other settings you configure in the connection settings
* Any macros that use `target.name`, environment variables, or other profile settings will resolve according to your Silicon configuration
* Make sure your Silicon target name matches the target you use for your production dbt runs to ensure Silicon behaves consistently with your dbt project
* If you have custom macros that depend on target settings or environment variables, ensure those settings are configured correctly in your Silicon connection settings

> [!TIP]
>
> If you're experiencing unexpected behavior with how Silicon compiles your dbt project, check that your target name in Silicon matches what your dbt macros expect, and verify any environment variables your macros depend on are properly set.

## dbt packages

Running `dbt deps` installs the packages listed in `packages.yml` and writes `package-lock.yml`, which records the exact version of every installed package plus a `sha1_hash` fingerprint of the whole dependency tree. On later runs, dbt installs the versions pinned in the lock file instead of re-resolving the ranges in `packages.yml`, so every environment gets the same versions.

`packages.yml` can specify version ranges:

```yaml theme={null}
packages:
  - package: dbt-labs/dbt_utils
    version: [">=1.0.0", "<2.0.0"]
  - package: calogica/dbt_expectations
    version: ">=0.8.0"
```

`package-lock.yml` pins what those ranges resolved to:

```yaml theme={null}
packages:
- package: dbt-labs/dbt_utils
  version: 1.1.1
  name: dbt_utils
- package: calogica/dbt_expectations
  version: 0.10.1
  name: dbt_expectations
sha1_hash: b980d166c84935d6d661192cf31db5144295c1af
```

Commit `package-lock.yml` to version control. Silicon runs `dbt deps` when it compiles your project server-side (the "Refresh dbt" button, `silicon refresh`, and the refresh API), so a committed lock file makes Silicon install the same package versions as your local and CI runs -- the same reason it keeps your team, CI, and production consistent.

To update packages, edit the version ranges in `packages.yml` (or delete `package-lock.yml` to force a fresh resolution), run `dbt deps`, test the change, and commit both files together.

### Private packages

Silicon runs `dbt deps` on its own servers, so a package hosted in a private repository only installs if the credentials to read that repository are available where dbt runs.

**Over the GitHub connector, this works with no extra configuration.** Silicon passes the same credentials it used to clone your project -- the GitHub App installation token or the personal access token on the connection -- to `dbt deps`. Package URLs written in SSH form are rewritten to HTTPS and authenticated with those credentials, so both of these install:

```yaml theme={null}
packages:
  - git: "git@github.com:my-org/my-private-package.git"
    revision: v1.0.0
  - git: "https://github.com/my-org/my-other-package.git"
    revision: v2.1.0
```

The credentials must be able to read the package repository as well as the project repository:

* **GitHub App**: install the app on the package repository too. If it is missing, `dbt deps` fails and the error tells you to add the dependency to the same installation.
* **Personal access token**: the token needs read access to the package repository.

This also applies to GitHub Enterprise, using the host domain set on the connection.

> [!WARNING]
>
> **SSH keys are never used.** The image that runs dbt has no SSH client, so git cannot fall back to SSH. Over the GitHub connector the SSH-form URL above is rewritten to HTTPS before dbt runs, so it still works. On every other connection type an SSH package URL fails with `error: cannot run ssh: No such file or directory`.

**On other connection types** -- GitLab, Azure DevOps, Bitbucket, and dbt Cloud -- the connection's credentials are not available to `dbt deps`. Declare the package over HTTPS with a token supplied as a dbt environment variable:

```yaml theme={null}
packages:
  - git: "https://{{ env_var('DBT_ENV_SECRET_PKG_TOKEN') }}@github.com/my-org/my-private-package.git"
    revision: v1.0.0
```

Set `DBT_ENV_SECRET_PKG_TOKEN` under **Advanced configuration options -> Environment variables** on the dbt connection, and use a read-only token scoped to the package repository. The `DBT_ENV_SECRET_` prefix tells dbt to mask the value in its logs.

> [!NOTE]
>
> In a project with [multiple dbt sources](#connecting-multiple-dbt-sources), every source resolves its own packages with its own connection's credentials, and environment variables are scoped to a single source. A token needed by two sources must be set on both.

For more on dbt package management, see the [dbt packages documentation](https://docs.getdbt.com/docs/build/packages).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.