Skip to main content

Blueprint

test

Declarative, deterministic Power BI report layouts. Write a short YAML file, get a PBIP report whose pages are built and aligned to your organisation's design guidelines — no dragging, no nudging, no eyeballing.

bp apply pages/sales-overview.yaml --report ./SalesReport.Report

Status: pre-alpha. Nothing here is stable. Every Power BI format fact the code relies on was verified in Desktop first — see How the PBIP format is learned. Do not point this at a report you care about. Work on copies, under version control.


Contents


Why this exists

Two things are true about Power BI report development:

  1. A large share of the work is mechanical. Placing visuals, aligning them, matching sizes, applying the palette, getting margins consistent across pages. It takes hours and produces nothing anyone values.
  2. Design guidelines get ignored. Not out of malice — following a style document by hand, under deadline, across several developers, simply doesn't hold. Reviewers end up policing consistency manually, report by report, team by team.

Blueprint attacks both by moving layout from a thing a human does in a GUI to a thing a program does from a spec. Guidelines stop being a document people are asked to remember and become configuration the generator enforces. Consistency becomes the default rather than the exception.

A secondary benefit, arguably the bigger one: report changes become reviewable. A page spec is a short text file. It diffs. It goes in a pull request. Reviewing "added a page with four visuals bound to these measures" is tractable in a way that reviewing a binary report file is not.

Where this sits

Blueprint handles report layout only. It is designed to sit alongside, not replace:

Concern Tool
Semantic model — tables, columns, measures, relationships, DAX Power BI Modeling MCP server
Report layout, page structure, visual placement, guideline conformance Blueprint (this tool)
Live reload of a running Power BI Desktop instance Power BI Desktop Bridge

An AI agent driving this stack calls the Modeling MCP for the model and bp for the report: as a CLI if it can run commands, or as an MCP server (bp mcp, or the VS Code extension, which needs no Python) if it can only call tools. Neither one writes PBIR JSON by hand.


What Blueprint does and does not do

Does:

  • Create pages from a declarative spec
  • Place visuals according to named layouts (standard-4-up, kpi-row-plus-detail, …)
  • Snap existing visuals to a grid (bp apply --snap PAGE; each edge to the nearest grid line)
  • Enforce palette, margins, title placement and page density from a guidelines file
  • Validate a report against guidelines without changing it (bp check)
  • Emit a manifest mapping visual IDs to types, pages, titles and field bindings
  • Support several guideline sets so different teams or clients can share one tool

Does not:

  • Replace Power BI Desktop. You will still open it to verify, and for the last stretch of formatting this tool doesn't cover.
  • Touch the semantic model. No measures, no DAX, no relationships.
  • Move content between pages on its own. It will warn that a page is over budget. Deciding what to do about that is a human's job (see Design principles).
  • Guess. Where the spec is ambiguous, Blueprint errors rather than inventing a layout.

Design principles

1. Deterministic. The same spec plus the same guidelines produces byte-identical output. No model in the generation path, no randomness, no token cost. An LLM may write the spec; it never writes the PBIR.

2. Generate loosely, validate strictly. Producing files is one job; guaranteeing they conform is another. The validator is a separate, dumb, deterministic pass. It is also available on its own (bp check) so it can run in CI over reports Blueprint didn't build.

3. Idempotent. bp apply --snap run twice must produce no diff on the second run. This is a test, not an aspiration — see tests/test_idempotence.py.

4. Never destroy, never silently relocate. Irreversible or surprising operations are refused, not performed. A formatter that reformats a file is useful; one that moves code into a different file is hated. Blueprint warns and exits non-zero instead.

5. Config over code. Grid size, margins, palette, density budgets and layout definitions live in data, not in Python. The guidelines will change next quarter; that must not mean a code change.

6. Escape hatches are mandatory. Someone will deliberately place a visual off-grid for a good reason. blueprint: ignore on a visual must be honoured, or the tool gets switched off permanently.


Install

Built and tested on WSL2 (Ubuntu) + Python 3.12.

pip install blueprint-pbi

That gives you the bp command, the 18 visual contracts and the vendored PBIR schemas. Layouts and guidelines are files you write: bp new project writes a starter set to edit (the repository's template/ and guidelines/layouts/, copied into the folder you name).

For agents, add the MCP server (bp mcp, see Commands) with pip install "blueprint-pbi[mcp]".

On Windows with VS Code you don't need Python at all. A machine with only VS Code, GitHub Copilot and Power BI Desktop is enough: the Blueprint for Power BI extension bundles the engine as a standalone bp.exe (with its own interpreter) and registers it as an MCP server for Copilot agent mode. Its command Blueprint: Set Up for Other MCP Clients gives other clients the same exe. It needs Windows x64, VS Code 1.101 or later, a local (not Remote-WSL) folder, and a project saved as PBIP in the PBIR format. Guidelines, layouts and page specs are files you provide either way. The full list is in the extension's Requirements.

To work on Blueprint itself, or to run the fixtures and probe replays:

git clone https://github.com/gurdasss/blueprint.git
cd blueprint

python3.12 -m venv .venv
source .venv/bin/activate

pip install -e ".[dev]"

Verify:

bp --version
pytest

Blueprint reads and writes files on disk. It does not need Power BI Desktop installed, and it does not need Windows. Desktop is only required to look at the result, and to run the Desktop Bridge for live reload.


Quick start

Against one of the bundled fixtures, so you can't break anything real:

# 1. Copy a fixture so the original stays pristine
cp -r fixtures/02-card-and-chart /tmp/demo
cd /tmp/demo && git init && git add -A && git commit -m "baseline" && cd -

# 2. Look at what's there
bp describe --report /tmp/demo/Fixture.Report --section pages

# 3. Check it against the example guidelines (expect failures)
bp check --report /tmp/demo/Fixture.Report --guidelines guidelines/example.yaml

# 4. Build a page from a spec
bp apply examples/sales-overview.yaml \
        --report /tmp/demo/Fixture.Report \
        --guidelines guidelines/example.yaml

# 5. See exactly what changed (a new page, three visuals, pages.json and the manifest)
cd /tmp/demo && git status --short && cd -

# 6. Align the rest of the report: snap the hand-built page, apply the guidelines theme
bp apply --snap Overview --report /tmp/demo/Fixture.Report --guidelines guidelines/example.yaml
bp apply --theme         --report /tmp/demo/Fixture.Report --guidelines guidelines/example.yaml

# 7. Check: 0 errors. The two warnings left are judgement calls on the hand-built page
#    (its 1920x1080 size, and a visual at the page edge), which Blueprint reports but never forces.
bp check --report /tmp/demo/Fixture.Report --guidelines guidelines/example.yaml

Then open the report in Power BI Desktop and look at it.

Commands

Four verbs: read, scaffold, write, verify. Each takes the same few flags, so one command does a family of related jobs instead of each job having a command of its own.

Command What it does
bp describe Read. Everything a spec can use: spec syntax, visual types and slots, layouts (their roles and suggested types), guideline limits, and with --report the model's fields in spec syntax (each field's type, sort-by column, summarization and format string, and the relationships) and every page with its visuals (type, region, title, fields, position). --section keeps only the named parts. Read-only.
bp new project <dir> Scaffold a starter set to edit: guidelines with every core key, seven layouts and a page spec.
bp new spec <file.yaml> [--layout NAME] A page spec skeleton from a layout: one visual per region, in placement order, with the layout's suggested types and every field left empty to fill in. Prints the skeleton. bp apply refuses it until every empty value is filled.
bp new layout <name> --row ... A rows layout from its rows alone (--row role:height[xcolumns][:visual,...], e.g. main:fillx2:line,column) into the guidelines' layouts folder, under its own name. Refused, and nothing written, if the rows don't fit the canvas and spacing or the name is taken. Prints the file and its regions in pixels.
bp new layout <name> --from <file> A fixed-coordinate layout rewritten as rows, only where the rows reproduce every region exactly on the layout's own canvas. Give the file's own name to rewrite it in place.
bp apply <spec>... --report R Write pages from page specs (files or folders of them). All are checked before anything is written. Rebuilds the manifest.
bp apply --theme --report R Write a custom theme from the guidelines (palette, text colour, sentiment colours, title/callout/card label fonts) and make the report use it.
bp apply --snap PAGE --report R Snap the visuals on the named page(s) to the grid (each edge to the nearest line), hand-placed ones included. Idempotent. There is no all-pages form: name each page.
bp check Verify against the guidelines. Read-only. Non-zero exit on violations.
bp mcp Serve the four verbs as MCP tools over stdio, for agents. Needs the optional extra: pip install "blueprint-pbi[mcp]". See below.

bp new never touches a report and never overwrites a file. bp apply does one kind of write per run (specs, --theme or --snap) and refuses a flag that belongs to another kind. --dry-run works on new and apply and prints the planned writes without performing them. check and describe take --json; check also takes --github.

Commands from before v0.14 are refused with their replacement named: init (new project), inspect (describe --section pages), spec new and layout new (new spec, new layout), layout convert (new layout --from), theme (apply --theme), fmt (apply --snap), and manifest (every apply rebuilds it).

Every command that reads guidelines takes --set KEY=VALUE (layer 4), repeatable: the key is a dotted path into the guidelines file and the value is read as YAML, so types survive.

bp check --report ./Sales.Report --set spacing.grid=4 --set page.max_visuals=8
bp apply --report ./Sales.Report --snap Overview --set spacing.grid=16

A key outside the core is refused there as in a file, naming the closest real one (--set spacing.margn=4 → did you mean margin?). --grid was the earlier, single-key form of this and now names its replacement.

For agents writing specs: start with bp new project <dir> for a working set of guidelines, layouts and a page spec to edit, then run bp describe --report <report> --json. That's the whole vocabulary in one call: which types, slots, layouts and fields exist, written the way a spec uses them, in compact JSON. Ask only for the parts you need with --section (repeatable; spec, guidelines, types, layouts, model, pages). The model section gives every field's data_type, sort_by (a month column sorted by its number shows as names), summarize_by and format_string, and the relationships. A property the model doesn't set is an explicit null, meaning "there is none", never a missing key. It also says where a spec ends: a spec binds only the fields listed, and a request that needs another (year-over-year, % of total, running totals, a month column) needs the model changed in Desktop first. bp apply reports every problem with its location (visuals[2].slots.value: …). bp check --json validates the result. Each finding ends by saying where its fix is: bp apply --theme for the theme, bp apply --snap <page> for the grid, and for a page no spec built, its author in Power BI Desktop.

As an MCP server: bp mcp serves the four verbs as MCP tools over stdio (describe, new, apply, check). Each tool takes the command's flags as parameters, named after them (dry_run, overwrite_edits, snap), runs the command and returns {exit_code, stdout, stderr, argv}: exactly what the CLI prints, so exit 1 from check is a result (findings), while exit 2 comes back as a tool error with the CLI's message. --json is always on. Left to the CLI: --github (CI annotations), --set and --visuals (a lasting override or contract belongs in the guidelines file) and --force-schema (a person's call). The server's instructions tell the agent the tools are the whole interface: the report's own files aren't for reading or editing by hand. Specs are file paths: a spec's identity is its file name, so pass the same file to update the page it built. The server's working directory is wherever the client starts it, so pass absolute paths (relative ones are made absolute against it, and the result's argv shows them), and set BLUEPRINT_GUIDELINES to give every call a default guidelines file. To add it to Claude Code:

pip install "blueprint-pbi[mcp]"
claude mcp add blueprint -e BLUEPRINT_GUIDELINES=/path/to/guidelines.yaml -- bp mcp

The mcp package stays an optional extra: a plain pip install blueprint-pbi never imports it.

In CI

bp check --github prints a GitHub Actions annotation per finding, on the page.json or visual.json it's about, before the usual report. The repository is also a composite action that installs Blueprint and runs it over one or more reports:

# .github/workflows/report-standards.yml
name: report standards
on: [pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: gurdasss/blueprint@v0.9.0        # a release tag (or commit SHA) pins Blueprint
        with:
          reports: |                           # one per line: .Report folder, .pbip, its folder, or a glob
            reports/Sales.Report
            reports/Operations.pbip
          guidelines: guidelines/corp.yaml     # optional; else $BLUEPRINT_GUIDELINES, else defaults
          strict: false                        # true fails on warnings too

The job fails if any report has errors (exit 1) or can't be read (exit 2). Each report's text output goes to the job summary, and the exit-code output holds the worst exit code. A report's own .blueprint.yaml still applies, as it does locally. GitHub shows at most 10 error and 10 warning annotations per step (50 per job) and drops the rest silently, so when a report has more, bp check --github adds a notice saying how many aren't annotated; the job summary always has every finding.


Page specs

A page spec is the input a human — or an AI agent — writes. It describes intent, not geometry.

# specs/sales-overview.yaml (examples/ has runnable specs for the bundled fixtures)
# id: sales-overview    (optional; defaults to the file name. See "Which page a spec builds" below.)
page: Sales Overview
layout: standard-4-up

visuals:
  - type: header
    title: Sales Overview

  - type: kpi                  # fills the KPI row (a kpi's default region)
    title: Sales vs target
    slots:
      value: "[Total Sales]"
      trend: "Calendar[Month]"
      target: "[Sales Target]"

  - type: bar
    title: Sales by Category
    slots:
      category: "Product[Category]"
      value: "[Total Sales]"

  - type: column
    title: Sales by Geography
    slots:
      # an ordered list makes this a drill-down path
      category:
        - "Geography[Country]"
        - "Geography[State]"
        - "Geography[City]"
      value: "[Total Sales]"

  - type: table
    blueprint: ignore          # hand-placed on purpose; leave it alone

A visual may also set options, formatting choices its type declares (bp describe lists them). Leaving one out keeps Desktop's default:

  - type: line
    options: { labels: on, legend: right }   # data labels on, legend on the right (probe 23)
    slots: { category: "Calendar[Month]", value: ["[Total Sales]", "[Sales Target]"] }

A slot entry can say more than a field name. The long form is {field, aggregate, format}; "X" is shorthand for {field: X}. aggregate summarises a column in the visual (sum, average, min, max, count, distinctcount) and is allowed only in a slot that takes a measure. format is a Power BI format string, written as given (probes 29 and 30):

page: Sales Detail
layout: two-up

visuals:
  - type: column
    title: Average amount by country
    slots:
      category: "Sales[Country]"
      value: { field: "Sales[Amount]", aggregate: average, format: "#,0.00" }
    sort: { by: "Sales[Country]", direction: ascending }

  - type: table
    title: Orders
    slots:
      columns: ["Sales[Country]", { field: "Sales[Amount]", aggregate: sum, format: "$#,0" }]

A visual's sort: {by, direction} writes the visual's own sort (probe 31). by must be a field the visual binds, because Desktop ignores any other. To sort on an aggregated column write by: Sales[Amount] (it follows the visual's only aggregate of that column) or, explicitly, by: {field: "Sales[Amount]", aggregate: sum}; Desktop stores that as an Aggregation (probe 41). A spec with no sort leaves Desktop's sort, or the one a user set, alone. labels and legend options are available on every chart type: column, bar, line, area and the stacked charts, and since v0.9.0 pie and donut too. scatter and map take legend but not labels — Desktop deletes that object on those two (probe 38). On pie and donut, labels takes "off" as well as "on", because detail labels are on by Desktop's default there.

column, bar and line also take a Legend column (legend: "Sales[Region]", one column, beside a drill-down if you like). Desktop refuses it together with several measures or a second Legend column, so Blueprint does too (probe 32). legend: off hides the legend, and the positions (top, bottom, left, right) show it: one option, one state. A table takes totals: "off" to remove its Total row ("on" is Desktop's default):

page: Sales Split
layout: two-up

visuals:
  - type: column
    title: Sales by country, by region
    options: { legend: bottom }
    slots: { category: "Sales[Country]", value: "[Total Sales]", legend: "Sales[Region]" }

  - type: table
    title: Orders
    options: { totals: "off" }
    slots: { columns: ["Sales[Country]", "Sales[Region]", "[Total Sales]"] }

Visual types, and your own

The core ships every type a Desktop probe has verified: header, card, multi-row-card, kpi, column, bar, line, area, scatter, table, matrix, slicer, pie, donut, map, stacked-column, stacked-column-100 and stacked-bar.

map needs turning on. Power BI Desktop disables map visuals by default (File > Options and settings > Options > Global > Security). Where that is off, Desktop shows a message in place of the visual, whoever wrote the file.

A spec naming anything else is refused, listing the types that are loaded.

Your own types. A contract is a YAML file, so you can add types Blueprint doesn't ship — per run, or for good in your guidelines:

bp apply spec.yaml --report <report> --visuals ./my-visuals
# guidelines.yaml — relative to this file, like layouts.search_path
extensions:
  custom_visuals:
    search_path: ["my-visuals"]

--visuals is for trying a type in one run. A report that keeps visuals of your own type should opt in through its guidelines (or its own .blueprint.yaml), because the manifest is built from the contracts: a later bp apply (any kind) without the opt-in rewrites those entries with the PBIR type and raw query roles instead of the spec type and slot names.

Every core type takes its own options, e.g.:

  - type: slicer
    region: kpi-row
    options: { style: dropdown }   # the slicer as a dropdown (probes 20, 22)
    slots: { field: "Sales[Country]" }

Which page a spec builds

bp apply marks the page it creates with the spec's id (the file name, or an explicit top-level id:), and finds it again by that id:

  • Rename page: in the spec and re-apply: the existing page is renamed and keeps its visuals. No second page is created.
  • Another spec uses the same page name: apply refuses and names the spec that owns the page. If it's the same spec under a new file name, set id: to the old one. To hand the page over on purpose, pass --take-over.
  • Pages built before spec ids existed are adopted on the next apply, without moving anything.

Changing a spec and re-applying

Re-running bp apply with an edited spec updates the visuals it built, in place:

  • Fields: change a slot (value: "[Total Units]" → ["[Total Units]", "[Sales $]"]) and the visual is rebound. Its title, formatting and position stay; the plan says rebind Category [Country]; Y [Total Amount] -> …. Sorts and Desktop's automatic filters on fields that are gone are cleared; filters someone set by hand are kept.
  • Options the spec sets are set; ones it leaves out are left to Desktop.
  • Layout and titles follow the spec, as before.
  • Edited in Desktop? If someone changed a Blueprint visual's fields in Desktop since Blueprint wrote them, apply refuses rather than undo their work, and says what's bound now. Put the change in the spec, or pass --overwrite-edits.
  • Page size follows the guidelines' canvas only with --resize-pages (see "Layouts"); without it, a page of another size is refused.
  • Type changes (a column that becomes a bar) are refused: delete the visual in Desktop and re-apply. Visuals dropped from the spec are kept, with a warning.

Typed slots

Each visual type declares the slots it accepts and what each slot takes — a dimension column, a measure, or an ordered list for drill-down. A hierarchy built in the model is written like a column (category: "Sales[Geography]") and binds all its levels, as dragging it in Desktop does. Column, bar, pie and line chart categories, the table's columns, a matrix's rows and a slicer's field take one (probes 16-19, 39 and 40); a matrix's columns doesn't, because no probe has put a hierarchy there. Blueprint validates bindings before writing anything, so a measure in a category slot is an error from bp, not a confusing result in Desktop.

# blueprint/visuals/pie.yaml  (slot contract, not the template; probes 08 and 11)
type: pie
visual_type: pieChart
region: main
slots:
  category: { role: Category, accepts: column, required: true, ordered: true }   # "Legend"; a list drills down
  value:    { role: Y, accepts: measure, required: true }
  details:  { role: Series, accepts: column }                                  # "Details"

Each contract cites the probe that verified its PBIR shape. A type with no probe behind it doesn't ship (see How the PBIP format is learned).

Layouts

A layout maps an ordered list of visuals to positions. Layouts are data, and they state structure only: rows, the role each row holds, how many columns it splits into, and how tall it is. The guidelines give it pixels: the canvas from canvas:, the margin, gaps and grid from spacing:. Change the canvas or the spacing and every layout follows, with no layout file to edit.

# guidelines/layouts/standard-4-up.yaml
name: standard-4-up
rows:
  - { role: header,  height: 64 }
  - { role: kpi-row, height: 160 }
  - { role: main,    height: fill, columns: 2 }

height is pixels or fill. A pixel height is what the content needs and never scales with the canvas: 64 holds a 20pt title, and at 120px Desktop clips a KPI visual's goal line, so every shipped KPI row is 160. fill rows share what the other rows leave. bp apply works out the pixels by fixed rules, and bp describe shows the result for the guidelines in force:

  • Content starts at the margin and ends at the last grid line that leaves at least the margin. Rows are one gutter apart (rounded up to the grid). A pixel height that isn't a multiple of the grid is rounded up to it (a height is a minimum).
  • A row's columns are equal and so are the gaps between them. Every edge is on the grid, each gap is at least the gutter, and the columns are the widest that fill the row exactly. With a 1280px canvas, a 16px margin and gutter and an 8px grid, that is 2 columns of 616 (16px gaps), 3 of 400 (24px gaps), and 4 of 288 (32px gaps). A gap grows past the gutter only when equal columns on the grid need it.
  • A canvas the grid doesn't divide (1366×768 on an 8px grid) keeps every edge on the grid and puts the leftover pixels, less than one grid step, in the right and bottom margins: a 22px right margin instead of 16. bp apply says so in its notes, and bp check accepts it because the margin is a minimum.
  • Nothing is guessed. Guidelines with no canvas, or rows taller than the canvas, are refused, and the message names the numbers.

Regions are numbered by role, top to bottom and left to right (main#1, main#2, …).

Scaffolds: write the structure, not the boilerplate

A row may also say which visual it suggests: visual: table for every column, or visual: [line, column] with one per column. Placement never reads it, so a spec can still put any visual there; bp new spec uses it to write a page skeleton, so a writer (usually an LLM agent) fills in fields instead of composing a spec from the syntax reference:

bp new layout trend-detail --guidelines guidelines.yaml \
   --row header:64 --row kpi-row:160x4:kpi,kpi,card,card --row main:fillx2:line,column
bp new spec pages/sales-trend.yaml --layout trend-detail --guidelines guidelines.yaml
page: Sales Trend
layout: trend-detail
visuals:
  - type: header          # header#1
    title: Sales Trend
  - type: kpi             # kpi-row#1
    title:
    slots:
      value:              # required: measure
      trend:              # required: column
      # target:           # optional: measure
  ...
  - type: card            # kpi-row#3
    region: kpi-row
    title:
    slots:
      value:              # required: measure
  ...
  - type: line            # main#1
    title:
    slots:
      category:           # required: column or hierarchy, a list allowed
      value:              # required: measure, a list allowed
      # legend:           # optional: column
    # options:
    #   labels: on
    #   legend: top | bottom | left | right | off

A region's type is the row's suggestion, else the one type whose contract fills that role (a header row holds a header, a kpi-row a kpi), else it is left empty with the choices in a comment. Every shipped layout suggests a type for its main rows. Nothing that would build is guessed: every field is empty, and bp apply refuses an empty type or slot by name (visuals[2].slots.value: empty; fill in a measure ...). bp describe lists each layout's suggestions.

The older form, a canvas: and a list of regions: with every x, y, w and h stated, still loads, so pages built from it keep working. It is deprecated: it fits one canvas and one set of spacing guidelines, so bp apply warns each time it uses one. bp new layout --from rewrites one as rows (give the file's own name to rewrite it in place):

bp new layout layouts/house.yaml --from layouts/house.yaml --guidelines guidelines.yaml --dry-run

A file is converted only when the rows reproduce every region exactly (key and rectangle) on its own canvas, with the guidelines' grid, margin and gutter, so a page built from it doesn't move. Of the rows that do, the most rows become fill, then the tallest: the main area follows the canvas, while a header and a KPI row keep their pixels. A layout that rows can't reproduce (unequal columns, a region spanning rows, gaps the rows rule doesn't give) is refused, and the message names the first region that would move, and nothing is written. The leading comments are kept as written.

Visuals fill regions in that order. Each visual takes the next free region of its type's role (region: in its slot contract: kpi → kpi-row, header → header, everything else → main), or of the role its spec names:

  - type: card
    region: kpi-row          # a card in the KPI row instead of a main region
    slots: { value: "[Total Sales]" }

Running out of regions is an error, not a reflow. Shipped with the example guidelines (guidelines/layouts/), each unit-tested against a range of canvases and spacings (1280×720, 1920×1080, 960×720, 1366×768, a 10px grid and others). Desktop drew and kept them at 1920×1080, 1366×768 and 960×720 too (probe 52):

Layout Regions
standard-4-up header, 1 KPI row, 2 main
dashboard-6 header, 3 KPI row, 3 main
kpi-row-plus-detail header, 4 KPI row, 1 full-width main
grid-2x3 header, 6 main (2 rows of 3)
two-up header, 2 full-height main
one-up header, 1 full-width main

A region no visual fills is left empty: a gap on the page. That's not a reflow either: bp apply warns, naming the layouts on the search path that would place the same visuals with every region filled (same canvas, within the guidelines), e.g. layout 'standard-4-up' leaves kpi-row#1 empty, a gap on the page; layout(s) that fit with no gap: two-up.

bp apply refuses a layout that doesn't fit the guidelines it runs with: regions off the grid, inside spacing.margin, or closer together than spacing.gutter. A rows layout can't break these, because they are what its pixels are worked out from. A deprecated fixed-coordinate layout can.

A page keeps the size it was built at. After a canvas change, bp apply refuses to re-apply a spec to a page of the old size and names both sizes. Pass --resize-pages to resize it: the page takes the guidelines' canvas, and its Blueprint visuals go where the layout puts them at the new size, as a fresh build would place them. Nothing is scaled. Hand-placed, ignored and dropped visuals stay where they are, and a resize that would leave one of them outside the page is refused. Desktop takes the result as written (probe 53).

bp apply pages --report my.Report --guidelines guidelines.yaml --resize-pages   # after a canvas change

Guidelines and layering

The whole point of a guidelines file is that the rules outlive any one report and can differ per team or per client, without forking the tool.

Resolution order, later overriding earlier:

1. built-in defaults          blueprint/defaults.yaml       (ships with the tool)
2. organisation guidelines    guidelines/<name>.yaml         (yours, usually private)
3. per-report overrides       <report>/.blueprint.yaml       (committed with the report)
4. command-line flags         --set spacing.grid=8
# guidelines/example.yaml
version: 1
name: Example Corp Reporting Standard

canvas:
  width: 1280
  height: 720

spacing:
  grid: 8
  margin: 16
  gutter: 16      # minimum gap between neighbouring visuals

palette:
  categorical: ["#4E79A7", "#F28E2B", "#E15759", "#76B7B2", "#59A14F"]
  background: "#FFFFFF"
  text: "#333333"
  enforce: strict        # strict | warn | off

typography:
  page_title:   { font: Segoe UI Semibold, size: 20 }  # bp apply writes this onto header textboxes
  visual_title: { font: Segoe UI Semibold, size: 18 }  # weight is part of the face name
  body:         { font: Segoe UI, size: 12 }           # textboxes

page:
  require_title: true      # pages built from a spec need a `type: header` visual...
  title_region: header     # ...placed in a header region (hand-built pages aren't checked)
  max_visuals: 6
  density_policy: data     # named policy implemented in code, not an if-statement here

layouts:
  search_path: ["layouts"]     # relative to this file
  default: standard-4-up

Core keys and extensions

The core file is small on purpose: version, name, canvas (width and height), spacing (grid, margin, gutter), page, palette, typography (page_title, visual_title, body) and layouts. Rule severities are fixed in code. palette also takes optional sentiment colours, good, neutral and bad (hex): bp apply --theme writes them as the theme's own keys, a KPI draws good at or above its goal and bad below it (probes 42, 43; no probe has yet seen what draws neutral), and bp check compares them with the theme. Divergent colours minimum, center and maximum are written the same way: Desktop starts every new conditional-format gradient from them, but a saved gradient keeps its own hex colours (probe 44), so a spec says {field: "T[Col]", aggregate: sum, gradient: 2|3} on a table column and Blueprint writes the guidelines' colours into the visual. Four structural colours, second_level, third_level, fourth_level and disabled_text, are named as Power BI's "Customize current theme" dialog labels them (first-level is text, background is background) and go to the theme the same way; probes 46 and 48 measured what each one paints. Everything else is opt-in under extensions::

extensions:
  severity: { grid: warning }          # override a rule's severity: error | warning | off
  decorative_types: [image, shape]     # may contain visuals; exempt from margin and gutter
  max_resize: 0.25                     # bp apply --snap skips a visual it would resize by more
  typography:                          # further text roles, checked like the core ones
    subtitle:   { font: Segoe UI, size: 12 }
    callout:    { font: Segoe UI Light, size: 32 }
    card_label: { font: Segoe UI, size: 12 }
  custom_visuals:
    search_path: ["my-visuals"]          # contracts of your own; see "Visual types, and your own"

Upgrading from v0.5.x. The old keys are refused, never ignored, and the error names the replacement: grid.size is spacing.grid; canvas.margin and canvas.gutter are spacing.margin and spacing.gutter; grid.max_resize, check.severity and check.decorative_types moved under extensions; grid.snap is gone (bp apply --snap always snaps); typography roles header, title and textbox are page_title, visual_title and body; subtitle, callout and card_label moved to extensions.typography. The bold setting is gone: a weight is part of the face name (Segoe UI Semibold). The one check this drops is a textbox run's own fontWeight.

Multi-tenant notes

  • The tool is generic; guideline files are the tenant-specific part. Keep yours out of the public repo. guidelines/example.yaml exists so strangers can run the tool, and is entirely invented.
  • guidelines/ is gitignored except for example.yaml and layouts/.
  • Select a tenant with --guidelines <path> or BLUEPRINT_GUIDELINES=<path>.
  • Never put conditional logic in a guidelines file. When a rule needs branching, implement it in Python as a named policy and let the config select it (density_policy: strict). Config files that grow if statements become bad programming languages.

The manifest

.blueprint.manifest.json (in the .Report folder, next to .blueprint.yaml) is the handoff artifact between the layout half of the stack and the semantic-model half. Without it, an agent has to re-derive the report structure by reading PBIR on every turn. bp apply rewrites it after every change, rebuilt from the report as it is on disk.

{
  "blueprint_version": "0.8.1",
  "guidelines": { "name": "Example Corp Reporting Standard", "version": 1 },
  "pbir_schema": { "page": ["2.1.0"], "visualContainer": ["2.13.0"] },
  "generated_at": "2026-11-09T04:00:00Z",
  "pages": [
    {
      "id": "b1df9ce53010a81607ce",
      "name": "Sales Overview",
      "spec_page": "Sales Overview",
      "layout": "two-up",
      "built_with": "Example Corp Reporting Standard@1",
      "size": { "w": 1280, "h": 720 },
      "visuals": [
        {
          "id": "b4f94ad3cfcc67642873",
          "type": "column",
          "visual_type": "clusteredColumnChart",
          "title": "Sales by Geography",
          "managed": true,
          "spec_id": "column-1",
          "region": "main#2",
          "position": { "x": 648, "y": 96, "w": 616, "h": 608 },
          "slots": {
            "category": ["Sales[Country]", "Sales[Region]"],
            "value": "[Total Amount]"
          }
        }
      ]
    }
  ]
}
  • Every page and visual is listed, hand-built ones too. Those have "managed": false, their PBIR visualType as type, and query roles (Category, Y, …) as slot names. Visuals Blueprint created have their spec type, spec id, slot names and layout region (<role>#<n>).
  • layout, region and built_with come from annotations bp apply leaves on the page and visuals. That's what makes the manifest rebuildable from the report alone, and it's how bp check can say which guidelines a page was built against.
  • It's deterministic. generated_at changes only when something else does, so regenerating an unchanged report is a no-op. Set SOURCE_DATE_EPOCH for reproducible timestamps.
  • bp check notes when the manifest is out of date (e.g. after a drag in Desktop).

It is generated, never hand-edited.


Project structure

blueprint/
├── README.md
├── CHANGELOG.md
├── pyproject.toml
├── action.yml                  # composite GitHub Action: bp check over reports
├── blueprint/
│   ├── __init__.py
│   ├── cli.py                  # argparse entry points; one module per command in commands/
│   ├── defaults.yaml           # built-in guideline defaults (layer 1)
│   │
│   ├── commands/               # init, inspect, check, fmt, apply, describe, manifest, theme,
│   │                           # and mcp_server.py (bp mcp: each command as an MCP tool)
│   ├── starter/                # what `bp new project` copies out: template/ + guidelines/layouts/
│   │
│   ├── pbir/                   # everything that knows the on-disk format
│   │   ├── reader.py           # report dir -> in-memory model
│   │   ├── writer.py           # in-memory model -> report dir (atomic)
│   │   ├── jsonfmt.py          # the only JSON reader/writer: Desktop's bytes, exactly
│   │   ├── schemas.py          # validation against the vendored Microsoft schemas
│   │   ├── schemas/            # the vendored schemas (scripts/vendor_schemas.py)
│   │   ├── render.py           # minimal PBIR documents for new pages and visuals
│   │   ├── registry.py         # the only code that changes pages.json pageOrder
│   │   ├── ids.py              # deterministic ids in the format Desktop uses
│   │   ├── semantic.py         # read-only TMDL model: tables, columns, measures, hierarchies
│   │   ├── formatting.py       # colours and fonts found by shape
│   │   ├── theme.py            # the guidelines theme file
│   │   └── schema.md           # verified format facts, each with its evidence
│   │
│   ├── model.py                # Report / Page / Visual dataclasses
│   ├── spec.py                 # page spec parsing + validation
│   ├── guidelines.py           # layered config resolution; retired keys refused by name
│   ├── layouts.py              # named layout -> regions
│   ├── slots.py                # visual contracts (blueprint/visuals/*.yaml), inherits:
│   ├── grid.py                 # the one definition of "on grid"
│   ├── plan.py                 # planned file writes and warnings (--dry-run)
│   ├── validate.py             # guideline rules (used by `check`)
│   ├── policies.py             # named policies the config selects (e.g. density)
│   ├── manifest.py
│   └── visuals/                # one slot contract per visual type
│
├── guidelines/
│   ├── example.yaml            # invented; committed so the tool is runnable
│   ├── layouts/
│   └── .gitignore              # ignore everything except example.yaml + layouts/
│
├── examples/                   # runnable specs, and demo/ (the end-to-end demo's pages)
│
├── fixtures/                   # synthetic PBIP reports, built from scratch
│   ├── 01-blank-report/
│   ├── 02-card-and-chart/
│   └── README.md               # how each was made, so they can be rebuilt
│
├── docs/
│   ├── probes/                 # raw Desktop diffs: the evidence behind schema.md
│   ├── interactions.md         # how guidelines, layout and page spec constrain each other
│   ├── visuals.md              # the visual contract format, and adding a type of your own
│   ├── extensions.md           # extension points by layer (mostly not built)
│   └── plan.md                 # history: how the v0.6 template rewrite was planned
│
├── scripts/                    # probe builders (probe_*.py), demo.sh, desktop.sh, ci_check.sh
├── packaging/windows/          # the standalone bp.exe (PyInstaller) and its no-Python gate
├── vscode-extension/           # the VS Code extension: carries bp.exe, registers `bp.exe mcp`
├── unverified-probes/          # probes written but never opened in Desktop: not evidence
├── template/                   # the three files a client copies, and a README to start from
│
└── tests/                      # includes golden/, pinned-layouts/, pinned-specs/ and
                                # test_probe_replay.py (every probe replayed against Blueprint)

pbir/ is the only package that knows the file format. Everything above it works on the in-memory model. When Microsoft changes PBIR, the blast radius is one directory.


How the PBIP format is learned

Blueprint doesn't write PBIR from memory. Guessing at the format would produce a tool that silently writes invalid files, so every format fact is established in Power BI Desktop first, and the code relies only on facts recorded as verified. The method is a probe:

  1. Predict. Write down what Desktop should produce before looking.
  2. Build a candidate. A scripts/probe_*.py script writes the change into a copy of a fixture (or has Desktop make it), in a git repository on the Windows drive.
  3. Let Desktop judge. Open it, check that it draws, press Ctrl+S, then git diff. What Desktop changes on save, and what it leaves alone, is the evidence.
  4. Record it. The diff goes under docs/probes/ (python scripts/probe_evidence.py), the fact goes into blueprint/pbir/schema.md marked verified, with the probe it came from, and the probe is added to tests/test_probe_replay.py, which rebuilds it from the evidence and tests Blueprint against Desktop's real output on every run.
  5. Only then ship it. A visual contract, option or spec key cites its probe. Open items in schema.md are not used by the code.

Probes 01 to 36 cover pages and the registry, annotations, formatting and themes, fonts, every shipped visual type and its bindings, drill-downs, hierarchies, chart options, aggregations and formats, sorts, a Legend column on clustered charts, table totals, and the scatter, multi-row card and map. Probes written but not yet run live in unverified-probes/, where nothing counts as evidence.

The first questions

The first probes answered these, in this order. They are all answered; schema.md and the code refer to them by number (README Q4).

# Question Answer lives in
1 What does a report directory contain at rest? schema.md, “Report folder”
2 What files appear when you add one blank page? schema.md, “Creating pages and visuals”
3 Which existing file gets modified? (pages.json: creating the folder alone leaves the page invisible) schema.md, “Pages”
4 What is the ID format, and is it validated? (20 hex characters; Blueprint's derived ids are accepted and kept) schema.md, “Names and IDs”; pbir/ids.py
5 Is page order a registry or implied by folder names? (pageOrder in pages.json) schema.md, “Pages”
6 What files appear when you add one card? schema.md, “Visuals”
7 Where does a visual's position and size live? schema.md, “Visuals”
8 Where does the visual title live? schema.md, “Visuals”
9 What does a field binding look like? schema.md, “Visuals”
10 What do the field wells look like per visual type? blueprint/visuals/*.yaml, each citing its probe
11 How is a drill-down path represented? (an ordered list of projections in one role) schema.md, “Visuals”
12 Is there a schema version string anywhere? ($schema on every document) schema.md, “Schema versions”
13 Does Desktop reformat JSON on save? (not unchanged files; what it writes has one fixed style, which jsonfmt reproduces byte for byte) schema.md, “File encoding”; pbir/jsonfmt.py
14 Can custom metadata survive a round trip? (yes, in annotations) schema.md, “What Desktop changes on its own” (probe 01)

schema.md is a living document. Each entry says what is verified and how:

## Pages

**Verified 2026-11-09, PBIR schema <x>, Desktop <version>.**

- A page lives at `definition/pages/<page-id>/page.json`.
- Pages are registered in `definition/pages/pages.json`, which holds an ordered
  `pageOrder` array and `activePageName`.
- Creating the folder without updating `pages.json` leaves the page invisible.

_Evidence: `git diff` after adding one blank page — see `docs/probes/02-add-page.diff`._

When a Desktop update changes the format, the replays fail and the raw diffs show what moved.


Fixtures and testing

Fixtures are synthetic PBIP reports built from scratch, committed to the repo. They exist so that:

  1. You can develop the entire tool at home, with no work files involved — ever.
  2. Anyone who clones the repo can actually run it, which is what makes this a project rather than a script.
  3. Schema drift surfaces as a failing test rather than as a surprise in a demo.
Fixture Contents Exercises
01-blank-report one empty 1920×1080 page reader, page creation, registry update
02-card-and-chart a card bound to [Total Amount] and a column chart with a Country → Region drill-down, both off-grid slots, bindings, fmt, idempotence, check

Over-budget pages and blueprint: ignore are covered by tests that copy a fixture or build a synthetic report (tests/builders.py), so no hand-edited fixtures are needed.

fixtures/README.md records how each one was produced, so they can be rebuilt against a newer PBIR schema.

Golden-file tests. For each fixture, tests/test_apply_golden.py runs a spec and compares the output tree byte-for-byte against a committed expected tree. When Microsoft changes the format, these fail loudly and the diff tells you exactly what moved.

The idempotence test is not optional. fmt twice must equal fmt once. It is the cheapest guard against a formatter that churns diffs forever.


Version compatibility

Three things version independently, and the manifest records all three:

Thing Where it's declared Why it matters
Blueprint blueprint.__version__ behaviour changes between releases
Guidelines version: in the guidelines file the standard evolves; old reports were built to old rules
PBIR schema read from the report Microsoft changes the format

Policy:

  • Blueprint refuses to write to a report whose PBIR schema it does not recognise, unless --force-schema is passed. Silently writing to an unknown format is how reports get corrupted.
  • bp check reports which guideline version a report was built against versus which one is being applied, so "this was compliant last quarter" is answerable.
  • Guideline files are versioned and additive. Renaming a key is a major version bump.

Roadmap

v0.1 — read and align. No generation at all. bp inspect and bp fmt (now bp describe --section pages and bp apply --snap) on existing reports: snap to grid, normalise sizes. Idempotence test passing. This version de-risks everything else — if reading PBIR, changing a position, writing it back and reloading in Desktop doesn't work cleanly, nothing above it matters.

v0.2 — validate. bp check against a guidelines file. Useful on its own: it can run over reports nobody generated and tell a reviewer what's off-standard.

v0.3 — generate. bp apply creates pages and places visuals from a spec, for three or four visual types. Manifest emitted. No field bindings yet.

v0.4 — bind. Typed slots, measures and columns, drill-down paths. This is where the tool becomes genuinely end-to-end with the Modeling MCP.

v0.5 — breadth. Drill-downs and legends on line and area, more chart options (done).

v0.6 — the template rewrite. Client-first input files: a small core guidelines schema with opt-in extensions:, a core of seven visual types, inherits: for visual contracts, per-field aggregate and format, labels/legend on all three chart types, sort, a Legend column on clustered charts, legend: off and table totals (done).

v0.7 — the core-20% audit. A guidelines key outside the core is refused instead of ignored, --set KEY=VALUE replaces --grid on every command that reads guidelines, and per-type PBIR facts live in the visual contracts rather than in core code (done).

v0.8 — every probed type is core. The archive is gone: all 18 probe-verified types ship in the core with no opt-in, the chart types take the same labels/legend options, and scatter, multi-row-card and map are new (done).

v0.9 — the options and wells the core still lacked. labels and legend on pie and donut, legend on scatter and map, and a model hierarchy in a matrix's rows and a slicer's field. Verified as candidates in probes 37-39 and accepted from bp apply in probe 40 (done).

v0.10 — the rest of the palette. Sentiment (good/neutral/bad), divergent (minimum/center/maximum) and structural (second_level ... disabled_text) colours in the guidelines, written to the theme; a table column's conditional-format gradient: 2|3 built from the divergent colours. Verified as candidates in probes 42, 44 and 46 and accepted from Blueprint's own output in probes 43, 45 and 49 (done).

v0.11 — Blueprint as an MCP server. bp mcp (the optional [mcp] extra) serves every command as an MCP tool, returning exactly what the CLI prints, for clients that can call tools but not run commands. The VS Code extension Blueprint for Power BI bundles it as a standalone bp.exe, so Windows needs no Python. No change to the core (done).

Nothing is queued, and that is a decision. A survey of the three sample reports (78 visuals, 2026-11-13) closed the backlog rather than ranking it. Blueprint builds 91% of the visuals in them, and each remaining candidate was measured, not guessed:

Candidate What the survey found Verdict
Axis titles 0 axis-title properties on 24 categoryAxis objects closed
categoryAxis.axisType 22 uses, but Desktop writes it itself and re-apply preserves it nothing to build
A matrix's subtotals 0 matrix (pivotTable) visuals in any of the three reports closed
A hierarchy in a matrix's columns same: no matrix to put one in closed
Rules and data bars 1 visual uses any FillRule; the core already writes a colour-scale gradient closed
The theme's neutral probes 42, 43: written and kept, but nothing was ever seen to draw it closed, unresolved
Five structural theme keys probes 46, 48, 50, 51: zero pixels in static, hover, selection, focus, a style preset, a shape and a button closed, unresolved

"Closed" means no probe is planned, not that the answer is known. Each reopens on evidence: a real report that uses the feature, or a practitioner who says they hand-fix it (docs/practitioner-survey.md). Counting PBIR says what ended up in a file; it cannot say what somebody gave up on. Until one of those arrives, adding surface would widen the part of Blueprint nobody has used.

Later, in no particular order. Bookmarks. Relative layout positioning. A bp new scaffold. Theme file generation (done: bp apply --theme). CI action for bp check (done: In CI).

Deliberately unscheduled: an interactive wizard. The declarative spec is the primary interface; a prompt-driven shell on top is a convenience, and conveniences come after the thing works.


Non-goals

  • No semantic model work. That is the Modeling MCP's job.
  • No LLM in the generation path. The tool must be deterministic and free to run.
  • No automatic content relocation. Warn, exit non-zero, let a human decide.
  • No conditionals in config. Named policies in code, selected by config.
  • No premature abstraction. create_page() and create_visual() stay as separate concrete functions until the duplication is real and understood.
  • Not a Power BI replacement. Desktop remains the place you look at the result.

Using this with client work

This repository is generic tooling. It contains no organisation's guidelines, no client data, no report files from any engagement, and it never should.

If you use Blueprint in a workplace:

  • Keep the guideline file internal. It is configuration, which is exactly why it can live somewhere else. guidelines/example.yaml here is invented.
  • Never commit real report files, measure names, table names or data — fixtures are built from scratch for this reason.
  • Go through your organisation's approval process for both cloning the repo onto a work machine and running it against real reports. Even code you wrote yourself is third-party software once it is on a public host.
  • Don't carry files in either direction outside those processes.
  • Check your employment agreement before publishing. IP assignment clauses are often broad enough to cover work related to the employer's business regardless of whose machine it was written on. Ask, and get the answer in writing, before rather than after.

License

MIT. See LICENSE.

Metadata

Release files for blueprint-pbi 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for blueprint-pbi 0.14.0
File Size Uploaded Provenance Actions
blueprint_pbi-0.14.0.tar.gz 222.6 kB With provenance Details for blueprint_pbi-0.14.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for blueprint-pbi 0.14.0
File Interpreter ABI Platform Actions
blueprint_pbi-0.14.0-py3-none-any.whl Python 3 none any Details for blueprint_pbi-0.14.0-py3-none-any.whl

Total release size: 427.7 kB

Release files / blueprint_pbi-0.14.0.tar.gz

Download URL blueprint_pbi-0.14.0.tar.gz
Size 222.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b9f433678ff5d6aa5a96f1ab37142d417ab381819b030b80e0f08a6e034f4da6
BLAKE2b-256 checksum
How to use checksums
3fe0bf9775c5a78cec2eb4d684e1e3bb22275ebbfc738cf8876948e97a9135d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Release files / blueprint_pbi-0.14.0-py3-none-any.whl

Download URL blueprint_pbi-0.14.0-py3-none-any.whl
Size 205.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6314609023c3f37f12c6a3d89241b26e70bc01ca70efdd9e3114975270047983
BLAKE2b-256 checksum
How to use checksums
5fca43f3ef3b6864d03fc1429a12ec1116e63d07fc322a201048c9a8b46c328b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

Security for blueprint-pbi 0.14.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for blueprint_pbi-0.14.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page