/semantic-model-analyzer:semantic-model-analyzerfrom semantic-model-analyzer
Audits and documents Power BI semantic models from TMDL, PBIP, or Power Query M files. Answers questions about measures, lineage, relationships, query folding, Copilot readiness, and version differences. Every claim is traced to a file and line.
Ships in semantic-model-analyzer. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The user gets an answer about a Power BI semantic model that is grounded in its definition, with
every claim traced to a file and line, and, when they ask for one, a set of offline HTML pages
that present the model: a landing page with data and measure lineage, a page per segment, an AI
readiness checklist and a finder. The bundled engine (sma) parses TMDL and Power Query M as
text into one dataset; the rules, the list and explain answers, the comparison of two
versions and the HTML all read that dataset, so an answer never rests on something the files do
not say.
.tmdl, .pq, .m or .txt files,
a folder, or a PBIP or .SemanticModel folder.What this skill adds over a general read of the files: every finding with its file and line, measure-to-measure lineage, a comparison of two versions, the AI readiness checklist and an offline report that can be walked through.
.Report folder) is under review: use a
report-review skill, and a PBIR tool for changes.fab export, or by saving it as a PBIP in Power BI Desktop) and hands it over..pbix, .zip or model.bim is available. Ask for the model saved as a PBIP with
TMDL, or exported as TMDL..tmdl, .pq, .m, .txt, a folder, a PBIP or
.SemanticModel folder) or text they pasted in this conversation. Only the model half of a
PBIP is read: a .Report folder on its own gives found nothing readable.sma-report under
the user's working folder; say the full path.--label "name" for page titles, --config rules.json for agreed thresholds
and suppressions (references/findings.md), a second version of the model for a comparison.SKILL_DIR: the directory that holds this SKILL.md, reported as the skill's base
directory when it loads. The engine is the sma package inside it.Data: only the model text the user hands over in this conversation. Given a definition
folder, the engine also reads the VerifiedAnswers folder beside it for the AI readiness check,
counting answers and trigger phrases without copying their text. The engine makes no network
request; what the skill may read is R3.
Engine: sma, bundled in SKILL_DIR, Python 3.9 or newer, standard library only, no
install. Run it from the user's working folder so their relative paths resolve, with
SKILL_DIR on the module path and bytecode off so nothing is written into the skill folder:
PYTHONPATH="SKILL_DIR" python -B -m sma COMMAND [PATHS] [options] # Bash, macOS/Linux: python3
$env:PYTHONPATH = "SKILL_DIR"; python -B -m sma COMMAND [PATHS] [options] # PowerShell
Below, sma stands for that prefix. Commands: inspect, dataset, analyse, list,
explain, diff, render, report. Every flag, input shape and worked example is in
references/commands.md.
Credential screen: built into the engine. Every command that parses refuses input holding
credential-looking text (a password in a connection string, an account or access key, a SAS
signature, a client secret, a bearer token, basic authentication, an API or subscription key, a
token in a URL or a literal, a vendor token, a JSON web token or a private key) and lists every
match by file and line, never the value. inspect reports the same without stopping. What to
do on a match is R1.
Writes, all under R2: the scratch folder (Workflow step 3), and on request only
report.json (dataset -o), a findings file (analyse --json), a comparison file
(diff --json), a rules file (references/findings.md), and the pages index.html,
semantic-model.html, power-query.html, ai-readiness.html and references.html
(render -o).
Each rule is stated once, here; the sections below refer to it by number.
screen : possible credential at FILE:LINE (kind) from inspect, or input error: possible credential in the input) or one
you notice yourself, flagged or not: the screen is best-effort, not proof that a file is clean.
On one, stop work on that input and render nothing; tell the user the file, line and kind
without quoting the value, and ask them to remove it from the source and rotate it if it is
real. Continue only on a clean copy, or with --no-credential-check after the user has looked
at every line listed and said none is a credential; never pass that flag on your own
judgement.SKILL_DIR. The one write without a request is the scratch folder (Workflow step 3), fresh
per run and deleted on every exit, finished or stopped. Look at the target first: a file this
conversation did not write (any of the five page names, a report.json, a named --json
file, a rules file) is replaced only after the user's yes in this conversation; otherwise use
a new subfolder. For a rules file, show the user the entry you add.VerifiedAnswers folder beside a named definition. On a
denied read, report the path and stop: never look for another copy, use elevated rights or
ask for someone else's export. Open no connection to any service, workspace, Desktop instance,
XMLA endpoint, gateway or database, and never try to reach the source behind a model; a
published model is analysed only from a definition the user exported with their own access.Find the input. Use the paths the user named or the text they pasted. If there is
neither, ask for the model; never answer from a description, a screenshot or memory of an
earlier run. A .pbix, .zip or model.bim alone: ask for a PBIP with TMDL or a TMDL export.
Inspect, every time: sma inspect PATHS (or the paste flag). It names what will be read
and as which segment, prints a note for anything it could not read or place, and ends with
the credential screen: screen : clean (N sources searched) or
screen : possible credential at FILE:LINE (kind). Stop on a could not read note (report
the path) and on a possible credential (R1).
Answer from the dataset, choosing the command by the question:
| Question | Command |
|---|---|
| Which ..., how many ... | sma list PATHS KIND --where FIELD=VALUE [--count] |
Everything about one measure, table, Table[Column], relationship, role or query | sma explain PATHS "Name" --wide |
| What needs attention | sma analyse PATHS (--all adds notes) |
| What changed between two versions | sma dataset each version into the scratch folder, then sma diff "SCRATCH/before.json" "SCRATCH/after.json" |
| How ready it is for Copilot or a data agent | sma dataset into the scratch folder, then read tmdl.aiReadiness (references/commands.md) |
| A report or document to walk someone through | sma render PATHS -o OUT |
For more than one question or a comparison, parse once into a fresh scratch folder and pass
--report to the rest, so parallel sessions never share a file. Create the folder and note
the full path it prints (python3 on macOS/Linux):
python -c "import tempfile; print(tempfile.mkdtemp(prefix='sma-'))"
sma dataset PATHS -o "SCRATCH/report.json" -q
SCRATCH stands for that printed path, written out in full in every later command. A shell
variable does not survive from one tool call to the next, and an empty one would turn
$SCRATCH/report.json into a file at the drive root.
Terminal output is shortened to fit. For the full text of findings use
sma list --report "SCRATCH/report.json" findings --all --wide; for what a finding code means
and why it matters, read the dataset's help map (references/commands.md). Do not read
answers out of the HTML. Reading the source files to check or add to what the engine reports
is fine; cite the file and line and say it is your reading, not an engine finding.
Check coverage before any whole-model claim. analyse and dataset print a read : line
and, when model.tmdl declares objects that were not handed over, a gap : line; the dataset
holds the same in tmdl.coverage. If the handover is partial (one table file,
0 relationships, undeclared-table findings, a gap line), say so and limit the answer to
what was read.
Write files only when asked, under R2: an absolute path for -o and --json, and a look
at the target before writing.
Clean up on every exit: delete the scratch folder from step 3 by its full path, whether
the task finished or stopped on an error, a denied read or a credential:
python -c "import shutil, sys; shutil.rmtree(sys.argv[1])" "SCRATCH".
Reply per the Output contract and the claims rules below.
Fit the reply to the question and keep it short. Every fact carries its evidence: the object name
with the File.tmdl:line the engine printed, and a coverage caveat when the handover was partial
(Workflow step 4).
File.tmdl:line. Quote a finding's help text only where it explains why that item matters.analyse prints it (N could not be read, N worth acting on, N worth knowing, N rules fired) and where to see the full list
(sma analyse --all, or the report's Findings section). Do not paste every note. When few
or no measures have descriptions, add the figure from tmdl.totals.described.diff: what changed in model terms and the measures downstream of
each changed one.index.html first. When pointing at one
reading, give its anchor link, for example semantic-model.html#card-t14?pick=Total%20Sales.
The page guide is references/report-pages.md.Facts come from the engine; anything from your own reading of the files is labelled as such. Outputs are never hand-edited; change the input and render again.
Value.NativeQuery with
EnableFolding=true is reported as the exception, at info.relationship-loop follows the direction filters
flow; two facts sharing two dimensions is not one.error means only that text could not be read (parse-failed, parse-recovered). A
modelling observation is warning or info, never an error.tmdl.totals.described), not a finding.The thirty rules, their levels and the rules file are in references/findings.md.
database, model, table,
column, partition, role and the other declaration words) cuts that expression short when
it is read from a .tmdl file. The Direct Lake template let database = Sql.Database(...) in database is the common case. It shows as a parse-recovered finding on the expression and no
steps or sources for it in explain; the rest of the model reads normally. Say which
expression was affected, and to read it, pass its M with --m-text, where this does not
happen; the query is then named pasted M.functions.tmdl) are not read. inspect says so, and calls
to them from measures are not in the lineage..pbix, .zip and model.bim files (Do not use when), and a PBIP's
.Report folder, which is why a measure is unreferenced rather than unused (Claims).sma --version, and a small made-up
example rather than the real model. A security problem goes through the repository's private
vulnerability report, not a public issue. When a team says a flagged pattern is intentional,
record a suppression with its reason in a rules file (references/findings.md) rather than
ignoring the finding.nothing to read. Give paths, or --text ...: ask for the model text.input error: no such path: ...: say which path; ask for the right one or look only
inside the folder the user named. Paths with spaces or an apostrophe need quoting.note : could not read FILE: ... (from inspect): that file was not read. Report it
and stop; anything said about the model would silently leave it out.input error: found nothing readable in ...: read the What was looked at line first. A
Permission denied there is a denied read (R3). Otherwise the input is not TMDL or M (often a
.pbix, .zip, model.bim or a .Report folder); ask for a PBIP with TMDL, a TMDL export or
the query text.input error: possible credential in the input, ...: R1.error: ... (exit code 1): relay it once, delete the scratch folder and stop. Do not edit
the engine to get past it.parse-failed or parse-recovered findings: that object's text did not come through.
Name it with its file and line; the rest of the read stands. Never guess the missing DAX or M.nothing called '...' in this dataset (explain, exit code 1): the name is not in what
was read. --match is a substring search (sma list PATHS measures --match TEXT); to browse
names, sma list PATHS KIND --fields name --all. Never answer from memory.gap : line, undeclared-table
findings or a single file) and answer only for what was read.references/commands.md: running the engine, every command and flag, the input shapes, the
list kinds and --where syntax, the help map, worked examples, and reading the dataset in
Python.references/findings.md: the thirty rules, levels, and the rules file.references/report-pages.md: the HTML pages, the landing page, the AI readiness checks and
the finder's keys and anchors.sma/dataset.py: the dataset's shape, which is the contract every command reads.README.md: how to use, for people.CHANGELOG.md (opens in a new tab)README.md (opens in a new tab)references/commands.md (opens in a new tab)references/findings.md (opens in a new tab)references/report-pages.md (opens in a new tab)sma/__init__.py (opens in a new tab)sma/__main__.py (opens in a new tab)sma/ask.py (opens in a new tab)sma/cli.py (opens in a new tab)sma/compare.py (opens in a new tab)sma/dataset.py (opens in a new tab)sma/dax_format.py (opens in a new tab)sma/findings.py (opens in a new tab)sma/inputs.py (opens in a new tab)sma/readiness.py (opens in a new tab)sma/render/__init__.py (opens in a new tab)sma/render/app.py (opens in a new tab)sma/render/assets/dc-doc.js (opens in a new tab)sma/render/assets/dc-logo-white.svg (opens in a new tab)sma/render/assets/dc-theme.css (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
power-bi, semantic-model, tmdl, power-query, data-modeling, audit
npx claudepluginhub datacrafterslab/craftys-fabric-skills --plugin semantic-model-analyzerOther plugins' skills for the same job