# pbi check loop

> Automates the Power BI Desktop reload loop for TMDL/PBIR edits with PID tracking and engine-state verification.

pbi check loop is a free AI agent skill on Agensi by Qiuyuan Cai, in APIs & Backend. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: Free
- Creator: [Qiuyuan Cai](https://www.agensi.io/creators/qiuyuan-cai)
- Category: [APIs & Backend](https://www.agensi.io/skills/apis-backend)
- Uses: 1
- Version: 1.0
- Last updated: 2026-10-10
- Security: scan passed (2026-10-24); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/pbi-check-loop
- Tags: api, automation, finance, powershell, power-bi, tmdl

## About this skill

### pbi-check-loop — close the loop on Power BI Desktop

Power BI Desktop has no command to reload a PBIP that changed on disk.

The sync only runs one way. Memory → disk exists: File → Save, Ctrl+S. Disk → memory has nothing. So when an agent edits a measure in TMDL, the running Desktop keeps its old model — and if you then press Ctrl+S in Desktop, it overwrites the new disk content with the stale in-memory model. The edit is gone.

This skill supplies the missing direction, plus a way for an agent to see what it produced, so AI-assisted Power BI development becomes a closed loop instead of one that stops for a human every iteration.

#### The two tools

**`pbi-reload.ps1`** — check and reload.

- `-ListOnly` reports what is running (PID, edition, title) and whether disk files are newer than the running instance.
- `-Yes` restarts Desktop so it re-reads TMDL and PBIR. It terminates without saving, so the stale model can never win; it cleans up the orphaned `msmdsrv` process and reopens the same project in the same edition, with the window restored where it was.
- `-Wait` blocks until the model has actually finished loading, and prints where to query it:

```
Ready after 23s - title settled and the model engine is up.
  Analysis Services: localhost:58894   [msmdsrv 29412]
```

That last line is the point. A screenshot proves the report rendered; only a query proves the numbers are right. The port is resolved by process ancestry rather than read from `msmdsrv.port.txt` — which, with two projects open, belongs to whichever loaded last, and will silently connect an agent to the wrong project's model.

`-Wait` matches the project name rather than the `Untitled - Power BI Desktop` title, which never settles on a localized Desktop (the zh-CN build shows `无标题`).

**`pbi-shot.ps1`** — capture the Desktop window to PNG, or `-Text` for plain text read through the UI Automation tree: dialog text, visual titles, matrix headers, cell values. Text is often more precise than the image — a column truncated on screen as `SALES_DETAIL_BY_RE…` comes back whole.

#### What it does not do

- **It does not make loading faster.** This is a restart, not a hot reload. The window does close, and the model load remains the dominant cost per iteration.
- **The agent cannot operate the report.** No scrolling, clicking, or page switching. If the problem is not on the current screen, a human navigates there first.
- **It does not verify numbers.** That is ADOMD's job, and that loop already existed.
- **A reload is not a data refresh.** It never goes back to source. Change a partition's M expression and that table's cached data is invalidated — it comes back empty, along with tables whose M references it. That is expected, not a broken edit.
- **Not every bad edit produces a dialog.** A broken calculated table opens normally and fails silently.

#### Relationship to the Power BI Desktop Bridge

Desktop shipped a Desktop Bridge in June 2026 — preview, build `2.155.756.0` or later, behind a Preview Features toggle. It is a local JSON-RPC server inside the Desktop process exposing four methods, and two of them overlap directly with this. Where they overlap, prefer the Bridge: its reload is in-process — no restart, no full model load, nothing destroyed if you had unsaved changes — and its snapshot renders internally rather than capturing a window.

What those four methods leave open:

- **Reach.** The Bridge needs a recent build and a preview toggle. Managed corporate installs do not move quickly, and Power BI Report Server Desktop is a separate product where there is no indication the Bridge exists at all. A PowerShell script runs against whatever is installed.
- **Errors.** `application.state.get/v1` returns `currentFilePath` and `hasUnsavedChanges`. Nothing else. When Desktop rejects a file, no method, trace log, stderr, or event log says so — the error exists only as an on-screen dialog.
- **The model.** No port, no query surface.

#### Requirements

Windows · PowerShell 5.1+ · Power BI Desktop · a `.pbip` project. macOS and Linux are not supported — Power BI Desktop does not exist there. MIT licensed.

#### Install

Unzip, then run:

```powershell
.\install.ps1
```

It copies the two scripts to `~\.claude\tools\` and the skill to `~\.claude\skills\pbi-check-loop\`, then verifies PowerShell syntax and UTF-8 BOM on every file it writes. Restart your agent to activate it.

On a multi-agent machine, always pass `-Path`: the script matches the project name against window titles to find your instance, and never touches another agent's Desktop.

Source and full findings: https://github.com/C-QY/pbi-check-loop

## Requires

- Git

## Known limitations

Windows only. Works only with .pbip projects, not .pbix. Does not support Power BI Service. Requires manual PowerShell tool installation.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the pbi check loop skill from Agensi" and describe your task.
3. Your agent loads the skill from Agensi when it needs it. Nothing is downloaded.

## Frequently asked questions

### How does this skill improve the Power BI development workflow for TMDL and PBIR files?

This skill automates the manual 'close and reopen' cycle required when editing Power BI metadata (TMDL/PBIR) by using PID tracking to safely restart specific Desktop instances only when disk changes are detected.

### Can I use this skill with standard .pbix files or on a macOS environment?

No, this skill specifically requires the Power BI Project (.pbip) format to track file-system changes and is currently only compatible with Windows-based environments where Power BI Desktop is installed.

### How does the skill handle multiple open instances of Power BI Desktop without crashing them all?

Unlike generic scripts, this skill uses parent-child PID mapping to identify the exact Analysis Services engine port, ensuring it doesn't interfere with other open reports or attempt to query the model before it is fully initialized.

### What assets are included in the purchase of the 'pbi check loop' skill?

The package includes the core PowerShell automation framework, specialized UI automation scripts for error diagnosis, and the integration logic for your AI agent to trigger reloads and verify model states.

### Which AI agents or development environments are compatible with this skill?

It is designed for AI agents that support local shell execution and UI interaction, such as those running in VS Code or dedicated developer environments that can interface with PowerShell and the Windows API.

### How does the skill handle errors if the TMDL or PBIR code is invalid?

The skill includes a diagnostic layer that uses UI automation to read error messages directly from Power BI modal dialogs, allowing your agent to identify and report syntax errors or broken relationships immediately after a reload.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
