AI writeback lets you ask an AI agent in chat or Slack to change something in the dbt repository that backs your project — rename a metric, add a dimension, edit a model’s SQL, fix a YAML description — and have the agent open a pull request with the change. This is the same writeback capability you would normally trigger from the Custom Metric or SQL Runner menus, surfaced inside the conversation with your AI agent.Documentation Index
Fetch the complete documentation index at: https://lightdash-mintlify-d04b4ea9.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
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
| You want to… | The agent uses… |
|---|---|
| Ask a question about data | Query and discovery tools |
| Edit an existing chart or dashboard in Lightdash | editContent |
| Propose an in-app change to a metric or dimension for review | proposeChange (see Self-improvement) |
| Change the underlying dbt repository | proposeWriteback |
Prerequisites
- The AI writeback feature flag must be enabled for your organization.
- Your project’s dbt connection must be a GitHub repository. GitLab, Bitbucket, Azure DevOps, and local dbt projects are not supported.
- The Lightdash GitHub App must be installed on the repository so the agent can open pull requests.
- 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 is opened against your repository’s default branch and the URL is returned to you in chat.
Pull request attribution
Writeback pull requests are opened as the GitHub user who connected the Lightdash GitHub App to your organization, not as the Lightdash bot. Commits are authored by that same user and signed by GitHub (created through the GitHub API on behalf of the user), so they appear as Verified in the GitHub UI and count toward branch protection rules that require signed or verified commits. A few things to know:- The connecting user must keep their GitHub authorization for the Lightdash App active. If their token can’t be refreshed, writeback falls back to opening the pull request as the
lightdash-app[bot]with unsigned commits authored byLightdash <developers@lightdash.com>. - Attribution is currently per organization, not per chat requester. Every writeback PR from your org is attributed to the same connecting GitHub user, regardless of who asked the agent for the change. The original requester is recorded in the chat thread and in the PR description, not on the commit.
- Because the PR author is a real GitHub user, that user receives the usual GitHub notifications (review requests, CI failures, etc.) for writeback PRs.
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 promptsWhat happens if it can’t run
| Situation | Result |
|---|---|
| Feature flag is off | The tool isn’t available. The agent answers normally without offering to open a pull request. |
| Project’s dbt connection isn’t GitHub | The agent tells you the project must be connected to GitHub for writeback. |
| GitHub App isn’t installed on the repo | The agent surfaces a setup error. Install the Lightdash GitHub App on the repository (from your project’s dbt connection settings) and try again. |
| Writeback agent makes no file changes | No pull request is opened. The agent reports back that nothing needed to change. |
Related
- dbt write-back — write back individual custom metrics, dimensions, and SQL Runner queries from the Lightdash UI.
- Self-improvement — let agents propose in-app changes to the semantic layer through reviewable changesets instead of pull requests.