slingdata-io/sling-cli/sling-build

Claude Code and agent skill by slingdata-io/sling-cli

Trust tier 2
  • community
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Build SQL models with Sling Build — `sling build`, `sling_build.yml`, model selectors, materialization modes, incremental ranges, and dbt compatibility. Use when asked to author or run SQL models / transformations.

Install

npx vskill@latest install slingdata-io/sling-cli/sling-build

SKILL.md

Sling Build — SQL Models with Dependency Resolution

sling build is Sling's lightweight SQL model builder with Jinja-style templating, dependency resolution from ref() calls, and incremental materializations. The single canonical reference is https://docs.slingdata.io/llms.txt — load that first if you need anything beyond the quick reference below.

Gather first

Resolve each row before you write YAML, in this order: the user's request, existing files, discovery (MCP / CLI), then the default in the table. Ask the user only for rows that stay unresolved, one at a time, with a proposed default. If every row resolves, do not ask — build, and state the assumptions you took. Confirm first only for destructive resolutions (for example a mode that drops or rewrites existing tables).

DecisionResolve byDefault
model namerequest, existing SQLstg_<source>__<entity> / fct_<entity> by layer
target connrequest, sling_build.yml, connection.listtarget: in sling_build.yml
layer / folderrequest, name prefix, STRUCTURE.mdstaging
materializationrequest, layer tableview (staging/intermediate); full-refresh (marts)
incremental keyrequest, columnsnone unless mode is incremental
upstreamsrequest, ref() / src(), discoverraw/staging tables for that entity

When you update a model, read the files first. Preserve incremental-state semantics unless asked otherwise.

Project layout

A build project is any directory containing sling_build.yml. Models are .sql files — usually grouped under schema folders or, with dbt_project: true, under models/ and seeds/.

In a full Sling project, put this tree under models/ (see PROJECT.md in the sling skill). First folder = schema. Naming rules: STRUCTURE.md.

models/
sling_build.yml
staging/ # views: stg_<source>__<entity>
stg_stripe__users.sql
stg_stripe__orders.sql
intermediate/ # views: int_<entity>__<verb>
int_orders__joined.sql
marts/ # tables: fct_* / dim_*
fct_orders.sql
LayerFolder = SchemaNamingMaterialization
rawraw_<source>source-nativereplication target — not a build folder
stagingstagingstg_<source>__<entity>view
intermediateintermediateint_<entity>__<verb>view
martsmartsfct_*, dim_*table / incremental

Staging selects from raw via src(). Marts use ref() to staging or intermediate only. Marts never touch raw.

src() and ref()

src() is a passthrough. It does not add a raw_ prefix.

sql
-- two args: schema, table
select * from {{ src('raw_stripe', 'invoice') }}
-- result: select * from raw_stripe.invoice
-- one arg: schema.table
select * from {{ src('raw_stripe.invoice') }}
-- result: select * from raw_stripe.invoice

source() is an alias of src().

ref('name') resolves a model or seed in this project to its full table name. An unknown name is a compile error.

sql
select * from {{ ref('stg_orders') }}
-- result: select * from staging.stg_orders

Duplicate model names in the project are a hard error at load time.

Front-matter

Put YAML in a /** **/ block. It must be the first content in the file. Leading whitespace is allowed. Comments before the block are not. The engine treats the rest of the file as SQL.

You can also use /* { ... } */ or -- { ... } with a brace object.

Front-matter does not rename the model. The model name is the file stem. ref(), selectors, and @name accept the stem or the prod table schema.table. Model names are unique across the project.

sling_build.yml essentials

yaml
target: MY_SNOWFLAKE
defaults:
mode: full-refresh
dev:
schema: dev_${USER}
target: MY_SNOWFLAKE_DEV
dbt_project: false # set true for models/+seeds/ layout

Model materialization modes

Canonical modes: view, full-refresh, incremental, append. Prefer these names.

  • view — CREATE OR REPLACE VIEW.
  • full-refresh — drop and rebuild every run (default). table is an accepted alias.
  • incremental — append/merge based on update_key + unique_key.
  • append — insert only. snapshot is a deprecated alias.
  • truncate — truncate target then reload.

Per-model overrides go in a YAML front-matter block at the top of the SQL. Jinja {%- config(...) -%} is dbt-compat only — prefer YAML:

sql
/**
mode: incremental
update_key: updated_at
unique_key: [id]
range:
start: '2020-01-01'
advance: 1mo
lookback: 2d
**/
select * from {{ ref("stg_orders") }} where {{ incremental_where_cond() }}

Front-matter range: (start, advance, lookback) is the durable backfill window. Pair it with update_key and unique_key. Do not reverse-engineer the binary for this.

Read raw table columns before you write SQL (sling conns discover CONN --columns or MCP database.get_columns). Do not guess column names or types.

Never reference a SELECT alias inside the same query's JOIN or WHERE. Use the source column (c_nationkey, not c.nation_key).

Common workflows

When the warehouse stores an authoritative total (for example o_totalprice), aggregate that column. Recompute from components only when asked.

GoalCommand
Compile (no execute)sling build compile
Run a subsetsling build run -s stg_users,fct_orders
Run a model + downstreamsling build run -s +stg_users
Run models by tagsling build run -s tag:daily
List selected models (no execute)sling build list -s tag:daily
Path globsling build list -s analytics/plausible/*
Force full-refresh on incrementalssling build run --full-refresh
Dev mode overridesling build run --schema dev_alice
Force prod modesling build run --prod
Backfill rangesling build run -s fct_orders --range 2024-01-01,2024-12-31,1mo
Pass variablessling build run --vars '{start_date: 2024-01-01}'
Parallel model runssling build run --threads 4
Skip seed loadingsling build run --no-seeds
Stop on first failuresling build run --fail-fast
Sub-project discoverysling build run -R (scans immediate subdirectories)
Run declarative tests onlysling build test
Create a projectsling init (writes models/sling_build.yml)

Notes:

  • Seeds (CSV files, in seeds/ with dbt_project: true) load before models unless --no-seeds is passed.
  • --range is a one-shot CLI backfill (start,end[,step], e.g. 2024-01-01,2024-12-31,1mo). Prefer front-matter range: for a durable window.
  • --schema forces dev mode and cannot combine with --prod.
  • One project root. Do not leave nested scratch projects (probe/, .probe/). Parent compile skips a subdirectory that has its own sling_build.yml unless you pass -R.
  • Resolve the Gather first checklist before you write a new model. When you edit an incremental model, preserve saved-state semantics unless asked otherwise.

Definition of done: sling build run . --target X (or sling build test) completes with 0 failures. Compile alone does not execute SQL, so it does not prove correctness.

${VAR} in sling_build.yml (for example dev.schema: dev_${USER}) is expanded from the environment. An unset variable in an active field is an error; use ${VAR:-fallback} or --prod / --schema to skip the field.

Use the MCP tools to validate

  • database.get_columns / database.get_schemata — read columns before you write SQL.
  • database.query — sanity-check the SQL against the target before committing.
  • connection.test — make sure target: resolves before the first sling build.

When the user asks for a new model, prefer to:

  1. Inspect upstream columns with database.get_columns (or sling conns discover CONN --columns).
  2. Draft the SQL, including YAML frontmatter when materialization isn't full-refresh.
  3. Run sling build compile -s <model> to confirm the SQL renders cleanly.
  4. Run sling build run . --target <conn> (or -s <model>) until it completes with 0 failures.
  5. Remove scratch files and nested probe projects before you finish.

Full Documentation

Append .md paths to https://docs.slingdata.io to fetch raw markdown. Full index: https://docs.slingdata.io/llms.txt

TopicDoc
Build overviewhttps://docs.slingdata.io/concepts/build.md
Structure & naminghttps://docs.slingdata.io/concepts/build/structure.md
Modelshttps://docs.slingdata.io/concepts/build/models.md
Modeshttps://docs.slingdata.io/concepts/build/modes.md
Incrementalhttps://docs.slingdata.io/concepts/build/incremental.md
Selectorshttps://docs.slingdata.io/concepts/build/selectors.md
Seedshttps://docs.slingdata.io/concepts/build/seeds.md
Macroshttps://docs.slingdata.io/concepts/build/macros.md
Dev & Prodhttps://docs.slingdata.io/concepts/build/dev-prod.md
Project layout (four layers)https://docs.slingdata.io/concepts/project-structure.md

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
917
Repository forks
87
7-day trend score
0

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/slingdata-io/sling-cli/sling-build/badge)](https://verified-skill.com/skills/slingdata-io/sling-cli/sling-build)

Something wrong with this skill or its page? Tell us.