When to use it
Use AI writeback when the change you want needs to land in your dbt project files:- Rename a metric in a YAML file
- Add a new metric or dimension to a dbt model
- Edit a model’s SQL
- Update a description, label, or
metablock - Fix a typo in a column definition
Prerequisites
- The AI writeback feature flag must be enabled for your organization.
- Your project’s dbt connection must be a GitHub or GitLab repository. Bitbucket, Azure DevOps, dbt Cloud, and local dbt projects are not supported.
- The matching Lightdash app must be installed for the repository so the agent can open requests:
- GitHub — install the Lightdash GitHub App on the repository.
- GitLab — connect the Lightdash GitLab App for your organization (self-hosted GitLab is supported via the project’s
host_domain).
- You need at least project Developer permissions on the project.
How it works
When you ask the agent for a change that belongs in the repo, it calls a tool calledproposeWriteback. The tool:
- Spawns a separate, sandboxed writeback agent with no memory of your chat.
- Hands that agent a self-contained instruction generated from your request.
- The writeback agent edits the relevant files, runs
lightdash compileto validate the result, and pushes a new branch. - A pull request (GitHub) or merge request (GitLab) is opened against your repository’s default branch and the URL is returned to you in chat.
GitHub commits are signed by the Lightdash GitHub App. GitLab commits are
pushed over OAuth and are unsigned.
Using it in chat
Phrase your request as a direct change to the repo and, where possible, name the file, model, or field you want touched. The more specific you are, the more reliably the writeback agent finds the right place to edit. Good promptsIterating on an existing pull request
If you’ve already opened a writeback pull request — either earlier in the same thread or by pasting a link to one — the agent commits follow-up changes onto that PR’s branch instead of opening a new one. The PR’s title and description are refreshed to reflect the latest change. There are two ways this happens:- Same thread. If the thread already has a writeback PR, any further writeback requests in that thread automatically resume it. You don’t need to paste the link.
- Paste a link. In a new thread (or before a writeback PR exists for the current thread), paste the GitHub pull request URL alongside your request. The agent picks up the link, checks out that PR’s branch, and commits your edits onto it.
- Live in the same GitHub repository as the project’s dbt connection.
- Be open — merged or closed PRs are rejected.
- Have its branch in the same repository (PRs opened from forks are rejected).
What happens if it can’t run
Related
- dbt write-back — write back individual custom metrics, dimensions, and SQL Runner queries from the Lightdash UI.