$npx -y skills add forcedotcom/sf-skills --skill experience-ui-bundle-deployMUST activate when the project contains a uiBundles/*/src/ directory or sfdx-project.json and the task involves deploying, pushing to an org, or post-deploy setup. Use this skill when deploying a UI bundle app to a Salesforce org. Covers the full deployment sequence: org authenti
| 1 | # Deploying a UI Bundle |
| 2 | |
| 3 | The order of operations is critical when deploying to a Salesforce org. This sequence reflects the canonical flow. |
| 4 | |
| 5 | ## Step 1: Org Authentication |
| 6 | |
| 7 | Check if the org is connected. If not, authenticate. All subsequent steps require an authenticated org. |
| 8 | |
| 9 | ## Step 2: Pre-deploy UI Bundle Build |
| 10 | |
| 11 | Install dependencies and build the UI bundle to produce `dist/`. Required before deploying UI bundle entities. |
| 12 | |
| 13 | Run when: deploying UI bundles and `dist/` is missing or source has changed. |
| 14 | |
| 15 | ## Step 3: Deploy Metadata |
| 16 | |
| 17 | Check for a manifest (`manifest/package.xml` or `package.xml`) first. If present, deploy using the manifest. If not, deploy all metadata from the project. |
| 18 | |
| 19 | Deploys objects, layouts, permission sets, Apex classes, UI bundles, and all other metadata. Must complete before schema fetch — the schema reflects org state. |
| 20 | |
| 21 | ## Step 4: Post-deploy Configuration |
| 22 | |
| 23 | Deploying does not mean assigning. After deployment: |
| 24 | |
| 25 | - **Permission sets / groups** — assign to users so they have access to custom objects and fields. Required for GraphQL introspection to return the correct schema. |
| 26 | - **Profiles** — ensure users have the correct profile. |
| 27 | - **Other config** — named credentials, connected apps, custom settings, flow activation. |
| 28 | |
| 29 | Proactive behavior: after a successful deploy, discover permission sets in `force-app/main/default/permissionsets/` and assign each one (or ask the user). |
| 30 | |
| 31 | ## Step 5: Data Import (optional) |
| 32 | |
| 33 | Only if `data/data-plan.json` exists. Delete runs in reverse plan order (children before parents). Import uses Anonymous Apex with duplicate rule save enabled. |
| 34 | |
| 35 | Always ask the user before importing or cleaning data. |
| 36 | |
| 37 | ## Step 6: GraphQL Schema and Codegen |
| 38 | |
| 39 | 1. Set default org |
| 40 | 2. Fetch schema (GraphQL introspection) — writes `schema.graphql` at project root |
| 41 | 3. Generate types (codegen reads schema locally) |
| 42 | |
| 43 | Run when: schema missing, or metadata/permissions changed since last fetch. |
| 44 | |
| 45 | ## Step 7: Final UI Bundle Build |
| 46 | |
| 47 | Build the UI bundle if not already done in Step 2. |
| 48 | |
| 49 | ## Summary: Interaction Order |
| 50 | |
| 51 | 1. Check/authenticate org |
| 52 | 2. Build UI bundle (if deploying UI bundles) |
| 53 | 3. Deploy metadata |
| 54 | 4. Assign permissions and configure |
| 55 | 5. Import data (if data plan exists, with user confirmation) |
| 56 | 6. Fetch GraphQL schema and run codegen |
| 57 | 7. Build UI bundle (if needed) |
| 58 | |
| 59 | ## Critical Rules |
| 60 | |
| 61 | - Deploy metadata **before** fetching schema — custom objects/fields appear only after deployment |
| 62 | - Assign permissions **before** schema fetch — the user may lack FLS for custom fields |
| 63 | - Re-run schema fetch and codegen **after every metadata deployment** that changes objects, fields, or permissions |
| 64 | - Never skip permission set assignment or data import silently — either run them or ask the user |
| 65 | |
| 66 | ## Post-deploy Checklist |
| 67 | |
| 68 | After every successful metadata deploy: |
| 69 | |
| 70 | 1. Discover and assign permission sets (or ask the user) |
| 71 | 2. If `data/data-plan.json` exists, ask the user about data import |
| 72 | 3. Re-run schema fetch and codegen from the UI bundle directory |