/bauplan:bauplan-data-semanticsfrom bauplan
Reads and drafts table-level and column-level documentation in a Bauplan lakehouse (Iceberg comments and field docs). Use to understand column semantics before querying, diagnose suspicious query results, or draft missing documentation.
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.
None: SKILL.md is the whole skill.
Bauplan can hold contextual meaning for data in table metadata: a table-level comment and a per-column doc, both stored in Iceberg, both versioned per data branch. The contextual meaning, stored as table and column documentation, provides support for the semantic layer. This skill reads table and column documentation and drafts what it should say when it is missing.
Documentation cannot be written through the CLI or SDK — it is authored in pipeline code and materialized by a run — so applying a draft always belongs to a write-capable skill.
bauplan-data-pipeline or bauplan-migrate-to-typed-sdk needs docstring and TableField(doc=) text for schemas it is about to declareFor data quality profiling use bauplan-explore-data; for whether a question is answerable at all, bauplan-data-assessment; for a failed run, bauplan-debug-and-fix-pipeline.
Updating documentation that already exists is not yet covered here.
models.py, *.sql, or a schema class. Never run, merge, or create a branch. Draft text and hand it off.--ref when reading a different branch, or comparing several at once.tty view truncates.If any rule cannot be satisfied, STOP and report the blocker.
bauplan table get <namespace>.<table> -O json
table get reads the active branch; pass --ref <ref> only to read a different branch or compare several. It surfaces documentation starting with 0.3.2, so an absent DOC column on an older CLI means nothing.
In JSON, the table comment is at properties.comment — there is no top-level comment key. Column docs are at fields[].doc; null means undocumented.
The tty view truncates, and truncation fires on newlines as well as width. A doc of "Pickup time.\nAlways in UTC." renders as Pickup time.... — a finished sentence with an ellipsis, the timezone silently gone. The footer Note: some documentation was truncated. is the only reliable signal.
import bauplan
client = bauplan.Client()
table = client.get_table("normalize_data", ref="<ref>", namespace="bauplan")
print(table.comment) # table documentation, or None
for field in table.fields:
print(field.name, "->", field.doc) # column documentation, or None
namespace is keyword-only. Columns are table.fields — Table is not iterable. Text comes back whole, so prefer the SDK when docs feed logic rather than a human. Note the asymmetry: table-level is .comment, column-level is .doc.
There is no API that writes documentation. It is a property of the model that produces the table, written to Iceberg when a run materializes it.
| What | Comes from | Lands in Iceberg as |
|---|---|---|
| Table documentation | The docstring on the model's function, if defined, otherwise the docstring on the annotated output TableSchema class. | properties.comment |
| Column documentation | doc parameter from the TableField type annotation. | the doc property of the schema field |
class NormalizedTripsSchema(bauplan.TableSchema):
"""One row per completed trip, normalized to UTC and filtered to 2023."""
trip_time: Annotated[
bauplan.Int64 | None,
bauplan.TableField(doc="Trip duration, in seconds."),
]
Three consequences for a draft:
bauplan run materializes the table, and reach main only through a merge.inspect.cleandoc, so indentation is normalized but spacing within a line is preserved verbatim. A whitespace-only docstring means no documentation at all.TableField accepts only name, doc and lineage; anything else fails with Unexpected TableField parameter: <name>. name= (0.3.3+) carries the real column name when it is not a valid Python identifier, so document the column under that name, not the attribute's. lineage=OtherSchema['field'] records provenance, not meaning, and does not substitute for doc.Always document a column when its name and type does not disambiguate its usage. However, some documentation is always useful; even if a column seems obvious by name and type, documenting that usage is useful to prevent, or manage, semantic and usage drift in the future.
| Trigger | What the doc must settle | Example |
|---|---|---|
| Units | Which unit | trip_time — seconds or minutes? |
| Inclusions | What the value leaves out | base_passenger_fare — tolls? tips? tax? |
| Timezone | Which zone, whose clock | pickup_datetime — UTC or local? |
| Population | Which rows exist at all | Are cancelled trips in the table? |
| Encoded categories | What the codes mean | hvfhs_license_num — HV0003 is which operator? |
| Sentinels | What a magic value means | Is 0 "none" or "unknown"? |
| Grain | What one row is | One trip, or one trip-day? |
"Fare before tolls and tax." does its whole job in five words."Trip duration, in seconds." beats "epoch delta of dropoff minus pickup"."Distanza percorsa: è espressa in miglia." documents the unit correctly and still fails most of its readers. Flag these.Write the draft to semantics/<table>_semantics.md. Another skill applies it to the code.
# Semantic Draft: <namespace>.<table>
**Ref inspected:** <ref>
**Producing model:** <file>:<function or SQL filename>, or "unknown — not in this project"
## Existing Documentation
Table comment: <current text, or "none">
| Column | Documented? | Current doc |
|--------|-------------|-------------|
<!-- Every column, as read from the catalog. -->
## Proposed
### Table comment
<!-- Docstring for the model function or output TableSchema class. -->
### Column docs
| Column | Proposed doc | Basis |
|--------|--------------|-------|
<!-- Basis: CATALOG (an upstream table's doc) | CODE (the transformation)
| USER (stated by the user) | UNRESOLVED (do NOT apply — ask first) -->
## Deliberately Not Documented
| Column | Why |
|--------|-----|
<!-- Keeps the omission visible rather than silent. -->
## Open Questions
<!-- Numbered. Every UNRESOLVED row appears here as a question the user can answer. -->
## How to Apply
<!-- Which schema class in which file each proposed doc belongs on. -->
Hand the draft to bauplan-data-pipeline (new pipeline) or bauplan-migrate-to-typed-sdk (existing pipeline gaining schemas); that skill owns the branch, run, diff and merge. If anything is UNRESOLVED, ask before handing off.
An analyst reports average revenue per trip for bauplan.normalize_data. The number looks right. It is not.
Wanting revenue per trip, the analyst finds base_passenger_fare and takes it:
bauplan query --ref <ref> \
"SELECT ROUND(AVG(base_passenger_fare), 2) AS avg_revenue FROM bauplan.normalize_data"
avg_revenue
22.99
$22.99 for an average NYC for-hire trip is entirely plausible, and the column profiles clean: 0% null, sane distribution, correct row count. A wrong answer that looks right cannot be caught by looking at the data.
Compare the loud version of the same class of error — average speed computed as if trip_time were minutes — which yields 5.56 / (1057.4 / 60) = 0.32 mph. Slower than walking, so it gets caught. The fare error does not.
bauplan table get bauplan.normalize_data -O json
{
"fields": [
{"name": "base_passenger_fare", "type": "double", "doc": "Fare before tolls and tax."},
{"name": "tolls", "type": "double", "doc": null},
{"name": "trip_time", "type": "long", "doc": "Trip duration, in seconds."}
],
"properties": {"comment": "A \"no-op\" normalization of taxi data from `bauplan.query_model` ..."}
}
base_passenger_fare is documented as "Fare before tolls and tax." Five words settle it: the column is a component of revenue, not revenue.
Had that doc been missing, this is the draft that closes the gap — note that tolls, undocumented, is exactly the column the reader now needs:
class NormalizedTripsSchema(bauplan.TableSchema):
"""
One row per completed trip.
Fares are decomposed into components; no column holds total revenue — sum the components.
"""
base_passenger_fare: Annotated[
bauplan.Float64 | None,
bauplan.TableField(doc="Fare in USD, before tolls and tax. Not total revenue."),
]
tolls: Annotated[
bauplan.Float64 | None,
bauplan.TableField(
doc="Tolls in USD, charged on top of base_passenger_fare.",
),
]
The table comment carries important cross-column meaning— no column holds total revenue— that describes how multiple columns relate, rather than describing a specific column.
bauplan query --ref <ref> \
"SELECT ROUND(AVG(base_passenger_fare), 2) AS avg_base,
ROUND(AVG(tolls), 2) AS avg_tolls,
ROUND(AVG(base_passenger_fare + tolls), 2) AS avg_revenue
FROM bauplan.normalize_data"
avg_base avg_tolls avg_revenue
22.99 1.29 24.28
The original figure understated revenue by $1.29 per trip — 5.3% — across 430,488 trips. Both numbers are plausible; the semantic layer is what distinguishes them.
The doc that mattered was not a description of the column. It was a warning about how the column would be misused. Write for the mistake you are preventing.
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
Catalog types: https://docs.bauplanlabs.com/reference/bauplan-schema.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/git-for-data/data-branches.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 table --help, bauplan query --help)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
bauplan, iceberg, semantic-layer, data-documentation, data-catalog
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-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.Other plugins' skills for the same job