Skip to content

Commit 6154ab3

Browse files
W-21745944 dry run deployment and adding guardrails (#107)
W-21745944 make deployment command use --dry-run, add strict guardrails to prevent agent from further editing page Co-authored-by: Hemant Singh Bisht <hsinghbisht@salesforce.com>
1 parent bba4327 commit 6154ab3

1 file changed

Lines changed: 31 additions & 57 deletions

File tree

skills/generating-flexipage/SKILL.md

Lines changed: 31 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -43,41 +43,54 @@ sf template generate flexipage \
4343
--output-dir force-app/main/default/flexipages
4444
```
4545

46-
**Field Selection Guidelines:**
46+
**Note:** If the `sf template generate flexipage` command fails, recommend users upgrade to the latest version of the Salesforce CLI:
47+
```bash
48+
npm install -g @salesforce/cli@latest
49+
```
50+
51+
#### **Field Selection Guidelines**
4752
- **Validate fields exist**: Use MCP tools or describe commands to discover available fields for the object before specifying them in the command
4853
- **Prefer compound fields**: Use `Name` (not `FirstName`/`LastName`), `BillingAddress` (not `BillingStreet`/`BillingCity`/`BillingState`), `MailingAddress`, etc. when available
4954

50-
**Template-specific requirements:**
55+
#### **Template-specific requirements**
5156
- **RecordPage**: Requires `--sobject` (e.g., Account, Custom_Object__c)
5257
- **RecordPage**: Requires `--primary-field` and `--secondary-fields` for dynamic highlights, `--detail-fields` for full record details. Use the most important identifying field as primary, e.g. Name. Use the secondary fields (max 12, recommended 4-6) to show a summary of the record. Use detail fields to show the full details of the record.
5358
- **AppPage**: No additional requirements
5459
- **HomePage**: No additional requirements
5560

56-
**Note:** If the `sf template generate flexipage` command fails, recommend users upgrade to the latest version of the Salesforce CLI:
57-
```bash
58-
npm install -g @salesforce/cli@latest
59-
```
60-
61-
62-
**What you get:**
61+
#### **What you get**
6362
- Valid FlexiPage XML with correct structure
6463
- Pre-configured regions and basic components
6564
- Proper field references and facet structure
6665
- Ready to deploy as-is or enhance further
6766

6867
### Step 2: Deploy Base Page
6968

69+
Run a **dry-run** deployment of the entire project to validate the page and dependencies:
7070
```bash
71-
sf project deploy start --source-dir force-app/main/default/flexipages
71+
sf project deploy start --dry-run -d "force-app/main/default" --test-level NoTestRun --wait 10 --json
7272
```
7373

74-
**Deploy early, deploy often.** Start with the bootstrapped page, validate it works, then enhance.
74+
**Critical:** Fix any deployment errors before proceeding. The page must validate successfully.
75+
76+
### Step 3: **STOP - No Further Modifications**
7577

76-
### Step 3: Update and Redeploy
78+
**MANDATORY: Stop after Step 2. Do not add components or edit the FlexiPage XML.**
7779

78-
Modify the generated XML, adding components discovered via MCP. Deploy incrementally.
80+
This applies even if the user requested:
81+
- Additional components
82+
- Page customization
83+
- Component configuration
7984

80-
**Note:** Warn users to use caution with updates beyond this step when using this command.
85+
What you CAN do:
86+
- Suggest what components would be useful
87+
- Explain what enhancements are possible
88+
- Document what would need to be added manually
89+
90+
What you CANNOT do:
91+
- Modify the XML file
92+
- Add any components
93+
- Make any enhancements
8194

8295
---
8396

@@ -223,6 +236,10 @@ Every fieldInstance requires:
223236

224237
## Common Deployment Errors
225238

239+
### "We couldn't retrieve or load the information on the field"
240+
**Cause:** Invalid field API name - field doesn't exist on the object or has incorrect spelling
241+
**Fix:** Use MCP tools or describe commands to discover valid fields, then update the field reference (see Field Selection Guidelines)
242+
226243
### "Invalid field reference"
227244
**Cause:** Used `ObjectName.Field` instead of `Record.Field`
228245
**Fix:** Change to `Record.{FieldApiName}`
@@ -253,49 +270,6 @@ Every fieldInstance requires:
253270

254271
---
255272

256-
## Incremental Development Pattern
257-
258-
**Philosophy:** Deploy small, working increments. Don't build entire complex page at once.
259-
260-
**Process:**
261-
1. **CLI bootstrap** → Deploy base page
262-
2. **Add one component** → Deploy
263-
3. **Add another component** → Deploy
264-
4. **Repeat** until complete
265-
266-
**Benefits:**
267-
- Isolated errors (know exactly what broke)
268-
- Faster debugging
269-
- Build confidence with each success
270-
- Get user feedback early
271-
272-
**Anti-pattern:** Building entire complex page → one giant error cascade.
273-
274-
---
275-
276-
## Adding Components to Existing FlexiPages
277-
278-
### Workflow
279-
280-
When user provides an existing FlexiPage file path:
281-
282-
1. **Read the file** using native file I/O
283-
2. **Parse XML** to extract:
284-
- **ALL existing component identifiers** (search for all `<identifier>` tags)
285-
- **ALL existing region/facet names** (search for all `<name>` tags in `<flexiPageRegions>`)
286-
- Available regions (parse from file, don't assume names)
287-
- Existing facets
288-
3. **Verify uniqueness** - ensure your new identifiers and names don't conflict with ANY existing ones
289-
4. **Check if target facet exists** - if adding to a named facet like `detailTabContent` that already exists:
290-
- **Add new `<itemInstances>` to existing region** (don't create duplicate region)
291-
- **Insert before the closing `</flexiPageRegions>` tag of that region**
292-
5. **Generate component XML** (apply all rules from "Critical XML Rules" section)
293-
6. **Insert** into appropriate region or add itemInstances to existing facet
294-
7. **Write** modified XML back to file
295-
8. **Deploy**: `sf project deploy start --source-dir force-app/...`
296-
297-
---
298-
299273
### Generating Unique Identifiers
300274

301275
**CRITICAL: Before generating ANY new identifier or facet name, follow the rules in section 5 of "Critical XML Rules" above.**

0 commit comments

Comments
 (0)