plugins/power-pages/skills/export-solution/SKILL.md
Exports a Dataverse solution containing Power Pages site components as a zip file, ready for deployment to another environment. Use when asked to: "export solution", "download solution", "export managed", "export unmanaged", "package for deployment", "create solution zip", "export site package", or "build deployment artifact".
npx skillsauth add microsoft/power-platform-skills export-solutionInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Plugin check: Run
node "${CLAUDE_PLUGIN_ROOT}/scripts/check-version.js"— if it outputs a message, show it to the user before proceeding.
Triggers an async Dataverse solution export, polls until complete, downloads the solution zip, and verifies it. Reads .solution-manifest.json to identify the solution; falls back to asking the user.
setup-solution first if needed)
plan-almis the front door. When the user expresses an ALM intent (promote / ship / deploy / set up CI-CD / move to staging / push to prod), the orchestrator (/power-pages:plan-alm) should run first. This Phase 0 enforces that and is meant to fail closed when there's no plan, not to be a one-time check the user can dismiss forever.
Skip rule. If this skill was invoked as part of an active plan-alm orchestration, skip Phase 0 entirely and proceed to Phase 1. The gate helper exposes this via its inExecution block — pass through silently to Phase 1 when:
inExecution.status === "active"
The helper computes this from docs/.alm-plan-data.json — PLAN_STATUS === "In Execution" AND LAST_INVOCATION_AT within the last 60 minutes. check-alm-plan.js refreshes LAST_INVOCATION_AT automatically on every invocation that finds the plan in execution, so each in-chain skill keeps the chain alive for the next one — even multi-hour deploys (deploy-pipeline alone can take 60 min per stage) survive the window without the chain incorrectly de-classifying. Stalled chains (no heartbeat for > 60 min) reclassify as stale-heartbeat and Phase 0 gates fire normally so an abandoned plan doesn't silently bypass user confirmation.
When inExecution.status is anything other than "active" ("not-running", "stale-heartbeat", "no-plan"), run the Phase 0 gate flow below. Branch on the remaining helper fields:
Step 1 — Run the gate helper.
node "${CLAUDE_PLUGIN_ROOT}/scripts/lib/check-alm-plan.js" \
--projectRoot "." \
--envUrl "{envUrl from .solution-manifest.json or pac env who, if available}" \
--token "{token, if Phase 1 already acquired one}" \
--solutionId "{solutionId from .solution-manifest.json, if available}"
The helper returns JSON with { exists, deferred, stale, staleness: { reason, detail }, generatedAt, planStatus, ... }. The freshness check requires env credentials + solutionId; without those the helper does an existence-only check.
Step 2 — Branch on the result.
| Result | Behavior |
|---|---|
| deferred: true | The user has explicitly deferred ALM for this project (.alm-deferred marker present). Pass through silently to Phase 1 — do not nag. |
| exists: false | The user hasn't run plan-alm yet. See Step 3. |
| exists: true, stale: false | Plan is current. Pass through silently to Phase 1. |
| exists: true, stale: true (reason: solution-modified) | The solution changed after the plan was generated. See Step 4. |
Step 3 — No plan. Tell the user:
<!-- gate: export-solution:0.no-plan | category=intent | cancel-leaves=nothing -->"No ALM plan exists for this project.
/power-pages:plan-almbuilds one — it detects the project state, asks about your promotion strategy (PP Pipelines vs Manual export/import), and orchestrates the right skills (including this one) in the right order. Want me to run plan-alm now?"
🚦 Gate (intent · export-solution:0.no-plan): Fail-closed entry gate when
check-alm-plan.jsreturnsexists:false. Helper-script-backed.
AskUserQuestion:
| Question | Header | Options |
|---|---|---|
| Run /power-pages:plan-alm first? | ALM plan gate | Yes — run /power-pages:plan-alm now (Recommended), Continue without a plan (advanced — I know what I'm doing), Cancel |
/power-pages:plan-alm. plan-alm's Phase 7 dispatches back into this skill at the appropriate stage.BYPASSED_PLAN_GATE = true and proceed to Phase 1.Step 4 — Stale plan. Tell the user:
<!-- gate: export-solution:0.stale-plan | category=intent | cancel-leaves=nothing -->"ALM plan exists from
{generatedAt}but the source solution has been modified since (at{solution.modifiedon}). Components may have changed. Re-runningplan-almwill refresh the analysis and the rendered HTML."
🚦 Gate (intent · export-solution:0.stale-plan): Fail-closed entry gate when
check-alm-plan.jsreturnsstale:true. Helper-script-backed.
AskUserQuestion:
| Question | Header | Options | |---|---|---| | Refresh the plan first? | ALM plan freshness | Refresh — re-run /power-pages:plan-alm (Recommended), Continue with the existing plan, Cancel |
/power-pages:plan-alm. After completion, re-run the Phase 0 helper once to confirm freshness; if still stale, surface the detail and proceed to Phase 1 anyway (don't infinite-loop).STALE_PLAN_ACK = true and proceed to Phase 1.Why this gate exists. Direct invocation of export-solution produces a zip without the orchestrator's pre-export completeness check. Users running this skill standalone often miss components that should have been added to the solution (cloud flows, env var values referenced by site settings, sample data references) and ship a zip that imports cleanly into staging but produces a broken site post-deploy. The pre-plan completeness check surfaces those gaps before any zip is built. The gate ensures plan-alm either ran (so completeness was verified and the export was scoped to the right solution lineage) or the user explicitly chose to bypass it.
Create all tasks upfront at the start of this phase.
Tasks to create:
Steps:
verify-alm-prerequisites.js with --require-manifest to confirm PAC CLI auth, acquire a token, verify API access, and validate that .solution-manifest.json exists:
node "${CLAUDE_PLUGIN_ROOT}/scripts/lib/verify-alm-prerequisites.js" --require-manifest
Capture output as JSON; extract .envUrl (store as envUrl) and .token (store as token). If the script exits non-zero, stop and explain what is missing (reference ${CLAUDE_PLUGIN_ROOT}/references/dataverse-prerequisites.md).Reference:
${CLAUDE_PLUGIN_ROOT}/references/alm-docs-grounding.md
Cap this step at ~30 seconds. If MCP search / fetch errors out, log a one-line note and continue — this skill must remain runnable offline.
microsoft_docs_search with the query: Power Pages solution export managed unmanaged ExportSolutionAsync ALM.https://learn.microsoft.com/en-us/power-platform/alm/solution-concepts-alm (and at most one sister page on managed vs unmanaged or solution layering) in parallel via microsoft_docs_fetch.${CLAUDE_PLUGIN_ROOT}/references/solution-api-patterns.md and flag any divergence in ExportSolutionAsync / DownloadSolutionExportData signatures..solution-manifest.json in project root (use findProjectRoot or glob('**/.solution-manifest.json'))solution.uniqueName, solution.solutionId, environmentUrl
AskUserQuestionGET {envUrl}/api/data/v9.2/solutions?$filter=uniquename eq '{solutionName}'&$select=solutionid,uniquename,friendlyname,version,ismanaged
Before exporting, run the shared site-inventory helper to detect any components that exist on the site but are not in the solution. Catching this here avoids shipping an incomplete package to staging/prod.
node "${CLAUDE_PLUGIN_ROOT}/scripts/lib/discover-site-components.js" \
--envUrl "{envUrl}" --token "{token}" \
--siteId "{websiteRecordId}" \
--publisherPrefix "{publisherPrefix from .solution-manifest.json}" \
--solutionId "{solutionId}"
Parse stdout and evaluate missing. Before doing anything else, capture the pre-sync state so a post-sync re-confirmation gate can show what changed:
PRE_SYNC_VERSION = solutionManifest.solution.version // from .solution-manifest.json read in Phase 2
PRE_SYNC_MISSING = { siteComponents, siteLanguages, cloudFlows, envVarDefinitions, customTables, ... } // from the discovery stdout above
Then:
All missing.* arrays empty → report "Solution contents match the site — no gaps detected." Proceed to Phase 3.
Any non-empty missing.* array → present a concise summary:
<!-- gate: export-solution:2.5.completeness | category=progress | cancel-leaves=nothing -->"The solution is missing {N} component(s) that exist on the site:
- {X} site components (e.g. {first 3 names}, …)
- {Y} cloud flows
- {Z} environment variable definitions with your publisher prefix
- {W} custom tables"
🚦 Gate (progress · export-solution:2.5.completeness): Source solution incomplete vs live site. Sync first, export as-is (gap recorded), or abort.
Then ask via AskUserQuestion:
"How would you like to proceed?
- Run
/power-pages:setup-solutionin sync mode now — adopts missing components, bumps the solution version, then re-confirms with you before exporting (Recommended)- Export as-is — ship what's currently in the solution; missing components won't travel
- Abort — I want to investigate before exporting"
Option 1 — Sync first, then re-confirm before export:
/power-pages:setup-solution (auto-detects the existing manifest, enters sync mode, adopts missing components, bumps the version). Wait for completion. setup-solution's final refresh step writes LAST_SYNC_AT into docs/.alm-plan-data.json so subsequent check-alm-plan.js calls do NOT falsely flag the plan as stale just because the sync bumped solutions.modifiedon past GENERATED_AT — the freshness reference becomes max(GENERATED_AT, LAST_SYNC_AT)..solution-manifest.json and capture POST_SYNC_VERSION = solutionManifest.solution.version.missing.* remain non-empty, repeat the Phase 2.5 prompt above.NEWLY_ADOPTED as a per-category set difference between PRE_SYNC_MISSING and the second discovery run's missing.* (the items that disappeared are what setup-solution just adopted into the solution). Total count = sum of all category lengths.🚦 Gate (progress · export-solution:2.5.post-sync): Post-sync re-confirm. Solution version bumped + components adopted — user inspects delta before export proceeds.
Re-confirm with the user before proceeding to Phase 3 — the solution about to be exported is now different from what the user originally saw when they started the export. Use AskUserQuestion:
"Sync complete.
{solutionUniqueName} is now v{POST_SYNC_VERSION} (was v{PRE_SYNC_VERSION}) with {NEWLY_ADOPTED.total} newly-adopted components:
- {first 3-5 names by category — prefer high-signal categories: cloud flows, server logic, env var definitions, then site components}
- {if more remain:
+ {N} more across {category list}}About to export this updated solution to a zip file.
Continue with the export?"
| Question | Header | Options | |---|---|---| | Continue with the export? | Post-sync approval | Yes — export v{POST_SYNC_VERSION} (Recommended), Pause — I want to review the new solution contents first, Cancel — abort the export |
/power-pages:export-solution when you're ready to export v{POST_SYNC_VERSION}.") so the user can inspect the synced manifest / Dataverse state and resume manually. Do not write any export artifacts — no export happened. Skip the skill-tracking call too.Option 2 — record the gap in the export manifest (see Phase 7 summary) so the user has an audit trail of what was intentionally left out.
Option 3 — stop the skill.
Why the post-sync gate exists: when sync mode runs mid-export, it produces a different solution version than the one the user had in mind when they invoked the skill. Re-confirming after sync gives the user an explicit chance to inspect the version bump and the list of newly-adopted components before the zip is produced and (typically) shipped onward via
import-solution. The Phase 2.5 trigger is intentional; the post-sync re-confirmation is the safety on top of it. This mirrors the same gate indeploy-pipelinePhase 3.5 — same shape, same options, same audit-trail rules — so users see consistent behavior whether they take the PP Pipelines path or the Manual export/import path.
Why Phase 2.5 exists in the first place: historically, components created after
setup-solution(server logic fromadd-server-logic, flows fromadd-cloud-flow, env vars fromconfigure-env-variables/setup-auth) were silently left out of the export zip and didn't travel to target environments. The ALM-aware-by-default principle inAGENTS.mdrequires this check at every gate where a solution leaves its source environment.
🚦 Gate (consent · export-solution:3.export-type): Managed vs Unmanaged — irreversible for the produced zip. Managed cannot be edited in target; Unmanaged can. Mismatch with stage strategy ships the wrong artifact downstream.
Invoke AskUserQuestion immediately — do NOT describe this choice as chat text. The user must answer live before export proceeds.
| Question | Header | Options | |---|---|---| | How would you like to export this solution? Managed solutions cannot be edited in the target environment and support clean upgrade/delete cycles — recommended for staging and production. Unmanaged solutions can be edited in the target environment — use for dev-to-dev deployments. | Export Type | Managed — for staging/production (Recommended), Unmanaged — for development environments |
Use the answer to set "Managed": true or "Managed": false in the ExportSolutionAsync request body.
Also ask (separate AskUserQuestion):
Step 4.0 — Bump source solution version (always-on).
Before exporting, bump the patch segment (4th segment) of the source solution's version. Without this, two consecutive exports without intervening setup-solution sync produce zips that carry the same version string — and importing the second zip into a target that already has the first installed is unreliable for managed solutions (no clean upgrade path) and depends on OverwriteUnmanagedCustomizations: true for unmanaged.
Why always-on, not "only when sync mode added components":
setup-solutiononly bumps when it has new components to add. A user who modifies content of an already-in-solution component (a web template, a site setting value, a web file) and then re-exports must still get a strictly-increasing version label — otherwise the manual export/import path quietly ships stale-version zips. See theWhy this step existscallout insetup-solutionPhase 4.
node "${CLAUDE_PLUGIN_ROOT}/scripts/lib/bump-solution-version.js" \
--envUrl "{envUrl}" \
--token "{token}" \
--uniqueName "{solutionUniqueName}" \
--projectRoot "."
Capture output as JSON; store .previous as PRE_EXPORT_VERSION, .next as EXPORT_VERSION, and inspect .manifestUpdated / .manifestUpdateReason to confirm the manifest sync succeeded. Report: "Bumped solution {solutionUniqueName} from v{PRE_EXPORT_VERSION} to v{EXPORT_VERSION} for export."
--projectRoot "." makes the helper update .solution-manifest.json's solution.version (single-solution) or matching solutions[].version (multi-solution) field atomically as part of the bump operation — no separate Edit step needed. If the manifest doesn't exist or has no matching entry, manifestUpdated: false and manifestUpdateReason tells you why (no-manifest, no-matching-entry, etc.); the bump itself still succeeded.
If the bump already happened earlier in this session (e.g.
setup-solutionsync mode ran with adopted components in Phase 2.5 and bumped the version, then handed back here): the helper still runs and bumps again. This is intentional — sync's bump is paired with new components; export's bump is paired with the produced zip. They're independent concerns and double-bumping is cheap (just an extra patch segment). The skill-skipping logic for "the manifest version already matches the live source version" is intentionally NOT added here; it would create a class of "I edited content but no sync was needed and no bump happened, so the export shipped a stale version" failures.
Step 4.1 — Trigger async export.
Run scripts/lib/export-solution-async.js to POST ExportSolutionAsync, poll until terminal state, and return the AsyncOperationId:
node "${CLAUDE_PLUGIN_ROOT}/scripts/lib/export-solution-async.js" \
--envUrl "{envUrl}" \
--token "{token}" \
--solutionName "{solutionUniqueName}" \
--managed {true|false}
Capture stdout as JSON; extract .asyncOperationId (store as asyncOperationId).
Report: "Export job started. Polling for completion..."
Handle script exit code:
asyncOperationIdRun scripts/lib/download-export-data.js to POST DownloadSolutionExportData, decode the base64 zip, and write it to disk:
node "${CLAUDE_PLUGIN_ROOT}/scripts/lib/download-export-data.js" \
--envUrl "{envUrl}" \
--token "{token}" \
--asyncOperationId "{asyncOperationId}" \
--outputPath "{outputDir}/{SolutionUniqueName}_{managed|unmanaged}.zip"
Capture stdout as JSON; extract .zipPath (store as zipPath) and .fileSizeBytes.
Report: "Downloading solution zip..."
Handle script exit code:
zipPath and fileSizeBytesfs.existsSync(zipPath)Solution.xml is inside the zip:
unzip -l "{zipPath}" | grep -i solution.xml or read zip TOC via Node.js (use Bash with unzip)Step 7.1 — Write docs/alm/last-export.json marker.
Ensure docs/alm/ exists, then write the marker so downstream skills (import-solution skew advisory, refresh-alm-plan-data.js rendering the Manual-path tab, future "modified-since-last-export" gates, audit trail) can reason about what was last shipped from this source.
node -e "require('fs').mkdirSync('docs/alm',{recursive:true})"
Then write docs/alm/last-export.json:
{
"exportedAt": "<ISO timestamp>",
"solutionUniqueName": "<solutionUniqueName>",
"solutionId": "<solutionId from .solution-manifest.json or Phase 2 query>",
"previousVersion": "<PRE_EXPORT_VERSION from Step 4.0>",
"version": "<EXPORT_VERSION from Step 4.0>",
"managed": <true|false>,
"sourceEnvironmentUrl": "<envUrl>",
"zipPath": "<zipPath>",
"fileSizeBytes": <fileSizeBytes>,
"asyncOperationId": "<asyncOperationId>"
}
The path is registered in scripts/lib/alm-paths.js under the key lastExport — programmatic consumers should resolve via almPath(projectRoot, 'lastExport') rather than re-inlining the path string. (Skill prose inlines the path verbatim for readability, matching the convention used for last-deploy.json, last-import.json, and the other ALM markers.)
Step 7.2 — Display the summary.
| Item | Value |
|---|---|
| Solution | {solutionUniqueName} v{EXPORT_VERSION} (was v{PRE_EXPORT_VERSION}) |
| Export type | Managed / Unmanaged |
| File | {zipPath} |
| File size | {size} KB |
| Export job | {AsyncJobId} |
| Marker written | docs/alm/last-export.json |
Suggested next steps:
/power-pages:import-solution to deploy this zip to another environment/power-pages:setup-pipeline to automate this process in CI/CDReference:
${CLAUDE_PLUGIN_ROOT}/references/skill-tracking-reference.md
Follow the skill tracking instructions in the reference to record this skill's usage. Use --skillName "ExportSolution".
node "${CLAUDE_PLUGIN_ROOT}/scripts/lib/refresh-alm-plan-data.js" \
--projectRoot "." \
--phase export-solution \
--render
Re-renders docs/alm-plan.html so any step-status updates the agent made during this skill (Export solution → status-completed) flow through. When docs/.alm-plan-data.json is absent (standalone invocation, not via plan-alm), the helper returns ok:false as a soft no-op — safe to run unconditionally.
ExportSolutionAsync. The bumped version (PRE_EXPORT_VERSION → EXPORT_VERSION) is surfaced in the Phase 7 summary so the user can see what version landed in the zip.message and friendlyMessage from the async operationExportSolutionFile: report error, suggest re-exporting| Task subject | activeForm | Description | |---|---|---| | Verify prerequisites | Verifying prerequisites | Confirm PAC CLI auth, acquire Azure CLI token, verify API access | | Identify solution | Identifying solution | Read .solution-manifest.json or ask user, confirm solution exists in environment | | Configure export | Configuring export | Ask user: managed vs unmanaged, output directory | | Trigger async export | Triggering async export | Bump source solution version (Step 4.0) via bump-solution-version.js so the zip carries a strictly-increasing version label; POST ExportSolutionAsync, capture AsyncJobId, poll until complete | | Download solution zip | Downloading solution zip | POST DownloadSolutionExportData, decode base64, write zip to disk | | Verify export | Verifying export | Confirm zip exists, size > 0, Solution.xml present inside | | Present summary | Presenting summary | Write docs/alm/last-export.json marker (via alm-paths.js); show zip path, size, type, version bump, and suggested next steps |
tools
Configure the Canvas Authoring MCP server for the current coauthoring session. USE WHEN "configure MCP", "set up MCP server", "MCP not working", "connect Canvas Apps MCP", "canvas-authoring not available", "MCP not configured", "set up canvas apps". DO NOT USE WHEN prerequisites are missing — direct the user to install .NET 10 SDK first.
development
Use when the user asks to "set up authentication", "add login", "add logout", "add sign in", "enable auth", "add role-based access", "add authorization", "protect routes", "configure identity provider", "configure Entra ID", "configure Entra External ID", "configure OpenID Connect", "add OIDC", "set up SAML", "set up WS-Federation", "set up local login", "add username password", "add Facebook login", "add Google sign in", "add Microsoft Account", "set up invitation login", or otherwise wants to set up authentication (login/logout) and role-based authorization for their Power Pages code site using any supported identity provider (Microsoft Entra ID, Entra External ID, OpenID Connect, SAML2, WS-Federation, local authentication, Microsoft Account, Facebook, or Google).
development
Creates, updates, and deploys Power Apps generative pages for model-driven apps using React v17, TypeScript, and Fluent UI V9. Orchestrates specialist agents for planning, entity creation, and code generation. Use it when user asks to build, retrieve, or update a page in an existing Microsoft Power Apps model-driven app. Use it when user mentions "generative page", "page in a model-driven", or "genux".
development
Creates a new Power Pages code site (SPA) using React, Angular, Vue, or Astro. Guides through the full process from initial concept to deployed site: requirements discovery, scaffolding, component planning, design, implementation, validation, and deployment. Use when the user wants to create, build, or scaffold a new Power Pages website or portal.