@salesforce/afv-skills 1.1.0 → 1.2.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 (103) hide show
  1. package/package.json +4 -4
  2. package/skills/agentforce-development/SKILL.md +427 -0
  3. package/skills/agentforce-development/assets/README-legacy.md +89 -0
  4. package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
  5. package/skills/agentforce-development/assets/agents/README.md +45 -0
  6. package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
  7. package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
  8. package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
  9. package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
  10. package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
  11. package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
  12. package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
  13. package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
  14. package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
  15. package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
  16. package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
  17. package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
  18. package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
  19. package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
  20. package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
  21. package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
  22. package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
  23. package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
  24. package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
  25. package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
  26. package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
  27. package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
  28. package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
  29. package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
  30. package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
  31. package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
  32. package/skills/agentforce-development/assets/patterns/README.md +254 -0
  33. package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
  34. package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
  35. package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
  36. package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
  37. package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
  38. package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
  39. package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
  40. package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
  41. package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
  42. package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
  43. package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
  44. package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
  45. package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
  46. package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
  47. package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
  48. package/skills/agentforce-development/assets/verification-gate.agent +208 -0
  49. package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
  50. package/skills/agentforce-development/references/actions-reference.md +592 -0
  51. package/skills/agentforce-development/references/agent-access-guide.md +72 -0
  52. package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
  53. package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
  54. package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
  55. package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
  56. package/skills/agentforce-development/references/agent-user-setup.md +526 -0
  57. package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
  58. package/skills/agentforce-development/references/known-issues.md +353 -0
  59. package/skills/agentforce-development/references/minimal-examples.md +67 -0
  60. package/skills/agentforce-development/references/production-gotchas.md +279 -0
  61. package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
  62. package/skills/agentforce-development/references/version-history.md +23 -0
  63. package/skills/generate-permission-set/SKILL.md +174 -0
  64. package/skills/salesforce-custom-application/SKILL.md +1 -2
  65. package/skills/salesforce-custom-field/SKILL.md +0 -4
  66. package/skills/salesforce-custom-tab/SKILL.md +84 -8
  67. package/skills/salesforce-experience-lwr-site/SKILL.md +196 -0
  68. package/skills/salesforce-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
  69. package/skills/salesforce-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
  70. package/skills/salesforce-experience-lwr-site/docs/configure-content-route.md +232 -0
  71. package/skills/salesforce-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
  72. package/skills/salesforce-experience-lwr-site/docs/configure-content-view.md +233 -0
  73. package/skills/salesforce-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
  74. package/skills/salesforce-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
  75. package/skills/salesforce-experience-lwr-site/docs/handle-ui-components.md +215 -0
  76. package/skills/salesforce-flow/SKILL.md +2 -2
  77. package/skills/salesforce-fragment/SKILL.md +85 -10
  78. package/skills/salesforce-lightning-app-build/SKILL.md +102 -10
  79. package/skills/apex-class/SKILL.md +0 -253
  80. package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
  81. package/skills/apex-class/examples/AccountSelector.cls +0 -193
  82. package/skills/apex-class/examples/AccountService.cls +0 -201
  83. package/skills/apex-class/templates/abstract.cls +0 -128
  84. package/skills/apex-class/templates/batch.cls +0 -125
  85. package/skills/apex-class/templates/domain.cls +0 -102
  86. package/skills/apex-class/templates/dto.cls +0 -108
  87. package/skills/apex-class/templates/exception.cls +0 -51
  88. package/skills/apex-class/templates/interface.cls +0 -25
  89. package/skills/apex-class/templates/queueable.cls +0 -92
  90. package/skills/apex-class/templates/schedulable.cls +0 -75
  91. package/skills/apex-class/templates/selector.cls +0 -92
  92. package/skills/apex-class/templates/service.cls +0 -69
  93. package/skills/apex-class/templates/utility.cls +0 -97
  94. package/skills/apex-test-class/SKILL.md +0 -101
  95. package/skills/apex-test-class/references/assertion-patterns.md +0 -209
  96. package/skills/apex-test-class/references/async-testing.md +0 -276
  97. package/skills/apex-test-class/references/mocking-patterns.md +0 -219
  98. package/skills/apex-test-class/references/test-data-factory.md +0 -176
  99. package/skills/deployment-readiness-check/SKILL.md +0 -257
  100. package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
  101. package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
  102. package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
  103. package/skills/salesforce-experience-site/SKILL.md +0 -178
@@ -1,219 +0,0 @@
1
- # Mocking Patterns
2
-
3
- ## HTTP Callout Mocking
4
-
5
- Apex doesn't allow real HTTP callouts in tests. Use `HttpCalloutMock` interface.
6
-
7
- ### Basic Mock Implementation
8
-
9
- ```apex
10
- @IsTest
11
- public class MockHttpResponse implements HttpCalloutMock {
12
-
13
- private Integer statusCode;
14
- private String body;
15
-
16
- public MockHttpResponse(Integer statusCode, String body) {
17
- this.statusCode = statusCode;
18
- this.body = body;
19
- }
20
-
21
- public HTTPResponse respond(HTTPRequest req) {
22
- HttpResponse res = new HttpResponse();
23
- res.setStatusCode(statusCode);
24
- res.setBody(body);
25
- res.setHeader('Content-Type', 'application/json');
26
- return res;
27
- }
28
- }
29
- ```
30
-
31
- ### Using the Mock
32
-
33
- ```apex
34
- @IsTest
35
- private static void shouldProcessApiResponse_WhenCalloutSucceeds() {
36
- // Given
37
- String mockResponse = '{"status": "success", "data": [{"id": "123"}]}';
38
- Test.setMock(HttpCalloutMock.class, new MockHttpResponse(200, mockResponse));
39
-
40
- // When
41
- Test.startTest();
42
- List<ExternalRecord> results = MyIntegrationService.fetchRecords();
43
- Test.stopTest();
44
-
45
- // Then
46
- System.Assert.areEqual(1, results.size(), 'Should parse one record from response');
47
- System.Assert.areEqual('123', results[0].externalId, 'Should extract correct ID');
48
- }
49
-
50
- @IsTest
51
- private static void shouldHandleError_WhenCalloutFails() {
52
- // Given
53
- String errorResponse = '{"error": "Unauthorized"}';
54
- Test.setMock(HttpCalloutMock.class, new MockHttpResponse(401, errorResponse));
55
-
56
- // When
57
- Test.startTest();
58
- CalloutResult result = MyIntegrationService.fetchRecords();
59
- Test.stopTest();
60
-
61
- // Then
62
- System.Assert.areEqual(false, result.isSuccess, 'Should indicate failure');
63
- System.Assert.isTrue(result.errorMessage.contains('Unauthorized'), 'Should capture error');
64
- }
65
- ```
66
-
67
- ### Multi-Request Mock
68
-
69
- For services making multiple callouts:
70
-
71
- ```apex
72
- @IsTest
73
- public class MultiRequestMock implements HttpCalloutMock {
74
-
75
- private Map<String, HttpResponse> endpointResponses;
76
-
77
- public MultiRequestMock(Map<String, HttpResponse> responses) {
78
- this.endpointResponses = responses;
79
- }
80
-
81
- public HTTPResponse respond(HTTPRequest req) {
82
- String endpoint = req.getEndpoint();
83
-
84
- for (String key : endpointResponses.keySet()) {
85
- if (endpoint.contains(key)) {
86
- return endpointResponses.get(key);
87
- }
88
- }
89
-
90
- // Default 404 if no match
91
- HttpResponse res = new HttpResponse();
92
- res.setStatusCode(404);
93
- res.setBody('{"error": "Not found"}');
94
- return res;
95
- }
96
- }
97
-
98
- // Usage:
99
- Map<String, HttpResponse> mocks = new Map<String, HttpResponse>();
100
-
101
- HttpResponse authResponse = new HttpResponse();
102
- authResponse.setStatusCode(200);
103
- authResponse.setBody('{"token": "abc123"}');
104
- mocks.put('/oauth/token', authResponse);
105
-
106
- HttpResponse dataResponse = new HttpResponse();
107
- dataResponse.setStatusCode(200);
108
- dataResponse.setBody('{"records": []}');
109
- mocks.put('/api/records', dataResponse);
110
-
111
- Test.setMock(HttpCalloutMock.class, new MultiRequestMock(mocks));
112
- ```
113
-
114
- ## StaticResourceCalloutMock
115
-
116
- For complex response bodies, store JSON in Static Resources:
117
-
118
- ```apex
119
- @IsTest
120
- private static void shouldParseComplexResponse() {
121
- StaticResourceCalloutMock mock = new StaticResourceCalloutMock();
122
- mock.setStaticResource('TestApiResponse'); // Static Resource name
123
- mock.setStatusCode(200);
124
- mock.setHeader('Content-Type', 'application/json');
125
-
126
- Test.setMock(HttpCalloutMock.class, mock);
127
-
128
- Test.startTest();
129
- Result r = MyService.callExternalApi();
130
- Test.stopTest();
131
-
132
- System.Assert.isNotNull(r, 'Should parse response');
133
- }
134
- ```
135
-
136
- ## Stub API (Enterprise Pattern)
137
-
138
- For mocking Apex class dependencies using `System.StubProvider`:
139
-
140
- ```apex
141
- @IsTest
142
- public class MyServiceMock implements System.StubProvider {
143
-
144
- public Object handleMethodCall(
145
- Object stubbedObject,
146
- String stubbedMethodName,
147
- Type returnType,
148
- List<Type> paramTypes,
149
- List<String> paramNames,
150
- List<Object> args
151
- ) {
152
- if (stubbedMethodName == 'getAccountData') {
153
- return new AccountData('Mock Account', 'Active');
154
- }
155
- return null;
156
- }
157
- }
158
-
159
- // Usage in test:
160
- @IsTest
161
- private static void shouldUseAccountData() {
162
- MyServiceMock mockProvider = new MyServiceMock();
163
- IMyService mockService = (IMyService)Test.createStub(IMyService.class, mockProvider);
164
-
165
- // Inject mock into class under test
166
- MyController controller = new MyController(mockService);
167
-
168
- Test.startTest();
169
- String result = controller.displayAccountInfo();
170
- Test.stopTest();
171
-
172
- System.Assert.isTrue(result.contains('Mock Account'), 'Should use mocked data');
173
- }
174
- ```
175
-
176
- ## Email Mocking
177
-
178
- Apex sends real emails by default. Use limits to verify:
179
-
180
- ```apex
181
- @IsTest
182
- private static void shouldSendEmail_WhenTriggered() {
183
- Integer emailsBefore = Limits.getEmailInvocations();
184
-
185
- Test.startTest();
186
- MyService.sendNotification(testContact);
187
- Test.stopTest();
188
-
189
- // Verify email was queued (not actually sent in tests)
190
- System.Assert.areEqual(
191
- emailsBefore + 1,
192
- Limits.getEmailInvocations(),
193
- 'One email should be sent'
194
- );
195
- }
196
- ```
197
-
198
- ## Platform Event Testing
199
-
200
- ```apex
201
- @IsTest
202
- private static void shouldPublishEvent_WhenRecordCreated() {
203
- Test.startTest();
204
-
205
- // Enable event delivery in test context
206
- Test.enableChangeDataCapture();
207
-
208
- Account acc = TestDataFactory.createAccount(true);
209
-
210
- // Deliver events
211
- Test.getEventBus().deliver();
212
-
213
- Test.stopTest();
214
-
215
- // Query platform event trigger results
216
- List<EventLog__c> logs = [SELECT Id FROM EventLog__c WHERE AccountId__c = :acc.Id];
217
- System.Assert.areEqual(1, logs.size(), 'Event handler should create log record');
218
- }
219
- ```
@@ -1,176 +0,0 @@
1
- # TestDataFactory Patterns
2
-
3
- ## Overview
4
-
5
- TestDataFactory is a centralized utility class for creating test records with sensible defaults. It ensures consistent test data across all test classes and reduces duplication.
6
-
7
- ## Base Template
8
-
9
- ```apex
10
- @IsTest
11
- public class TestDataFactory {
12
-
13
- // ============ ACCOUNTS ============
14
-
15
- public static List<Account> createAccounts(Integer count, Boolean doInsert) {
16
- List<Account> accounts = new List<Account>();
17
- for (Integer i = 0; i < count; i++) {
18
- accounts.add(new Account(
19
- Name = 'Test Account ' + i,
20
- BillingStreet = '123 Test St',
21
- BillingCity = 'San Francisco',
22
- BillingState = 'CA',
23
- BillingPostalCode = '94105',
24
- BillingCountry = 'USA',
25
- Industry = 'Technology',
26
- Type = 'Customer'
27
- ));
28
- }
29
- if (doInsert) insert accounts;
30
- return accounts;
31
- }
32
-
33
- public static Account createAccount(Boolean doInsert) {
34
- return createAccounts(1, doInsert)[0];
35
- }
36
-
37
- // ============ CONTACTS ============
38
-
39
- public static List<Contact> createContacts(List<Account> accounts, Integer countPerAccount, Boolean doInsert) {
40
- List<Contact> contacts = new List<Contact>();
41
- Integer index = 0;
42
- for (Account acc : accounts) {
43
- for (Integer i = 0; i < countPerAccount; i++) {
44
- contacts.add(new Contact(
45
- FirstName = 'Test',
46
- LastName = 'Contact ' + index,
47
- Email = 'test.contact' + index + '@example.com',
48
- Phone = '555-000-' + String.valueOf(index).leftPad(4, '0'),
49
- AccountId = acc.Id
50
- ));
51
- index++;
52
- }
53
- }
54
- if (doInsert) insert contacts;
55
- return contacts;
56
- }
57
-
58
- // ============ OPPORTUNITIES ============
59
-
60
- public static List<Opportunity> createOpportunities(List<Account> accounts, Integer countPerAccount, Boolean doInsert) {
61
- List<Opportunity> opps = new List<Opportunity>();
62
- Integer index = 0;
63
- for (Account acc : accounts) {
64
- for (Integer i = 0; i < countPerAccount; i++) {
65
- opps.add(new Opportunity(
66
- Name = 'Test Opportunity ' + index,
67
- AccountId = acc.Id,
68
- StageName = 'Prospecting',
69
- CloseDate = Date.today().addDays(30),
70
- Amount = 10000 + (index * 1000)
71
- ));
72
- index++;
73
- }
74
- }
75
- if (doInsert) insert opps;
76
- return opps;
77
- }
78
-
79
- // ============ USERS ============
80
-
81
- public static User createUser(String profileName, Boolean doInsert) {
82
- Profile p = [SELECT Id FROM Profile WHERE Name = :profileName LIMIT 1];
83
- String uniqueKey = String.valueOf(DateTime.now().getTime());
84
-
85
- User u = new User(
86
- FirstName = 'Test',
87
- LastName = 'User ' + uniqueKey,
88
- Email = 'testuser' + uniqueKey + '@example.com',
89
- Username = 'testuser' + uniqueKey + '@example.com.test',
90
- Alias = 'tuser',
91
- TimeZoneSidKey = 'America/Los_Angeles',
92
- LocaleSidKey = 'en_US',
93
- EmailEncodingKey = 'UTF-8',
94
- LanguageLocaleKey = 'en_US',
95
- ProfileId = p.Id
96
- );
97
- if (doInsert) insert u;
98
- return u;
99
- }
100
-
101
- // ============ CUSTOM OBJECTS ============
102
-
103
- // Add methods for your custom objects following the same pattern:
104
- // public static List<MyObject__c> createMyObjects(Integer count, Boolean doInsert) { ... }
105
- }
106
- ```
107
-
108
- ## Field Override Pattern
109
-
110
- Allow callers to override default values:
111
-
112
- ```apex
113
- public static Account createAccount(Map<String, Object> fieldOverrides, Boolean doInsert) {
114
- Account acc = new Account(
115
- Name = 'Test Account',
116
- Industry = 'Technology'
117
- );
118
-
119
- // Apply overrides
120
- for (String fieldName : fieldOverrides.keySet()) {
121
- acc.put(fieldName, fieldOverrides.get(fieldName));
122
- }
123
-
124
- if (doInsert) insert acc;
125
- return acc;
126
- }
127
-
128
- // Usage:
129
- Account acc = TestDataFactory.createAccount(new Map<String, Object>{
130
- 'Name' => 'Custom Name',
131
- 'Industry' => 'Healthcare'
132
- }, true);
133
- ```
134
-
135
- ## Handling Required Fields and Validation Rules
136
-
137
- ```apex
138
- public static Account createAccountWithRequiredFields(Boolean doInsert) {
139
- Account acc = new Account(
140
- Name = 'Test Account',
141
- // Required custom fields
142
- External_Id__c = 'EXT-' + String.valueOf(DateTime.now().getTime()),
143
- // Fields required by validation rules
144
- Phone = '555-123-4567',
145
- Website = 'https://example.com'
146
- );
147
- if (doInsert) insert acc;
148
- return acc;
149
- }
150
- ```
151
-
152
- ## Record Type Support
153
-
154
- ```apex
155
- public static Account createAccountByRecordType(String recordTypeName, Boolean doInsert) {
156
- Id recordTypeId = Schema.SObjectType.Account
157
- .getRecordTypeInfosByDeveloperName()
158
- .get(recordTypeName)
159
- .getRecordTypeId();
160
-
161
- Account acc = new Account(
162
- Name = 'Test Account',
163
- RecordTypeId = recordTypeId
164
- );
165
- if (doInsert) insert acc;
166
- return acc;
167
- }
168
- ```
169
-
170
- ## Best Practices
171
-
172
- 1. **Always include doInsert parameter** - Allows flexibility for tests that need to modify records before insert
173
- 2. **Use unique identifiers** - Include index or timestamp in Name/Email fields to avoid duplicates
174
- 3. **Set all required fields** - Include all fields required by validation rules
175
- 4. **Return the created records** - Enables chaining and further manipulation
176
- 5. **Create bulk methods first** - Single record methods should call bulk methods with count=1
@@ -1,257 +0,0 @@
1
- ---
2
- name: deployment-readiness-check
3
- description: Comprehensive pre-deployment validation checklist for Salesforce releases. Use before deploying to production to catch metadata issues, test coverage gaps, and configuration errors.
4
- license: Apache-2.0
5
- compatibility: Requires Salesforce CLI, jq, bash
6
- metadata:
7
- author: afv-library
8
- version: "1.0"
9
- allowed-tools: Bash Read
10
- ---
11
-
12
- ## When to Use This Skill
13
-
14
- Use this skill before deploying Salesforce metadata to production (or higher environments) to:
15
- - Validate metadata quality and completeness
16
- - Check test coverage meets organizational standards
17
- - Verify security settings and permissions
18
- - Identify configuration issues before deployment
19
- - Generate deployment documentation
20
-
21
- ## Prerequisites
22
-
23
- - Salesforce CLI installed and authenticated to target org
24
- - `jq` command-line JSON processor installed
25
- - Bash shell (Linux, macOS, or WSL on Windows)
26
- - Source metadata in SFDX project format
27
-
28
- ## Step 1: Run Metadata Validation
29
-
30
- Execute the validation script to check for common metadata issues:
31
-
32
- ```bash
33
- bash scripts/check_metadata.sh
34
- ```
35
-
36
- The script validates:
37
- - **Metadata format** - Ensures all XML is well-formed
38
- - **API versions** - Checks for outdated API versions
39
- - **Deprecated features** - Identifies deprecated components
40
- - **Naming conventions** - Validates standard naming patterns
41
- - **File completeness** - Ensures meta.xml files are present
42
-
43
- Review the output for any warnings or errors before proceeding.
44
-
45
- ## Step 2: Verify Test Coverage
46
-
47
- Check that your Apex test coverage meets organizational standards:
48
-
49
- ```bash
50
- # Run all tests and generate coverage report
51
- sf apex test run --test-level RunLocalTests --result-format human --code-coverage --wait 10
52
-
53
- # Check coverage percentage
54
- sf apex get test --test-run-id <test-run-id> --code-coverage --result-format json | jq '.summary.testRunCoverage'
55
- ```
56
-
57
- **Minimum requirements**:
58
- - Overall org coverage: ≥75% (Salesforce minimum)
59
- - Individual class coverage: ≥75% (recommended)
60
- - No classes with 0% coverage
61
-
62
- If coverage is below threshold:
63
- 1. Identify uncovered classes using the coverage report
64
- 2. Add test methods to increase coverage
65
- 3. Rerun tests until requirements are met
66
-
67
- ## Step 3: Security and Permissions Review
68
-
69
- Review security settings and permissions to ensure proper access controls:
70
-
71
- 1. **Profile and Permission Set Review**
72
- - Check that custom profiles/permission sets follow least-privilege principle
73
- - Verify admin permissions are not granted to standard users
74
- - Ensure sensitive objects have appropriate FLS
75
-
76
- 2. **Sharing Rules and OWD**
77
- - Review Organization-Wide Defaults are appropriate
78
- - Validate sharing rules grant necessary access without over-sharing
79
- - Check for public groups with excessive membership
80
-
81
- 3. **API Access**
82
- - Verify Connected Apps have appropriate scopes
83
- - Check Named Credentials use secure authentication
84
- - Review Remote Site Settings are necessary
85
-
86
- Consult the [security checklist reference](references/security_checklist.md) for detailed guidance.
87
-
88
- ## Step 4: Configuration Validation
89
-
90
- Verify configuration settings are deployment-ready:
91
-
92
- ```bash
93
- # Check for hardcoded URLs or IDs
94
- grep -r "https://.*\.salesforce\.com" force-app/main/default/
95
- grep -r "[a-zA-Z0-9]{15,18}" force-app/main/default/ | grep -v "meta.xml"
96
-
97
- # Validate Custom Settings and Custom Metadata
98
- sf project retrieve start --metadata CustomObject:*__c
99
- ```
100
-
101
- **Configuration checklist**:
102
- - [ ] No hardcoded production URLs in code
103
- - [ ] No hardcoded record IDs
104
- - [ ] Custom Settings configured correctly for target org
105
- - [ ] Custom Metadata Types populated appropriately
106
- - [ ] Email templates reference correct org email
107
- - [ ] Reports and Dashboards folders have correct permissions
108
-
109
- ## Step 5: Review Dependencies
110
-
111
- Check for dependency conflicts or missing components:
112
-
113
- ```bash
114
- # Generate dependency report
115
- sf project deploy validate --manifest package.xml --test-level RunLocalTests --verbose
116
-
117
- # Check for missing dependencies
118
- grep -i "error.*component" deployment_log.txt
119
- ```
120
-
121
- Common dependency issues:
122
- - Missing Custom Fields referenced in code
123
- - Validation Rules referencing deleted fields
124
- - Workflows or Process Builders using deprecated actions
125
- - Lightning Components with missing design resources
126
-
127
- See [dependency troubleshooting guide](references/dependency_resolution.md) for solutions.
128
-
129
- ## Step 6: Generate Deployment Checklist
130
-
131
- Use the deployment checklist template to document your release:
132
-
133
- ```bash
134
- cp assets/deployment_checklist.md deployment_checklist_$(date +%Y%m%d).md
135
- ```
136
-
137
- Fill out the checklist with:
138
- - [ ] Deployment date and time window
139
- - [ ] Components being deployed (attach package.xml)
140
- - [ ] Test execution results and coverage
141
- - [ ] Backup verification (data and metadata)
142
- - [ ] Rollback procedure documented
143
- - [ ] Stakeholders notified
144
- - [ ] Post-deployment validation steps
145
- - [ ] Monitoring plan for 24-48 hours
146
-
147
- ## Step 7: Execute Pre-Deployment Validation
148
-
149
- Run a validation-only deployment to catch issues before actual deployment:
150
-
151
- ```bash
152
- # Validate deployment without committing
153
- sf project deploy validate \
154
- --manifest package.xml \
155
- --test-level RunLocalTests \
156
- --verbose
157
-
158
- # Save the validation ID for quick deploy
159
- sf project deploy start --use-most-recent-validation --async
160
- ```
161
-
162
- **Benefits of validation**:
163
- - Tests run in production environment
164
- - Identifies environment-specific issues
165
- - Generates Quick Deploy ID for faster deployment
166
- - No changes committed until you confirm
167
-
168
- Review validation results and address any failures before scheduling deployment.
169
-
170
- ## Step 8: Prepare Rollback Plan
171
-
172
- Document rollback procedures before deploying:
173
-
174
- 1. **Backup current state**
175
- ```bash
176
- sf project retrieve start --manifest package.xml --target-org production
177
- git tag pre-deployment-$(date +%Y%m%d) && git push --tags
178
- ```
179
-
180
- 2. **Test rollback procedure** in sandbox:
181
- - Deploy previous version of metadata
182
- - Verify functionality is restored
183
- - Document any data cleanup required
184
-
185
- 3. **Establish rollback criteria**:
186
- - Critical bugs found within 2 hours
187
- - Core functionality broken
188
- - Performance degradation >50%
189
- - Data integrity issues
190
-
191
- See [rollback procedures reference](references/rollback_procedures.md) for detailed steps.
192
-
193
- ## Post-Deployment Validation
194
-
195
- After successful deployment, verify the release:
196
-
197
- 1. **Smoke tests** - Execute critical user workflows
198
- 2. **Monitor logs** - Check debug logs for errors (24-48 hours)
199
- 3. **Query test data** - Verify triggers and automation work correctly
200
- 4. **User acceptance** - Confirm with stakeholders functionality works
201
- 5. **Performance check** - Review governor limit usage in logs
202
-
203
- ## Common Issues and Solutions
204
-
205
- ### Issue: Test Coverage Drops Below 75%
206
-
207
- **Cause**: New Apex classes added without sufficient tests.
208
-
209
- **Solution**:
210
- 1. Run `sf apex test run --code-coverage` to identify gaps
211
- 2. Add test methods covering uncovered lines
212
- 3. Revalidate coverage
213
-
214
- ### Issue: Validation Fails with "Component Not Found"
215
-
216
- **Cause**: Missing dependency in package.xml.
217
-
218
- **Solution**:
219
- 1. Review error message for missing component
220
- 2. Add component to package.xml
221
- 3. Retrieve component from source org if needed
222
- 4. Revalidate
223
-
224
- ### Issue: Permission Errors After Deployment
225
-
226
- **Cause**: FLS or object permissions not deployed correctly.
227
-
228
- **Solution**:
229
- 1. Verify profiles/permission sets are in package.xml
230
- 2. Check that CustomObject metadata includes field permissions
231
- 3. Deploy profiles separately if needed
232
- 4. Use Permission Set Groups for complex permission hierarchies
233
-
234
- ## Best Practices
235
-
236
- 1. **Always validate before deploying** - Never deploy directly to production without validation
237
- 2. **Run full test suite** - Use RunLocalTests, not NoTestRun
238
- 3. **Deploy during maintenance windows** - Minimize impact on users
239
- 4. **Communicate with stakeholders** - Notify before, during, and after deployment
240
- 5. **Monitor post-deployment** - Watch logs and user feedback for 24-48 hours
241
- 6. **Document everything** - Maintain deployment logs and decisions
242
- 7. **Use version control tags** - Tag releases for easy rollback
243
-
244
- ## References
245
-
246
- - [Security Checklist](references/security_checklist.md) - Detailed security review steps
247
- - [Dependency Resolution Guide](references/dependency_resolution.md) - Solve dependency conflicts
248
- - [Rollback Procedures](references/rollback_procedures.md) - Step-by-step rollback guide
249
- - [Deployment Checklist Template](assets/deployment_checklist.md) - Reusable checklist
250
-
251
- ## Automation Opportunities
252
-
253
- Consider automating this skill:
254
- - **CI/CD Integration** - Run validation script in pipeline
255
- - **Scheduled Coverage Checks** - Monitor test coverage daily
256
- - **Auto-generated Documentation** - Create deployment notes from package.xml
257
- - **Slack/Email Notifications** - Alert team of deployment status