@salesforce/afv-skills 1.30.0 → 1.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/package.json +1 -1
  2. package/skills/data360-code-extension-generate/SKILL.md +15 -2
  3. package/skills/dx-pkg-post-install-configure/SKILL.md +184 -0
  4. package/skills/experience-ui-bundle-app-coordinate/SKILL.md +198 -34
  5. package/skills/experience-ui-bundle-app-coordinate/scripts/check-hosting-target.sh +26 -0
  6. package/skills/experience-ui-bundle-app-coordinate/scripts/check-sfdx-project.sh +15 -0
  7. package/skills/experience-ui-bundle-metadata-generate/SKILL.md +19 -8
  8. package/skills/experience-ui-bundle-metadata-generate/references/csp-metadata-format.md +2 -2
  9. package/skills/experience-ui-bundle-metadata-generate/scripts/check-api-version.sh +30 -0
  10. package/skills/platform-custom-field-generate/SKILL.md +12 -11
  11. package/skills/platform-custom-field-generate/references/advanced-picklists.md +17 -17
  12. package/skills/platform-custom-report-type-generate/SKILL.md +259 -0
  13. package/skills/platform-custom-report-type-generate/examples/AccountProjectsWithTasks.reportType-meta.xml +51 -0
  14. package/skills/platform-custom-report-type-generate/examples/AccountsWithIndustry.reportType-meta.xml +27 -0
  15. package/skills/platform-custom-report-type-generate/examples/AccountsWithProjects.reportType-meta.xml +44 -0
  16. package/skills/platform-custom-report-type-generate/references/category-values.md +32 -0
  17. package/skills/platform-custom-report-type-generate/references/errors-and-troubleshooting.md +24 -0
  18. package/skills/platform-dataspace-access-configure/SKILL.md +318 -0
  19. package/skills/platform-docs-get/SKILL.md +4 -0
  20. package/skills/platform-docs-get/scripts/extract_salesforce_doc.py +78 -13
  21. package/skills/platform-encryption-configure/SKILL.md +122 -0
  22. package/skills/platform-encryption-configure/assets/EncryptionKey.settings-meta.xml +17 -0
  23. package/skills/platform-encryption-configure/assets/PlatformEncryption.settings-meta.xml +15 -0
  24. package/skills/platform-encryption-configure/assets/encrypted-field.field-meta.xml +22 -0
  25. package/skills/platform-encryption-configure/examples/cache-only-keys.settings-meta.xml +11 -0
  26. package/skills/platform-encryption-configure/references/encryption-schemes.md +34 -0
  27. package/skills/platform-encryption-configure/references/key-models.md +34 -0
  28. package/skills/platform-encryption-configure/references/tenant-secret-lifecycle.md +23 -0
  29. package/skills/platform-encryption-configure/scripts/validate-encryption-metadata.sh +54 -0
  30. package/skills/platform-metadata-api-context-get/SKILL.md +13 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforce/afv-skills",
3
- "version": "1.30.0",
3
+ "version": "1.31.0",
4
4
  "description": "Salesforce skills for Agentforce Vibes",
5
5
  "license": "CC-BY-NC-4.0",
6
6
  "files": [
@@ -3,6 +3,19 @@ name: data360-code-extension-generate
3
3
  description: "Develop and deploy Data Cloud Code Extensions using SF CLI plugin. Use this skill when creating custom Python transformations for Data Cloud, deploying code extensions, or testing data transformations. Supports init, run, scan, and deploy operations."
4
4
  metadata:
5
5
  version: "1.0"
6
+ relatedSkills:
7
+ - "data360-schema-get"
8
+ cliTools:
9
+ - tool: ["sf"]
10
+ semver: ">=2.0.0"
11
+ - tool: ["pip"]
12
+ semver: ">=21.0.0"
13
+ - tool: ["python3"]
14
+ semver: ">=3.11.0"
15
+ - tool: ["docker"]
16
+ semver: ">=20.0.0"
17
+ - tool: ["git"]
18
+ semver: ">=2.0.0"
6
19
  ---
7
20
 
8
21
  # data360-code-extension-generate Skill
@@ -30,7 +43,7 @@ Before executing any code extension commands, verify prerequisites:
30
43
  ```
31
44
  If not installed:
32
45
  ```bash
33
- sf plugins install @salesforce/plugin-data-codeextension
46
+ sf plugins install @salesforce/plugin-data-code-extension
34
47
  ```
35
48
 
36
49
  2. **Python 3.11**
@@ -254,7 +267,7 @@ sf data-code-extension script deploy --target-org <org_alias> --name <name> --pa
254
267
 
255
268
  | Error | Solution |
256
269
  |-------|----------|
257
- | `command data-code-extension not found` | `sf plugins install @salesforce/plugin-data-codeextension` |
270
+ | `command data-code-extension not found` | `sf plugins install @salesforce/plugin-data-code-extension` |
258
271
  | `datacustomcode CLI not found` | `pip install salesforce-data-customcode` |
259
272
  | `Python version mismatch` | Use pyenv: `pyenv install 3.11.0 && pyenv local 3.11.0` |
260
273
  | `Cannot connect to Docker daemon` | Start Docker Desktop |
@@ -0,0 +1,184 @@
1
+ ---
2
+ name: dx-pkg-post-install-configure
3
+ description: "Use this skill to automate managed package post-install configuration. Package-agnostic — works with any managed package (LMA, FMA, work.com, Certinia, etc.). TRIGGER when: user installs a managed package and needs post-install configuration, mentions LMA/FMA/work.com post-install setup, asks to configure permission sets/FLS/page layouts for an installed package, says 'post-install', 'package setup', 'configure LMA', 'set up FMA', 'post-install steps'. DO NOT TRIGGER for: standalone permission set assignment (use dx-org-permission-set-assign), generating permission set metadata XML (use platform-permission-set-generate), package installation, or org switching."
4
+ metadata:
5
+ version: "2.2"
6
+ minApiVersion: "67.0"
7
+ cliTools:
8
+ - tool: ["sf"]
9
+ semver: ">=2.0.0"
10
+ ---
11
+
12
+ ## When to Use This Skill
13
+
14
+ Use when automating post-install configuration for any Salesforce managed package. This skill reads the package's post-install documentation, discovers available execution methods, and automates the configuration steps — including permission sets, object/field permissions, page layouts, Visualforce page access, and tab settings.
15
+
16
+ ## Input
17
+
18
+ - **Required:** Package name (e.g., `LMA`, `FMA`, `work.com`)
19
+ - **Optional:** Path to post-install doc (PDF, markdown, URL)
20
+
21
+ If no doc is provided, ask the user to supply it.
22
+
23
+ ## Workflow
24
+
25
+ Execute phases in order. Each phase must pass before proceeding.
26
+
27
+ ---
28
+
29
+ ### Phase 1: Discover Available Execution Methods
30
+
31
+ **Priority order:**
32
+ 1. Org-native platform MCP servers (highest — direct org access via Headless 360)
33
+ 2. Claude Code external MCP servers (sf-sobject-all, sf-sobject-all-sb, etc.)
34
+ 3. sf CLI fallback (always available if authenticated)
35
+
36
+ #### Step 1A: Resolve org API version
37
+
38
+ Discover the org's current API version dynamically — never hardcode a version number:
39
+
40
+ ```bash
41
+ sf org display --target-org <alias> --json
42
+ ```
43
+
44
+ From the JSON response, read `result.apiVersion` (e.g., `"67.0"`). Store this value and use it as `v<apiVersion>` in all subsequent REST paths. If the command fails, fall back to the `minApiVersion` declared in this skill's metadata (`67.0`).
45
+
46
+ #### Step 1B: Check for org-native platform MCP servers
47
+
48
+ Query the Tooling API for MCP server availability:
49
+
50
+ ```bash
51
+ sf api request rest "/services/data/v<apiVersion>/tooling/query?q=SELECT+Id,DeveloperName,MasterLabel+FROM+McpServerAccess" --target-org <alias>
52
+ ```
53
+
54
+ #### Step 1C: Determine execution method
55
+
56
+ Check which Claude Code MCP tools are available and authenticated.
57
+
58
+ **MCP tool prefixes by org type:**
59
+
60
+ | Org Type | Tool Prefix |
61
+ |---|---|
62
+ | Production | `mcp__sf-sobject-all__` |
63
+ | Sandbox | `mcp__sf-sobject-all-sb__` |
64
+ | Falcon Test (pc-rnd) | `mcp__sf-sobject-all-falcon__` |
65
+
66
+ If MCP needs auth, call the authenticate tool. If auth fails, fall back to sf CLI.
67
+
68
+ ---
69
+
70
+ ### Phase 2: Verify Authentication & Org Identity
71
+
72
+ 1. Run a lightweight test query (`SELECT Id, Name, IsSandbox FROM Organization`)
73
+ 2. If MCP auth fails, automatically fall back to sf CLI
74
+ 3. Display org info and ask user to confirm before proceeding
75
+
76
+ ---
77
+
78
+ ### Phase 3: Verify Package Installation
79
+
80
+ 1. Determine the package namespace (ask user if unknown)
81
+ 2. Check via Tooling API (`InstalledSubscriberPackage`) — do NOT use `PackageLicense`
82
+ 3. If package not found, stop and inform user
83
+
84
+ ---
85
+
86
+ ### Phase 4: Read and Parse Post-Install Document
87
+
88
+ Read the provided document and extract discrete configuration steps.
89
+
90
+ **Supported formats:** PDF, markdown, URL (via WebFetch), pasted text.
91
+
92
+ **Parsing approach:**
93
+ 1. Extract each numbered/bulleted step from the document
94
+ 2. Present the extracted steps to the user for validation before proceeding
95
+
96
+ ---
97
+
98
+ ### Phase 5: Classify Steps & Interactive Plan Review
99
+
100
+ For each step extracted from the doc, classify as Automated or Manual.
101
+
102
+ #### Automation capabilities reference
103
+
104
+ **Via MCP (sobject-all) or sf CLI CRUD:**
105
+ - Record CRUD on any standard or custom object (PermissionSet, ObjectPermissions,
106
+ FieldPermissions, SetupEntityAccess, PermissionSetTabSetting, PermissionSetAssignment, etc.)
107
+
108
+ **Via Metadata API retrieve/deploy (sf CLI):**
109
+ - Page layout modifications (add related lists, fields, sections)
110
+ - Profile settings
111
+ - Custom metadata type records
112
+
113
+ **Via sf CLI Tooling API:**
114
+ - Tooling queries (InstalledSubscriberPackage, ApexPage, ApexClass, etc.)
115
+ - Any REST-accessible Tooling operation
116
+
117
+ **Manual (no API path — requires Setup UI):**
118
+ - System permissions not exposed via REST
119
+ - Connected app OAuth configuration
120
+ - Environment Hub linkage
121
+
122
+ #### Interactive approval
123
+
124
+ Present the classified plan and let the user choose:
125
+ - **"Approve all"** — Execute all steps as planned
126
+ - **"Let me choose"** — Select which steps to approve/skip
127
+ - **"I have questions"** — Discuss specific steps before deciding
128
+
129
+ ---
130
+
131
+ ### Phase 6: Execute Approved Steps
132
+
133
+ For each approved step, use the resolved execution method.
134
+
135
+ #### Execution method reference
136
+
137
+ | Operation | Via MCP | Via sf CLI |
138
+ |---|---|---|
139
+ | SOQL query | `soqlQuery` tool | `sf data query --query "<SOQL>" --target-org <alias> --json` |
140
+ | Create record | `createSobjectRecord` tool | `sf data create record --sobject <Object> --values "..." --target-org <alias> --json` |
141
+ | Update record | `updateSobjectRecord` tool | `sf data update record --sobject <Object> --record-id <id> --values "..." --target-org <alias> --json` |
142
+ | Describe object | `getObjectSchema` tool | `sf api request rest "/services/data/v<apiVersion>/sobjects/<Object>/describe" --target-org <alias>` |
143
+ | Page layout | N/A | Metadata API retrieve/deploy |
144
+
145
+ #### Page layout modifications via Metadata API
146
+
147
+ Use `sf project retrieve start` → edit the layout XML → `sf project deploy start`.
148
+
149
+ #### Execution rules
150
+
151
+ - **Idempotency:** Before creating any record, query to check if it already exists. Skip if so.
152
+ - **Report after each step:** Show success count, skipped items, and reasons.
153
+ - **Automatic fallback:** If MCP fails mid-execution, retry via sf CLI.
154
+ - **On failure:** Report error, ask user to retry/skip/stop.
155
+
156
+ ---
157
+
158
+ ### Phase 7: Guide Manual Steps (if any)
159
+
160
+ If any steps could not be automated, present each with Setup navigation instructions.
161
+ Wait for user confirmation before proceeding to the next.
162
+
163
+ ---
164
+
165
+ ### Phase 8: Summary
166
+
167
+ Display final summary with step-by-step status, method used, and any skipped items.
168
+
169
+ ---
170
+
171
+ ## Error Handling
172
+
173
+ - **Auth failure mid-execution:** Stop, ask user to re-auth, offer to resume
174
+ - **Duplicate record errors:** Treat as "already configured", skip and continue
175
+ - **Permission errors:** Report which permission is missing, suggest resolution
176
+ - **Unknown step type:** Ask user to clarify, offer to mark as manual
177
+
178
+ ## Notes
179
+
180
+ - **Priority: org-native MCP > Claude Code MCP > sf CLI > manual**
181
+ - sf CLI is always a valid fallback for all CRUD and Tooling API operations
182
+ - Page layout modifications are automated via Metadata API retrieve/deploy
183
+ - Always verify org identity before making changes
184
+ - All actions respect the authenticated user's permissions
@@ -3,7 +3,14 @@ name: experience-ui-bundle-app-coordinate
3
3
  description: "MUST activate when the user wants to build, create, or generate a React application, React app, web application, single-page application (SPA), or frontend application — even if no project files exist yet. MUST also activate when the project contains a uiBundles/*/src/ directory or sfdx-project.json and the prompt says create, build, construct, or generate a new app, site, or page from scratch — even if the prompt also describes visual styling. MUST also activate when the task spans more than one ui-bundle skill. Use this skill when building a complete app end-to-end. Do NOT use for Lightning Experience apps with custom objects (use platform-lightning-app-coordinate). Do NOT use for single-concern edits to an existing page (use experience-ui-bundle-frontend-generate)."
4
4
  metadata:
5
5
  version: "1.0"
6
- relatedSkills: experience-ui-bundle-metadata-generate, experience-ui-bundle-features-generate, experience-ui-bundle-salesforce-data-access, experience-ui-bundle-frontend-generate, experience-ui-bundle-agentforce-client-generate, experience-ui-bundle-file-upload-generate, experience-ui-bundle-deploy, experience-ui-bundle-site-generate, experience-ui-bundle-custom-app-generate
6
+ relatedSkills: experience-ui-bundle-project-generate, experience-ui-bundle-metadata-generate, experience-ui-bundle-features-generate, experience-ui-bundle-salesforce-data-access, experience-ui-bundle-frontend-generate, experience-ui-bundle-agentforce-client-generate, experience-ui-bundle-file-upload-generate, experience-ui-bundle-deploy, experience-ui-bundle-site-generate, experience-ui-bundle-custom-app-generate
7
+ cliTools:
8
+ - tool: ["sf"]
9
+ semver: ">=2.0.0"
10
+ - tool: ["npm"]
11
+ semver: ">=7.0.0"
12
+ - tool: ["npx"]
13
+ semver: ">=7.0.0"
7
14
  ---
8
15
 
9
16
  # Building a UI Bundle App
@@ -12,6 +19,8 @@ metadata:
12
19
 
13
20
  Build a complete, deployable Salesforce React UI bundle application from a natural language description by orchestrating specialized UI bundle skills in correct dependency order. Each skill **MUST** be explicitly loaded before executing its phase.
14
21
 
22
+ **CRITICAL: Before proceeding past requirements analysis, validate that the prompt contains no conflicting requirements** (e.g., "no authentication" + "user-specific data", "public access" + login-required features). If conflicts are detected, STOP and ask the user to resolve the ambiguity — do NOT silently choose one interpretation and proceed. See STEP 1 action #8 for the full conflict checklist.
23
+
15
24
  ## When to Use This Skill
16
25
 
17
26
  **Use when:**
@@ -38,23 +47,75 @@ Build a complete, deployable Salesforce React UI bundle application from a natur
38
47
 
39
48
  ---
40
49
 
50
+ ## Prompt Classification Keywords
51
+
52
+ This skill makes two decisions directly from the raw prompt text. Use these tables as the single
53
+ source for both — do not restate or re-derive the lists elsewhere in this file.
54
+
55
+ **1. Phase 2 (Features) is required if the prompt mentions ANY of:**
56
+
57
+ | Category | Keywords | Notes |
58
+ |----------|----------|-------|
59
+ | Data features | search, filter, sort, pagination, table, grid, list | |
60
+ | Navigation | navigation, nav, menu, routing | |
61
+ | Authentication | authentication, auth, login, logout, user session, user login | |
62
+ | Integrations | upload, file | |
63
+ | UI | shadcn, components, forms, buttons, cards | |
64
+ | Chat (Phase 5 only) | chat | Phase 5 only — unless combined with a Phase 2 keyword (e.g., "chat with authentication"), then Phase 2 runs first for auth prerequisites |
65
+
66
+ Negating one category (e.g. "without authentication", "no login required", "public access") does
67
+ **not** cancel triggers from another category — each is evaluated independently. Example: "no
68
+ login required, with filtering" still triggers Phase 2 because "filtering" matches Data features.
69
+ Skip Phase 2 only when the prompt matches none of the keywords above.
70
+
71
+ **2. Hosting target — extract from prompt keywords:**
72
+
73
+ | Hosting target | Keywords |
74
+ |-----------------|----------|
75
+ | Experience Site | "Experience Site", "Community", "external users", "public users", "guest users" |
76
+ | Custom Application | "Custom Application", "internal users", "Lightning app" |
77
+
78
+ If the prompt matches neither list, or matches both, ask the user to clarify before proceeding — do not guess.
79
+
80
+ ---
81
+
41
82
  ## Dependency Graph & Build Order
42
83
 
84
+ ### Phase 0: Template Offer & Bootstrap (Prerequisites)
85
+
86
+ ```text
87
+ Offer prebuilt starter template (experience-ui-bundle-project-generate)
88
+ v
89
+ If template chosen: scaffold via sf template generate project -- Phase 1 skipped
90
+ v
91
+ If declined: run scripts/check-sfdx-project.sh
92
+ v
93
+ If missing: create sfdx-project.json
94
+ v
95
+ Verify project directory initialized
96
+ ```
97
+
98
+ Offers a faster, less error-prone starting point before building from scratch. If no template is used, ensures an SFDX project exists before attempting to generate a UI bundle — without this, `sf template generate ui-bundle` will fail with a hard error. Always check first — do not assume the project structure exists.
99
+
100
+ **Action:** Load `experience-ui-bundle-project-generate` and offer the two starter templates. If declined, run `scripts/check-sfdx-project.sh` and report any errors it returns. If the script reports an error, create the missing `sfdx-project.json` before proceeding.
101
+
43
102
  ### Phase 1: Scaffolding (Foundation)
44
103
 
45
104
  ```text
46
- UI Bundle scaffold (sf template generate ui-bundle)
105
+ Determine hosting target (Experience Site / Custom Application)
106
+ v
107
+ UI Bundle scaffold (sf template generate ui-bundle --template reactbasic)
47
108
  v
48
109
  Install dependencies (npm install)
49
110
  v
50
- Bundle metadata (uibundle-meta.xml, ui-bundle.json)
111
+ Bundle metadata (uibundle-meta.xml with <target>, ui-bundle.json)
51
112
  v
52
113
  CSP Trusted Sites (if external domains needed)
53
114
  ```
54
115
 
55
- Creates the UI bundle directory structure, meta XML, and optional routing/headers config. All subsequent phases require the scaffold to exist.
116
+ Creates the UI bundle directory structure, meta XML (including hosting target), and optional routing/headers config. **CRITICAL**: Hosting target must be determined FIRST because the metadata skill requires `<target>` in Phase 1. All subsequent phases require the scaffold to exist.
56
117
 
57
- ### Phase 2: Features (Optional)
118
+ ### Phase 2: Features (Required if prompt mentions feature keywords — see "Prompt Classification Keywords" above)
58
119
 
59
120
  ```text
60
121
  Search project code (src/) for existing implementations
@@ -68,7 +129,9 @@ Resolve conflicts (two-pass: --on-conflict error, then --conflict-resolution)
68
129
  Integrate __example__ files into target files, then delete them
69
130
  ```
70
131
 
71
- Installs pre-built, tested feature packages. Skip if the app requires no pre-built features. Always check for an existing feature before building from scratch. Features provide the foundation that UI components build on top of.
132
+ Installs pre-built, tested feature packages. See "Prompt Classification Keywords" above for the full trigger keyword list and negative-phrasing handling these features provide the foundation that UI components build on top of.
133
+
134
+ Only skip this phase if the app is truly a minimal "hello world" with no interactive features (no trigger keywords present at all).
72
135
 
73
136
  ### Phase 3: Data Access (Backend Wiring)
74
137
 
@@ -123,16 +186,16 @@ Post-deploy configuration (permissions, profiles, named credentials, connected a
123
186
  Import data (if data plan exists)
124
187
  v
125
188
  Fetch GraphQL schema and run codegen
126
- *(Re-fetches schema from the deployed org -- required because the remote schema may differ from the local one used in Phase 3)*
189
+ *(Re-fetches schema from the deployed org -- required because the remote schema may differ from the local one used in Phase 3. Guard against an empty or stale result -- Salesforce Edge caching can briefly serve the pre-deploy schema; re-fetch/retry before trusting it as empty and before running codegen)*
127
190
  v
128
191
  Final UI bundle build (rebuilds with the deployed schema)
129
192
  ```
130
193
 
131
194
  Follows the canonical 7-step deployment sequence. Must deploy metadata before fetching schema. Must assign permissions before schema fetch.
132
195
 
133
- ### Phase 7: Hosting Target
196
+ ### Phase 7: Hosting Target Infrastructure
134
197
 
135
- Choose **one** of the following based on the app's audience:
198
+ Deploy the hosting target infrastructure determined in Phase 1. Choose **one** of the following based on the app's audience:
136
199
 
137
200
  #### Phase 7a: Experience Site (External)
138
201
 
@@ -144,7 +207,7 @@ Generate site metadata (Network, CustomSite, DigitalExperience)
144
207
  Deploy site infrastructure
145
208
  ```
146
209
 
147
- Creates the Digital Experience site that hosts the UI bundle. Use when the user wants a public-facing or authenticated site URL for external users.
210
+ Creates the Digital Experience site that hosts the UI bundle. Use when the user wants a public-facing or authenticated site URL for external users. **Note**: The `<target>ExperienceSite</target>` was already set in meta XML during Phase 1.
148
211
 
149
212
  #### Phase 7b: Custom Application (Internal)
150
213
 
@@ -153,17 +216,30 @@ Resolve app properties (appName, appNamespace, appLabel)
153
216
  v
154
217
  Generate CustomApplication metadata (applications/*.app-meta.xml)
155
218
  v
156
- Add <target>CustomApplication</target> to .uibundle-meta.xml
157
- v
158
219
  Deploy custom application
159
220
  ```
160
221
 
161
- Creates a Custom Application entry in the Lightning App Launcher. Use when the app is for internal users accessing it within Lightning Experience.
222
+ Creates a Custom Application entry in the Lightning App Launcher. Use when the app is for internal users accessing it within Lightning Experience. **Note**: The `<target>CustomApplication</target>` was already set in meta XML during Phase 1.
162
223
 
163
224
  ---
164
225
 
165
226
  ## Execution Workflow
166
227
 
228
+ ### STEP 0: Offer a Prebuilt Template (before scaffolding from scratch)
229
+
230
+ **Before** analyzing requirements or scaffolding, check whether a prebuilt starter template fits —
231
+ it is faster and less error-prone than building from scratch.
232
+
233
+ - **Load skill: Invoke `experience-ui-bundle-project-generate`.** It offers two minimal React starter
234
+ projects (internal / employee-facing and external / customer-facing) and, if the user picks one,
235
+ generates it into the project directory with `sf template generate project`.
236
+ - **If the user chooses a template:** the scaffolding phase (Phase 1) is effectively done. Skip
237
+ straight to populating/customizing the project — continue at the phase that matches what they
238
+ want to change (typically Phase 4 UI, or Phase 3 data access), then Phase 6 deployment.
239
+ - **If the user declines** (wants to start from scratch, or none fit): proceed normally to STEP 1.
240
+
241
+ Do not skip this step silently — always offer the choice at the start of a from-scratch app build.
242
+
167
243
  ### STEP 1: Requirements Analysis & Planning
168
244
 
169
245
  **Actions:**
@@ -173,8 +249,12 @@ Creates a Custom Application entry in the Lightning App Launcher. Use when the a
173
249
  3. Extract pages and navigation structure
174
250
  4. Identify data entities and Salesforce objects needed
175
251
  5. Detect feature requirements (authentication, search, file upload, chat)
176
- 6. Determine if an Experience Site is needed
252
+ 6. Determine hosting target (Experience Site OR Custom Application) — see "Prompt Classification Keywords" above; if ambiguous, ask user to clarify before proceeding
177
253
  7. Identify external domains for CSP registration
254
+ 8. **Check for conflicting requirements** — STOP and ask user if any of the following conflicts are detected:
255
+ - "No authentication" OR "public/guest access" AND "user-specific data" OR "show current user's data" OR "My [Entity]" view
256
+ - "External users" AND "Custom Application" (Custom Apps are internal-only)
257
+ - "Public access" AND features requiring login (file upload, user profile, personalization)
178
258
 
179
259
  > **The plan MUST contain an explicit grounding step before any query authoring.** Do not list
180
260
  > guessed object/field names as settled facts and defer verification to codegen. The data-access
@@ -183,6 +263,18 @@ Creates a Custom Application entry in the Lightning App Launcher. Use when the a
183
263
  > authors queries first and codegens later is the failure mode that produces guessed fields and
184
264
  > hand-stubbed types — do not emit it.
185
265
 
266
+ **Before proceeding to Output (Build Plan), validate:**
267
+
268
+ - [ ] **No conflicting requirements detected** — if conflicts exist (see action #8 above), STOP and report:
269
+ ```text
270
+ ERROR: Conflicting requirements detected:
271
+ - [describe the specific conflict, e.g., "The prompt requires 'no authentication' while also requiring a 'My Cases' view scoped to the current user's identity"]
272
+
273
+ RESOLUTION NEEDED: Please clarify:
274
+ - [specific question, e.g., "Should the app require login (removing the 'no authentication' requirement), or should all data be public (removing the user-scoped view)?"]
275
+ ```
276
+ **Do NOT proceed to build plan generation or any phase execution until this conflict is resolved.**
277
+
186
278
  **Output: Build Plan**
187
279
 
188
280
  ```text
@@ -190,6 +282,7 @@ UI Bundle App Build Plan: [App Name]
190
282
 
191
283
  SCAFFOLDING:
192
284
  - App name: [PascalCase name]
285
+ - Hosting target: [Experience Site / Custom Application] **REQUIRED**
193
286
  - Routing: [SPA rewrites, trailing slash config]
194
287
  - External domains: [domains needing CSP registration]
195
288
 
@@ -214,10 +307,10 @@ INTEGRATIONS (if applicable):
214
307
 
215
308
  DEPLOYMENT:
216
309
  - Target org: [org alias if known]
217
- - Hosting target: [Experience Site / Custom Application / none]
218
310
 
219
311
  SKILL LOAD ORDER:
220
- 1. experience-ui-bundle-metadata-generate
312
+ 0. experience-ui-bundle-project-generate (offer a prebuilt template first; if chosen, Phase 1 scaffolding is skipped; if declined, run the Bootstrap check for an existing SFDX project -- no skill load required)
313
+ 1. experience-ui-bundle-metadata-generate (determines hosting target FIRST)
221
314
  2. experience-ui-bundle-features-generate (if features needed)
222
315
  3. experience-ui-bundle-salesforce-data-access (if data access needed)
223
316
  4. experience-ui-bundle-frontend-generate
@@ -239,33 +332,45 @@ Execute each phase sequentially. Complete all steps within a phase before moving
239
332
  | **3. Verify** | Run lint and build from the UI bundle directory | Catch errors before moving to the next phase |
240
333
  | **4. Checkpoint** | Confirm phase completion before proceeding | Ensures dependencies are satisfied for the next phase |
241
334
 
242
- **Do NOT skip step 1 (loading the skill).** Even if you remember the skill's content, skills evolve. Always load the current version.
335
+ **CRITICAL: Do NOT skip step 1 (loading the skill).** Even if you remember the skill's content, skills evolve. Always load the current version. **Skipping or reordering phases produces broken, non-deployable apps.** Phase dependencies are strict and cannot be violated.
243
336
 
244
337
  ---
245
338
 
246
- **Phase 1 -- Scaffolding**
339
+ **Phase 0 -- Template Offer & Bootstrap** (always, before scaffolding)
340
+ - 1. Load skill: Invoke `experience-ui-bundle-project-generate`
341
+ - 2. Execute: Offer the two starter templates; if the user picks one, generate it into the project dir with `sf template generate project`
342
+ - 3. Decision: If a template was used, the project is scaffolded (including a valid SFDX project structure) — skip Phase 1 and continue at the phase matching the user's customization (usually Phase 4 UI). If declined, proceed to the Bootstrap check below.
343
+ - 4. Bootstrap (no skill load required, only if no template was used): Run `scripts/check-sfdx-project.sh` and report any errors it returns. If the script reports an error, create the SFDX project structure (`sf project generate` or manually create sfdx-project.json).
344
+ - 5. Checkpoint: SFDX project ready -- proceed to Phase 1
345
+
346
+ **Phase 1 -- Scaffolding** (skip if a template was generated in Phase 0)
247
347
  - 1. Load skill: Invoke `experience-ui-bundle-metadata-generate`
248
- - 2. Execute: Run `sf template generate ui-bundle`, install dependencies (`npm install`), configure meta XML, ui-bundle.json, and CSP trusted sites
249
- - 3. Verify: Confirm directory structure and metadata files exist
348
+ - 2. Execute: Determine hosting target (Experience Site / Custom Application) FIRST. Run `sf template generate ui-bundle --template reactbasic`, install dependencies (`npm install`), configure meta XML (with `<target>`), ui-bundle.json, and CSP trusted sites.
349
+ - 3. Verify: Confirm directory structure and metadata files exist with hosting target specified
250
350
  - 4. Checkpoint: UI bundle scaffold is ready -- proceed to Phase 2
251
351
 
252
- **Phase 2 -- Features** (skip if no pre-built features needed)
352
+ **Phase 2 -- Features** (Required if prompt mentions feature keywords — see "Prompt Classification Keywords" above)
253
353
  - 1. Load skill: Invoke `experience-ui-bundle-features-generate`
254
354
  - 2. Execute: Install dependencies, search and install features, integrate example files
255
355
  - 3. Verify: Run `npm run build` to confirm features integrate cleanly
256
- - 4. Checkpoint: Features installed -- proceed to Phase 3
356
+ - **Trigger conditions**: See "Prompt Classification Keywords" above for the full keyword list (by category) and how negative phrasing is handled -- negating one category does not cancel triggers from another.
257
357
 
258
358
  **Phase 3 -- Data Access** (skip if no Salesforce data needed)
259
359
  - 1. Load skill: Invoke `experience-ui-bundle-salesforce-data-access`
260
- - 2. Execute: **Ground entities/fields against the org first** (per the skill), then author queries/mutations **from the verified names**, run codegen, wire into components. Never guess fields or hand-edit generated types.
261
- - 3. Verify: Run `npx eslint` on files with GraphQL queries
360
+ - 2. Execute: Check preconditions (authenticated org, npm dependencies installed). Fetch schema (`npm run graphql:schema`), guard against empty schema. Look up entities, generate queries/mutations, wire into components.
361
+ - 3. Verify: Run `npx eslint` on files with GraphQL queries. Verify schema is non-empty.
262
362
  - 4. Checkpoint: Data layer ready -- proceed to Phase 4
263
363
 
264
- **Phase 4 -- UI**
364
+ **Phase 4 -- UI** (ALWAYS REQUIRED - CANNOT BE SKIPPED)
265
365
  - 1. Load skill: Invoke `experience-ui-bundle-frontend-generate`
266
366
  - 2. Execute: Build layout, pages, components, navigation. Replace all boilerplate.
367
+ - If Phase 2 was skipped: Generate UI components from scratch without feature templates
368
+ - If Phase 3 was skipped: Use mock data or static content for display
369
+ - Phase 4 MUST execute even if prior phases were skipped
267
370
  - 3. Verify: Run lint and build -- 0 errors required
268
- - 4. Checkpoint: UI complete -- proceed to Phase 5
371
+ - 4. Checkpoint: UI complete -- proceed to Phase 5 if integrations needed, or stop here if building only
372
+
373
+ ⚠️ **CRITICAL**: Phase 4 generates the actual React user interface. Skipping it results in a UI bundle with only metadata and no user-facing pages or components. ALWAYS execute Phase 4 for every UI bundle build.
269
374
 
270
375
  **Phase 5 -- Integrations** (skip if not requested)
271
376
  - 1. Load skill(s): Invoke `experience-ui-bundle-agentforce-client-generate` (5a) and/or `experience-ui-bundle-file-upload-generate` (5b). If both are needed, they are independent and can be executed in parallel.
@@ -275,21 +380,76 @@ Execute each phase sequentially. Complete all steps within a phase before moving
275
380
 
276
381
  **Phase 6 -- Deployment**
277
382
  - 1. Load skill: Invoke `experience-ui-bundle-deploy`
278
- - 2. Execute: Follow the 7-step deployment sequence (auth, build, deploy, permissions, data, schema, final build)
279
- - 3. Verify: Confirm deployment succeeds and app is accessible
280
- - 4. Checkpoint: App deployed -- proceed to Phase 7 if needed
383
+ - 2. Execute: Check preconditions (authenticated org, successful build). Follow the 7-step deployment sequence (auth, build, deploy, permissions, data, schema, final build). When available, prefer using a project-level `scripts/org-setup.mjs` automation script over re-deriving the deployment flow each run. Guard the post-deploy schema re-fetch against an empty/stale result (Edge caching) before running final codegen -- retry rather than trusting an empty schema.
384
+ - 3. Verify: Confirm deployment succeeds, app is accessible, and the re-fetched schema is non-empty
385
+ - 4. Checkpoint: App deployed -- proceed to Phase 7 if hosting target deployment is needed
281
386
 
282
387
  **Phase 7a -- Experience Site** (skip if not requested or if Custom Application chosen)
283
388
  - 1. Load skill: Invoke `experience-ui-bundle-site-generate`
284
389
  - 2. Execute: Resolve properties, generate site metadata, deploy
285
- - 3. Verify: Confirm site URL is accessible
390
+ - 3. Verify: Confirm site URL is accessible (hosting target already verified by `scripts/check-hosting-target.sh` in trigger evaluation)
286
391
  - 4. Checkpoint: Site live -- build complete
392
+ - **Trigger conditions**: Run `scripts/check-hosting-target.sh` and check output for "ExperienceSite" OR prompt matches an Experience Site keyword in "Prompt Classification Keywords" above
393
+ - **Note**: The `<target>ExperienceSite</target>` was already set in meta XML during Phase 1 -- do not add it again
287
394
 
288
395
  **Phase 7b -- Custom Application** (skip if not requested or if Experience Site chosen)
289
396
  - 1. Load skill: Invoke `experience-ui-bundle-custom-app-generate`
290
- - 2. Execute: Resolve app properties, generate CustomApplication metadata, add CustomApplication target to meta XML
291
- - 3. Verify: Confirm app appears in App Launcher
397
+ - 2. Execute: Resolve app properties, generate CustomApplication metadata
398
+ - 3. Verify: Confirm app appears in App Launcher (hosting target already verified by `scripts/check-hosting-target.sh` in trigger evaluation)
292
399
  - 4. Checkpoint: App registered -- build complete
400
+ - **Trigger conditions**: Run `scripts/check-hosting-target.sh` and check output for "CustomApplication" OR prompt matches a Custom Application keyword in "Prompt Classification Keywords" above
401
+ - **Note**: The `<target>CustomApplication</target>` was already set in meta XML during Phase 1 -- do not add it again
402
+
403
+ ### STEP 2.5: Phase Completion Validation
404
+
405
+ Before proceeding to STEP 3 (Final Summary), validate that all required phases were executed:
406
+
407
+ **Critical Validation (MUST pass):**
408
+ - [ ] **Phase 0 (Template Offer & Bootstrap) executed**: If no template was used, run `scripts/check-sfdx-project.sh`. If it returns non-zero, STOP and report error:
409
+ ```text
410
+ ERROR: No SFDX project detected. Phase 0 (Bootstrap) is REQUIRED before scaffolding.
411
+ Run `sf project generate` (or create sfdx-project.json) before invoking
412
+ `sf template generate ui-bundle`.
413
+ ```
414
+ If a template was used in Phase 0, this check is satisfied by the template's own scaffolding — skip re-running the script.
415
+
416
+ - [ ] **Phase 1 hosting target resolved**: Run `scripts/check-hosting-target.sh`. If it returns non-zero, STOP and report error:
417
+ ```text
418
+ ERROR: Hosting target was not resolved in Phase 1. A UI bundle without a <target> in its
419
+ meta XML will not be visible in the org. Determine Experience Site vs Custom Application
420
+ (see "Prompt Classification Keywords" above; ask the user if ambiguous) before proceeding
421
+ past Phase 1 -- do not defer this to Phase 7 and do not record "none"/"skipped".
422
+ ```
423
+
424
+ - [ ] **Phase 4 (Frontend) executed**: If Phase 4 was NOT executed, STOP and report error:
425
+ ```text
426
+ ERROR: Phase 4 (UI/Frontend generation) is REQUIRED for all UI bundle apps.
427
+ Cannot complete build without generating the React user interface.
428
+ Please review the phase execution logic and ensure Phase 4 is always executed.
429
+ ```
430
+
431
+ - [ ] **Phase 7 hosting infrastructure deployed**: If neither Phase 7a nor Phase 7b was executed, STOP and report error:
432
+ ```text
433
+ ERROR: Hosting target infrastructure (Phase 7a Experience Site or Phase 7b Custom
434
+ Application) was not deployed. The app was built but is not reachable by any user.
435
+ Exactly one of Phase 7a/7b must run -- it is never optional or "skipped".
436
+ ```
437
+
438
+ **Warning Validation (log warnings, but can proceed):**
439
+ - [ ] **Phase 2 execution**: If Phase 2 was skipped but the prompt matches any keyword in "Prompt Classification Keywords" above (data features, navigation, authentication, integrations, or UI category):
440
+ ```text
441
+ WARNING: Phase 2 (Features) was skipped but prompt contains feature keywords.
442
+ This may indicate a trigger detection failure. Generated UI may be missing
443
+ required feature functionality. Consider re-running with Phase 2 included.
444
+ ```
445
+
446
+ - [ ] **Phase 3 execution**: If Phase 3 was skipped but prompt mentions Salesforce objects, "GraphQL", "data", or "query":
447
+ ```text
448
+ WARNING: Phase 3 (Data Access) was skipped but prompt mentions Salesforce data.
449
+ Generated UI may not connect to backend correctly. Verify data access is working.
450
+ ```
451
+
452
+ **Proceed to STEP 3 only if all Critical Validation checks pass (Phase 0, hosting target, Phase 4, Phase 7).**
293
453
 
294
454
  ### STEP 3: Final Summary
295
455
 
@@ -299,13 +459,14 @@ After all phases complete, present a build summary:
299
459
  UI Bundle App Build Complete: [App Name]
300
460
 
301
461
  PHASES COMPLETED:
302
- [x] Phase 1: Scaffolding -- [app name] UI bundle created
462
+ [x] Phase 0: Template Offer & Bootstrap -- [template used: <name> / declined; SFDX project verified/created]
463
+ [x] Phase 1: Scaffolding -- [app name] UI bundle created with hosting target [Experience Site / Custom Application]
303
464
  [x] Phase 2: Features -- [list of features installed, or "skipped"]
304
465
  [x] Phase 3: Data Access -- [list of entities wired up]
305
466
  [x] Phase 4: UI -- [count] pages, [count] components
306
467
  [x] Phase 5: Integrations -- [list or "none"]
307
468
  [x] Phase 6: Deployment -- deployed to [org]
308
- [x] Phase 7: Hosting Target -- [Experience Site URL / Custom Application name / "skipped"]
469
+ [x] Phase 7: Hosting Target -- [Experience Site URL / Custom Application name] **(never "skipped" -- Phase 1 requires a target, so exactly one of 7a/7b always runs)**
309
470
 
310
471
  FILES GENERATED:
311
472
  [list key files and their paths]
@@ -321,8 +482,10 @@ NEXT STEPS:
321
482
  Before presenting the build as complete, verify:
322
483
 
323
484
  - [ ] **Scaffold exists**: UI bundle directory with valid meta XML and ui-bundle.json
485
+ - [ ] **Hosting target resolved and deployed**: Meta XML contains `<target>ExperienceSite</target>` or `<target>CustomApplication</target>` (never left unset), and the matching Phase 7a or 7b infrastructure was generated and deployed -- not skipped
324
486
  - [ ] **Dependencies installed**: `node_modules/` exists and `package.json` has expected packages
325
487
  - [ ] **Build passes**: `npm run build` produces `dist/` with no errors
488
+ - [ ] **Dist content exists**: `dist/` contains index.html, JS/CSS bundles, and assets (not just an empty directory)
326
489
  - [ ] **Lint passes**: `npx eslint src/` reports 0 errors
327
490
  - [ ] **No boilerplate**: All placeholder text, default titles, and template content has been replaced
328
491
  - [ ] **Navigation works**: `appLayout.tsx` has real nav items matching created pages
@@ -337,6 +500,7 @@ Before presenting the build as complete, verify:
337
500
 
338
501
  - App purpose is too vague to determine pages or data needs
339
502
  - User wants features that conflict (e.g., "no authentication" + "show user-specific data")
503
+ - Hosting target cannot be determined (ask: "Is this for internal users (Custom Application) or external users (Experience Site)?")
340
504
  - Target org is unknown and deployment is requested
341
505
 
342
506
  ### Category 2: Log Warning, Continue