Skip to content

A plugin marketplace for GitHub Copilot and other AI agents that provides Power Platform development plugins, including reusable skills, agents, and commands for building and deploying solutions.

51.9 KB
Raw Blame

Authoring Flow — the App Spec playbook (run in the main loop)

This is the authoring playbook the /app-builder skill executes itself, in the main conversation — Phase 1 of skills/app-builder/SKILL.md. It is not a subagent: a Task subagent is headless, so AskUserQuestion and plan mode would never reach the user from inside one. Throughout this file, "you" means the orchestrator running in the main loop; run every prompt yourself so each question and the plan-mode gate surface to the user.

Your job: validate the environment, authenticate with PAC CLI, detect what already exists, build a complete App Spec through levelled interactive authoring, run the guardrail lint, get user approval in plan mode, and write app-spec.json + model-app-plan.md so the build engine can execute without re-asking or re-discovering.

Inputs you already have in the main loop:

  • The user's requirements ($ARGUMENTS)
  • The working directory (absolute path where artifacts should be written)
  • The plugin root directory (${PLUGIN_ROOT})

Workflow-log requirements (applies to every step below)

As you work through the steps, append a Phase 1 section to <working-dir>/workflow-log.md (create the file if it doesn't exist). The section MUST record commands and structured calls verbatim — not just their outcomes — because the eval harness greps the log for these tokens. Concretely:

  • Every shell command invocation is recorded on its own line as `node --version` / `pac help` / `pac auth list` / `node "${PLUGIN_ROOT}/scripts/list-tables.js" --env '<envUrl>' --search '<term>'` / `node "${PLUGIN_ROOT}/scripts/apps.js" list --env '<envUrl>'`. Include the literal flag values. Result goes on the next line.
  • Every AskUserQuestion call is recorded as AskUserQuestion: <question text> → <selected option>. The literal string AskUserQuestion is required.
  • The plan-presentation call is recorded as EnterPlanMode called followed by the user's response (approved / revised).
  • The PAC CLI version output is recorded explicitly (the assertion parses the recorded version and requires > 2.10.0, e.g. PAC CLI Version 2.11.0; an older pac fails).

Decisions and outcomes can be summarized at the end of the section, but they do not substitute for command-level entries. See an existing fixture (evals/model-apps/genpage/fixtures/1-account-card-gallery/workflow-log.md) for the expected format.

Step 1 — Validate Prerequisites

Run these checks (first invocation per session only). Run each command separately — do not chain with &&:

node --version
pac help

pac help output includes the version number. Verify the version is > 2.10.0 (the plugin's minimum; see the README prerequisites). If the version is older, instruct the user to update: dotnet tool update --global Microsoft.PowerApps.CLI.Tool.

If either command fails, inform the user and provide installation instructions. Do NOT proceed until prerequisites are met.

Step 2 — Authenticate and Select Environment

Check PAC CLI authentication:

pac auth list

If no profiles: Ask user to authenticate:

pac auth create --environment https://your-env.crm.dynamics.com

Wait for user to complete browser sign-in, then re-verify.

If one profile: Confirm it's active (has * marker). If not, activate it:

pac auth select --index 1

If multiple profiles: Show the list, ask which environment to use via AskUserQuestion, then:

pac auth select --index <user-chosen-index>

After the active profile is confirmed, capture the environment URL:

pac org who

Extract the Org URL: line (strip any trailing slash). Store this as $ENV_URL for use in solution-listing and any downstream build calls. It is also the --env of the table and app reads below (<envUrl>): the https origin only — no path, no trailing slash.

Report: "Working with environment: [name] ([url])" and proceed.

Step 3 — Detect What Exists

Entity Detection

Use scripts/list-tables.js to check which entities the user has mentioned or that are implied by their requirements. Pass requested entity logical names via --search (comma-separated) with --exact:

node "${PLUGIN_ROOT}/scripts/list-tables.js" --env '<envUrl>' --search 'entity1,entity2' --exact

It prints one JSON line: { "ok": true, "search": [...], "exact": true, "count": N, "tables": [{ "logicalName", "displayName", "schemaName", "isCustom" }], "missing": [...] }.

Important: without --exact, --search matches substrings across logical name, schema name, and display name — so --search 'account' also returns accountleads, accountlevelmonitoring, etc. --exact keeps only the tables whose logical name is a search term (any letter case) and names the terms that have none in missing:

  • For each requested entity, look for a table whose logicalName equals it.
  • If found → mark as "exists" (build around it).
  • If it is in missing → mark as "needs creation".

If the script fails (exit 1, { "ok": false, "error", "code" }), entity detection did not happen. Report why (most often the Azure CLI is missing, signed out or signed in to another tenant) and stop: a failed read is never "no entities exist", and nothing is created on it.

Dominant-prefix detection (for solution UX)

Also run a broader scan to detect the env's working prefix. This lets the solution question steer the user to a consistent choice:

node "${PLUGIN_ROOT}/scripts/list-tables.js" --env '<envUrl>' --type custom

--type custom keeps the custom tables only (isCustom: true; a table a managed solution brought counts as custom). Extract each logicalName's prefix (everything before the first _). Count prefixes excluding system ones (msdyn, msdynce, msdynmkt, adx, msa, mscrm, appsource, msft).

  • If one non-system prefix accounts for ≥50% of custom tables AND there are at least 3 such tables, record this as the detected prefix (e.g. crb2b). Use it as the default solution suggestion below.
  • Otherwise, there's no clear dominant prefix — fall back to new as the safe suggestion.

Store: detectedPrefix, detectedTableCount for use in solution selection.

App Detection

Run:

node "${PLUGIN_ROOT}/scripts/apps.js" list --env '<envUrl>'

It prints { "ok": true, "count": N, "apps": [{ "id", "name", "uniqueName", "description", "published", "unpublishedChanges" }] }, drafts included. Offer each app by its name and id. name and description come from the app's saved layer (what a maker sees in the designer): an app whose rename is saved but not yet published (unpublishedChanges: true) is listed by its new name, which its users see only after a publish. published (users can open the app) and unpublishedChanges (a saved edit is waiting for a publish) are two separate facts about it — an app can be both published and have changes — so say which applies when it matters. If the script fails (exit 1), report why and stop; a failed read is never "no apps".

  • 0 apps: Ask user via AskUserQuestion: "No model-driven apps found. Would you like to create a new one, or cancel?"
  • 1 app: Confirm with user: "Found app [name] ([app-id]). Use this one?"
  • N apps: Ask user to select one or create a new one via AskUserQuestion.

Solution Selection

The spec's solution block always contains both uniqueName and publisherPrefix — never omit them. The default fallback is uniqueName: Default + publisherPrefix: new, which works in every env.

The user-facing question about which solution to use is conditional:

  • Ask the question when there is metadata work to do — any entity needs creating, OR a new app will be created in this run.
  • Skip the question for reuse-only flows (existing entities + existing app). Write uniqueName: Default and publisherPrefix: new into the spec directly.

1. List custom solutions

Query the env for non-managed solutions:

node "${PLUGIN_ROOT}/scripts/dataverse-request.js" "$ENV_URL" GET \
  "solutions?\$select=uniquename,friendlyname&\$expand=publisherid(\$select=customizationprefix)&\$filter=ismanaged eq false and uniquename ne 'Default' and uniquename ne 'Active' and isvisible eq true&\$top=10"

Parse the JSON; capture each uniquename, friendlyname, and publisherid.customizationprefix.

2. Ask the user

Use AskUserQuestion. Order options so the matching-prefix choice is first (recommended) and the conflict choices are visibly flagged.

Recommended-first ordering rule:

  1. If there's a detectedPrefix AND at least one existing custom solution uses that prefix → put that solution first, labelled "matches your existing custom tables".
  2. If there's a detectedPrefix but no existing solution uses it → put "Create new solution under publisher <detectedPrefix>" first.
  3. Then any other existing custom solutions.
  4. Then "Create a new solution under Default Publisher (prefix: new)".
  5. Then "Use Default Solution (prefix: new)" — annotate with ⚠ if detectedPrefix exists and is not new.

Example with detectedPrefix = crb2b:

"Your env has 12 existing custom tables using prefix crb2b. Where should the new tables / app go?

  • Continue in 'Crdec34' (prefix: crb2b) — matches existing work [RECOMMENDED]
  • Create new 'model-app-' solution under crb2b publisher
  • Use existing 'LandscapeBusiness' (prefix: lndscp)
  • Use Default Solution (prefix: new) ⚠ different prefix from existing work"

Example when no detectedPrefix:

"Which solution should the new tables / app go in?

  • Create new 'model-app-' solution (prefix: new) [RECOMMENDED]
  • Use Default Solution (prefix: new)"

3. Act on the answer

Just record uniqueName + publisherPrefix in the spec's solution block — do not create the solution (or the publisher) here. The build creates it idempotently via the SDK (createSolution) on apply, resolving/creating the publisher and reusing an existing solution of the same name. Specifics:

  • Existing solution → use it directly; capture its prefix from the query above.
  • Create new under publisher <prefix> → record uniqueName + publisherPrefix; the build resolves the publisher (or creates <prefix>publisher) and the solution.
  • Default Solution → uniqueName: Default, publisherPrefix: new.

If the chosen prefix differs from detectedPrefix, log a one-line warning to the user before continuing:

"Heads up — env has <detectedPrefix>_* tables but you chose <chosenPrefix>. New tables won't match the prefix of your existing work."

Step 4 — Multi-Turn, Levelled Interactive Authoring

This is the core of model-app-planner — the step that distinguishes it from genpage-planner. Rather than drafting the entire App Spec in one shot, you author it one topic at a time through conversational turns, persisting the working spec to <working-dir>/app-spec.json after each round so the user can hand-edit between turns.

Do not present the entire spec at once. Level (a0) must be agreed before Level (a), and Level (a) before Level (b).

Phase 1 is a design-only author: page .tsx is never written here — pages are declared as intents (source: { kind: "intent" }) and their code is generated in Phase 1.5 — Generate pages (see SKILL.md → Phase 1.5) after plan approval and after the data pre-build. The levels are: (a0) personas & jobs-to-be-done, (a) data model, (b) artifacts + page-intents + design, and (c) access. The author never emits .tsx; pages remain intents until generate-pages.

Read the spec format once, up front — don't reverse-engineer it from scripts: references/app-spec-schema.md (every always-present field; conditional ones are in app-spec-schema-advanced.md) and the worked sample samples/app-spec.support-desk.json. Author to that shape. Do not pre-create tables/columns/solution during authoring — the build is idempotent and creates only what's missing.

Level (a0) — Personas & jobs-to-be-done

Do this FIRST, before proposing any tables. Ask who will use the app and what each of them needs to get done. Jobs-to-be-done are what the app EXISTS to do, so they drive everything that follows: a table exists because some job needs its data, a view or form exists because some job needs to work with those records, and a page exists because some job needs an overview, an analysis, or a guided flow. Deriving the data model first and the jobs afterwards gets this backwards and reliably misses surfaces.

Propose personas and their jobs, then confirm with AskUserQuestion:

"Before I design the data model — who will use this app, and what does each of them need to get done? Here's my read: Dispatcher (assign incoming work, watch today's queue), Field Technician (see my jobs, record what I did, log parts). Does that cover it, or is there a role or a task I've missed?"

Write them into personas[] as you go — the same block Level (c) later sizes security roles from, so you ask once and use the answer twice:

"personas": [
  { "persona": "Dispatcher",
    "jobs": [
      { "name": "Assign incoming work", "description": "Triage new work orders and route them to a technician" },
      { "name": "Watch today's queue",  "description": "See at a glance what is overdue, unassigned, or at risk" }
    ],
    "excludes": ["Approving budgets — handled in the Finance app"] }
]

privileges[] is not filled in yet — entities don't exist until Level (a). Level (c) adds it.

Capture what the app deliberately leaves out, too, in excludes[]. When the user rules something out — "dispatchers don't approve anything", "we won't touch invoicing here" — that is a scope decision, and it renders into the design document as Deliberately out of scope beside the traceability table. Two apps built over the same tables are told apart by what each declines to do, and an omission the reviewer was never shown cannot be approved. It is documentary only; nothing is applied to Dataverse.

Carry the jobs forward. At Level (b), every job must be answerable with "this surface lets them do it". Record that link in jobs[].surfaces[] (view/form/page names, or a page key):

{ "name": "Watch today's queue", "surfaces": ["Today's Queue"] }

That mapping is what the design document renders as a traceability table, and an unmapped job is flagged by the lint gate — so a job with no surface is a visible design gap rather than a silent one.

Offer each optional capability that applies — once, as a question, never as a default. Ask even when the maker has not mentioned it (they may not know it exists), and skip an offer only for a capability the maker already asked for: an explicit request counts as acceptance. Each one stays off unless the maker says yes or asks for it; a "no" or silence adds nothing to the spec:

  • Branding — for every new app, ask whether it should be branded (brand colours, a header colour, a logo). If yes, add app.theme — Preview, published with the app, and an app publication publishes every pending change of the app.
  • Outside services and per-environment values — when the app calls an outside service or a value differs per environment (a base URL, a key, a connector, an action a page calls), offer configuration items: environment variables and connection references; the values stay out of the spec.
  • Duplicate records — when the jobs identify duplicate records (the same customer or contact entered twice, one record per email address), offer a duplicate-detection rule on that table, even when the app uses no outside service.
  • A reusable server-side operation — when the app needs an operation that several surfaces, flows or pages call, or that must run on the server (a calculation, a multi-step change), offer a Custom API, even when nothing outside Dataverse is involved.
  • Rules and processes — when the jobs include a validation or a guided process (a required field once a record closes, stages a record moves through), offer a declared business rule or business process flow: the build manages the whole rule or flow, creates it or adopts one that exists, and never edits one in place; binding an existing one needs an --authorize adopt: approval.

Level (a) — Data model

Propose the entities block (including columns and primaryAttribute) and the relationships block — derived from the Level (a0) jobs: each table should exist because a job needs its data, and each job's data needs should be satisfiable. Present your proposal clearly, then use AskUserQuestion to confirm or refine:

"Here's the data model I'd suggest for your [app name]. Does this look right, or would you like to adjust any tables, columns, or relationships before we move on to forms and views?"

Column type is one of: Text · Memo · Choice · MultiChoice · Boolean · Money · DateTime · Integer · BigInt · Decimal · Double · File · Image · AutoNumber · Customer. A Choice/MultiChoice column needs options[] or a globalChoice reference, and an AutoNumber column needs an autoNumberFormat such as "C-{SEQNUM:5}" (Text is the plain text column). Lookups are not a column type — declare a OneToMany relationship instead.

Author from references/app-spec-schema.md — it is the source for everything an app always has; app-spec-schema-advanced.md carries the conditional fields it points at (business rules, BPFs, commands, web resources, global choices, dashboards, roleGrants[]). Its modeling cheatsheet answers the recurring questions without reading the SDK/lint/engine: auto-number identity → autoNumberFormat on primaryAttribute; N:N with attributes (e.g. Technician↔Work-Order with a Role) → a junction entity + two OneToMany (sample rows bind both via $parents); "my/this-week/not-Completed" views → view filters[]; records pre-set to a custom status → statusReason on sample rows. The builder does all of this in one pass — never hand-author post-build association/status/FetchXML scripts.

When the user has entities that already exist (detected in Step 3), propose columns that complement rather than duplicate what's already there. Build around existing tables.

Table icons (assign one per custom table — default)

By default, give every custom table you create a meaningful table icon so the app nav shows a recognizable glyph instead of the generic Dataverse table cube. This is the default authoring behavior — only skip it if the user declines. (A model-driven app's nav icon for an entity subarea normally comes from the table's own icon, so leaving the subarea's icon unset is the right default. A subarea vectorIcon is honoured on an entity subarea when it is a resolvable path or $webresource: reference; only a bare Fluent token is dropped there, because that shape breaks the modern app designer's property pane.)

Propose the icon in words FIRST, before you author any SVG. For each custom table, say what the glyph will depict — "a briefcase", "an outlined clipboard with a checkmark", "a laptop with a clock overlay" — and record it on the entity as iconDescription. Present the list and confirm it with AskUserQuestion alongside the data model.

Never propose a Fluent icon token name (Briefcase, ClipboardTask, DocumentBulletList24Regular). The SVG is drawn fresh in this phase — there is no icon library being picked from — and a token name the user has never seen tells them nothing about what the glyph will look like. Validation rejects a token-shaped iconDescription for exactly this reason.

The same rule applies to any sitemap area or group icon you propose: describe the depiction, not a token. (Entity subareas take the table's icon, so describe it on the table.)

Only once the depictions are agreed, author the icons into the App Spec (so the app stays self-contained on export/import):

  1. Add an SVG web resource to webResources[] ("type": "svg") carrying the icon markup, named <publisherPrefix>_<tablelogical>_icon (e.g. new_project_icon).
  2. Point the table at it with entities[].vectorIcon: "<that web resource name>" (→ Dataverse IconVectorName). The build creates the web resource, publishes it, then sets the table icon.

Draw the glyph you described — a briefcase for Projects, a clipboard/checklist for Work Items, a person for Team Members, a calendar for Sprints, a document for Contracts — and emit clean, original, single-color SVG; do not paste a third-party icon file. Author it like a Fluent V9 glyph:

  • viewBox="0 0 24 24" (or 0 0 32 32), no fixed width/height.
  • One or two <path> elements, fill="currentColor" (Dataverse tints it) — simple, legible at 16px.
  • Keep it geometric and minimal; avoid gradients, embedded rasters, or <script>.
"webResources": [
  { "name": "new_project_icon", "type": "svg",
    "content": "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='currentColor' d='M9 4h6a2 2 0 0 1 2 2v1h3a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h3V6a2 2 0 0 1 2-2Zm0 3h6V6H9v1Z'/></svg>" }
],
"entities": [
  { "schemaName": "new_project", "displayName": "Project", "vectorIcon": "new_project_icon",
    "iconDescription": "a briefcase with a handle and a centre seam",
    "primaryAttribute": { "schemaName": "new_name", "displayName": "Name" }, "columns": [ ... ] }
]

Standard/reused tables (Account, Contact, systemuser, …) already ship an icon — leave them alone. See references/app-spec-schema.md → entities[].vectorIcon and webResources[].

Persist the agreed data model to <working-dir>/app-spec.json, then run an early data-model lint on it before proceeding to Level (b) — this catches structural data-model errors (e.g. the relationship-name-vs-lookup-name collision Dataverse rejects) before the user authors forms/views on top of a broken model, the most expensive point to unwind:

node "${PLUGIN_ROOT}/scripts/lint-app-spec.js" --spec @<abs-path-to-app-spec.json> --json

On a data-model-only spec the linter surfaces only data-model findings (the forms/views/app checks are no-ops until those sections exist), so treat any errors[] here as a hard gate: fix the data model and re-run before moving to Level (b). Warnings teach — surface and proceed. (The full lint at Step 5 re-checks the complete spec once artifacts are added.)

Level (b) — Artifacts, page-intents, and design

Once the data model is confirmed, propose all of the following together in a single turn (they are closely related — the user should see charts and sample data alongside the forms they reference). This level is design-only: do not author page .tsx here — propose page intents and defer code generation to Phase 1.5.

Offer declared layouts, once, as a question — never as a default. Whenever you propose forms or dashboards, ask whether the maker wants the layout of any of them to stay as the spec says on every rebuild; if yes, write reconcile: "declared" on that one form or Global Standard dashboard. The parts the spec does not declare stay the maker's, and binding one that already exists needs an --authorize adopt: approval. Without a yes and without an explicit request, write nothing declared; forms stay layout: "auto". A maker who already asked for a fixed layout is not asked again: their request is the yes.

Forms

Propose one main form per entity. Default "layout": "auto". For any entity that is on the referenced (parent) side of a OneToMany relationship, declare a subgrids entry that shows the child records inline:

{
  "entity": "new_customer",
  "type": "main",
  "name": "Customer",
  "layout": "auto",
  "subgrids": [
    { "childEntity": "new_ticket", "view": "Active Tickets", "label": "Related Tickets" }
  ]
}

Each sub-grid renders in its own 1-column, full-width section (it spans the form). The label is optional — omit it to title the grid with the child entity's pluralName (then displayName); supply it to override. To ship only your form and hide the blank stock "Information" form, set "deactivateOtherMainForms": true on the form (opt-in; only affects tables this build owns).

By default a grid's section goes at the end of the form. To put it elsewhere — a full-width related-records grid between two sections, say — declare the form's layout (tabs[].name / sections[].name) and name where the grid goes: "after": "<section>" or "before": "<section>", or "tab": "<tab>" (with "column": <n> for a form-column of that tab). A grid is as wide as the form-column it is in, so for a full-width grid use a tab of one form-column. The wireframe draws a placed grid where it will land; see app-spec-schema.md (Where a sub-grid goes).

Choosing auto vs an explicit layout. auto is the right default and already adapts: it puts the primary field first and switches to two columns above six fields (Quick Create stays one column, which Dataverse requires). What it cannot do is group by task.

So prefer an explicit layout — tabs and sections named for the work — once a Main form is field-heavy or the fields fall into obviously different jobs (execution vs estimates vs approval). Group by what the user is doing, put the record's name and its most decision-relevant status or lookup first, and use colspan for a field that reads badly in a narrow cell (a long description, a full-width summary). This is a default, not a rule: a short form, a Quick Create, or a single coherent group is genuinely better as one column, and auto remains a correct answer.

⚠ When EDITING a deployed form, an explicit layout also switches pruning on — a field the form carries that your tabs do not list is removed. Either re-declare the full field set, or set "prune": false to restructure a subset safely. Tabs and sections themselves now converge (they are created, patched and have fields moved into them), so the layout you show in the wireframe is the layout that lands.

Show the form wireframe. After writing the proposed forms to app-spec.json, render an ASCII wireframe so the user can see each form's tabs, sections, fields, the Notes block, and sub-grids before approving — then ask for changes. Fields carry their authored state, so a (hidden) or (read-only) annotation in the wireframe is part of what is being approved:

node "${PLUGIN_ROOT}/scripts/preview-form.js" --spec @<working-dir>/app-spec.json [--entity <schemaName>]

Include the wireframe in the same turn as the forms/views/charts proposal (it's the visual companion to the JSON) — reproduce the full rendered output verbatim in your chat reply, inside a fenced code block, because tool/shell output is collapsed and invisible to the user by default. Iterate on the spec and re-render until the user is happy with the layout.

Form JS (optional — client-side logic)

When the user wants validation or dynamic behaviour (e.g. "warn when priority is High", "default the due date"), propose a webResources[] script and wire it onto the form with events[]. Keep the JS small and real (no placeholders); name the script with the solution prefix and a .js extension:

"webResources": [
  { "name": "new_ticket.js", "displayName": "Ticket Scripts", "type": "js",
    "content": "var Ticket={onLoad:function(ctx){},onPriority:function(ctx){}};" }
],
"forms": [
  { "entity": "new_ticket", "type": "main", "name": "Ticket", "layout": "auto",
    "events": [
      { "event": "onload", "library": "new_ticket.js", "function": "Ticket.onLoad" },
      { "event": "onchange", "attribute": "new_priority", "library": "new_ticket.js", "function": "Ticket.onPriority" }
    ] }
]

event is onload/onsave/onchange (onchange needs an attribute); library must reference a declared webResources[] name (lint-enforced). Only propose form JS when the user asks for behaviour the data model can't express — don't add it by default.

Views

Propose one active-records view per entity. Include the primary attribute plus the 2–4 most useful columns for quick scanning. Set "activeOnly": true and provide a sensible sort.

Then add a task-oriented view wherever a persona's job implies a question the default view cannot answer — My Active Work Items, Blocked Work Items, High-Severity Open Risks. Name it for the decision it supports, and sort by the field the user actually prioritizes by. Direct-column filters on the view's own table are supported, including current-user (ownerid / eq-userid) and relative dates; a filter through a related table is not expressible and must not be faked — say so and propose a supported alternative.

A filter on a Choice column may name the option by its label, in any language it has. The build resolves the label against the options the environment holds for that column, and stops — before it writes anything where the environment already shows the label is wrong, and in any case before any view is written — when a label matches no option (the error lists the valid ones), so spell it exactly as the column does, or use the option's integer value. (Where your spec numbers the options — inline options[], or a global choice you declare — an option a maker renamed in the environment still resolves to the number your spec gave it, with a warning, unless the environment shows the options are numbered otherwise, as when you added options after the column was built; then it stops.) A spec with a localized label is checked only in the views phase, after the tables and columns are written, because reading option labels ahead of creating a multi-language label can cost it every language but the base one. This covers a column of a table you reuse (account.industrycode) without declaring it.

Two edit-time limits worth stating up front, because both bite silently: an authored view whose name collides with the table's stock default view MERGES onto that default (its filters and sort are ignored), and an existing view's filters/sort are not reapplied on a rebuild — only its columns and description converge. Prefer a distinct name for anything you want filtered your way.

Charts

Auto-suggest one chart per Choice column on the primary entity, alternating Pie / Column chart types:

  • First Choice column → "chartType": "Pie"
  • Second Choice column → "chartType": "Column"
  • Third → "Pie", and so on.

Always set "measure": "count".

Entities with no Choice columns get no chart suggestion (but the user may add one).

A chart's groupBy MUST be a Choice column. The build validator (validateAppSpec) rejects a chart that groups by a non-Choice column — the lint gate only warns, so this would otherwise surface as a confusing build failure after approval. Never propose (or accept) a chart over a Text/DateTime/Number column; steer the user to a Choice column instead.

Sample data

Suggest a sampleData block right alongside the forms/views/charts. Populate it with realistic, domain-appropriate records — not "Test Record 1". Include:

  • 3–5 parent records per top-level entity.
  • 2–4 child records per parent, using $parent to express the relationship:
    {
      "new_name": "Cannot log in to portal",
      "new_priority": "High",
      "$parent": { "entity": "new_customer", "match": { "new_name": "Northwind Traders" } }
    }
    
  • Choice values must be label strings (matching the options[] you defined), not integer codes.

Pages (generative page intents — design only)

Enumerate every surface this app needs before you author any of them. Walk the Level (a0) jobs one at a time and name the surface that satisfies each. Then classify each surface with the genpage-first policy (SKILL.md → Genpage-first policy):

  • create/read/update/list a table's rows → a model-driven form + view
  • anything else → a generative page in pages[]

"Anything else" is broader than it first looks, and these are the surfaces that get missed:

If a job needs… Author
an at-a-glance overview, home or landing surface a page
a dashboard, KPIs, or a "what needs attention" queue a page (not a classic dashboard)
analytics, trends, or a chart-led summary a page
a guided multi-step or wizard flow a page
a composite screen spanning several tables a page
side-by-side comparison, or a review/approval console a page

State the classification out loud for each surface in the same turn you propose forms and views — e.g. "Watch today's queue → overview surface → generative page todays-queue". If you conclude the app needs no pages at all, say so and why, so the user can disagree; don't just omit the section. Record the mapping back on the job (jobs[].surfaces[]) — the lint gate warns about any job with no surface, and about a spec with no pages.

Author the intent shape — not .tsx:

{
  "key": "overview",
  "name": "Overview",
  "purpose": "At-a-glance dashboard of open work",
  "dataSources": ["contoso_workorder"],
  "navigatesTo": [{ "targetKey": "wo-detail", "data": { "workOrderId": "string" } }],
  "pageInput": { "data": { "workOrderId": "string" } },
  "source": { "kind": "intent" }
}
  • key is the single stable identity: used by navigatesTo.targetKey, cross-page PAGEREF_<key> placeholders, and appShell page subareas. Reference each page from appShell by key. Never use recordId for nav; custom ids go in data: (read as pageInput?.data?.<field>).
  • The optional design contract (accent/density/cornerRadius/darkMode/layout) threads to every page for a consistent look — propose one when the user cares about visual style.
  • Do not write codeFile here. The .tsx is generated in Phase 1.5 — Generate pages (after plan approval + data pre-build). Pages remain source: { kind: "intent" } until then.
  • See references/app-spec-schema.md → pages[] and design.

App shell

Also propose the appShell block — the sitemap areas, groups, and subAreas that wire each entity into the app's navigation.

Group by the workflow a user is in, not by "one group per table". A handful of named groups that read like the jobs from Level (a) — e.g. Delivery (Projects, Work Items, Sprints), Tracking (Risks, Issues), Customers (Accounts, Contacts) — is what separates a polished app from a flat list, and the builder already emits groups and subAreas in the order you author them. For a small app (roughly four tables or fewer) one group is genuinely the right answer; above that, say which workflow each group serves.

Leave a table out of the nav when users never start a task there — a junction or configuration table reached only through a parent form or a sub-grid. A table with no subarea still works everywhere it is referenced (verification deliberately allows supporting tables without navigation).

Shippable-defaults note

Mention, but do not author or build: quick-create forms and standard system views (All Records, Lookup, etc.) are sensible future additions but are out of scope for this authoring phase.

Declared web resources (maker's choice)

By default a rebuild reuses an existing web resource as it is. Offer reconcile: "declared" only when the maker wants a rebuild to keep one web resource's content in step with the spec: declare one resource at a time, at the maker's request, never an external one, and never every resource of a downloaded or older spec. A declared web resource sets minimumPluginVersion to "2.21.0" or newer (validation warns otherwise). When a rebuild would change one that already exists, the build stops before writing and names --authorize adopt:webresource:<web resource name> with the components that depend on it: show them and get a yes. Declared form layouts, Global Standard dashboards, business rules and business process flows are opt-in the same way (minimumPluginVersion: "2.21.0"): write reconcile: "declared" on one only when the maker asks for it — a form's layout or a dashboard's tiles to follow the spec on every rebuild, or a rule or flow the build manages whole (created and adopted, never edited in place). The app-builder skill's bullets for each kind say what to tell the maker and which approval binds one that already exists. Without reconcile, the build keeps its existing behaviour for each.

Confirm Level (b)

Only now — with forms, views, charts, sample data, pages and the app shell all proposed — present Level (b) as a whole and use AskUserQuestion to let the user edit or remove any section:

"Here are the proposed surfaces for your app — pages, forms, views, charts — plus sample data and the navigation. Each of your jobs-to-be-done maps to at least one of them. Feel free to edit any section — or tell me what to change — before I lock the spec."

Security roles ARE in scope — they are authored in Level (c) below from the personas and jobs you captured in Level (a0).

Persist the fully agreed spec to <working-dir>/app-spec.json before Level (c).

Level (c) — Access (size the roles from the jobs)

You already captured personas and their jobs in Level (a0), and the entities now exist, so this level only adds the privileges each job needs. Do not re-ask who the users are.

For every job, DECLARE the entity access it requires — the builder never infers privileges from a job's text:

{ "name": "Assign incoming work",
  "surfaces": ["Today's Queue", "Work Order"],
  "privileges": [
    { "entity": "contoso_workorder", "access": ["read", "write", "assign"], "scope": "businessUnit" },
    { "entity": "contoso_technician", "access": ["read"], "scope": "organization" }
  ] }
  • access: read · create · write · delete · append · appendTo · assign · share
  • scope: user (Basic) · businessUnit (Local) · parentChild (Deep) · organization (Global)

The builder authors one role per persona, unioning every job's declared access (max scope wins per entity+access), and grants the app to that role so it opens for that persona, not just for system administrators (appAccess: false opts a role out).

Extending an app that already has roles (a downloaded spec): leave personas[] out. The roles associated with an existing app are not changed by a spec that authors none, and a persona's role is converged to exactly the privileges declared (so naming an existing role there is the opposite of leaving it alone). Give an existing role access to a new table with a roleGrants[] entry instead — it adds privileges and removes none (see app-spec-schema-advanced.md → roleGrants[]). The lint's "no access declared" warning names each new table that no persona job and no grant covers.

Render the proposed roles and their per-entity access as a table in your chat reply, then confirm with AskUserQuestion — the user cannot approve an access model they cannot see, and tool output is collapsed and invisible to them.

If the user wants no security roles, say plainly that jobs-to-be-done currently live inside personas[], so dropping the roles also drops the recorded jobs and the jobs→surfaces traceability in model-app-plan.md — the design rationale goes with them. Offer to keep the personas with minimal read-only privileges instead, which preserves the record. Only remove personas[] if they still want it gone; a job cannot be kept without privileges[] (validation requires it).

Column-level security is isSecured + fieldSecurityProfiles[] (2.21.0; see app-spec-schema-advanced.md) — name who is assigned each profile. Access teams are not yet supported.

Persist the fully agreed spec to <working-dir>/app-spec.json before Step 5.

Step 5 — Guardrail Lint (Hard Gate Before Plan Mode)

Before entering plan mode, run the full lint on the complete agreed spec (this re-checks the whole spec — the data model was already gated by the early lint at the end of Level (a), so here you are validating the artifacts/sample-data/app layered on top):

node "${PLUGIN_ROOT}/scripts/lint-app-spec.js" --spec @<abs-path-to-app-spec.json> --json

Replace <abs-path-to-app-spec.json> with the actual absolute path to <working-dir>/app-spec.json. Pass an absolute path so it resolves regardless of cwd. The CLI runs migration and validateAppSpec — the gates the build itself runs on load — plus the lintAppSpec authoring guardrails, which the builder does not run. It exits non-zero on errors. It validates under the plan profile, which allows pages that are still intents (they are generated in Phase 1.5, after this gate); plan relaxes only that rule. Errors are tagged schema: (the hard gate) or lint: (authoring guardrails); fix the schema: ones first, because lint advice on a spec that fails the gate is advice on a spec that cannot build.

Interpret the result:

  • ok: true, no errors → proceed to Step 6.
  • Warnings (warnings[] non-empty, ok: true) → surface each warning to the user with a short explanation of what it means and why it's a consideration (e.g., "A Choice column with more than 12 options may be better modelled as a lookup table"). Allow the user to acknowledge and proceed, or loop back to Step 4 to fix.
  • Errors (errors[] non-empty, ok: false) → do NOT proceed to Step 6. Surface each error clearly, explain the root cause (e.g., "The relationship schema name collides with the lookup attribute name — Dataverse rejects this combination"), and loop back to Step 4 to fix the spec. Re-run the lint after each fix cycle until ok: true.

Common errors the lint catches (teach these to the user if they arise):

  • Duplicate entity schemaName — two entities with the same schemaName.
  • Missing primaryAttribute — every entity needs a primaryAttribute with both schemaName and displayName.
  • Choice column missing options[] — a type: "Choice" column must have a non-empty options array.
  • Relationship-name collision — the relationship's auto-derived schema name equals the lookup attribute's schemaName; use a distinct name for the relationship.
  • Subgrid with no matching relationship — a form subgrid references a child entity that has no OneToMany relationship pointing to the form's entity.
  • Chart on unknown entity or column — the chart's entity or groupBy doesn't match what's in the spec.

Step 6 — Plan-Mode Approval

Create tasks via TaskCreate:

  1. "Capture personas and jobs-to-be-done"
  2. "Build data model (entities, columns, relationships)"
  3. "Author surfaces and sample data (pages, forms, views, charts)"
  4. "Size access from the jobs (personas[].privileges)"
  5. "Write app-spec.json and render model-app-plan.md"

Enter plan mode (EnterPlanMode) and present a rendered summary. Resolve and display full prefixed names for the user (e.g., crb2b_customer.crb2b_segment) even though the underlying spec stores the schemaName as provided:

## Build Plan

### App
- Name: [app name]
- Description: [description]
- Routing description: [app.aiDescription — omit the line when the spec does not set one]
- Action: [Create new | Use existing: <app-id>]

### Solution
- [solution uniqueName] — Publisher prefix: [prefix]

### Jobs to be done
| Persona | Job | Surfaces that satisfy it |
|---------|-----|--------------------------|
| [persona] | [job name] | [view/form/page names] |

### Data Model
#### Tables
| Table | Status | Columns | Nav icon depicts |
|-------|--------|---------|------------------|
| [schemaName] | Create / Reuse | [col1 (Type), col2 (Type), ...] | [what the glyph shows, e.g. "a briefcase"] |

#### Relationships
| Type | Parent | Child | Lookup Column |
|------|--------|-------|---------------|
| OneToMany | [referenced] | [referencing] | [lookup.schemaName] |

### Surfaces
- Pages (generative): [N — list keys, or "none — record-CRUD only because <reason>"]
- Forms: [N forms — list entity names]
- Views: [N views — list entity names]
- Charts: [N charts — list names and chart types]
- App shell: [N areas / N subAreas]

### Access
| Role (persona) | Tables and access |
|----------------|-------------------|
| [persona] | [entity: read/write @ scope, ...] |

### Sample Data
- [entity]: [N records]
- [child entity]: [N records] (linked via $parent)

### Lint
- [✓ No errors | ⚠ N warning(s) acknowledged: <list>]

### Notes
- Quick-create forms and standard system views are out of scope for this phase
  and can be added later.

This is the in-chat approval summary, not the model-app-plan.md file — that document is rendered separately by scripts/write-app-spec-doc.js in Step 7.

Include the engine's real build plan (this is the SINGLE build approval). Before ExitPlanMode, run the build dry-run (no --apply) and show its phase-grouped plan beneath the summary above:

node "${PLUGIN_ROOT}/scripts/build-model-app.js" --env <envUrl> --spec @<working-dir>/app-spec.json

This reflects the idempotent detect-existing logic (what will be created vs skipped), so the user approves the plan the engine will actually run — not a hand-rendered approximation. On ExitPlanMode approval, Phase 2 applies directly — do not take a second dry-run + go-ahead in Phase 2 (that redundant double-gate is removed; plan mode is the one build approval).

Then call ExitPlanMode to request user approval.

  • If approved: proceed to Step 6.5.
  • If changes requested: revise the relevant section (loop back to Step 4 if the spec needs editing, re-run lint, then re-enter plan mode).

Mark the "Build data model" and "Author artifacts and sample data" tasks complete after approval.

Step 6.5 — Generate pages (after approval — main loop)

Plan-mode approval is the single build approval. After the user approves, proceed to Phase 1.5 — Generate pages as documented in SKILL.md → Phase 1.5:

  1. Data pre-build — build-model-app.js --stage data --apply (solution + data-model only; no rows — sample data is created in the full build). Only --stage data is apply-safe; do not apply any other stage in isolation.
  2. Type generation — genpage.js types → RuntimeTypes.ts.
  3. Page generation — headless page-builder worker (via Task) fills each intent page's .tsx; all-or-nothing transition source: intent → { kind: "tsx", codeFile }.

After generate-pages, proceed to Step 7 and then Phase 2 (the full idempotent build). You are still in the main loop — all user-facing narration happens here.

Step 7 — Write Artifacts and Return

Write app-spec.json

After Step 6.5 (generate-pages), <working-dir>/app-spec.json has source: { kind: "tsx", codeFile } for every page. Confirm the file is current — this is the machine contract consumed by the downstream build step — do not abbreviate or omit any section.

The spec shape follows plugins/model-apps/samples/app-spec.support-desk.json:

{
  "schemaVersion": 2,
  "solution": { "uniqueName": "...", "displayName": "...", "publisherPrefix": "..." },
  "app": { "name": "...", "description": "...", "aiDescription?": "..." },
  "entities": [ { "schemaName", "displayName", "pluralName", "primaryAttribute", "columns" } ],
  "relationships": [ { "type", "referenced", "referencing", "lookup" } ],
  "forms": [ { "entity", "type", "name", "layout", "subgrids?" } ],
  "views": [ { "entity", "name", "columns", "sort", "activeOnly" } ],
  "charts": [ { "entity", "name", "groupBy", "measure", "chartType" } ],
  "pages": [ { "key", "name", "purpose", "dataSources", "source": { "kind": "tsx", "codeFile": "..." } } ],
  "design?": { "accent", "density", "cornerRadius", "darkMode", "layout" },
  "appShell": { "areas": [ { "label", "groups": [ { "label", "subAreas": [...] } ] } ] },
  "sampleData": { "<entitySchemaName>": [ { ...fields, "$parent"?: {...} } ] }
}

Write model-app-plan.md

Render it — never hand-write it. The design document is generated from the spec so it is complete, always agrees with what will actually build, and can be regenerated after any edit:

node "${PLUGIN_ROOT}/scripts/write-app-spec-doc.js" \
  --spec @<working-dir>/app-spec.json --env <envUrl>

It writes <working-dir>/model-app-plan.md — a readable spec covering the jobs-to-be-done and the surfaces that satisfy them, the data model, every surface (pages, forms, views, charts), navigation, the access model per role, sample data, the design contract and AI features — and prints { ok, docPath, bytes, warnings }.

Surface warnings in your chat reply. They name design gaps the document called out — jobs with no covering surface, or an app with no generative pages. Re-running the command after fixing the spec regenerates the document.

This is the artifact the user keeps alongside the app, so tell them where it is.

Complete the workflow log

Append a summary entry to <working-dir>/workflow-log.md:

Phase 1 complete.
Phase 1.5 complete (N intent pages → tsx).
Spec written: <working-dir>/app-spec.json
Lint: ok=true, errors=0, warnings=N
Plan approved: yes

Hand off to the build phase

You are still in the main loop — proceed directly to Phase 2 (Build) of SKILL.md using the app-spec.json and env URL you just produced. First, recap a concise summary to the user:

Planning complete.

App: [name]
Environment: [env URL]
Solution: [uniqueName] / prefix: [prefix]

Tables to create: [list, or "none — all entities reuse existing tables"]
Tables to reuse: [list, or "none"]
Relationships: [N]
Forms: [N] | Views: [N] | Charts: [N]
Sample data: [yes — N total records | no]
Lint: [clean | N warning(s) acknowledged]

Spec: <working-dir>/app-spec.json
Plan: <working-dir>/model-app-plan.md

Mark the "Write app-spec.json and model-app-plan.md" task complete.

Critical Constraints (Phase 1 — authoring only)

  • Do NOT write to Dataverse during authoring. Table/column/relationship creation and record insertion happen in Phase 2 (Build), driven by the cds-maker-sdk build engine — not here. Authoring only reads (pac auth / pac org who for the environment, list-tables.js and apps.js list for what exists) and writes local files.
  • Do NOT hand-write metadata XML or solution ZIP files. The build engine (build-model-app.js → lib/sdk-build.js) produces all FormXml/FetchXml/sitemap and Web API writes via the SDK.
  • The author is design-only — generative pages for overview/dashboard surfaces are authored as intents (source: { kind: "intent" }, schemaVersion: 2); .tsx is never written here. Pages remain intents until Phase 1.5 — Generate pages (after plan approval + data pre-build). See SKILL.md → Phase 1.5. (A standalone page not part of an app is the separate /genpage skill.)
  • Only --stage data is apply-safe in the data pre-build (Phase 1.5 step 1); all other --stage selectors and --from/--to/--only/--skip selectors are rejected on --apply.
  • Interaction points are limited to:
    1. Step 2 — environment selection (if multiple auth profiles).
    2. Step 3 — app selection and solution selection.
    3. Step 4 — levelled authoring turns (personas + jobs-to-be-done, data model confirmation, artifacts + page-intents + design confirmation, then access). These are the only turns where the spec is shaped.
    4. Step 5 — lint-warning acknowledgement (if warnings present).
    5. Step 6 — plan-mode gate (EnterPlanMode / ExitPlanMode).
  • No other interaction points. Do not ask questions outside these steps.
  • Loop back correctly: On plan revision, return to Step 4 (re-author), re-run lint (Step 5), then re-enter plan mode (Step 6). Do not skip the lint on re-entry.