scc-universal 1.1.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 (271) hide show
  1. package/.claude-plugin/plugin.json +44 -0
  2. package/.cursor/agents/deep-researcher.md +142 -0
  3. package/.cursor/agents/doc-updater.md +219 -0
  4. package/.cursor/agents/eval-runner.md +335 -0
  5. package/.cursor/agents/learning-engine.md +210 -0
  6. package/.cursor/agents/loop-operator.md +245 -0
  7. package/.cursor/agents/refactor-cleaner.md +119 -0
  8. package/.cursor/agents/sf-admin-agent.md +127 -0
  9. package/.cursor/agents/sf-agentforce-agent.md +126 -0
  10. package/.cursor/agents/sf-apex-agent.md +117 -0
  11. package/.cursor/agents/sf-architect.md +426 -0
  12. package/.cursor/agents/sf-aura-reviewer.md +369 -0
  13. package/.cursor/agents/sf-bugfix-agent.md +101 -0
  14. package/.cursor/agents/sf-flow-agent.md +155 -0
  15. package/.cursor/agents/sf-integration-agent.md +141 -0
  16. package/.cursor/agents/sf-lwc-agent.md +123 -0
  17. package/.cursor/agents/sf-review-agent.md +357 -0
  18. package/.cursor/agents/sf-visualforce-reviewer.md +465 -0
  19. package/.cursor/hooks/adapter.js +81 -0
  20. package/.cursor/hooks/after-file-edit.js +26 -0
  21. package/.cursor/hooks/after-mcp-execution.js +12 -0
  22. package/.cursor/hooks/after-shell-execution.js +30 -0
  23. package/.cursor/hooks/after-tab-file-edit.js +12 -0
  24. package/.cursor/hooks/before-mcp-execution.js +11 -0
  25. package/.cursor/hooks/before-read-file.js +13 -0
  26. package/.cursor/hooks/before-shell-execution.js +29 -0
  27. package/.cursor/hooks/before-submit-prompt.js +23 -0
  28. package/.cursor/hooks/pre-compact.js +7 -0
  29. package/.cursor/hooks/session-end.js +10 -0
  30. package/.cursor/hooks/session-start.js +10 -0
  31. package/.cursor/hooks/stop.js +18 -0
  32. package/.cursor/hooks/subagent-start.js +10 -0
  33. package/.cursor/hooks/subagent-stop.js +10 -0
  34. package/.cursor/hooks.json +107 -0
  35. package/.cursor/skills/aside/SKILL.md +115 -0
  36. package/.cursor/skills/checkpoint/SKILL.md +50 -0
  37. package/.cursor/skills/configure-scc/SKILL.md +160 -0
  38. package/.cursor/skills/continuous-agent-loop/SKILL.md +260 -0
  39. package/.cursor/skills/mcp-server-patterns/SKILL.md +142 -0
  40. package/.cursor/skills/model-route/SKILL.md +81 -0
  41. package/.cursor/skills/prompt-optimizer/SKILL.md +366 -0
  42. package/.cursor/skills/refactor-clean/SKILL.md +133 -0
  43. package/.cursor/skills/resume-session/SKILL.md +111 -0
  44. package/.cursor/skills/save-session/SKILL.md +183 -0
  45. package/.cursor/skills/search-first/SKILL.md +140 -0
  46. package/.cursor/skills/security-scan/SKILL.md +142 -0
  47. package/.cursor/skills/sessions/SKILL.md +124 -0
  48. package/.cursor/skills/sf-agentforce-development/SKILL.md +449 -0
  49. package/.cursor/skills/sf-apex-async-patterns/SKILL.md +324 -0
  50. package/.cursor/skills/sf-apex-best-practices/SKILL.md +421 -0
  51. package/.cursor/skills/sf-apex-constraints/SKILL.md +79 -0
  52. package/.cursor/skills/sf-apex-cursor/SKILL.md +336 -0
  53. package/.cursor/skills/sf-apex-enterprise-patterns/SKILL.md +344 -0
  54. package/.cursor/skills/sf-apex-testing/SKILL.md +407 -0
  55. package/.cursor/skills/sf-api-design/SKILL.md +237 -0
  56. package/.cursor/skills/sf-approval-processes/SKILL.md +312 -0
  57. package/.cursor/skills/sf-aura-development/SKILL.md +260 -0
  58. package/.cursor/skills/sf-build-fix/SKILL.md +120 -0
  59. package/.cursor/skills/sf-data-modeling/SKILL.md +274 -0
  60. package/.cursor/skills/sf-debugging/SKILL.md +362 -0
  61. package/.cursor/skills/sf-deployment/SKILL.md +291 -0
  62. package/.cursor/skills/sf-deployment-constraints/SKILL.md +153 -0
  63. package/.cursor/skills/sf-devops-ci-cd/SKILL.md +322 -0
  64. package/.cursor/skills/sf-docs-lookup/SKILL.md +100 -0
  65. package/.cursor/skills/sf-e2e-testing/SKILL.md +321 -0
  66. package/.cursor/skills/sf-experience-cloud/SKILL.md +248 -0
  67. package/.cursor/skills/sf-flow-development/SKILL.md +376 -0
  68. package/.cursor/skills/sf-governor-limits/SKILL.md +319 -0
  69. package/.cursor/skills/sf-harness-audit/SKILL.md +139 -0
  70. package/.cursor/skills/sf-help/SKILL.md +156 -0
  71. package/.cursor/skills/sf-integration/SKILL.md +479 -0
  72. package/.cursor/skills/sf-lwc-constraints/SKILL.md +128 -0
  73. package/.cursor/skills/sf-lwc-development/SKILL.md +302 -0
  74. package/.cursor/skills/sf-lwc-testing/SKILL.md +387 -0
  75. package/.cursor/skills/sf-metadata-management/SKILL.md +285 -0
  76. package/.cursor/skills/sf-platform-events-cdc/SKILL.md +372 -0
  77. package/.cursor/skills/sf-quickstart/SKILL.md +170 -0
  78. package/.cursor/skills/sf-security/SKILL.md +330 -0
  79. package/.cursor/skills/sf-security-constraints/SKILL.md +125 -0
  80. package/.cursor/skills/sf-soql-constraints/SKILL.md +129 -0
  81. package/.cursor/skills/sf-soql-optimization/SKILL.md +353 -0
  82. package/.cursor/skills/sf-tdd-workflow/SKILL.md +332 -0
  83. package/.cursor/skills/sf-testing-constraints/SKILL.md +198 -0
  84. package/.cursor/skills/sf-trigger-constraints/SKILL.md +88 -0
  85. package/.cursor/skills/sf-trigger-frameworks/SKILL.md +343 -0
  86. package/.cursor/skills/sf-visualforce-development/SKILL.md +259 -0
  87. package/.cursor/skills/strategic-compact/SKILL.md +205 -0
  88. package/.cursor/skills/update-docs/SKILL.md +162 -0
  89. package/.cursor/skills/update-platform-docs/SKILL.md +86 -0
  90. package/.cursor-plugin/plugin.json +26 -0
  91. package/LICENSE +21 -0
  92. package/README.md +522 -0
  93. package/agents/deep-researcher.md +145 -0
  94. package/agents/doc-updater.md +222 -0
  95. package/agents/eval-runner.md +340 -0
  96. package/agents/learning-engine.md +211 -0
  97. package/agents/loop-operator.md +247 -0
  98. package/agents/refactor-cleaner.md +122 -0
  99. package/agents/sf-admin-agent.md +131 -0
  100. package/agents/sf-agentforce-agent.md +132 -0
  101. package/agents/sf-apex-agent.md +124 -0
  102. package/agents/sf-architect.md +435 -0
  103. package/agents/sf-aura-reviewer.md +372 -0
  104. package/agents/sf-bugfix-agent.md +105 -0
  105. package/agents/sf-flow-agent.md +159 -0
  106. package/agents/sf-integration-agent.md +146 -0
  107. package/agents/sf-lwc-agent.md +127 -0
  108. package/agents/sf-review-agent.md +366 -0
  109. package/agents/sf-visualforce-reviewer.md +468 -0
  110. package/assets/logo.svg +18 -0
  111. package/docs/ARCHITECTURE.md +133 -0
  112. package/docs/authoring-guide.md +373 -0
  113. package/docs/hook-development.md +578 -0
  114. package/docs/token-optimization.md +139 -0
  115. package/docs/workflow-examples.md +645 -0
  116. package/examples/agentforce-action/README.md +227 -0
  117. package/examples/apex-trigger-handler/README.md +114 -0
  118. package/examples/devops-pipeline/README.md +325 -0
  119. package/examples/flow-automation/README.md +188 -0
  120. package/examples/integration-pattern/README.md +416 -0
  121. package/examples/lwc-component/README.md +180 -0
  122. package/examples/platform-events/README.md +492 -0
  123. package/examples/scratch-org-setup/README.md +138 -0
  124. package/examples/security-audit/README.md +244 -0
  125. package/examples/visualforce-migration/README.md +314 -0
  126. package/hooks/hooks.json +338 -0
  127. package/hooks/memory-persistence/README.md +73 -0
  128. package/manifests/install-modules.json +217 -0
  129. package/manifests/install-profiles.json +17 -0
  130. package/mcp-configs/mcp-servers.json +19 -0
  131. package/package.json +89 -0
  132. package/schemas/hooks.schema.json +123 -0
  133. package/schemas/install-modules.schema.json +76 -0
  134. package/schemas/install-profiles.schema.json +28 -0
  135. package/schemas/install-state.schema.json +73 -0
  136. package/schemas/package-manager.schema.json +18 -0
  137. package/schemas/plugin.schema.json +112 -0
  138. package/schemas/scc-install-config.schema.json +29 -0
  139. package/schemas/state-store.schema.json +111 -0
  140. package/scripts/cli/install-apply.js +170 -0
  141. package/scripts/cli/uninstall.js +193 -0
  142. package/scripts/hooks/check-console-log.js +101 -0
  143. package/scripts/hooks/check-hook-enabled.js +17 -0
  144. package/scripts/hooks/check-platform-docs-age.js +48 -0
  145. package/scripts/hooks/cost-tracker.js +78 -0
  146. package/scripts/hooks/doc-file-warning.js +63 -0
  147. package/scripts/hooks/evaluate-session.js +98 -0
  148. package/scripts/hooks/governor-check.js +220 -0
  149. package/scripts/hooks/learning-observe.sh +206 -0
  150. package/scripts/hooks/mcp-health-check.js +588 -0
  151. package/scripts/hooks/post-bash-build-complete.js +34 -0
  152. package/scripts/hooks/post-bash-pr-created.js +43 -0
  153. package/scripts/hooks/post-edit-console-warn.js +61 -0
  154. package/scripts/hooks/post-edit-format.js +79 -0
  155. package/scripts/hooks/post-edit-typecheck.js +98 -0
  156. package/scripts/hooks/post-write.js +168 -0
  157. package/scripts/hooks/pre-bash-git-push-reminder.js +35 -0
  158. package/scripts/hooks/pre-bash-tmux-reminder.js +47 -0
  159. package/scripts/hooks/pre-compact.js +51 -0
  160. package/scripts/hooks/pre-tool-use.js +163 -0
  161. package/scripts/hooks/pre-write-doc-warn.js +9 -0
  162. package/scripts/hooks/quality-gate.js +251 -0
  163. package/scripts/hooks/run-with-flags-shell.sh +32 -0
  164. package/scripts/hooks/run-with-flags.js +135 -0
  165. package/scripts/hooks/session-end-marker.js +29 -0
  166. package/scripts/hooks/session-end.js +311 -0
  167. package/scripts/hooks/session-start.js +202 -0
  168. package/scripts/hooks/sfdx-scanner-check.js +142 -0
  169. package/scripts/hooks/sfdx-validate.js +119 -0
  170. package/scripts/hooks/stop-hook.js +170 -0
  171. package/scripts/hooks/suggest-compact.js +67 -0
  172. package/scripts/lib/agent-adapter.js +82 -0
  173. package/scripts/lib/apex-analysis.js +194 -0
  174. package/scripts/lib/hook-flags.js +74 -0
  175. package/scripts/lib/install-config.js +73 -0
  176. package/scripts/lib/install-executor.js +363 -0
  177. package/scripts/lib/install-state.js +121 -0
  178. package/scripts/lib/orchestration-session.js +299 -0
  179. package/scripts/lib/package-manager.js +124 -0
  180. package/scripts/lib/project-detect.js +228 -0
  181. package/scripts/lib/schema-validator.js +190 -0
  182. package/scripts/lib/skill-adapter.js +100 -0
  183. package/scripts/lib/state-store.js +376 -0
  184. package/scripts/lib/tmux-worktree-orchestrator.js +598 -0
  185. package/scripts/lib/utils.js +313 -0
  186. package/scripts/scc.js +164 -0
  187. package/skills/_reference/AGENTFORCE_PATTERNS.md +112 -0
  188. package/skills/_reference/APEX_CURSOR.md +159 -0
  189. package/skills/_reference/API_VERSIONS.md +78 -0
  190. package/skills/_reference/APPROVAL_PROCESSES.md +105 -0
  191. package/skills/_reference/ASYNC_PATTERNS.md +163 -0
  192. package/skills/_reference/AURA_COMPONENTS.md +146 -0
  193. package/skills/_reference/DATA_MIGRATION_PATTERNS.md +151 -0
  194. package/skills/_reference/DATA_MODELING.md +124 -0
  195. package/skills/_reference/DEBUGGING_TOOLS.md +140 -0
  196. package/skills/_reference/DEPLOYMENT_CHECKLIST.md +87 -0
  197. package/skills/_reference/DEPRECATIONS.md +79 -0
  198. package/skills/_reference/DOCKER_CI_PATTERNS.md +138 -0
  199. package/skills/_reference/ENTERPRISE_PATTERNS.md +122 -0
  200. package/skills/_reference/EXPERIENCE_CLOUD.md +143 -0
  201. package/skills/_reference/FLOW_PATTERNS.md +113 -0
  202. package/skills/_reference/GOVERNOR_LIMITS.md +77 -0
  203. package/skills/_reference/INTEGRATION_PATTERNS.md +105 -0
  204. package/skills/_reference/LWC_PATTERNS.md +79 -0
  205. package/skills/_reference/METADATA_TYPES.md +115 -0
  206. package/skills/_reference/NAMING_CONVENTIONS.md +84 -0
  207. package/skills/_reference/PACKAGE_DEVELOPMENT.md +150 -0
  208. package/skills/_reference/PLATFORM_EVENTS.md +121 -0
  209. package/skills/_reference/REPORTING_API.md +143 -0
  210. package/skills/_reference/SCRATCH_ORG_PATTERNS.md +126 -0
  211. package/skills/_reference/SECURITY_PATTERNS.md +127 -0
  212. package/skills/_reference/SHARING_MODEL.md +120 -0
  213. package/skills/_reference/SOQL_PATTERNS.md +119 -0
  214. package/skills/_reference/TESTING_STANDARDS.md +96 -0
  215. package/skills/_reference/TRIGGER_PATTERNS.md +114 -0
  216. package/skills/_reference/VISUALFORCE_PATTERNS.md +121 -0
  217. package/skills/aside/SKILL.md +118 -0
  218. package/skills/checkpoint/SKILL.md +53 -0
  219. package/skills/configure-scc/SKILL.md +163 -0
  220. package/skills/continuous-agent-loop/SKILL.md +264 -0
  221. package/skills/mcp-server-patterns/SKILL.md +146 -0
  222. package/skills/model-route/SKILL.md +84 -0
  223. package/skills/prompt-optimizer/SKILL.md +369 -0
  224. package/skills/refactor-clean/SKILL.md +136 -0
  225. package/skills/resume-session/SKILL.md +114 -0
  226. package/skills/save-session/SKILL.md +186 -0
  227. package/skills/search-first/SKILL.md +144 -0
  228. package/skills/security-scan/SKILL.md +146 -0
  229. package/skills/sessions/SKILL.md +127 -0
  230. package/skills/sf-agentforce-development/SKILL.md +450 -0
  231. package/skills/sf-apex-async-patterns/SKILL.md +326 -0
  232. package/skills/sf-apex-best-practices/SKILL.md +425 -0
  233. package/skills/sf-apex-constraints/SKILL.md +81 -0
  234. package/skills/sf-apex-cursor/SKILL.md +338 -0
  235. package/skills/sf-apex-enterprise-patterns/SKILL.md +348 -0
  236. package/skills/sf-apex-testing/SKILL.md +409 -0
  237. package/skills/sf-api-design/SKILL.md +238 -0
  238. package/skills/sf-approval-processes/SKILL.md +315 -0
  239. package/skills/sf-aura-development/SKILL.md +263 -0
  240. package/skills/sf-build-fix/SKILL.md +121 -0
  241. package/skills/sf-data-modeling/SKILL.md +278 -0
  242. package/skills/sf-debugging/SKILL.md +363 -0
  243. package/skills/sf-deployment/SKILL.md +295 -0
  244. package/skills/sf-deployment-constraints/SKILL.md +155 -0
  245. package/skills/sf-devops-ci-cd/SKILL.md +325 -0
  246. package/skills/sf-docs-lookup/SKILL.md +103 -0
  247. package/skills/sf-e2e-testing/SKILL.md +324 -0
  248. package/skills/sf-experience-cloud/SKILL.md +249 -0
  249. package/skills/sf-flow-development/SKILL.md +377 -0
  250. package/skills/sf-governor-limits/SKILL.md +323 -0
  251. package/skills/sf-harness-audit/SKILL.md +142 -0
  252. package/skills/sf-help/SKILL.md +159 -0
  253. package/skills/sf-integration/SKILL.md +483 -0
  254. package/skills/sf-lwc-constraints/SKILL.md +130 -0
  255. package/skills/sf-lwc-development/SKILL.md +303 -0
  256. package/skills/sf-lwc-testing/SKILL.md +388 -0
  257. package/skills/sf-metadata-management/SKILL.md +288 -0
  258. package/skills/sf-platform-events-cdc/SKILL.md +375 -0
  259. package/skills/sf-quickstart/SKILL.md +173 -0
  260. package/skills/sf-security/SKILL.md +334 -0
  261. package/skills/sf-security-constraints/SKILL.md +127 -0
  262. package/skills/sf-soql-constraints/SKILL.md +131 -0
  263. package/skills/sf-soql-optimization/SKILL.md +354 -0
  264. package/skills/sf-tdd-workflow/SKILL.md +336 -0
  265. package/skills/sf-testing-constraints/SKILL.md +200 -0
  266. package/skills/sf-trigger-constraints/SKILL.md +90 -0
  267. package/skills/sf-trigger-frameworks/SKILL.md +347 -0
  268. package/skills/sf-visualforce-development/SKILL.md +260 -0
  269. package/skills/strategic-compact/SKILL.md +208 -0
  270. package/skills/update-docs/SKILL.md +165 -0
  271. package/skills/update-platform-docs/SKILL.md +90 -0
@@ -0,0 +1,315 @@
1
+ ---
2
+ name: sf-approval-processes
3
+ description: >-
4
+ Use when designing Salesforce Apex approval processes, multi-step approvals,
5
+ or Flow-integrated submissions. Do NOT use for general Apex or Flow-only work.
6
+ origin: SCC
7
+ user-invocable: false
8
+ ---
9
+
10
+ # Salesforce Approval Processes
11
+
12
+ @../_reference/APPROVAL_PROCESSES.md
13
+
14
+ ## When to Use
15
+
16
+ - Designing multi-step approval workflows (discounts, expenses, contracts)
17
+ - Building Apex-driven approval submissions or programmatic approvals/rejections
18
+ - Integrating approval logic with Flows (Spring '26 Integrated Approval Screen component)
19
+ - Troubleshooting approval routing, locked records, or missing approval history
20
+ - Migrating from email-based approvals to in-app approval workflows
21
+
22
+ ---
23
+
24
+ ## Approval Process Architecture
25
+
26
+ ```
27
+ ┌─────────────────────────────────────────────────────┐
28
+ │ Approval Process │
29
+ ├─────────────────────────────────────────────────────┤
30
+ │ Entry Criteria │ WHO can submit? WHEN? │
31
+ │ Initial Submitter │ Record owner, specific users │
32
+ ├─────────────────────────────────────────────────────┤
33
+ │ Step 1: Manager │ Approver: Manager field │
34
+ │ Step 2: VP │ Approver: Related user field │
35
+ │ Step 3: Finance │ Approver: Queue │
36
+ ├─────────────────────────────────────────────────────┤
37
+ │ Initial Actions │ Lock record, set Status │
38
+ │ Approval Actions │ Unlock, update field, email │
39
+ │ Rejection Actions │ Unlock, set Status to Rejected │
40
+ │ Recall Actions │ Unlock, clear approval fields │
41
+ └─────────────────────────────────────────────────────┘
42
+ ```
43
+
44
+ ### Entry Criteria
45
+
46
+ ```
47
+ Amount__c > 10000 AND Status__c = 'Draft'
48
+ RecordType.Name = 'Enterprise' AND Discount__c > 20
49
+
50
+ Formula:
51
+ AND(Amount__c > 10000, ISPICKVAL(Status__c, 'Draft'), NOT(ISBLANK(OwnerId)))
52
+ ```
53
+
54
+ ### Approval Steps
55
+
56
+ | Property | Options |
57
+ |---|---|
58
+ | Approver | User field, Manager field, Queue, Related user |
59
+ | Criteria | All records OR filter criteria (step-specific) |
60
+ | Reject behavior | Final rejection OR go to previous step |
61
+ | Unanimity | All must approve OR first response |
62
+
63
+ ### Parallel Approvals
64
+
65
+ - **Unanimous**: All assigned approvers must approve
66
+ - **First Response**: First approver's decision applies
67
+ - For true parallel independent steps (Legal AND Finance simultaneously), use multiple processes or custom Apex
68
+
69
+ ---
70
+
71
+ ## Approval Actions
72
+
73
+ ### Initial Submission Actions
74
+
75
+ - Field Update: `Status__c = "Pending Approval"`
76
+ - Email Alert: Notify approver(s)
77
+ - Record Lock: Prevent edits during approval
78
+ - Outbound Message: Notify external system
79
+
80
+ ### Final Approval Actions
81
+
82
+ - Field Update: `Status__c = "Approved"`
83
+ - Email Alert: Notify submitter
84
+ - Record Unlock: Allow edits again
85
+
86
+ ### Final Rejection Actions
87
+
88
+ - Field Update: `Status__c = "Rejected"`
89
+ - Email Alert: Notify submitter with rejection reason
90
+ - Record Unlock
91
+
92
+ ---
93
+
94
+ ## Apex Approval Processing
95
+
96
+ ### Submitting a Record for Approval
97
+
98
+ ```apex
99
+ public class ApprovalService {
100
+ public static void submitForApproval(Id recordId, String comments) {
101
+ Approval.ProcessSubmitRequest request = new Approval.ProcessSubmitRequest();
102
+ request.setObjectId(recordId);
103
+ request.setSubmitterId(UserInfo.getUserId());
104
+ request.setComments(comments);
105
+
106
+ Approval.ProcessResult result = Approval.process(request);
107
+ if (result.isSuccess()) {
108
+ System.debug('Submitted. Instance ID: ' + result.getInstanceId());
109
+ } else {
110
+ for (Database.Error err : result.getErrors()) {
111
+ System.debug(LoggingLevel.ERROR, 'Failed: ' + err.getMessage());
112
+ }
113
+ }
114
+ }
115
+ }
116
+ ```
117
+
118
+ ### Approving or Rejecting Programmatically
119
+
120
+ ```apex
121
+ public static void approveRecord(Id workItemId, String comments) {
122
+ Approval.ProcessWorkitemRequest request = new Approval.ProcessWorkitemRequest();
123
+ request.setWorkitemId(workItemId);
124
+ request.setAction('Approve');
125
+ request.setComments(comments);
126
+
127
+ Approval.ProcessResult result = Approval.process(request);
128
+ if (!result.isSuccess()) {
129
+ throw new ApprovalException('Approval failed: ' + result.getErrors());
130
+ }
131
+ }
132
+
133
+ public static void rejectRecord(Id workItemId, String comments) {
134
+ Approval.ProcessWorkitemRequest request = new Approval.ProcessWorkitemRequest();
135
+ request.setWorkitemId(workItemId);
136
+ request.setAction('Reject');
137
+ request.setComments(comments);
138
+
139
+ Approval.ProcessResult result = Approval.process(request);
140
+ if (!result.isSuccess()) {
141
+ throw new ApprovalException('Rejection failed: ' + result.getErrors());
142
+ }
143
+ }
144
+ ```
145
+
146
+ ### Querying Approval Status
147
+
148
+ ```apex
149
+ // Pending work items for current user
150
+ List<ProcessInstanceWorkitem> pendingItems = [
151
+ SELECT Id, ProcessInstance.TargetObjectId, ProcessInstance.Status,
152
+ ProcessInstance.TargetObject.Name, CreatedDate
153
+ FROM ProcessInstanceWorkitem
154
+ WHERE ActorId = :UserInfo.getUserId()
155
+ ORDER BY CreatedDate DESC
156
+ ];
157
+
158
+ // Approval history for a record
159
+ List<ProcessInstanceStep> history = [
160
+ SELECT StepStatus, Comments, Actor.Name, CreatedDate
161
+ FROM ProcessInstanceStep
162
+ WHERE ProcessInstance.TargetObjectId = :recordId
163
+ ORDER BY CreatedDate ASC
164
+ ];
165
+
166
+ // Active work item for a specific record
167
+ ProcessInstanceWorkitem workItem = [
168
+ SELECT Id FROM ProcessInstanceWorkitem
169
+ WHERE ProcessInstance.TargetObjectId = :recordId
170
+ AND ProcessInstance.Status = 'Pending'
171
+ LIMIT 1
172
+ ];
173
+ ```
174
+
175
+ ---
176
+
177
+ ## Flow Integration
178
+
179
+ ### Submitting for Approval from Flow
180
+
181
+ Use the **Submit for Approval** action element: specify the record ID, optionally the approval process name, submitter, and comments.
182
+
183
+ ### Spring '26 — Integrated Approval Screen Component
184
+
185
+ Screen Flows can include an Integrated Approval component for in-flow approve/reject:
186
+
187
+ ```
188
+ Screen Flow:
189
+ 1. Show Record Details
190
+ 2. Integrated Approval Component (history, Approve/Reject buttons, comments)
191
+ 3. Decision: Check outcome
192
+ 4. Update Records based on outcome
193
+ ```
194
+
195
+ ### Dynamic Approvers via Flow
196
+
197
+ ```
198
+ Autolaunched Flow (invoked by Approval Process):
199
+ 1. Get Records: record's Region__c and Amount__c
200
+ 2. Decision: Route by amount and region
201
+ - > 500K → VP Finance
202
+ - > 100K → Regional Manager
203
+ - Otherwise → Direct Manager
204
+ 3. Return approver User ID
205
+ ```
206
+
207
+ ---
208
+
209
+ ## Design Patterns
210
+
211
+ ### Delegation and Backup Approvers
212
+
213
+ - Configure Delegated Approvers in user settings for vacation coverage
214
+ - Use Queues as approvers so any queue member can approve
215
+ - Set approval step timeout for auto-escalation
216
+
217
+ ### Approval History Tracking
218
+
219
+ ```apex
220
+ public static List<Map<String, Object>> getApprovalHistory(Id recordId) {
221
+ List<Map<String, Object>> trail = new List<Map<String, Object>>();
222
+ for (ProcessInstance pi : [
223
+ SELECT Id, Status, CreatedDate,
224
+ (SELECT StepStatus, Comments, Actor.Name, CreatedDate
225
+ FROM StepsAndWorkitems ORDER BY CreatedDate)
226
+ FROM ProcessInstance
227
+ WHERE TargetObjectId = :recordId
228
+ ORDER BY CreatedDate DESC
229
+ ]) {
230
+ for (ProcessInstanceHistory step : pi.StepsAndWorkitems) {
231
+ trail.add(new Map<String, Object>{
232
+ 'status' => step.StepStatus,
233
+ 'approver' => step.Actor.Name,
234
+ 'comments' => step.Comments,
235
+ 'date' => step.CreatedDate
236
+ });
237
+ }
238
+ }
239
+ return trail;
240
+ }
241
+ ```
242
+
243
+ ---
244
+
245
+ ## Testing Approval Processes
246
+
247
+ These tests require an approval process to be deployed in the org's metadata. Approval processes cannot be created programmatically in tests.
248
+
249
+ ```apex
250
+ @isTest
251
+ static void testApprovalSubmission() {
252
+ Account testAccount = new Account(Name = 'Test Account', AnnualRevenue = 50000);
253
+ insert testAccount;
254
+
255
+ Test.startTest();
256
+ Approval.ProcessSubmitRequest request = new Approval.ProcessSubmitRequest();
257
+ request.setObjectId(testAccount.Id);
258
+ request.setSubmitterId(UserInfo.getUserId());
259
+ Approval.ProcessResult result = Approval.process(request);
260
+ Test.stopTest();
261
+
262
+ System.assert(result.isSuccess(), 'Approval submission should succeed');
263
+ System.assertEquals('Pending', result.getInstanceStatus());
264
+ }
265
+
266
+ @isTest
267
+ static void testApprovalProcess() {
268
+ Account testAccount = new Account(Name = 'Test', AnnualRevenue = 50000);
269
+ insert testAccount;
270
+
271
+ Approval.ProcessSubmitRequest submitReq = new Approval.ProcessSubmitRequest();
272
+ submitReq.setObjectId(testAccount.Id);
273
+ Approval.ProcessResult submitResult = Approval.process(submitReq);
274
+
275
+ Id workItemId = submitResult.getNewWorkitemIds()[0];
276
+
277
+ Approval.ProcessWorkitemRequest approveReq = new Approval.ProcessWorkitemRequest();
278
+ approveReq.setWorkitemId(workItemId);
279
+ approveReq.setAction('Approve');
280
+ approveReq.setComments('Looks good');
281
+
282
+ Test.startTest();
283
+ Approval.ProcessResult approveResult = Approval.process(approveReq);
284
+ Test.stopTest();
285
+
286
+ System.assert(approveResult.isSuccess());
287
+ System.assertEquals('Approved', approveResult.getInstanceStatus());
288
+ }
289
+ ```
290
+
291
+ ---
292
+
293
+ ## Metadata Deployment
294
+
295
+ ```
296
+ approvalProcesses/
297
+ Discount_Approval.approvalProcess-meta.xml
298
+ ```
299
+
300
+ Include in `package.xml`:
301
+
302
+ ```xml
303
+ <types>
304
+ <members>Opportunity.Discount_Approval</members>
305
+ <name>ApprovalProcess</name>
306
+ </types>
307
+ ```
308
+
309
+ Approval processes reference users, queues, and email templates. Ensure dependencies exist in the target org before deployment.
310
+
311
+ ---
312
+
313
+ ## Related
314
+
315
+ - **Constraints**: `sf-apex-constraints` — Governor limits and Apex safety rules
@@ -0,0 +1,263 @@
1
+ ---
2
+ name: sf-aura-development
3
+ description: >-
4
+ Salesforce Aura component development — bundles, events, server-side actions,
5
+ Locker Service, and LWC migration. Use when maintaining or migrating Aura.
6
+ origin: SCC
7
+ user-invocable: false
8
+ ---
9
+
10
+ # Aura Component Development
11
+
12
+ Aura is Salesforce's original Lightning component framework (introduced 2014). While LWC is the modern standard, thousands of production orgs still run Aura components. This skill covers authoring, maintaining, and migrating Aura components.
13
+
14
+ **Note:** Aura is in maintenance mode. For new development, use LWC (see sf-lwc-development).
15
+
16
+ ## When to Use
17
+
18
+ - When maintaining or extending existing Aura components that cannot be rewritten immediately
19
+ - When migrating Aura components to LWC and needing to understand the source patterns
20
+ - When building interoperability layers between LWC and Aura
21
+ - When debugging Aura event propagation, server-side action callbacks, or Locker Service errors
22
+ - When working with features that still require Aura wrappers (Lightning Out, legacy AppExchange)
23
+
24
+ @../_reference/AURA_COMPONENTS.md
25
+
26
+ ---
27
+
28
+ ## Component Creation Procedure
29
+
30
+ An Aura component is a folder (bundle) containing up to eight files. Only the `.cmp` file is required.
31
+
32
+ ```
33
+ force-app/main/default/aura/AccountManager/
34
+ AccountManager.cmp <- Component markup (required)
35
+ AccountManagerController.js <- Client-side controller (action handlers)
36
+ AccountManagerHelper.js <- Reusable logic (called by controller)
37
+ AccountManagerRenderer.js <- Custom rendering overrides (rare)
38
+ AccountManager.css <- Component-scoped styles
39
+ AccountManager.design <- App Builder property editor config
40
+ AccountManager.cmp-meta.xml <- Metadata (apiVersion, description)
41
+ ```
42
+
43
+ ### Component Markup (.cmp)
44
+
45
+ ```xml
46
+ <aura:component controller="AccountController"
47
+ implements="force:appHostable,flexipage:availableForAllPageTypes"
48
+ access="global">
49
+ <aura:attribute name="accounts" type="Account[]" default="[]" />
50
+ <aura:attribute name="isLoading" type="Boolean" default="true" />
51
+ <aura:attribute name="errorMessage" type="String" />
52
+
53
+ <aura:registerEvent name="accountSelected" type="c:AccountSelectedEvent" />
54
+ <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
55
+
56
+ <lightning:card title="Account Manager" iconName="standard:account">
57
+ <aura:if isTrue="{!v.isLoading}">
58
+ <lightning:spinner alternativeText="Loading" size="small" />
59
+ <aura:set attribute="else">
60
+ <aura:iteration items="{!v.accounts}" var="acct">
61
+ <lightning:tile label="{!acct.Name}">
62
+ <dl class="slds-list_horizontal slds-wrap">
63
+ <dt class="slds-item_label">Type:</dt>
64
+ <dd class="slds-item_detail">{!acct.Type}</dd>
65
+ </dl>
66
+ </lightning:tile>
67
+ </aura:iteration>
68
+ </aura:set>
69
+ </aura:if>
70
+ </lightning:card>
71
+ </aura:component>
72
+ ```
73
+
74
+ ---
75
+
76
+ ## Event Handling
77
+
78
+ ### Component Events (Parent-Child)
79
+
80
+ ```xml
81
+ <!-- AccountSelectedEvent.evt -->
82
+ <aura:event type="COMPONENT" description="Fired when an account is selected">
83
+ <aura:attribute name="accountId" type="String" />
84
+ </aura:event>
85
+ ```
86
+
87
+ ```javascript
88
+ // Child controller — firing
89
+ handleAccountClick: function(component, event, helper) {
90
+ var compEvent = component.getEvent("accountSelected");
91
+ compEvent.setParams({ accountId: event.currentTarget.dataset.accountId });
92
+ compEvent.fire();
93
+ }
94
+ ```
95
+
96
+ ```xml
97
+ <!-- Parent — handling -->
98
+ <c:AccountTile onaccountSelected="{!c.handleAccountSelected}" />
99
+ ```
100
+
101
+ ### Application Events (Cross-Component)
102
+
103
+ ```xml
104
+ <aura:event type="APPLICATION" description="Broadcast notification">
105
+ <aura:attribute name="message" type="String" />
106
+ </aura:event>
107
+ ```
108
+
109
+ ```javascript
110
+ // Firing
111
+ var appEvent = $A.get("e.c:GlobalNotificationEvent");
112
+ appEvent.setParams({ message: "Record saved" });
113
+ appEvent.fire();
114
+ ```
115
+
116
+ ```xml
117
+ <!-- Any component can handle -->
118
+ <aura:handler event="c:GlobalNotificationEvent" action="{!c.handleNotification}" />
119
+ ```
120
+
121
+ Prefer component events over application events. For new cross-component communication, use Lightning Message Service instead.
122
+
123
+ ---
124
+
125
+ ## Controller and Helper Patterns
126
+
127
+ Keep controllers thin; helpers do the work.
128
+
129
+ ```javascript
130
+ // AccountManagerController.js
131
+ ({
132
+ doInit: function(component, event, helper) {
133
+ helper.loadAccounts(component);
134
+ },
135
+ handleSearch: function(component, event, helper) {
136
+ helper.loadAccounts(component);
137
+ }
138
+ })
139
+ ```
140
+
141
+ ```javascript
142
+ // AccountManagerHelper.js
143
+ ({
144
+ loadAccounts: function(component) {
145
+ component.set("v.isLoading", true);
146
+ var action = component.get("c.getAccounts");
147
+ action.setParams({
148
+ searchTerm: component.get("v.searchTerm") || ""
149
+ });
150
+ action.setCallback(this, function(response) {
151
+ var state = response.getState();
152
+ if (state === "SUCCESS") {
153
+ component.set("v.accounts", response.getReturnValue());
154
+ } else if (state === "ERROR") {
155
+ this.handleErrors(component, response.getError());
156
+ } else if (state === "INCOMPLETE") {
157
+ component.set("v.errorMessage", "Server unreachable.");
158
+ }
159
+ component.set("v.isLoading", false);
160
+ });
161
+ $A.enqueueAction(action);
162
+ },
163
+
164
+ handleErrors: function(component, errors) {
165
+ var message = "Unknown error";
166
+ if (errors && errors[0] && errors[0].message) {
167
+ message = errors[0].message;
168
+ }
169
+ component.set("v.errorMessage", message);
170
+ }
171
+ })
172
+ ```
173
+
174
+ ---
175
+
176
+ ## Server-Side Communication
177
+
178
+ ### $A.enqueueAction() Pattern
179
+
180
+ All Apex calls in Aura go through the action queue. Handle all three states: SUCCESS, ERROR, INCOMPLETE.
181
+
182
+ ### Storable Actions (Client-Side Caching)
183
+
184
+ ```javascript
185
+ var action = component.get("c.getPicklistValues");
186
+ action.setStorable(); // Only for @AuraEnabled(cacheable=true) methods
187
+ ```
188
+
189
+ Callback may fire twice: once from cache, once from server. Do not use for DML operations.
190
+
191
+ ### $A.getCallback() for Async Code
192
+
193
+ Any code executing outside the Aura lifecycle (setTimeout, Promises, third-party callbacks) must use `$A.getCallback()`:
194
+
195
+ ```javascript
196
+ setTimeout($A.getCallback(function() {
197
+ if (component.isValid()) {
198
+ component.set("v.status", "Complete");
199
+ }
200
+ }), 2000);
201
+ ```
202
+
203
+ ---
204
+
205
+ ## Interoperability with LWC
206
+
207
+ ### Embedding LWC Inside Aura
208
+
209
+ ```xml
210
+ <!-- AuraWrapper.cmp -->
211
+ <aura:component>
212
+ <c:lwcRecordDetail
213
+ record-id="{!v.selectedRecordId}"
214
+ onrecordupdate="{!c.handleRecordUpdate}" />
215
+ </aura:component>
216
+ ```
217
+
218
+ **Aura to LWC** — pass data via attributes mapped to `@api` properties.
219
+ **LWC to Aura** — dispatch `CustomEvent`; Aura receives via `on{eventname}` handler, access detail via `event.getParam("detail")`.
220
+
221
+ ---
222
+
223
+ ## Migration to LWC
224
+
225
+ ### Strategy
226
+
227
+ 1. **Inventory** — list all Aura components, dependencies, usage locations
228
+ 2. **Prioritize** — start with leaf components (no child Aura dependencies)
229
+ 3. **Wrap** — replace Aura parents with LWC, keeping Aura children via interop
230
+ 4. **Convert** — rewrite using LWC patterns
231
+ 5. **Test** — validate behavior parity
232
+ 6. **Deploy** — replace references on pages/apps
233
+
234
+ ### Key Mappings
235
+
236
+ | Aura | LWC |
237
+ |------|-----|
238
+ | `aura:handler name="init"` | `connectedCallback()` |
239
+ | `aura:handler name="destroy"` | `disconnectedCallback()` |
240
+ | `aura:attribute` | `@api` properties |
241
+ | `aura:if` / `aura:set` | `lwc:if` / `lwc:elseif` / `lwc:else` |
242
+ | `aura:iteration` | `for:each` with `key` |
243
+ | `$A.enqueueAction()` | `@wire` or imperative `await` |
244
+ | `component.get("v.attr")` | `this.propertyName` |
245
+ | `component.set("v.attr", val)` | `this.propertyName = val` |
246
+ | `component.find("auraId")` | `this.template.querySelector()` |
247
+ | Component events | `CustomEvent` |
248
+ | Application events | Lightning Message Service |
249
+ | `$A.getCallback()` | Not needed (LWC handles async natively) |
250
+ | Helper.js (separate file) | Class methods (single JS file) |
251
+ | `$A.createComponent()` | `lwc:component` with `lwc:is` |
252
+
253
+ ---
254
+
255
+ ## Related
256
+
257
+ ### Guardrails
258
+
259
+ - **sf-lwc-constraints** — Enforced rules for LWC (relevant for interop and migration targets)
260
+
261
+ ### Agents
262
+
263
+ - **sf-aura-reviewer** — For interactive, in-depth Aura review guidance
@@ -0,0 +1,121 @@
1
+ ---
2
+ name: sf-build-fix
3
+ description: "Auto-fix Salesforce build errors — Apex compilation, metadata conflicts, dependencies, test failures. Use when build errors block deployment. Do NOT use for writing new features or refactoring."
4
+ origin: SCC
5
+ user-invocable: false
6
+ disable-model-invocation: true
7
+ ---
8
+
9
+ # Build Fix — Salesforce Build and Deployment Error Resolution
10
+
11
+ Fix build and deployment errors incrementally. Parse error output, classify issues, fix one at a time, re-validate.
12
+
13
+ Reference: @../_reference/DEPLOYMENT_CHECKLIST.md
14
+
15
+ ## When to Use
16
+
17
+ - When Apex compilation errors are blocking a deployment
18
+ - When metadata conflicts prevent deploying to a target org
19
+ - When test failures need to be resolved before deployment validation passes
20
+ - When dependency resolution is needed (missing objects, fields, or class references)
21
+ - When you receive build errors from `sf project deploy` and need systematic resolution
22
+
23
+ ## Workflow
24
+
25
+ ### Step 1 — Capture Errors
26
+
27
+ Run a dry-run deployment or check compiler output:
28
+
29
+ ```bash
30
+ sf project deploy validate --target-org <alias> --json 2>&1
31
+ ```
32
+
33
+ If the user pasted error output directly, use that instead.
34
+
35
+ ### Step 2 — Parse and Classify
36
+
37
+ Group errors by type and fix in this dependency order:
38
+
39
+ | Priority | Error Type | Fix Strategy |
40
+ |----------|-----------|--------------|
41
+ | 1 | Missing object/field metadata | Deploy metadata first -- objects before classes |
42
+ | 2 | Missing class/interface reference | Check spelling, verify class exists, check API version |
43
+ | 3 | Type mismatch | Cast explicitly, check null handling, verify generic types |
44
+ | 4 | Method signature changed | Update all callers, check for overloaded methods |
45
+ | 5 | Metadata conflict | Retrieve latest from org with `sf project retrieve start`, merge |
46
+ | 6 | Test failure | Fix test data setup, update assertions, check @TestSetup |
47
+ | 7 | Governor limit in test | Add Test.startTest()/stopTest(), reduce data volume |
48
+
49
+ ### Step 3 — Fix One at a Time
50
+
51
+ For each error:
52
+
53
+ 1. Read the file at the reported line number
54
+ 2. Understand the context (class, method, trigger)
55
+ 3. Apply the minimal fix
56
+ 4. Verify it compiles: `sf project deploy validate --metadata "ApexClass:<ClassName>" --target-org <org>`
57
+
58
+ ### Step 4 — Re-validate
59
+
60
+ After all fixes:
61
+
62
+ ```bash
63
+ sf project deploy validate --target-org <alias> --test-level RunLocalTests
64
+ ```
65
+
66
+ ## Common Apex Compilation Errors
67
+
68
+ | Error Message Pattern | Root Cause | Fix |
69
+ |----------------------|------------|-----|
70
+ | `Variable does not exist: X` | Undeclared variable or field removed | Declare variable or check field API name |
71
+ | `Method does not exist or incorrect signature` | Wrong parameter types or method renamed | Check method signature in target class |
72
+ | `Illegal assignment from X to Y` | Type mismatch | Add explicit cast or fix generic type |
73
+ | `Non-void method might not return a value` | Missing return in a branch | Add return statement to all code paths |
74
+ | `Compile Error: unexpected token` | Syntax error | Check line above the reported line |
75
+ | `System.NullPointerException` (test) | Null reference in test setup | Add null checks or fix @TestSetup |
76
+ | `Duplicate value found` (test) | Test data collision | Use unique identifiers, avoid SeeAllData |
77
+ | `FIELD_CUSTOM_VALIDATION_EXCEPTION` (test) | Validation rule blocking test DML | Populate all required fields in test data |
78
+ | `MIXED_DML_OPERATION` (test) | Setup + non-setup DML in same transaction | Use `System.runAs()` in tests or `@future` in production |
79
+ | `UNABLE_TO_LOCK_ROW` (test) | Concurrent test data conflicts | Use unique records per test method |
80
+
81
+ ## Dependency Resolution Order
82
+
83
+ When deploying multiple metadata types, follow this order:
84
+
85
+ 1. Custom Objects and Fields
86
+ 2. Record Types and Page Layouts
87
+ 3. Apex Classes (utilities and base classes first)
88
+ 4. Apex Triggers
89
+ 5. Lightning Web Components
90
+ 6. Flows (Process Builder is deprecated since Winter '23 -- migrate to Flows)
91
+ 7. Permission Sets and Profiles
92
+ 8. Apex Test Classes (verify at end)
93
+
94
+ ## Metadata Conflict Resolution
95
+
96
+ When `sf project deploy` reports conflicts:
97
+
98
+ 1. **Retrieve current org state**: `sf project retrieve start --metadata <type>:<name>`
99
+ 2. **Compare**: `diff force-app/main/default/<path> <retrieved-path>`
100
+ 3. **Merge**: Keep production changes, layer your modifications on top
101
+ 4. **Do not force-overwrite** production metadata without understanding the diff
102
+
103
+ ## Rules
104
+
105
+ - Fix one error at a time -- cascade fixes often resolve multiple issues
106
+ - Do NOT refactor while fixing builds
107
+ - Do NOT change architecture
108
+ - If a fix introduces new errors, revert and try a different approach
109
+
110
+ ## Examples
111
+
112
+ ```
113
+ sf-build-fix
114
+ sf-build-fix Fix the Apex compile errors from this deployment output: <paste errors>
115
+ sf-build-fix The AccountService.cls has a type mismatch on line 47
116
+ sf-build-fix Resolve the metadata conflicts blocking our deployment to UAT
117
+ ```
118
+
119
+ ## Related
120
+
121
+ - **Constraints**: `sf-deployment-constraints` -- deployment safety rules and validation gates