/bauplan:bauplan-data-pipelinefrom bauplan
Creates bauplan data pipeline projects with SQL and Python models, including DAG transformations, model definitions, and project structure setup.
Ships in bauplan. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
This skill guides you through creating a new bauplan data pipeline project from scratch, including the project configuration and transformation models.
NEVER run pipelines on
mainbranch. ALWAYS use a separate data branch for development.
Branch naming convention: <username>.<branch_name> (e.g., john.feature-pipeline). Get your username by running bauplan info.
Before writing pipeline code, check whether the project uses uv (look for pyproject.toml or uv.lock). If so, use uv run to execute commands and uv add to install packages. Otherwise, use pip install.
Ensure the environment has a typed SDK build (0.3.0+). Typed declarations are only available with SDK 0.3.0+: older versions are not compatible. Use that same environment for all CLI commands and verify connectivity with bauplan info. Models declare their own runtime dependencies via @bauplan.python('3.13', pip={...}); annotation imports require pyarrow locally too.
<namespace>.<table_name> (e.g., bauplan.taxi_fhvhv).bauplan.Before writing a pipeline, you MUST gather the following from the user:
bauplan table get <namespace>.<table_name>.REPLACE): Should output tables use REPLACE or APPEND?bauplan-data-semantics skill for details.If any required item is missing, ask the user before writing any code.
A bauplan pipeline is a DAG of functions (models). Key concepts:
Annotated[pa.Table, bauplan.Model(...)] parameters, either from the outputs of previous Models or as Source Tables.def clean_trips() → clean_trips).bauplan-data-quality-checks skill — do not write expectations directly in this skill.[lakehouse: taxi_fhvhv] ──→ [trips] ──→ [clean_trips] ──→ [daily_summary]
↑
[lakehouse: taxi_zones] ──────────────────────┘
taxi_fhvhv and taxi_zones are Source Tables (already in lakehouse)trips is a Python Model reading from taxi_fhvhv (single input)clean_trips is a Python Model taking trips and taxi_zones as inputs (multiple inputs)daily_summary is a Python Model taking clean_trips as input (single input)Python models are the preferred way to write all transformations. They are Python functions registered with decorators.
from typing import Annotated
import bauplan
import pyarrow as pa
class TripColumns(bauplan.TableSchema):
"""Trip fields needed to filter positive mileage."""
pickup_datetime: bauplan.TimestampMicro | None
PULocationID: bauplan.Int64 | None
trip_miles: bauplan.Float64 | None
class CleanTripsSchema(bauplan.TableSchema):
"""Trips with positive mileage."""
pickup_datetime: bauplan.TimestampMicro | None
PULocationID: bauplan.Int64 | None
trip_miles: bauplan.Float64 | None
@bauplan.model(
# persist output as an Iceberg table; omit for intermediate models
materialization_strategy='REPLACE'
)
# specify Python version and dependencies; prefer Polars or DuckDB over Pandas
@bauplan.python('3.13', pip={'polars': '2.0.0'})
def clean_trips(
# Projection and filtering restrict the data read before the function runs
data: Annotated[
pa.Table,
bauplan.Model('trips', projection_schema=TripColumns, filter="trip_miles > 0"),
],
) -> Annotated[pa.Table, CleanTripsSchema]:
"""
Filters trips to include only those with positive mileage.
| pickup_datetime | PULocationID | trip_miles |
|---------------------|--------------|------------|
| 2022-12-01 08:00:00 | 123 | 5.2 |
"""
# Import processing dependencies inside the function for its model environment
import polars as pl
df = pl.DataFrame(data)
df = df.filter(pl.col('trip_miles') > 0.0)
return df.to_arrow()
Models can take multiple tables as input — add more bauplan.Model() parameters.
See examples.md for complete examples.
Consult the skill bauplan-dag-optimization for thorough instructions on DAG optimization.
Declare model outputs with -> Annotated[pa.Table, OutputSchema], where OutputSchema inherits directly from bauplan.TableSchema. The return annotation is mandatory and must take this exact form: a bare -> pa.Table and a missing annotation are both rejected at parse time. The contract is exhaustive and enforced on every run with no flag to opt in: the returned table must carry exactly the declared columns, so an extra column fails the run with ModelOutputContractError just as a missing one does. The columns keyword is no longer accepted by @bauplan.model(), it only worked for SDK versions < 0.3.0. Inspect source column types with bauplan table get <namespace>.<table> and derive output types from the transformation; ask when a type cannot be determined. Give schema classes descriptive docstrings and names unique across project files. Use Annotated[FieldType, bauplan.TableField(doc=...)] when a column needs documentation, and lineage= when it should point at a field of another schema class in the same file. Use name= (0.3.3+) when the column name is not a valid Python identifier: trip_miles: Annotated[bauplan.Float64 | None, bauplan.TableField(name="trip miles")]. A lineage= pointing at such a field uses its attribute name, not its column name: lineage=OtherSchema['trip_miles']. Those three are the only TableField parameters: anything else fails at parse time with Unexpected TableField parameter: <name>.
Use the field type mapping as below:
| SDK type | Arrow type | Iceberg type (catalog) |
|---|---|---|
| Bool | bool | boolean |
| Int32 | int32 | int |
| Int64 | int64 | long |
| Float64 | float64 | double |
| String | string (utf8) | string |
| Date32 | date32 (days) | date |
| Date64 | date64 (milliseconds) | date (Iceberg has day precision only) |
| TimestampMicro | timestamp('us') | timestamp |
| TimestampNano | timestamp('ns') | timestamp_ns (Iceberg v3 only) |
| TimestampMicroUTC | timestamp('us', tz='UTC') | timestamptz |
| TimestampNanoUTC | timestamp('ns', tz='UTC') | timestamptz_ns (Iceberg v3 only) |
| Binary | binary | binary |
| Any | passthrough, whatever the artifact carries | any type, not validated |
Return an actual pa.Table.
Nullability is part of the type, not a parameter: a bare bauplan.Int64 declares a required column, bauplan.Int64 | None an optional one. In an Annotated field the union goes on the data type, as Annotated[bauplan.Int64 | None, bauplan.TableField(doc=...)]; wrapping the whole annotation is rejected.
The two positions are decided differently. A projection schema must mirror the source: an optional source column cannot satisfy a required field, so read the NULLABLE column of bauplan table get and use | None for every column it marks nullable. An output schema is your declaration about the data the model produces: it is checked by counting actual nulls in the returned table, not by reading Arrow's nullability flag, and it becomes the written column's nullability in the catalog. | None is the safe default there too; declare an output column required only when the transformation guarantees no nulls, such as a count or other aggregate, a fill_null, or a column the filter cannot leave null.
Cast unsigned aggregation counts to signed integers and align float widths and timestamp units with the declared contract. Decimal columns and nested list, struct, and map fields have no supported schema type: annotate them as bauplan.Any, the SDK's own passthrough type and not typing.Any (the column still carries its real Arrow type at runtime, it is just not pinned by the contract), and report the limitation.
Run parameters use plain Python types in annotations, for example rate: Annotated[float, bauplan.Parameter("rate")], matching the parameter's type in bauplan_project.yml.
Every Python model should have a docstring describing the transformation and showing the output table structure as an ASCII table. If the table is too wide, show only key columns; if values are too large, truncate them.
This docstring is published metadata, not just a comment: it is written to Iceberg as the table's comment, and each field's TableField(doc=...) is written as that column's doc. Starting with 0.3.2, bauplan table get surfaces table and column documentation (properties.comment and doc, respectively). Table documentation is displayed first, then the table schema is displayed with an extra column, DOC. When a model has no docstring the output schema's docstring is used instead. Both are passed through inspect.cleandoc, so indentation is normalized and a whitespace-only doc means no documentation at all. Write them as documentation the reader of the catalog will see. See the bauplan-data-semantics skill for more guidelines and details for documentation to support a semantic layer.
projection_schema and filterUse projection_schema and filter in bauplan.Model() to restrict the data read at the storage level. Declare only needed columns and their types in a projection TableSchema. The supported Model arguments are name, projection_schema, and filter.
projection_schema: a TableSchema class containing only the fields your model needs.filter: a literal SQL-like string to restrict rows (e.g., filter="price > 0"). $param interpolation is supported; Python variables and f-strings are not.Note well: the use of filter= on models now applies only to tables read from the catalog; when applied to other models (nodes in the DAG) it results in an error. Move this filter inside the body of the function.
See examples.md for a complete guide.
Use Polars or DuckDB for data processing inside Python models. Do not use Pandas. Bauplan models receive and return Apache Arrow tables. Polars and DuckDB operate natively on Arrow with zero-copy reads and multi-threaded execution. Pandas requires a full data copy into its own format — slower, single-threaded, and uses significantly more memory.
pl.DataFrame(data) on input, result.to_arrow() on output. Prefer pl.DataFrame over pl.from_arrow for type-checking purposes.con.register("name", data) and return con.sql(query).to_arrow_table(), pinning duckdb 2.0.0 or later.Note: client.query() in the SDK returns a PyArrow table directly — no .to_arrow() needed. Inside models, the data parameter is also already an Arrow table. The only place you call .to_arrow() is when converting a Polars DataFrame back to Arrow for the model return value.
A bauplan project is a folder containing:
my-project/
bauplan_project.yml # Required: project configuration
models.py # Python models (one file can contain the entire pipeline)
expectations.py # Optional: generated by the bauplan-data-quality-checks skill
You can generate one automatically using bauplan init <PATH> --name <NAME>. Note that it scaffolds three files, not one: bauplan_project.yaml (the .yaml spelling, though both extensions are accepted), plus a pyproject.toml and a models.py of boilerplate you should get rid of.
bauplan_project.ymlEvery project requires this configuration file:
project:
id: <unique-uuid> # Generate, if needed, with: python3 -c "import uuid; print(uuid.uuid4())"
name: <project_name> # Descriptive name for the project
Always run from inside the project directory (the folder containing bauplan_project.yml).
The annotations are what make a pipeline checkable without running it, so use them. Before any bauplan command, run the type checker from the project directory with uvx ty check. Model runtime dependencies (polars, duckdb, local utility modules) live in the remote model environment, so the checker reports them as unresolved imports. Fix that by adding them to the project's dev dependencies, uv add --dev polars, ideally at the version pinned in @bauplan.python(pip={...}): it only affects the local checker, never what the model runs with, and it keeps the report clean without suppression comments scattered through the models. Unresolved bauplan symbols are a different matter and always a real error.
A dry run validates the pipeline without materializing tables: DAG wiring, source tables, SQL, and schema references. Always dry-run before a full run.
bauplan run --dry-run
If the dry run fails, read the error output, fix the issue, and dry-run again. Don't proceed to a full run until the dry run passes.
bauplan run
This executes the pipeline and materializes all models that have a materialization_strategy set. After a successful run, verify the output:
bauplan table get <namespace>.<output_table>
bauplan query "SELECT * FROM <namespace>.<output_table> LIMIT 5"
Strict mode is on by default: a failing expectation fails the run. There is no --strict flag to pass. --no-strict is a bare flag that disables enforcement for the whole run; the SDK equivalent is client.run(..., strict=False), and strict, cache, and transaction all default to True.
After writing models, verify each model has the correct materialization_strategy:
materialization_strategy → @bauplan.model()@bauplan.model(materialization_strategy='REPLACE') or 'APPEND'bauplan infobauplan branch checkout mainbauplan branch create <username>.<branch_name>bauplan branch checkout <username>.<branch_name>bauplan table get <namespace>.<table_name>bauplan_project.ymlbauplan-data-semantics skill with the project path. The skill reads models.py and the source tables' existing documentation, then drafts the docstrings and TableField(doc=) text to apply.uvx ty check, fix everything it reportsbauplan run --dry-runbauplan runbauplan table get + bauplan querybauplan-data-quality-checks skill with the project path. The skill reads models.py, derives checks from how the pipeline uses each table, and generates expectations.py.Bauplan also supports SQL models for simple reads from source tables. SQL models are .sql files where the filename becomes the output table name and the FROM clause defines the inputs.
-- trips.sql
-- bauplan: output_schema = TripsSqlSchema
SELECT
pickup_datetime,
PULocationID,
trip_miles
FROM taxi_fhvhv
WHERE pickup_datetime >= '2022-12-01'
Output table: trips (from filename). Add -- bauplan: materialization_strategy=REPLACE as a comment to materialize.
Define the referenced schema in the sibling models.py, using the actual source types:
import bauplan
class TripsSqlSchema(bauplan.TableSchema):
"""Trip fields selected by the SQL model."""
pickup_datetime: bauplan.TimestampMicro | None
PULocationID: bauplan.Int64 | None
trip_miles: bauplan.Float64 | None
Limitations:
output_schema; document fields in the Python schema class and express projections and filters in SQL.See examples.md for:
When unsure about a method signature, CLI flag, or concept, fetch the relevant doc page via WebFetch rather than guessing. Pages are markdown and LLM-friendly.
Python SDK: https://docs.bauplanlabs.com/reference/bauplan.md
SDK types: https://docs.bauplanlabs.com/reference/bauplan-sdk-types.md
Standard expectations: https://docs.bauplanlabs.com/reference/bauplan-standard-expectations.md
Relevant concept pages:
https://docs.bauplanlabs.com/concepts/semantic-annotations.mdhttps://docs.bauplanlabs.com/concepts/models.mdhttps://docs.bauplanlabs.com/concepts/pipelines.mdhttps://docs.bauplanlabs.com/concepts/projects.mdhttps://docs.bauplanlabs.com/concepts/expectations.mdhttps://docs.bauplanlabs.com/overview/execution-model.mdhttps://docs.bauplanlabs.com/common-scenarios/parameterized-runs.mdFull doc index: https://docs.bauplanlabs.com/llms.txt
CLI: The bauplan CLI is self-documenting:
bauplan --help — lists all available commandsbauplan <command> --help — shows arguments and options for a specific command (e.g., bauplan run --help, bauplan table --help)Validating generated Python: After writing or updating models.py or expectations.py, run uvx ruff check and uvx ruff format to catch syntax errors and style issues, and uvx ty check to catch type errors: these verify the code compiles and the annotations and SDK calls are well-formed without executing it. This is the fast first gate, always before bauplan run --dry-run.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
9 skills in this plugin
/bauplan-dag-optimizationOptimizes an existing, poorly structured Bauplan DAG so it runs faster without changing its outputs. Reads the code and profiles the data, then restructures the models, decides what is materialized, narrows inputs with projections and filters, merges or splits projects, and proposes a data-driven partitioning plan with concrete columns and transforms. Use whenever the user has a working pipeline and wants it faster or leaner on Bauplan, for example 'optimize this DAG', 'this pipeline is slow, speed it up', 'we write too many intermediate tables', 'should I partition this table', 'make this pipeline more efficient on Bauplan'. Do NOT use to scaffold a new pipeline from scratch (use bauplan-data-pipeline) or to diagnose a single failed job (use bauplan-debug-and-fix-pipeline)./bauplan-data-assessmentAssesses whether a business question can be answered with data available in a Bauplan lakehouse. Maps business concepts to tables and columns, checks data quality on the relevant subset, validates semantic fit, and renders a verdict: answerable, partially answerable, or not answerable. Produces a structured feasibility report. Use when a user brings a business question, asks 'can we answer this', wants to know if the data supports an analysis, or before building a one-off analysis or pipeline./bauplan-data-quality-checksGenerates data quality check code for bauplan pipelines and ingestion workflows. Invoked by the bauplan-data-pipeline and bauplan-safe-ingestion skills, or directly by the user. Produces expectations.py for pipelines or validation logic for WAP scripts. Output is always code, never reports./bauplan-data-semanticsReads and drafts the semantic layer of a Bauplan lakehouse — the table-level and column-level documentation carried in Iceberg as `comment` and field `doc`. Use to find out what a column means before querying it, to diagnose a query that returned a plausible but wrong number, or to draft documentation for columns whose meaning is not obvious from name and type. Also invoked by bauplan-data-pipeline and bauplan-migrate-to-typed-sdk when a pipeline needs documentation written. Read-only: drafts documentation text, never edits model code or runs pipelines./bauplan-debug-and-fix-pipelineDiagnose a failed Bauplan job, pin the exact data state, collect evidence, apply a minimal fix, and rerun. Evidence first, changes second./bauplan-explore-dataExplores data in a Bauplan lakehouse safely using the Bauplan Python SDK. Use to inspect namespaces, tables, schemas, samples, and profiling queries; and to export larger result sets to files. Read-only exploration only; no writes or pipeline runs.npx claudepluginhub bauplanlabs/bauplan-skills --plugin bauplanOther plugins' skills for the same job