$npx -y skills add microsoft/power-platform-skills --skill setup-datamodelUse when the user wants to design or redesign the Dataverse schema and connector plan for an existing mobile app, or has an ER diagram (image, Mermaid, or text) to apply. Skip when the user is creating a brand-new app — /create-mobile-app handles the data model inline.
| 1 | **📋 Shared instructions: [shared-instructions.md](${CLAUDE_SKILL_DIR}/../../shared/shared-instructions.md)** — read first. |
| 2 | |
| 3 | # Set Up Data Model + Connectors |
| 4 | |
| 5 | Combined orchestrator for standalone data source planning. Designs the Dataverse schema, plans connectors, gets approval on both, then delegates execution to `/add-dataverse` and `/add-connector`. |
| 6 | |
| 7 | | Use this skill when | Use `/add-dataverse` directly when | |
| 8 | |---|---| |
| 9 | | Standalone schema + connector design (project may or may not exist yet) | The plan already exists and you just need to apply tables + generate services | |
| 10 | | You have an existing ER diagram (image / Mermaid / text) to import | `/create-mobile-app` is invoking this as a sub-step with `--skip-planning` | |
| 11 | | Re-planning the schema or connectors mid-project | You only need to add a single table or a single connector | |
| 12 | |
| 13 | ## Workflow |
| 14 | |
| 15 | 1. Verify project & auth → 2. Design data model → 3. Plan connectors → 4. Combined approval → 5. Execute data model → 6. Execute connectors → 7. Summary |
| 16 | |
| 17 | --- |
| 18 | |
| 19 | ### Phase 1 — Verify Project & Auth |
| 20 | |
| 21 | Confirm we're inside a Power Apps mobile app: |
| 22 | |
| 23 | ```bash |
| 24 | test -f power.config.json && echo "OK" || echo "ERROR: not a mobile app — run /create-mobile-app first" |
| 25 | node "${CLAUDE_SKILL_DIR}/../../scripts/resolve-environment.js" "$(node -e \"console.log(require('./power.config.json').environmentId)\")" |
| 26 | ``` |
| 27 | |
| 28 | Capture the **environment URL**, **environment ID**, **tenant ID**, and **organization ID** for Phase 5. |
| 29 | |
| 30 | ### Phase 2 — Design Data Model |
| 31 | |
| 32 | Check `$ARGUMENTS` for diagram hints first (`*.png`, `*.jpg`, `erDiagram` keyword, `||--o{` cardinality syntax). If a hint is present → Path A. If `$ARGUMENTS` describes the app at all → silently take Path B (architect propose). Only if both are empty, ask: |
| 33 | |
| 34 | > "How would you like to define the data model?" |
| 35 | |
| 36 | | Option | What happens | |
| 37 | |---|---| |
| 38 | | Upload an existing ER diagram | Provide a PNG/JPG path, Mermaid block, or text description | |
| 39 | | Let the Data Model Architect propose one (default) | Spawns `data-model-architect` agent to infer from requirements | |
| 40 | | Skip — no Dataverse tables needed | Jump to Phase 3 | |
| 41 | |
| 42 | Default the answer to "architect propose" so an empty answer auto-proceeds without blocking the user. |
| 43 | |
| 44 | #### Artifact storage rules for PDFs and signatures |
| 45 | |
| 46 | When requirements mention signatures, sign-off, ink, drawings, generated PDFs, exported reports, evidence packets, or retained documents, make the storage target explicit in `## Data Model` before approval: |
| 47 | |
| 48 | | User signal | Dataverse model implication | |
| 49 | |---|---| |
| 50 | | "capture signature", "sign off", "approval signature", "ink" | Image column on the signed record for one current signature, or child Evidence/Signature table for multiple captures/history | |
| 51 | | "generate PDF", "export report", "evidence packet", "certificate PDF" | Ask whether the generated PDF should be retained. If yes, use a Dataverse File column, usually on the parent record or a child Evidence/Attachment table. If no, document on-device/share-only behavior and add no column. | |
| 52 | | "upload PDF", "attach file", "import document" | File column or child Attachment table with lookup to parent | |
| 53 | | "view PDF" | Store or reference an HTTPS URL if the app has a durable source. Native PDF viewer 0.2.9+ also supports local `file://` URIs; `content://`, `blob:`, and `http://` remain unsupported. | |
| 54 | |
| 55 | PDF content must never be modeled as long text/base64 text. Use Dataverse File columns for retained PDFs. Signature PNGs may use Image columns when the generated service supports image payloads; use File columns or child Evidence rows when the capture should behave like an attachment. |
| 56 | |
| 57 | #### Path A — Parse user-provided diagram |
| 58 | |
| 59 | Accept PNG/JPG (use `Read` to view), Mermaid syntax (paste in chat), or text description. Parse into tables + columns + relationships. Query existing Dataverse tables to mark each as new / extend / reuse. Generate a Mermaid ER diagram for confirmation. Enter `EnterPlanMode` for data model approval. On `ExitPlanMode` approval, write the data model into `native-app-plan.md` `## Data Model` section (creating the file if absent). |
| 60 | |
| 61 | #### Path B — Spawn data-model-architect |
| 62 | |
| 63 | ``` |
| 64 | Task: mobile-app:data-model-architect |
| 65 | |
| 66 | Prompt: |
| 67 | You are the data-model-architect agent for a Power Apps mobile app. |
| 68 | Requirements: <$ARGUMENTS or ask the user what the app does> |
| 69 | Working directory: <cwd> |
| 70 | Plugin root: ${CLAUDE_SKILL_DIR}/../../ |
| 71 | |
| 72 | Follow your agent file. Return a ## Data Model section with Mermaid ER diagram, |
| 73 | reuse/extend/create table, and dependency-tier ordering. If require |