Skip to content

Add dbt-duckdb workflow keybindings for neovim#73

Closed
michaelbarton wants to merge 17 commits intomasterfrom
claude/dbt-duckdb-workflow-w1GVy
Closed

Add dbt-duckdb workflow keybindings for neovim#73
michaelbarton wants to merge 17 commits intomasterfrom
claude/dbt-duckdb-workflow-w1GVy

Conversation

@michaelbarton
Copy link
Owner

Summary

  • Add neovim keybindings for a complete dbt-duckdb development workflow
  • All <leader>d keymaps: run, build, test, compile, show, with sqlfmt formatting on save
  • Navigation: jump to ref()/source() under cursor, fuzzy model picker via fzf-lua, grep across models, open compiled SQL in readonly split
  • Add sql to treesitter ensure_installed for better SQL highlighting

Keybindings

Keymap Action
<leader>dr dbt run -s model
<leader>dR dbt run -s model+ (with downstream)
<leader>db dbt build -s model (run + test)
<leader>dc dbt compile -s model
<leader>dt dbt test -s model
<leader>ds dbt show -s model (preview results)
<leader>dg Go to ref/source under cursor
<leader>df Fuzzy model picker (ctrl-r/b/t to run/build/test)
<leader>do Open compiled SQL in readonly vsplit
<leader>d/ Grep across all models

Test plan

  • Open a .sql file in a dbt project and verify <leader>dr formats + runs
  • Place cursor on a ref('model') call and verify <leader>dg jumps to the file
  • Verify <leader>df opens fzf picker scoped to models/**/*.sql
  • Verify <leader>do opens compiled SQL after running dbt compile

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ

claude and others added 17 commits March 5, 2026 05:46
Add <leader>dr (dbt run), <leader>dc (dbt compile), and <leader>dt
(dbt test) keybindings that format the current SQL file with sqlfmt
via conform, save, then send the dbt command to toggleterm. Also add
sql to treesitter ensure_installed for better SQL highlighting.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
- <leader>dR: dbt run -s model+ (model and all downstream dependents)
- <leader>db: dbt build (run + test in DAG order)
- <leader>ds: dbt show (preview query results without materializing)

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
- <leader>dg: jump to ref() or source() under cursor
- <leader>df: fzf model picker with ctrl-r/b/t to run/build/test
- <leader>do: open compiled SQL in readonly vsplit
- <leader>d/: grep across all models (find columns, CTEs, etc.)

Inspired by fzf-dbt CLI tool, adapted for neovim with fzf-lua.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
<leader>da: quick analysis with sonnet — reviews the current model
and suggests improvements in non-interactive mode.

<leader>dA: deep analysis with sonnet thinking — interrogates the
duckdb database and cross-references with the current model to check
data quality, joins, types, and more.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
The <leader>dA keymap now compiles the model first, then passes
the compiled SQL and first 20 rows from dbt show as extra context
to the claude agent for more informed analysis.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
Prompts now live in nvim/prompts/ as markdown files with {{var}}
template placeholders. The quick analysis prompt is loaded and
substituted in Lua; the deep analysis prompt uses sed at runtime
to inject compiled SQL and sample rows before passing to claude.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
- <leader>da now replaces the buffer with the annotated SQL (undo with :u)
- Updated prompt to allow brief explanations alongside suggestions
- All dbt commands (run, build, test, compile, show) now use uv run

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
<leader>dA now opens a new tmux window named 'dbt:<model>' that
compiles the model, gathers sample rows, then starts an interactive
claude session with that context so you can discuss the model.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
Runs dbt show --limit 20 asynchronously and displays the results
in a read-only scratch buffer. Press q to close.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
fzf-lua is not installed; the config uses telescope via LazyVim.
Converts wiki search, wiki insert link, dbt model finder (with
C-r/C-b/C-t actions), and dbt grep to telescope equivalents.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
Pipes `dbt show --output csv --limit 500` into visidata via
toggleterm. Formats and saves the file first like other dbt commands.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
Uses a dedicated toggleterm Terminal with close_on_exit and an
on_exit callback instead of the shared terminal, so focus returns
to the previous window when visidata is quit.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
dbt show only supports --output json/text, not csv. Use
--output json --log-format json and pipe through a python
script that extracts the preview data and converts to CSV.

https://claude.ai/code/session_016johXLfEd6P4umaT14YQEQ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants