# Pbi Semantic Layer Tmdl

> Edit the Power BI semantic model as code by authoring TMDL files in a PBIP project (offline, Desktop closed). Covers structure, syntax, and post-edit verification.

- **Type:** Skill
- **Install:** `agentstack add skill-luccapinto-agentic-data-kit-pbi-semantic-layer-tmdl`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [luccapinto](https://agentstack.voostack.com/s/luccapinto)
- **Installs:** 0
- **Category:** [Developer Tools](https://agentstack.voostack.com/c/developer-tools)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [luccapinto](https://github.com/luccapinto)
- **Source:** https://github.com/luccapinto/agentic-data-kit/tree/main/.opencode/skills/pbi-semantic-layer-tmdl

## Install

```sh
agentstack add skill-luccapinto-agentic-data-kit-pbi-semantic-layer-tmdl
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Skill: pbi-semantic-layer-tmdl

Author and edit the semantic model (tables, columns, measures, relationships, RLS) by writing
**TMDL** files directly. TMDL is the GA, human-readable text format for tabular models — great
diffs, one file per table, fully scriptable.

## Hard precondition
**Power BI Desktop must be CLOSED** before saving. Desktop keeps the model in memory and
overwrites disk on save, so editing live corrupts files or loses work.

## `.SemanticModel` structure
```
.SemanticModel/
  definition.pbism          ← pointer (do not hand-edit)
  definition/
    model.tmdl              ← model-level definition, lists tables
    database.tmdl           ← compatibility level / annotations
    tables/.tmdl     ← ONE table per file (golden rule)
    relationships.tmdl      ← all relationships
    expressions.tmdl        ← shared M expressions / parameters
    cultures/               ← translations
    roles.tmdl              ← RLS
  .pbi/                     ← local cache/settings — NEVER edit (localSettings.json, cache.abf)
```
Edit `.tmdl` files only. One table per file — never define every table inside `model.tmdl`.

## TMDL syntax reference
```tmdl
table 'Sales'
    description: "Primary sales fact."

    measure 'Total Sales' = SUM(Sales[Amount])
        formatString: "#,##0.00"
        displayFolder: "Financials"
        description: "Sum of sales amount."

    column 'Amount'
        dataType: decimal
        sourceColumn: BaseAmount
```
```tmdl
relationship Sales_Date
    fromColumn: Sales.DateId
    toColumn: Date.DateId
    fromCardinality: many
    toCardinality: one
```

**Serialization rules:** keep functional properties (`dataType`, `sourceColumn`) before
cosmetic ones; match the file's existing indentation; for multi-line DAX, break with `\` at the
end of the line.

## Tooling
- **Tabular Editor 2 (free)** can open the `.SemanticModel` folder, validate, batch-edit, and
  re-serialize clean TMDL. Use it to sanity-check non-trivial edits.
- **Optional:** Microsoft's `powerbi-modeling-mcp` (preview) edits the same PBIP/TMDL files and
  is handy for bulk operations. File editing remains the default, accessible path.

## Post-edit verification
1. Ask the user to open the `.pbip` in Desktop and wait for the field list to populate.
2. **View → Diagnostics** — report any error/warning shown.
3. For each new/changed measure, drop it on a **Card** and confirm the value (no red error icon).
4. On error: re-read the edited TMDL, find the syntax/reference issue, propose the fix.
5. Run the `pbi-quality-rules` skill (BPA) after significant changes.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [luccapinto](https://github.com/luccapinto)
- **Source:** [luccapinto/agentic-data-kit](https://github.com/luccapinto/agentic-data-kit)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-luccapinto-agentic-data-kit-pbi-semantic-layer-tmdl
- Seller: https://agentstack.voostack.com/s/luccapinto
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
