fabric-data
Skill108 starsChanged 5 months agoMITView on GitHub
Manage Fabric semantic-model connections with fabric-app-data and query Fabric semantic models at runtime with @microsoft/fabric-app-data. Covers fabric.yaml, generated TypeScript config, CLI schema/query testing, and essential FabricClient/use-semantic-model-query result handling.
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 2 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Use this skill when you need to wire a Power BI semantic model, inspect schema, quick-test DAX, or handle query results in the app.
- Distinctive: line 17
If no alias exists, add one:
- Very specific: line 23
Use workspaceId: "me" for My Workspace.
- Very specific: line 35
If you only have the workspace + item (dataset) id of the model, wire it with fabric-app-data add <alias> -w <workspaceId> -i <itemId>.
- Very specific: line 39
All commands except init walk up from the current directory until they find fabric.yaml.
- Very specific: line 136
Always check
result.status: when using the SDK result directly.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Fabric Data — Connections and Runtime Queries
Use this skill when you need to wire a Power BI semantic model, inspect schema, quick-test DAX, or handle query results in the app.
Fast path
- Confirm the connection alias in
fabric.yaml. - If no alias exists, add one:
Usenpx fabric-app-data add <alias> --from-url "<Fabric portal URL>" # or, when you have IDs: npx fabric-app-data add <alias> -w <workspaceId> -i <itemId>workspaceId: "me"for My Workspace. The long flags are--workspaceand--item; do not use--workspace-idor--item-id. - Regenerate the config:
npx fabric-app-data generate -o src/fabric.generated.ts - Discover schema or test DAX with the same pipeline the app uses:
npx fabric-app-data query <alias> --query "EVALUATE INFO.VIEW.TABLES()" npx fabric-app-data query <alias> --file src/queries/hero.dax --limit 100 - In app code, use the template's query hook; do not hand-edit generated config.
If you only have the workspace + item (dataset) id of the model, wire it with fabric-app-data add <alias> -w <workspaceId> -i <itemId>.
CLI essentials
All commands except init walk up from the current directory until they find fabric.yaml; run init from the project root.
| Command | Use |
npx fabric-app-data init [-p <profile>] [--force] | Create fabric.yaml with an active profile. |
npx fabric-app-data add <alias> --from-url "<url>" | Add a semantic model from a Fabric portal URL. |
npx fabric-app-data add <alias> -w <workspaceId> -i <itemId> | Add by explicit IDs. Short flags: -w, -i; long flags: --workspace, --item. |
npx fabric-app-data remove <alias> [-p <profile>] | Remove a connection. |
npx fabric-app-data list [-p <profile>] | List connections. |
npx fabric-app-data use <profile> [-o <path>] | Switch active profile and regenerate config. |
npx fabric-app-data generate [-p <profile>] [-o src/fabric.generated.ts] | Generate TypeScript config. |
npx fabric-app-data query <alias> --query '<DAX>' | Execute DAX against a semantic model. Aliases: execute, exec. |
query options:
-q, --query <query>— inline DAX.-f, --file <path>—.daxfile.-l, --limit <rows>— max returned rows; default 1000, max 1000.-p, --profile <name>— profile; defaults toactiveProfile.
The CLI caps output at 1000 rows. Trimmed JSON includes _cliWarning; refine the DAX with filters or aggregation instead of trying to pull more rows for a visual.
Feeds the headless preview. A saved
queryresult (… --file q.dax > rows.json) can be piped straight intonpm run preview -- --spec s.json --data rows.jsonto render a chart against this live data, or the preview script can run the query itself (--query <alias> --dax-file q.dax). See theheadless-previewskill.
fabric.yaml
activeProfile: dev
profiles:
dev:
semanticModels:
sales:
workspaceId: "00c98f7c-..."
itemId: "03f2dc11-..."
myModel:
workspaceId: "me"
itemId: "c078a68d-..."
production:
semanticModels:
sales:
workspaceId: "aabbccdd-..."
itemId: "11223344-..."Supported URL segments include semanticmodels, modeling, lakehouses, and warehouses; semantic-model dashboard work usually needs semanticModels.
Generated contract
fabric.generated.ts is auto-generated from the active profile and exports a plain config object:
export const fabricConfig = {
semanticModels: {
sales: {
workspaceId: "00c98f7c-...",
itemId: "03f2dc11-...",
},
},
} as const;Edit fabric.yaml, then regenerate. Never hand-edit src/fabric.generated.ts.
Runtime querying
The template already wires FabricClient and exposes useSemanticModelQuery; query through that hook unless you are changing plumbing.
const result = useSemanticModelQuery({ connection, query });
const rows = toChartData(result.data, {
columns: { Category: "Product[Category]", Revenue: "Revenue" },
});Direct SDK shape, when needed:
import { FabricClient } from "@microsoft/fabric-app-data";
const client = new FabricClient({ proxy, ...fabricConfig });
const model = client.semanticModel("sales");
const result = await model.query("EVALUATE SUMMARIZECOLUMNS('Product'[Category], \"Revenue\", [Revenue])");
if (result.status === "success") {
// result.table.columns -> [{ name: "Product[Category]", dataType: "String" }, { name: "Revenue", dataType: "Double" }]
// result.table.rows -> [["Bikes", 12345], ["Accessories", 6789]]
} else {
console.error(result.error.category, result.error.message);
}Result rules agents must remember
- Always check
result.statuswhen using the SDK result directly; queries never throw. - Successful queries return one table:
table.columnsmetadata andtable.rowsasunknown[][]. - Rows are positional:
rows[i][j]matchescolumns[j]. Map deliberately before charting. - Error categories:
query(bad DAX),overflow(unsafe numeric value),api(HTTP/Fabric),network,unknown. - Date/DateTime values are strings like
"2024-01-15T10:30:00.000"with no timezone suffix. Treat them as timezone-unaware model values. - Integers outside
Number.MAX_SAFE_INTEGERreturncategory: "overflow"instead of losing precision.
Caching
Query results are cached in memory by default (LRU, 64 entries). Successes and DAX query errors are cached; transient api, network, and unknown errors are not.
await model.query(dax); // cached on repeat
await model.query(dax, { bypassCache: true }); // force fresh
model.clearCache(); // this model
client.clearCache(); // all modelsDisable or tune only when you are changing data plumbing:
new FabricClient({ proxy, ...fabricConfig, cache: { enabled: true, maxEntries: 64 } });Minimal types
type WorkspaceId = "me" | (string & {});
interface FabricItemRef { workspaceId: WorkspaceId; itemId: string }
interface QueryColumn { name: string; dataType: string }
interface QueryTable { columns: QueryColumn[]; rows: unknown[][] }
interface QueryError { category: "api" | "query" | "overflow" | "network" | "unknown"; message: string; code?: string; details?: string }
type QueryResult =
| { status: "success"; table: QueryTable; requestId: string }
| { status: "error"; error: QueryError; requestId: string };
type CachedQueryResult = QueryResult & { fromCache: boolean; cachedAt?: Date };In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- templates/angular-blankapp/AGENTS.mdAGENTS.md
- templates/angular-dashboard/AGENTS.mdAGENTS.md
- templates/campus-scheduler/AGENTS.mdAGENTS.md
- templates/fabric-atlas/AGENTS.mdAGENTS.md
- templates/field-technician/AGENTS.mdAGENTS.md
- templates/finance-analytics/AGENTS.mdAGENTS.md
- templates/ibcs-trainer/AGENTS.mdAGENTS.md
- templates/maritime-insights/AGENTS.mdAGENTS.md
- templates/paragliding-insights/AGENTS.mdAGENTS.md
- templates/slide-deck/AGENTS.mdAGENTS.md
- templates/static-blankapp/AGENTS.mdAGENTS.md
- templates/todo-local-experimental/AGENTS.mdAGENTS.md
- templates/universal-app/AGENTS.mdAGENTS.md
- template-gallerySkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- rayfinSkill
- analyticsSkill
- app-designSkill
- authenticationSkill
- build-workflowSkill
- capability-routerSkill
- data-modelingSkill
- daxSkill
- graphein-visualsSkill
- headless-previewSkill
- visualsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

