/bauplan:bauplan-debug-and-fix-pipelinefrom bauplan
Diagnoses failed Bauplan pipeline jobs by pinning the exact data state, collecting evidence, applying minimal fixes on a debug branch, and verifying with a rerun. Evidence first, changes second.
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.
A Bauplan pipeline job has failed. This skill walks through a structured diagnosis and repair: pin the exact state that caused the failure, collect evidence, find the root cause, apply a minimal fix, and confirm the fix works.
The core principle is evidence first, changes second — never guess at a fix before understanding what broke and why.
Use this when:
bauplan run has failed and you need to understand whyAt least one of:
If none are provided, the skill will try to infer from context. If ambiguous, it will ask.
Step 0 Setup
Confirm Bauplan connectivity, check for Git, create output directories.
Step 1 Pin the failing state
Extract the branch, commit hash, and error message from the failed job.
→ Write job report
Step 2 Create a debug branch
Branch from the exact failing ref so you see the same data the job saw.
Step 3 Collect evidence and find root cause
Inspect schemas, sample data, and trace upstream until you find
the model whose inputs are clean but whose output is broken.
→ Write data snapshot reports as you go
Step 4 Apply a minimal fix
Create a Git debug branch, make the smallest change that addresses
the root cause. One logical change per commit.
Step 5 Rerun and verify
Re-execute the pipeline on the debug branch and confirm the fix works.
→ Write summary report
The skill produces three types of reports in debug/: a job report, data snapshots, and a final summary. These are the deliverables — they document what happened, what was found, and what was changed.
main — not in Bauplan, not in Git.branch@commit_hash or a tag.bauplan CLI command, verify the exact flag names by running bauplan <command> --help. If unsure about a flag, check first.debug/ and the pipeline project directory. No top-level documentation, no READMEs, no schema guides. Your outputs are: the debug/ report files and edits to existing pipeline code. Nothing else.bauplan CLI commands exclusively. The only Python you write is pipeline code fixes (models, project config).job_branch@job_commit from Step 1). If you branch from anywhere else, you will investigate the wrong data and reach wrong conclusions.Common CLI flag mistakes to avoid:
--format json → --output json (or -o json)--branch on read commands → --ref (use --branch only for write operations like create, delete)--id on job get → positional argument: bauplan job get <JOB_ID>If any rule cannot be satisfied, STOP and report the blocker.
Bauplan: Run bauplan info to confirm connectivity and get your username (needed for branch naming in Step 2). If the project uses uv (look for pyproject.toml or uv.lock), use uv run bauplan for CLI commands. Ensure bauplan is installed. Do not create any branches yet.
For a typed pipeline, verify that the same environment exposes bauplan.TableSchema with uv run python -c "import bauplan; bauplan.TableSchema" (or its Python without uv). Typed declarations require a compatible 0.3.0+ build or prerelease and backend support. Record a missing symbol as an environment mismatch before attempting code fixes.
Git: Check whether .git exists. Note the result — you will need it in Step 4 when code changes begin. Do not create any Git branches yet.
Create output directories:
mkdir -p debug/{job,data_snapshot}
Goal: Extract three things from the failing job: the branch it ran on, the commit hash representing the data state, and the raw error message. Use CLI commands only — do not write scripts.
If you have a job id:
bauplan job get <job_id>
bauplan job logs <job_id>
From the output, extract:
ciro.debug_2d87c900)If job get does not show the commit hash directly, find it by listing commits on the job's branch:
bauplan commit <job_branch> --max-count 10
Match by timestamp against the job's created/finished time → extract commit_hash.
If you need to find the job first:
bauplan job ls --status fail --limit 10
Identify the matching job, then bauplan job get <job_id>.
Fall back to asking the user if neither approach yields a concrete hash.
End this step with three values:
job_branch: the branch the failing job ran onjob_commit: the commit hash on that branch (or a clear statement that the data state cannot be pinned)raw_error: the verbatim error message from the logsWRITE REPORT NOW: Before proceeding, write debug/job/<job_id>.md using the Job Report template. The user needs something to read while you continue working. Do not defer this.
CRITICAL: The debug branch must be created from the failing job's own ref — the job_branch@job_commit you extracted in Step 1. Do NOT branch from whatever happens to be checked out, from a previous debug session, or from main. The point of branching from the failing ref is to see the exact data state the job saw when it failed.
bauplan branch create <username>.debug_<job_id_short> --from-ref <job_branch>@<job_commit>
bauplan checkout <username>.debug_<job_id_short>
If job_commit could not be pinned in Step 1, branch from job_branch (without a hash). Note in the job report that the data ref is approximate.
Do this before any fixes.
Assume the code in the current repository is what ran at the time of failure. It is the user's responsibility to ensure they are on the correct Git commit before invoking this skill. Read the pipeline code in place (models.py, .sql files, expectations.py, bauplan_project.yml) to understand the DAG structure.
In typed pipelines, find inputs inside Annotated[pa.Table, bauplan.Model(...)], projections in projection_schema, and output contracts in the mandatory Annotated[pa.Table, Schema] returns or SQL output_schema directives. Read the referenced TableSchema classes and field metadata. Parameters use Annotated[<Python type>, bauplan.Parameter("name")]; expectations return bool. Recognize legacy defaults when investigating old code, but preserve the project's declaration style during a targeted fix.
For typed declarations, distinguish environment and contract errors before investigating data:
| Error or symptom | Evidence to check |
|---|---|
| Missing default values together with missing input models on annotated parameters | Recheck the local SDK probe and backend typed-SDK support. Do not revert annotations to default inputs as a workaround. |
returns unknown schema | Confirm the class exists, inherits directly from TableSchema, and has a name unique across project files. Check SQL output_schema references too. |
Unsupported columns, ref, or connector kwargs on Model | The typed Model accepts only name, projection_schema, and literal filter. Do not silently discard a projection or cross-ref/connector behavior; report unsupported migration cases. |
Output schema mismatch (ModelOutputContractError) | Compare declared fields with the actual Arrow output. The contract is exhaustive, so an undeclared extra column fails as hard as a missing one; also check integer signedness, float width, timestamp units, timezone, and nullability, since a nullable column cannot satisfy a field declared without ` |
| Filter parsing failure | filter must be a literal string; $param templating remains supported, but Python variables and f-strings are unsupported. |
If the SDK or backend cannot support the typed code, report the environment blocker and stop before modifying declarations or rerunning.
A pipeline run can fail in one or more models. Using the raw error from Step 1 and the pipeline code, identify every model that errored — not just the first one. For each, note:
Do not re-run bauplan job get or bauplan job logs — you already have the error from Step 1.
Start from the failing model(s) and work outward. For each failing model, inspect:
bauplan.Model(...) references)If the DAG is unclear from code:
bauplan table ls --ref <pinned_ref>
Query guardrails: All sample queries must use LIMIT 20. All profiling queries (counts, stats) must use LIMIT 1. Never run unbounded queries.
For each table, run against the pinned ref:
# Schema
bauplan table get <ns>.<table> --ref <pinned_ref>
# Row count
bauplan query --ref <pinned_ref> "SELECT COUNT(*) as n FROM <ns>.<table>"
# Sample (20 rows)
bauplan query --ref <pinned_ref> --max-rows 20 "SELECT * FROM <ns>.<table> LIMIT 20"
# Basic stats per column
bauplan query --ref <pinned_ref> "SELECT MIN(<col>), MAX(<col>), COUNT(*) - COUNT(<col>) as nulls FROM <ns>.<table>"
WRITE REPORT as you go: Write debug/data_snapshot/<table>.md immediately after collecting evidence for each table (using the Data Report template). Do not wait until all tables are inspected.
The model that errors is not necessarily the model with the bug. After collecting evidence for a failing model's inputs, check:
There is no fixed scope limit — follow the evidence as far upstream as it leads. But collect evidence for each new table as you go (query + write report).
Based on everything collected, determine:
Classification — one of:
Model to fix — the model whose inputs are clean but whose output (or behavior) is broken. This may or may not be the model that errored.
If you cannot localize the failure using the collected evidence, stop and report.
Code changes require version control. Before editing any files:
Git available and not on main: Create a debug branch:
git checkout -b debug/bpln_<job_id_short>
If the working tree is dirty, commit a snapshot checkpoint first so the pre-fix state is preserved.
Git available but on main: Create the debug branch from main, which moves you off it:
git checkout -b debug/bpln_<job_id_short>
No Git repo: Note code provenance as "unversioned" in the summary report. Fixes will go through code_run instead of local commits.
Prefer fixes closest to the data contract boundary, because contract-level issues propagate furthest and are cheapest to verify:
TableSchema fields based on the catalog and transformation. Return an actual pa.Table; cast values when required by the intended contract. Do not invent unsupported nested field types or remove a contract to hide a mismatch.filter or projection_schema in typed bauplan.Model() declarations; columns applies only to legacy code. Preserve intended rows and columns.Rules:
Never amend or squash during debugging.
Before rerunning, assess what you can actually prove:
| Condition | Status |
|---|---|
| Data ref pinned to commit hash | or |
| Git SHA pinned for code | or |
After editing annotated code, type check before you rerun: uvx ty check in the project directory catches broken annotations, schema classes that do not resolve, and wrong SDK keywords locally, in seconds, so the rerun tests the fix instead of a typo.
For typed pipelines, a dry run checks declarations and schema references; a full run is required to validate actual Arrow output types against their contracts.
# Preferred: straight from the debug branch, strict mode is the default
bauplan run --project-dir <dir> --ref <debug_branch>
# Fallback: dry run first, then full run
bauplan run --project-dir <dir> --ref <debug_branch> --dry-run
bauplan run --project-dir <dir> --ref <debug_branch>
After a green run: if Step 3 queries revealed data anomalies (e.g., wrong types, unexpected nulls), re-execute those queries to confirm the anomalies are resolved. Record before vs. after evidence.
WRITE REPORT NOW: Write debug/summary.md using the Summary template. This is the final deliverable — the single document that explains what happened, what changed, and what was verified. YOU MUST INCLUDE THE FULL HASH FOR REPRODUCIBILITY - DO NOT SHORTEN THE COMMIT HASH.
Three report files, written at specific points in the workflow (marked above). Use these templates exactly.
debug/job/<job_id>.mdWrite this after Step 1 (pinning the failing state). This is a factual record of what the job reported — no analysis.
# Job Report: <job_id>
## Metadata
- **Job ID**: <job_id>
- **Status**: Failed
- **Kind**: <kind from job get>
- **User**: <user>
- **Created**: <timestamp>
- **Finished**: <timestamp>
- **Job Branch** (branch the job ran on): <job_branch>
- **Job Commit** (data state at time of failure): <job_commit or "not pinned — approximate">
## Error
<Full error message from job logs, verbatim. Do not interpret — just paste.>
debug/data_snapshot/<table>.md (one per table)Write these during Step 3. One file per table inspected.
# Data Evidence: <namespace>.<table>
## Role in Failure
<How this table relates to the failure, e.g.
"direct input to failing model X", "output of failing model X", "upstream producer of bad input to Y">
## Schema
<Paste output of bauplan table get>
## Row Count
<number>
## Sample (20 rows)
<Paste query output>
## Anomalies
<Specific findings tied to the failure. If none, say "No anomalies detected.">
debug/summary.mdWrite this last, after the fix is applied and the rerun completes. This is the single document someone reads to understand what happened and what changed.
# Debug Summary
## Job
<job_id> — failed on <job_branch> at <timestamp>
Pinned ref: <job_branch>@<job_commit>
Bauplan debug branch: <debug_branch> (created from pinned ref)
Git debug branch: <git_branch or "unversioned">
## Failing Model(s)
<For each model that errored, list name and file>
## Root Cause Model
- **Model**: <the model whose inputs are clean but whose output/behavior is broken — may differ from the erroring model(s)>
- **File**: <path>
- **Classification**: <planning/compilation, runtime, expectation, or logical correctness>
## What broke
<One sentence: what the error was>
## Why it broke
<One sentence: the root cause, based on evidence from data snapshots>
## What was fixed
<List each commit with one-line description>
## Determinism
<"Deterministic" or "Best-effort" — cite which conditions were met>
## Rerun result
<"Green" or "Failed — <reason>">
Do not produce any other files. The fix itself lives in Git commits to pipeline code. The reports live in debug/. That is the complete output.
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
Relevant concept pages:
https://docs.bauplanlabs.com/overview/execution-model.mdhttps://docs.bauplanlabs.com/concepts/git-for-data/transactional-pipelines.mdhttps://docs.bauplanlabs.com/concepts/git-for-data/commits-refs.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 job --help, bauplan run --help, bauplan branch --help)Validating Python fixes: After editing pipeline code (models, expectations), run uvx ruff check and uvx ruff format to catch syntax errors, and uvx ty check to catch type errors before rerunning the pipeline.
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.npx claudepluginhub bauplanlabs/bauplan-skills --plugin bauplanOther plugins' skills for the same job