/bauplan:bauplan-migrate-to-typed-sdkfrom bauplan
Migrates bauplan pipeline projects from SDK 0.1.x/0.2.x to the typed 0.3.x SDK, converting old-style declarations to TableSchema classes and Annotated type annotations.
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.
Bauplan 0.3.x replaces the old declaration style with type annotations that double as a semantic layer: column projections and output contracts become TableSchema classes, model inputs become Annotated[pa.Table, Model(...)] parameters, and run parameters become Annotated[<type>, Parameter(...)]. This skill takes an existing old-style project, rewrites it to the typed style, and validates the result until the pipeline runs green.
The complete old-to-new pattern catalog with real code is in examples.md. Read it before rewriting any file.
| Old (0.1.x or 0.2.x) | New (0.3.x) |
|---|---|
data=bauplan.Model("t", columns=[...], filter=...) | data: Annotated[pa.Table, Model("t", projection_schema=SomeSchema, filter=...)] |
@bauplan.model(columns=[...]) | @bauplan.model() + -> Annotated[pa.Table, OutputSchema] |
| no schema objects | class SomeSchema(TableSchema) with typed fields, optional TableField(name=, doc=, lineage=) |
x=bauplan.Parameter("x") | x: Annotated[float, Parameter("x")] |
| return list/pandas/polars/arrow | return an actual pa.Table |
NEVER run pipelines on
mainbranch. Always checkout to a test branch first:bauplan checkout -b <username>.<branch_name> --from-ref main. ALWAYS validate the migrated pipeline on a separate data branch.
Get the username by running bauplan info.
Before starting, you need to find all the Bauplan projects that need migration. A Bauplan project is a folder containing bauplan_project.yml or bauplan_project.yaml.
You can find them using e.g. find . -name 'bauplan_project.yml' -o -name 'bauplan_project.yaml'.
Read every models.py, expectations.py, other *.py model files, *.sql files, and bauplan_project.yml (also accepted as bauplan_project.yaml) in the project. List:
@bauplan.model and @bauplan.expectation functionbauplan.Model(...) input and its columns / filter / other kwargsbauplan.Parameter(...) and its type: in bauplan_project.ymlcolumns=[...] on a @bauplan.model() decoratorinternet_access=... on a @bauplan.model() decoratorThe constructs below have no direct equivalent in the typed SDK. If found, report them to the user and exclude the affected models from the mechanical migration:
bauplan.Model(...) using ref, connector, connector_config_key, or connector_config_uri: the new Model is a dataclass accepting only name, projection_schema, filter.filter= built from an f-string or variable: the new filter must be a string literal ($param templating inside the literal is fine).@bauplan.resources(), @bauplan.extras() are not supported anymore and need to be removed. Confirm with user.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. This is not a hard-blocker since one can move the logic inside the body of the function.@bauplan.model() kwarg internet_access is not supported anymore. Flag to the user.The typed SDK requires Python >= 3.11 and the schema classes use X | None union syntax, so raising the interpreter is mandatory, not a preference: on an older interpreter the install will not resolve. Bump requires-python in pyproject.toml to >=3.11 (and uv python pin 3.11 if the project uses uv) before touching the SDK version.
Then check whether the project uses uv (pyproject.toml / uv.lock) or plain pip, and upgrade bauplan to the newest release. Do not trust the version number alone: verify the installed package actually ships the typed SDK by probing it. If the project uses uv:
uv run python -c "import bauplan; bauplan.TableSchema"
If this raises, the installed release predates the typed SDK. Stop and ask the user which build to install; do not proceed with a package that lacks the symbols.
From now on run the CLI through the project environment (uv run bauplan ...) so the upgraded version is the one executing.
The old columns=[...] lists carry names only; TableSchema classes need types.
uv run bauplan table get <namespace>.<table>.
DOC column that gets truncated, request table metadata again with json output: uv run bauplan table get <namespace>.<table> -O json.Map catalog types to the field types listed in examples.md. There is no unsigned or 32-bit float field type; use Float64 for floats and cast unsigned integers in the model body. If the catalog type is nullable, then the field type should be marked optional: Type | None. A bare Type declares a column that is "non-nullable" or "required".
Nested types (list, struct, map) and decimals have no field type at all. Annotate those fields as bauplan.Any, the SDK's passthrough type rather than typing.Any: the column keeps its real type at runtime, the contract just does not pin it. This applies to output schemas and to projection_schema classes migrated from an old columns=[...] list, so a nested or decimal column is never a reason to drop a projection or a return annotation. Flag every Any field in the report.
A schema field is a class attribute, so its name must be a valid Python identifier. Use TableField(name=...) for every column whose name is not one: a name with a space, a dash or another symbol, a leading digit, or a Python keyword such as class. Give the attribute an identifier and set name= to the exact column name from the catalog or the old columns=[...] list: passenger_class: Annotated[Int64 | None, TableField(name="Passenger Class")]. Leave name= out when the column name is already a valid identifier. Do not rename the column to avoid it: the table and the model body keep the real column name.
table get also surfaces any documentation the source tables already have: the table comment above the schema, column docs in the DOC column, or properties.comment and fields[].doc in the JSON output. A pipeline on the old SDK had no way to persist either, but they may have been written outside of Bauplan; capture any existing documentation for item 8 of step 5.
Apply the patterns from examples.md to each file, in this order:
TableSchema class per input projection and one per model output, with | None on every column the catalog marks nullable and TableField(name=...) on every column whose name is not a Python identifier (patterns 3, 4, 5)Annotated (pattern 2)-> bool on every expectation (patterns 4, 6)Annotated (pattern 7)pa.Table, dtype casts where the schema pins a type (patterns 8, 9)output_schema directive (pattern 10)bauplan-data-semantics skill for details.Respect the "do not over-migrate" list in examples.md: decorators, project yml, filters, and DAG semantics are untouched.
While rewriting, flag (do not delete) expectations that only assert a column's dtype: the declared schema now covers them, so propose replacing each with a value-level check.
Work on an isolated branch: bauplan checkout -b <username>.<branch> --from-ref main.
Validation ladder, from cheapest to most complete:
uvx ruff check and uvx ty check on the project. This is the payoff of the migration: the typed SDK ships stubs, so a wrong kwarg, a misspelled field type, or a schema class that does not resolve fails here in seconds, locally, before any job reaches the platform. Never skip it.bauplan run --dry-run. Schema contracts are enforced on every run, there is no flag to opt in, and strict mode is the default so a failing expectation halts the run. The dry run executes every model, so runtime dtype mismatches (unsigned counts, float widths) and extra output columns already surface here, as ModelOutputContractError.bauplan run, which also materializes the outputs.Known error signatures and their causes:
A model cannot have input arguments without a default value: "<name>" found, usually together with A model must have at least one input model (same pair for expectations), on lines you migrated: the environment does NOT understand the typed syntax yet, on the client side or on the backend side. The migrated code is fine. Do NOT "fix" it by reverting to default-argument inputs; re-check the SDK probe from step 3, then report to the user that their environment predates typed-SDK support and stop at static validation.returns unknown schema "<Name>": the return annotation names a class that does not exist, is misspelled, or does not inherit directly from TableSchema.Model must have a valid return type annotation, or Model return type annotation must be of the form: Annotated[pyarrow.Table, SchemaType]: a model was left without a return annotation, or with a bare -> pa.Table. Every model needs a schema contract, so give it one instead of removing the annotation.Unexpected TableField parameter: <name>: TableField takes only name, doc and lineage. title and nullable are gone; nullability is | None on the type.only the data type may be marked optional: the | None was wrapped around the whole Annotated[...] instead of sitting on the data type inside it.while parsing your code: syntax-level problem in the rewritten file; re-read the corresponding pattern in examples.md.ModelOutputContractError on a full run: the returned table does not match the contract exactly, either because the output schema declares columns or types the function does not produce, or because the function returns a column the schema does not declare; fix the schema or add a cast (pattern 9).ty reporting unresolved imports for the model's runtime dependencies (duckdb, polars, local utils modules) is expected: those live in the remote model environment, not locally. Add them to the project's dev dependencies (uv add --dev polars) so the checker resolves them; the local install has no effect on the model environment declared by @bauplan.python(pip={...}). Unresolved bauplan symbols are real errors; unresolved third-party modules are not.Iterate on errors until dry run and full run both pass. Then clean up: delete the validation branch if the user does not want to keep it.
Summarize for the user: files rewritten, schema classes created (and which table or model each describes), parameters retyped, casts added, columns migrated to | None, lineage dropped because it pointed at the catalog, fields left as Any because nested types and decimals have no field type, expectations flagged as redundant, documentation added or deliberately omitted, and any blockers left unmigrated with the reason.
connector/ref kwargs, non-literal filters, internet_access)uv run bauplan table get <namespace>.<table> -O jsonuvx ruff check → uvx ty check → dry run → full run → iterate until greenWhen unsure about a signature or concept, fetch the doc page via WebFetch rather than guessing. Pages are markdown and LLM-friendly.
Python SDK: https://docs.bauplanlabs.com/reference/bauplan.md
Relevant concept pages:
https://docs.bauplanlabs.com/concepts/semantic-annotations.mdhttps://docs.bauplanlabs.com/concepts/models.mdhttps://docs.bauplanlabs.com/concepts/tables.mdhttps://docs.bauplanlabs.com/concepts/expectations.mdhttps://docs.bauplanlabs.com/common-scenarios/parameterized-runs.mdFull doc index: https://docs.bauplanlabs.com/llms.txt
CLI: self-documenting via bauplan --help and bauplan <command> --help.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub bauplanlabs/bauplan-skills --plugin bauplan9 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-pipelineCreates bauplan data pipeline projects with SQL and Python models. Use when starting a new pipeline, defining DAG transformations, writing models, or setting up bauplan project structure from scratch./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.Other plugins' skills for the same job