plugins/fabric-skills/skills/semantic-model-authoring/SKILL.md
Manages Power BI semantic models, including tables, columns, measures, relationships, DAX authoring and tuning, Import, DirectQuery and Direct Lake designs, sources, connections, permissions, refresh, and deployment. Load this skill before acting on a semantic model, unless it is part of publishing a PBIP project, which powerbi-report-management owns. For natural-language data questions use fabriciq; for visuals use powerbi-report-authoring.
npx skillsauth add microsoft/skills-for-fabric semantic-model-authoringInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Telemetry — MANDATORY. Every
api.fabric.microsoft.comcall must carryx-ms-fabric-skill: semantic-model-authoring(az rest:--headers "x-ms-fabric-skill=semantic-model-authoring"), including every LRO poll,fabric_lroand retry. Snippets omit it — add it anyway.
CRITICAL NOTES
- To find the workspace details (including its ID) from workspace name: list all workspaces and, then, use JMESPath filtering
- To find the item details (including its ID) from workspace ID, item type, and item name: list all items of that type in that workspace and, then, use JMESPath filtering
- Always consider the Tool selection priority when choosing which tool to use for each operation. Do not default to TMDL edits or
az restif MCP is available and connected to the target model.
Use this decision tree to route to the correct workflow based on user intent:
| User wants to... | Workflow | | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | Create a semantic model from scratch | Create new semantic model | | Inspect or discover model metadata (tables, columns, measures, relationships) | Discover Semantic Model Metadata | | Add/edit semantic model objects (e.g. measures, tables, columns, relationships) | Modify an Existing Model | | Write or refactor DAX code | Modify an Existing Model | | Improve DAX query or measure performance | Optimize DAX Performance | | Analyze semantic model against best practices | Analyze Best Practices | | Prepare a semantic model for AI consumption (Copilot / Data Agents) | Semantic Model AI Readiness | | Deploy a model to a Fabric workspace | Deploy to Fabric | | Refresh a semantic model | Refresh Semantic Model | | Configure data sources, parameters, or permissions | Manage Semantic Model in Fabric | | Bind a semantic model to a Fabric connection (or unbind) | Bind Semantic Model to a Connection | | Export / Get semantic model definition as PBIP | Export to PBIP |
Load these references on demand when a workflow step requires them. Do not load all at once.
| Topic | Reference | When to load |
| -------------------------------- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
| Modeling Best Practices | modeling-guidelines.md | Before creating or editing any model |
| Naming Conventions | naming-conventions.md | When naming or renaming tables, columns, measures |
| Direct Lake Modeling | direct-lake-guidelines.md | When model connects to OneLake |
| TMDL Editing | tmdl-guidelines.md | Before generating or editing any TMDL file |
| PBIP Projects | pbip.md | When working with PBIP folders |
| DAX Language | dax-guidelines.md | When writing or reviewing any DAX code |
| Metadata Discovery (DAX INFO functions) | metadata-discovery.md | When discovering model metadata via DAX INFO functions (see Workflow: Discover Semantic Model Metadata) |
| DAX Performance Decision Guide | dax-perf-decision-guide.md | Start here when optimizing DAX |
| DAX Performance Pattern Catalog | dax-perf-patterns.md | Load on demand after the decision guide identifies candidate patterns |
| Semantic Model AI Readiness | semantic-model-ai-readiness.md | When preparing a model for Copilot or Data Agents |
| Semantic Model REST API | semantic-model-rest-api.md | When using az rest for TMDL CRUD, refresh, parameters, permissions, or property retrieval |
| Connection Binding | connection-binding.md | When binding/unbinding a semantic model to a Fabric data connection (gateway, cloud, VNet, automatic, none) |
| Finding Workspaces/Items | COMMON-CLI.md | When resolving workspace/item IDs |
| Fabric Control-Plane API | COMMON-CLI.md | When using az rest patterns, LRO, pagination |
| Authentication | COMMON-CLI.md | When authenticating with az login |
| Authentication & Token Acquisition | COMMON-CORE.md § Authentication & Token Acquisition | Wrong audience = 401; read before any auth issue |
| Core Control-Plane REST APIs | COMMON-CORE.md § Core Control-Plane REST APIs | Includes pagination, LRO polling, and rate-limiting patterns |
| Definition Envelope | ITEM-DEFINITIONS-CORE.md | When building TMDL definition payloads |
| Examples | Examples | Reference end-to-end walkthroughs. |
Priority order (highest first):
Tier 1 — powerbi-modeling-mcp MCP is registered -> Use MCP for authoring (new or edit) operations against the model from any source: Power BI Desktop, Fabric workspace, or local PBIP folder. MCP is the most reliable and full-featured way to edit semantic models, with immediate effect on the live model and no risk of TMDL desync.
Important: In case of dynamic search tools is available (e.g. tool_search_tool_regex) search for an available MCP server matching the pattern powerbi-modeling-mcp.
This includes BOTH writes AND reads/inspection.
view-ing, glob-ing or otherwise reading TMDL files (*.tmdl) while MCP is connected. The MCP-loaded model is the source of truth - the on-disk TMDL is stale. The only exceptions is when the user explicitly asks to work with the TMDL files.Tier 2 — MCP not registered + PBIP folder or Fabric workspace -> Edit TMDL files directly. Load tmdl-guidelines.md and pbip.md. When the source is a Fabric workspace, use az rest to round-trip the TMDL (load semantic-model-rest-api.md): getDefinition -> edit TMDL locally -> updateDefinition.
Fallback — none of the above available (e.g., Power BI Desktop with no PBIP and no MCP) -> STOP. The agent cannot author the model in this configuration. Instruct the user to either (a) install and register the powerbi-modeling-mcp MCP server, or (b) save the PBIX as a PBIP project, then restart the workflow.
All workflows below are tool-agnostic. Workflow steps describe the intent (connect, create, edit, save, deploy, refresh). The tool used to perform each step is determined here. Always select the highest-priority tool available for the current environment; do not mix tools when a higher-priority option works. Some workflows OVERRIDE this default priority, always check the workflow's own tool-selection rules before defaulting to Tier 1.
A semantic model can live in three locations. Resolve the connection per Tool Selection Priority:
SemanticModel in that workspace to resolve the model ID by name. Then connect to the model (live) or export its TMDL definition for local editing.[Name].SemanticModel/definition folder. Load pbip.md to understand the PBIP folder structure - only load the [Name].SemanticModel/definition folder that includes the TMDL code.How changes are persisted depends on where the model lives and which tool tier (per Tool Selection Priority) is in use:
Live connection (Tier 1 - MCP against Desktop or Fabric workspace):
[Name].SemanticModel/definition folder at the end of the session. If the PBIP folder does not exist yet, follow Export to PBIP to create the full structure first.Local TMDL editing (Tier 2 - direct file edits or az rest round-trip):
updateDefinition flow) to push changes back to the workspace.When this applies: User asks to create a new semantic model from scratch.
Steps:
Gather requirements - interview the user until both reach a shared understanding of: purpose of the model, data source connection details and schemas, and key business entities/facts. If data source information is not available, STOP and use ask_user. Do not guess or fabricate.
Determine storage mode - data source is Fabric OneLake -> Direct Lake; otherwise default to Import. Only use DirectQuery when the user explicitly asks for it.
Design star schema - identify fact and dimension tables and relationship keys.
Load applicable guidelines - MANDATORY: load modeling-guidelines.md before building any object (including the Tier 1 MCP path below); also load direct-lake-guidelines.md if Direct Lake. Don't build from memory.
Build - follow Tool Selection Priority: prefer the modeling MCP to build the whole model when one is available; otherwise use the TMDL code-edit path. Create an empty database (compatibility level 1702+), then for each table follow the execution order from Modify an Existing Model (partitions -> columns -> relationships -> measures). Storage-mode specifics:
Server, Database, ...) and reference them in partition M code; ensure proper dataType and sourceColumn mapping on columns.AzureStorage.DataLake connector; use EntityPartitionSource with directLake mode mapped to the lakehouse table columns.Build the whole model in one pass, then deploy once. Add every table, column, relationship and measure before deploying - don't deploy a partial model and edit-redeploy. On the MCP path, keep the model in the session end to end.
Deploy or save - Fabric workspace available -> Deploy to Fabric; otherwise -> Export to PBIP. See Saving Changes to a Semantic Model. Deploy through the same path you built with.
Validate - run Validation Checklist.
When this applies: User asks to inspect, list, or discover the model's structure - tables, columns, measures, relationships, hierarchies, partitions, roles, or storage internals. Also used internally by other workflows (Modify, Analyze Best Practices, AI Readiness) to inventory the model before editing.
Pick a discovery method (highest priority first):
powerbi-modeling-mcp TOM inspection (List / Get) - the default when powerbi-modeling-mcp is registered and connected to the target model with Write access. It returns the structured object model directly and stays in sync with pending edits, so it is preferred while authoring.
DAX INFO.VIEW functions - query the model's INFO.VIEW.* metadata rowsets. MANDATORY: before writing or running ANY INFO-function DAX, you MUST load metadata-discovery.md first. Do NOT compose INFO queries from memory; load the reference and use its patterns. Prioritize this method when any of the following is true:
powerbi-modeling-mcp List / Get operations require Write; with Build access, use INFO.VIEW functions executed via the dax_query_operations tool.powerbi-modeling-mcp is not registered or not available. Use Tier 2: export the model definition (getDefinition) and inspect the .tmdl files for schema metadata.Start narrow: run the scope-estimation and INFO.VIEW.* queries first, then project/filter to only the objects relevant to the task (see metadata-discovery.md).
When this applies: User asks to add/edit/remove measures, tables, columns, relationships, write DAX code, refactor with UDFs, or edit TMDL directly.
Steps:
When this applies: User asks to improve DAX query performance, diagnose slow measures, or optimize calculations.
Hard requirement: Requires a trace-capable client (MCP preferred))
Load dax-perf-decision-guide.md first and follow the framework defined there. Load dax-perf-patterns.md only when applying candidate optimization patterns. The framework includes:
When this applies: User asks to review, audit, or analyze a semantic model against best practices.
Steps:
formatString, column data types and sourceColumn, hidden FK columns, calculated-column-vs-measure choices, Direct Lake constraints, etc.).When this applies: User asks to make a semantic model ready for Microsoft Fabric Copilot, a Power BI Data Agent, or any conversational BI experience. Triggers include "Copilot readiness", "AI readiness", "Prep for AI", "prepare model for Copilot".
Load semantic-model-ai-readiness.md before starting.
Steps:
ask_user, confirm consumption mode (reports only / conversational BI / both) and model stability per the When to Apply section. Collect business context (process, key metrics, common natural-language questions, vocabulary). Do not invent.When this applies: User asks to export or save a semantic model to a PBIP project folder, or there is no Fabric workspace available to deploy to (e.g., after building a model in-memory).
Key fact: Exporting a model only produces the TMDL definition files. It does NOT create the surrounding PBIP folder structure (Report folder,
definition.pbism,definition.pbir,.pbipentry point). The agent must scaffold these before exporting, otherwise the result cannot be opened in Power BI Desktop.
Load pbip.md before starting and follow the PBIP folder structure defined there.
Steps:
ask_user, get the target folder path and the semantic model name. If only a folder is provided, use the model's database name as the semantic model folder name.<Name>.SemanticModel/ (with definition/ and definition.pbism), <Name>.Report/ (with definition/ and definition.pbir using a byPath reference), and <Name>.pbip exist. Create any missing piece.<Name>.SemanticModel/definition/, per Tool Selection Priority:
getDefinition (load semantic-model-rest-api.md) and write the returned parts.definition/ folder.definition/ folder contains at minimum model.tmdl and table .tmdl files; confirm definition.pbism, <Name>.Report/definition.pbir (with correct byPath to ../<Name>.SemanticModel), and <Name>.pbip exist and reference each other correctly.When this applies: User asks to deploy or publish a semantic model to a Fabric workspace.
Hard rule — this workflow OVERRIDES the default Tool Selection Priority. Do not default to MCP just because it is available. The deployment path is determined by the source of the model, not by which tools are connected. If the source is PBIP/TMDL files on disk, you MUST use the Fabric REST API even when an MCP session is active.
Decision tree (pick exactly one — top-down, first match wins):
az rest with createItemWithDefinition (new model) or updateDefinition (existing model). Load semantic-model-rest-api.md.
Verify deployment succeeded by listing workspace items of type SemanticModel.
Deploy exactly once; the deploy is NOT idempotent. A retried deploy creates a second model with the same name, after which the deploy fails with
There are multiple datasets named '<name>'. If you hit that error, do NOT retry blindly: list the workspace's semantic models, delete every duplicate with that name, then deploy once from the clean state. If deploying a model that may already exist, delete the existing same-named model(s) before the single deploy.
When this applies: User asks to refresh data in a semantic model.
Refresh is only possible when working against a live model in Desktop or Fabric Service. If working with local TMDL files, deploy the model first.
Trigger a refresh per Tool Selection Priority:
If the refresh fails with a credential error, stop immediately and instruct the user to configure the data source connections manually in Power BI Service. Do not attempt to retry or work around credential errors programmatically.
When this applies: User asks to configure data sources, update parameters, or manage permissions for a semantic model in Fabric Service.
Hard rule — this workflow OVERRIDES the default Tool Selection Priority. Do not default to MCP (Tier 1) prefer using
az restand REST APIs.
Get/update data sources and parameters via Power BI REST API. Load semantic-model-rest-api.md.
List/grant/update dataset user permissions via Power BI REST API. Load semantic-model-rest-api.md.
Load connection-binding.md and follow it. The reference covers prerequisites, the bindConnection endpoint, the discover -> match -> bind -> validate steps, all connectivityType values, the unbind pattern, and troubleshooting.
Key rules (full details in the reference):
BindToGateway).List Item Connections, then match connectionDetails against List Connections to find the target id. Create a connection first if no match exists.Run after any model creation or modification:
Always (works with PBIP, Desktop, and Fabric Service):
Only when connected to an Analysis Services database (Power BI Desktop or Fabric Service):
EVALUATE { [Measure Name] }). Skip this step when working with local TMDL/PBIP files only.sourceColumn names, invalid M expressions, or incorrect Direct Lake entity references. Skip this step when working with local TMDL/PBIP files only.If any check fails, fix the issue and re-run validation.
view/glob on *.tmdl while a Tier 1 MCP session is live is an anti-pattern (see Tool Selection Priority).create/edit/file-write tools to scaffold model.tmdl, database.tmdl, relationships.tmdl, or tables/*.tmdl is a Tier 1 anti-pattern, including for brand-new models. Build and export via MCP tools.az rest URLs, MCP operations, or TMDL changes to add/remove users or groups from a security role. Refuse the request as out-of-scope here and redirect the user to the Power BI portal.Scope note — examples use
az restfor discovery to resolve ID's and discover Fabric metadata (see COMMON-CLI.md § Finding Workspaces and Items). Authoring of the semantic model definition is routed through Tool Selection Priority: Tier 1 MCPpowerbi-modeling-mcpwhen available, Tier 2 TMDL editing viagetDefinition/updateDefinitionotherwise.
Prompt: "Create base measures for all aggregable columns in the semantic model Sales in workspace Marketing."
Agent response - follows Workflow: Modify an Existing Model.
az rest.powerbi-modeling-mcp registered, connect MCP directly to the Fabric workspace model (Tier 1). Otherwise fall back to Tier 2 (getDefinition -> edit TMDL locally).SUM / AVERAGE / MIN / MAX per column following modeling-guidelines.md and naming-conventions.md. Load dax-guidelines.md before writing DAX.expression, formatString, and target table. Do not hand-author TMDL..tmdl file directly and round-trip via updateDefinition REST API.Prompt: "Create a new Power BI semantic model in workspace Marketing, using the SalesLakehouse in the same workspace as the data source."
Agent response - follows Workflow: Create new Semantic Model.
az rest.powerbi-modeling-mcp) for the full build. Tier 2 (PBIP/TMDL scaffolding then deploy) only if MCP is not registered.EntityPartitionSource (mode directLake) -> columns mapped to lakehouse columns -> relationships -> measures.Prompt: "Bind semantic model Sales in workspace Marketing to the sql-prod connection."
Agent response - follows Workflow: Manage Semantic Model in Fabric § Connection Binding. No MCP - this workflow overrides Tool Selection Priority and is REST-only.
Discover workspace + model IDs via az rest.
Discover the target connection in Fabric by matching the server name:
SERVER="sql-prod"
CONN_ID=$(az rest --method get --resource "https://api.fabric.microsoft.com" \
--url "https://api.fabric.microsoft.com/v1/connections" \
--query "value[?connectionDetails.path | contains(@, '$SERVER')] | [0].id" -o tsv)
If no connection matches, stop and instruct the user to create one first per connection-binding.md.
Execute the bind per Workflow: Manage Semantic Model in Fabric § Connection Binding - load connection-binding.md and follow the discover -> match -> bind -> validate flow:
List Item Connections).connectionDetails matches $CONN_ID, call the Fabric bindConnection endpoint one request per data source reference (no bulk binding).Validate - re-list item connections to confirm the binding, prompt the user to trigger a refresh per Workflow: Refresh Semantic Model. Credential errors -> stop and direct the user to the Service portal (per TROUBLESHOOTING).
| Symptom | Fix |
| ------------------------------------ | --------------------------------------------------------------------------------------------------------------------- |
| MCP connection failure | Fall back to TMDL editing (see Tool Selection Priority). Inform the user about the fallback. |
| TMDL validation errors | Read error details, fix syntax, re-validate. Load tmdl-guidelines.md. |
| 403 Forbidden / identity None | User needs Contributor+ role - stop immediately. Do not retry. |
| 401 Unauthorized | Correct the --resource audience once (see semantic-model-rest-api.md). If it persists after the audience is right, it is missing permissions - stop and tell the user. Do not retry-loop. |
| 202 Accepted but no result | Poll LRO to completion. |
| Parts missing after updateDefinition | Must include ALL parts - modified + unmodified. |
| Refresh credential error | Direct user to configure in Service portal. Do not retry. |
| DAX errors in measures | Check column/table name references (case-sensitive). Verify referenced objects exist. |
| Deployment failure | Check workspace permissions, model compatibility level, and Direct Lake expression source references. |
| Missing data source | Verify M parameters or named expressions are correctly defined. |
tools
Manages Fabric Spark work, including notebook cell code with %%configure, %%sql, PySpark and notebookutils, named notebook runs, Livy sessions, triage of failed or OOM notebook and pipeline Spark runs, and the Materialized Lake View (MLV) lifecycle. Load it before writing MLV SQL, since CREATE MATERIALIZED LAKE VIEW and its CONSTRAINT clause are Fabric-only. KQL materialized views belong to eventhouse-cli.
tools
Governs Microsoft Fabric OneLake catalog health, protection, and trust through Fabric Admin, Core, and Power BI REST APIs. Use for tenant or owner-scoped audits and guarded remediation of domains, workspace assignment, capacity, labels, tags, descriptions, refresh, and item identity. Catalog item discovery belongs to search-consumption-cli.
tools
Runs the Fabric Git integration lifecycle through fab api or az rest, including connecting a workspace to Azure DevOps or GitHub, committing, updating from Git, reading sync status, resolving conflicts, disconnecting a connected workspace, and automating sync with a service principal. For stage promotion use deployment-pipelines-authoring-cli. Branch switching, fab deploy, fabric-cicd and cross-workspace rebinding are out of scope.
tools
Manages Fabric IQ Ontology items, including entity and relationship types, data bindings, and definition updates, plus schema, lineage, grounding, and graph-walk exploration. Use for ontology modelling and traversal. For natural-language questions over a Power BI report use fabriciq.