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,645 @@
1
+ # Workflow Examples
2
+
3
+ This guide provides step-by-step workflow examples showing how Salesforce Claude Code (SCC) is used in practice. Each workflow shows the commands invoked, agents delegated to, hooks that fire, and expected outcomes.
4
+
5
+ ## Workflow 1: Apex TDD -- Test-Driven Development
6
+
7
+ Build a new Apex service using the Red-Green-Refactor cycle. Tests are written first, then the implementation, then reviewed and refactored.
8
+
9
+ ### Scenario
10
+
11
+ You need to create an `AccountRatingService` that assigns ratings to accounts based on their annual revenue.
12
+
13
+ ### Step 1 -- Plan the Implementation
14
+
15
+ ```
16
+ Plan an AccountRatingService that rates accounts as Hot (>= $1M revenue), Warm ($100K-$1M), or Cold (< $100K)
17
+ ```
18
+
19
+ **Agent invoked**: `sf-architect`
20
+
21
+ **What happens**: The planner agent analyzes the requirement and produces a structured plan including:
22
+
23
+ - Classes to create (`AccountRatingService.cls`, `AccountRatingServiceTest.cls`)
24
+ - Governor limit considerations (no SOQL/DML needed -- pure in-memory logic)
25
+ - Test scenarios (happy path, bulk 200 records, null input, empty list, permission testing)
26
+
27
+ ### Step 2 -- Write Tests First (Red Phase)
28
+
29
+ ```
30
+ /sf-tdd-workflow Create an AccountRatingService that rates accounts based on AnnualRevenue
31
+ ```
32
+
33
+ **Agent invoked**: `sf-apex-agent`
34
+
35
+ **What happens**:
36
+
37
+ 1. Checks if `TestDataFactory.cls` exists in the project.
38
+ 2. Creates `AccountRatingServiceTest.cls` with test methods:
39
+ - `testRateAccount_HighRevenue_SetsHotRating` -- single record, Hot path
40
+ - `testRateAccount_Bulk200Records_NoLimitExceptions` -- bulk test with 200 records
41
+ - `testRateAccount_ZeroRevenue_SetsColdRating` -- edge case
42
+ - `testRateAccount_NullList_ThrowsIllegalArgument` -- negative case
43
+ - `testRateAccount_EmptyList_NoException` -- empty input
44
+ - `testRateAccount_RunAsLimitedUser_EnforcesSharingRules` -- permission test
45
+ 3. Runs the tests to confirm they fail (Red phase confirmed).
46
+
47
+ **Hook activity**:
48
+
49
+ - `post-write.js` fires after the test class file is written, reminding about test coverage.
50
+
51
+ ### Step 3 -- Implement the Service (Green Phase)
52
+
53
+ The TDD workflow continues by creating the minimal `AccountRatingService.cls` to pass all tests:
54
+
55
+ ```bash
56
+ sf apex run test --class-names AccountRatingServiceTest --target-org MyScratchOrg --result-format human --wait 10
57
+ ```
58
+
59
+ **Hook activity**:
60
+
61
+ - `governor-check.js` fires after each Edit to the Apex file, checking for SOQL/DML in loops.
62
+ - `quality-gate.js` fires after edits, checking for anti-patterns.
63
+ - `sfdx-validate.js` fires before the test command, checking for missing flags.
64
+
65
+ **Expected outcome**: All 6 test methods pass. Coverage is 90%+.
66
+
67
+ ### Step 4 -- Review the Code
68
+
69
+ ```
70
+ /sf-apex-best-practices Review AccountRatingService.cls
71
+ ```
72
+
73
+ **Agent invoked**: `sf-review-agent`
74
+
75
+ **What happens**: The reviewer checks the implementation against its checklist:
76
+
77
+ 1. Sharing declaration (`with sharing` present)
78
+ 2. SOQL outside loops (no SOQL needed in this case)
79
+ 3. DML outside loops (single `update` call on a collection)
80
+ 4. Null safety (null parameter check)
81
+ 5. Security (CRUD/FLS enforcement)
82
+ 6. Test quality (meaningful assertions, bulk test, negative cases)
83
+
84
+ **Expected outcome**: Review report with 0 CRITICAL findings, possibly LOW suggestions for constants or documentation.
85
+
86
+ ### Step 5 -- Refactor
87
+
88
+ With green tests as a safety net, refactor:
89
+
90
+ - Extract revenue thresholds to Custom Metadata or constants
91
+ - Apply service layer pattern if needed
92
+ - Run tests after each change to confirm they still pass
93
+
94
+ ```
95
+ /sf-governor-limits Check AccountRatingService for governor limit risks
96
+ ```
97
+
98
+ **Agent invoked**: `sf-apex-agent`
99
+
100
+ **Expected outcome**: Clean audit -- no governor limit risks in pure in-memory logic.
101
+
102
+ ---
103
+
104
+ ## Workflow 2: LWC Development -- Component Creation to Testing
105
+
106
+ Build a new Lightning Web Component with full testing and accessibility review.
107
+
108
+ ### Scenario
109
+
110
+ You need to create an `accountRatingCard` LWC that displays an account's rating with color-coded badges.
111
+
112
+ ### Step 1 -- Scaffold the Component
113
+
114
+ ```
115
+ /sf-lwc-development Create an accountRatingCard component that shows account name, rating badge (Hot=red, Warm=orange, Cold=blue), and annual revenue
116
+ ```
117
+
118
+ **Agent invoked**: `sf-lwc-agent`
119
+
120
+ **What happens**: Reviews the plan for the component and provides guidance on:
121
+
122
+ - Component structure (HTML template, JS controller, CSS, meta XML)
123
+ - Wire service vs imperative Apex for data loading
124
+ - Accessibility requirements (ARIA labels, color contrast, keyboard navigation)
125
+ - SLDS (Salesforce Lightning Design System) badge patterns
126
+
127
+ ### Step 2 -- Create the Component Files
128
+
129
+ The agent creates four files:
130
+
131
+ **`accountRatingCard.html`** -- Template with SLDS badge and conditional styling.
132
+
133
+ **`accountRatingCard.js`** -- Controller with `@wire` to fetch account data and computed properties for badge styling.
134
+
135
+ **`accountRatingCard.css`** -- Custom styles (minimal, relying on SLDS).
136
+
137
+ **`accountRatingCard.js-meta.xml`** -- Metadata defining targets (Lightning Record Page, App Page).
138
+
139
+ **Hook activity**:
140
+
141
+ - `post-write.js` fires after each file write, detecting LWC files and reminding about test coverage.
142
+ - `post-edit-console-warn.js` fires after JS edits, warning about any `console.log` statements.
143
+
144
+ ### Step 3 -- Write Jest Tests
145
+
146
+ ```
147
+ /sf-tdd-workflow Write Jest tests for the accountRatingCard LWC component
148
+ ```
149
+
150
+ **What happens**: Creates `__tests__/accountRatingCard.test.js` with:
151
+
152
+ ```javascript
153
+ import { createElement } from 'lwc';
154
+ import AccountRatingCard from 'c/accountRatingCard';
155
+ import getAccountRating from '@salesforce/apex/AccountRatingService.getAccountRating';
156
+
157
+ // Mock the Apex wire adapter
158
+ jest.mock('@salesforce/apex/AccountRatingService.getAccountRating',
159
+ () => ({ default: jest.fn() }),
160
+ { virtual: true }
161
+ );
162
+
163
+ describe('c-account-rating-card', () => {
164
+ afterEach(() => { while (document.body.firstChild) document.body.removeChild(document.body.firstChild); });
165
+
166
+ it('renders Hot badge with correct styling', async () => { /* ... */ });
167
+ it('renders Cold badge for low revenue accounts', async () => { /* ... */ });
168
+ it('shows loading spinner while data is being fetched', async () => { /* ... */ });
169
+ it('displays error message when wire service fails', async () => { /* ... */ });
170
+ it('is accessible (no ARIA violations)', async () => { /* ... */ });
171
+ });
172
+ ```
173
+
174
+ ### Step 4 -- Run Tests
175
+
176
+ ```bash
177
+ npx lwc-jest --coverage
178
+ ```
179
+
180
+ **Expected outcome**: All tests pass with 80%+ coverage.
181
+
182
+ ### Step 5 -- Accessibility Review
183
+
184
+ ```
185
+ /sf-lwc-development Review accountRatingCard for accessibility compliance
186
+ ```
187
+
188
+ **Agent invoked**: `sf-lwc-agent`
189
+
190
+ **What it checks**:
191
+
192
+ - Color is not the only indicator (badges also have text labels)
193
+ - ARIA attributes on interactive elements
194
+ - Keyboard navigation support
195
+ - Screen reader compatibility
196
+ - Color contrast ratios meet WCAG 2.1 AA
197
+
198
+ **Expected outcome**: Accessibility report. Common findings include missing `aria-label` on badges or insufficient color contrast on the Cold (blue) badge.
199
+
200
+ ### Step 6 -- Deploy to Scratch Org
201
+
202
+ ```
203
+ /sf-deployment Deploy accountRatingCard and AccountRatingService to scratch org
204
+ ```
205
+
206
+ **Agent invoked**: `sf-architect`
207
+
208
+ **Hook activity**:
209
+
210
+ - `sfdx-validate.js` fires before the deploy command, checking for missing `--test-level` flag.
211
+ - `post-bash-build-complete.js` fires after deployment completes.
212
+
213
+ ---
214
+
215
+ ## Workflow 3: Deployment Pipeline -- Scratch Org to Production
216
+
217
+ Full development lifecycle from scratch org creation through production deployment.
218
+
219
+ ### Step 1 -- Create a Scratch Org
220
+
221
+ ```
222
+ /sf-deployment Create a new scratch org for feature/account-rating
223
+ ```
224
+
225
+ **Agent invoked**: `sf-architect`
226
+
227
+ **What happens**:
228
+
229
+ 1. Verifies Dev Hub is connected:
230
+
231
+ ```bash
232
+ sf org list --json
233
+ ```
234
+
235
+ 2. Creates a scratch org with the project definition:
236
+
237
+ ```bash
238
+ sf org create scratch --definition-file config/project-scratch-def.json --alias account-rating --duration-days 7 --set-default
239
+ ```
240
+
241
+ 3. Pushes source to the new scratch org:
242
+
243
+ ```bash
244
+ sf project deploy start --source-dir force-app/ --target-org account-rating
245
+ ```
246
+
247
+ 4. Imports sample data if a data plan exists:
248
+
249
+ ```bash
250
+ sf data import tree --plan data/sample-data-plan.json --target-org account-rating
251
+ ```
252
+
253
+ **Hook activity**:
254
+
255
+ - `session-start.js` fires at session start, displaying the newly created scratch org.
256
+ - `sfdx-validate.js` fires before each SF CLI command.
257
+
258
+ ### Step 2 -- Develop the Feature
259
+
260
+ Use the Apex TDD workflow (Workflow 1) and LWC development workflow (Workflow 2) to build the feature in the scratch org.
261
+
262
+ ### Step 3 -- Run All Tests
263
+
264
+ ```
265
+ /sf-apex-testing Run all local tests in the scratch org
266
+ ```
267
+
268
+ **What happens**:
269
+
270
+ ```bash
271
+ sf apex run test --target-org account-rating --test-level RunLocalTests --code-coverage --result-format human --wait 30
272
+ ```
273
+
274
+ **Expected outcome**: All tests pass. Org-wide coverage is above 75%.
275
+
276
+ ### Step 4 -- Validate Against Staging
277
+
278
+ ```
279
+ /sf-deployment Validate deployment to staging (dry run)
280
+ ```
281
+
282
+ **Agent invoked**: `sf-architect`
283
+
284
+ ```bash
285
+ sf project deploy validate --source-dir force-app/ --target-org Staging --test-level RunLocalTests --wait 30
286
+ ```
287
+
288
+ **Hook activity**:
289
+
290
+ - `sfdx-validate.js` recognizes the validate command and confirms it is a dry run (no destructive action).
291
+
292
+ **Expected outcome**: Validation succeeds. No test failures, no missing dependencies, coverage thresholds met.
293
+
294
+ ### Step 5 -- Deploy to Staging
295
+
296
+ ```bash
297
+ sf project deploy start --source-dir force-app/ --target-org Staging --test-level RunLocalTests --wait 30
298
+ ```
299
+
300
+ **Hook activity**:
301
+
302
+ - `sfdx-validate.js` checks for `--test-level` flag (present -- good).
303
+ - `post-bash-build-complete.js` fires after deployment completes, logging a success notice.
304
+
305
+ ### Step 6 -- Verify Deployment
306
+
307
+ ```
308
+ Verify the deployment to Staging succeeded and all tests pass
309
+ ```
310
+
311
+ **Agent invoked**: `sf-review-agent`
312
+
313
+ **What happens**:
314
+
315
+ 1. Queries the deployment status.
316
+ 2. Runs a subset of tests on Staging to confirm everything works.
317
+ 3. Checks that the new components are accessible in the target org.
318
+
319
+ **Expected outcome**: Verification passes. The feature is ready for production deployment.
320
+
321
+ ---
322
+
323
+ ## Workflow 4: Security Audit -- Scan, Fix, Re-Scan
324
+
325
+ Run a comprehensive security audit on the codebase, fix findings, and verify the fixes.
326
+
327
+ ### Step 1 -- Run the Security Scan
328
+
329
+ ```
330
+ /sf-security Run a full security audit on force-app/
331
+ ```
332
+
333
+ **Agent invoked**: `sf-review-agent`
334
+
335
+ **What happens**: The security reviewer performs a multi-pass analysis:
336
+
337
+ **Pass 1 -- Sharing Model**:
338
+
339
+ - Checks every Apex class for explicit sharing declaration (`with sharing`, `without sharing`, `inherited sharing`).
340
+ - Flags classes without sharing declaration as CRITICAL.
341
+ - Flags `without sharing` classes that lack a justification comment as HIGH.
342
+
343
+ **Pass 2 -- CRUD/FLS Enforcement**:
344
+
345
+ - Checks SOQL queries for `WITH USER_MODE` (preferred) or `WITH SECURITY_ENFORCED` (legacy).
346
+ - Checks DML operations for `AccessLevel.USER_MODE` or `Security.stripInaccessible`.
347
+ - Flags unprotected queries as HIGH.
348
+
349
+ **Pass 3 -- SOQL Injection**:
350
+
351
+ - Scans for string concatenation in dynamic SOQL (`Database.query()`).
352
+ - Checks if `String.escapeSingleQuotes()` is used.
353
+ - Flags direct user input concatenation as CRITICAL.
354
+
355
+ **Pass 4 -- LWC Security**:
356
+
357
+ - Checks for `innerHTML` usage (XSS risk).
358
+ - Verifies `lightning/platformResourceLoader` is used for external scripts (not direct script tags).
359
+ - Checks for hardcoded credentials or API keys.
360
+
361
+ **Expected output**:
362
+
363
+ ```
364
+ Security Audit Report
365
+ =====================
366
+ Classes scanned: 24
367
+ LWC components scanned: 8
368
+
369
+ CRITICAL (2):
370
+ AccountQueryController.cls:15 -- SOQL injection via string concatenation in Database.query()
371
+ ReportExporter.cls:1 -- Missing sharing declaration (defaults to without sharing)
372
+
373
+ HIGH (3):
374
+ ContactService.cls:42 -- SOQL query without FLS enforcement (no WITH USER_MODE)
375
+ OpportunityService.cls:18 -- DML without AccessLevel.USER_MODE
376
+ LeadProcessor.cls:1 -- 'without sharing' without justification comment
377
+
378
+ MEDIUM (1):
379
+ accountList.js:22 -- innerHTML assignment (potential XSS)
380
+ ```
381
+
382
+ ### Step 2 -- Fix the Findings
383
+
384
+ Address each finding by severity, starting with CRITICAL:
385
+
386
+ **Fix SOQL injection:**
387
+
388
+ ```
389
+ /sf-apex-best-practices Fix the SOQL injection in AccountQueryController.cls
390
+ ```
391
+
392
+ The agent replaces string concatenation with bind variables:
393
+
394
+ ```apex
395
+ // Before (CRITICAL)
396
+ String query = 'SELECT Id FROM Account WHERE Name = \'' + searchTerm + '\'';
397
+ List<Account> results = Database.query(query);
398
+
399
+ // After (SAFE)
400
+ List<Account> results = [SELECT Id FROM Account WHERE Name = :searchTerm];
401
+ ```
402
+
403
+ **Fix missing sharing:**
404
+
405
+ ```apex
406
+ // Before
407
+ public class ReportExporter {
408
+
409
+ // After
410
+ public with sharing class ReportExporter {
411
+ ```
412
+
413
+ **Fix FLS enforcement:**
414
+
415
+ ```apex
416
+ // Before
417
+ List<Contact> contacts = [SELECT Id, Name, Email FROM Contact WHERE AccountId = :accountId];
418
+
419
+ // After
420
+ List<Contact> contacts = [SELECT Id, Name, Email FROM Contact WHERE AccountId = :accountId WITH USER_MODE];
421
+ ```
422
+
423
+ **Hook activity**:
424
+
425
+ - `governor-check.js` fires after each edit, checking the modified files.
426
+ - `quality-gate.js` fires after each edit, running additional quality checks.
427
+
428
+ ### Step 3 -- Re-Scan
429
+
430
+ ```
431
+ /sf-security Re-scan force-app/ to verify all security findings are resolved
432
+ ```
433
+
434
+ **Expected output**:
435
+
436
+ ```
437
+ Security Audit Report
438
+ =====================
439
+ Classes scanned: 24
440
+ LWC components scanned: 8
441
+
442
+ CRITICAL: 0
443
+ HIGH: 0
444
+ MEDIUM: 0
445
+ LOW: 1
446
+ LeadProcessor.cls:12 -- Consider adding FLS check on custom field access
447
+
448
+ All critical and high severity findings resolved.
449
+ ```
450
+
451
+ ### Step 4 -- Run sfdx-scanner (Strict Profile)
452
+
453
+ For teams using the strict hook profile, the `sfdx-scanner-check.js` hook automatically runs PMD static analysis before every `git push` or `sf deploy`:
454
+
455
+ ```bash
456
+ # This happens automatically via the hook, or manually:
457
+ sf scanner run --target force-app/ --engine pmd --format table
458
+ ```
459
+
460
+ ---
461
+
462
+ ## Workflow 5: Performance Optimization -- Governor Audit to SOQL Tuning
463
+
464
+ Identify and fix performance bottlenecks in an existing Salesforce codebase.
465
+
466
+ ### Step 1 -- Run the Governor Audit
467
+
468
+ ```
469
+ /sf-governor-limits Scan force-app/main/default/classes/ for governor limit risks
470
+ ```
471
+
472
+ **Agent invoked**: `sf-apex-agent`
473
+
474
+ **What happens**: The agent scans all Apex classes and triggers for:
475
+
476
+ - SOQL queries inside loops (CRITICAL)
477
+ - DML operations inside loops (CRITICAL)
478
+ - HTTP callouts inside loops (CRITICAL)
479
+ - Async operations inside loops (HIGH)
480
+ - Non-bulkified trigger patterns (HIGH)
481
+ - Schema describe calls in loops (MEDIUM)
482
+ - Deeply nested loops (3+ levels) (MEDIUM)
483
+ - Unbounded SOQL on large standard objects (LOW)
484
+
485
+ **Expected output**:
486
+
487
+ ```
488
+ Governor Limit Audit
489
+ ====================
490
+ Files scanned: 42 (.cls + .trigger)
491
+ Test classes skipped: 18
492
+
493
+ CRITICAL (3):
494
+ OrderProcessor.cls:67 -- SOQL query inside for loop (will hit 100 SOQL limit)
495
+ Fix: Move query before the loop and use a Map for lookups
496
+ OrderProcessor.cls:89 -- DML inside for loop (will hit 150 DML limit)
497
+ Fix: Collect records in a List and perform DML after the loop
498
+ IntegrationSync.cls:34 -- HTTP callout inside while loop (will hit 100 callout limit)
499
+ Fix: Batch callouts or use Queueable for async processing
500
+
501
+ HIGH (2):
502
+ AccountTrigger.trigger:5 -- Non-bulkified trigger: Trigger.new[0]
503
+ Fix: Iterate over Trigger.new to handle bulk operations
504
+ NotificationService.cls:23 -- System.enqueueJob() inside loop
505
+ Fix: Collect work items and enqueue a single Queueable after the loop
506
+
507
+ MEDIUM (1):
508
+ ReportGenerator.cls:112 -- Loop nesting depth 3 -- high CPU time risk
509
+ Fix: Refactor to reduce nesting or use Maps for lookups
510
+ ```
511
+
512
+ ### Step 2 -- Optimize SOQL Queries
513
+
514
+ ```
515
+ /sf-soql-optimization Optimize the SOQL queries in OrderProcessor.cls
516
+ ```
517
+
518
+ **Agent invoked**: `sf-apex-agent`
519
+
520
+ **What happens**: The agent refactors the code to move queries outside loops:
521
+
522
+ ```apex
523
+ // Before (CRITICAL -- SOQL in loop)
524
+ for (Order__c order : orders) {
525
+ List<OrderItem__c> items = [
526
+ SELECT Id, Quantity__c, Product__c
527
+ FROM OrderItem__c
528
+ WHERE Order__c = :order.Id
529
+ ];
530
+ processItems(order, items);
531
+ }
532
+
533
+ // After (SAFE -- single query with Map lookup)
534
+ Set<Id> orderIds = new Map<Id, Order__c>(orders).keySet();
535
+ Map<Id, List<OrderItem__c>> itemsByOrder = new Map<Id, List<OrderItem__c>>();
536
+ for (OrderItem__c item : [
537
+ SELECT Id, Quantity__c, Product__c, Order__c
538
+ FROM OrderItem__c
539
+ WHERE Order__c IN :orderIds
540
+ ]) {
541
+ if (!itemsByOrder.containsKey(item.Order__c)) {
542
+ itemsByOrder.put(item.Order__c, new List<OrderItem__c>());
543
+ }
544
+ itemsByOrder.get(item.Order__c).add(item);
545
+ }
546
+
547
+ for (Order__c order : orders) {
548
+ List<OrderItem__c> items = itemsByOrder.get(order.Id);
549
+ if (items != null) {
550
+ processItems(order, items);
551
+ }
552
+ }
553
+ ```
554
+
555
+ ### Step 3 -- Fix the Trigger Bulkification
556
+
557
+ ```
558
+ /sf-trigger-frameworks Refactor AccountTrigger to use a handler pattern with proper bulkification
559
+ ```
560
+
561
+ **Agent invoked**: `sf-architect`
562
+
563
+ **What happens**: Converts the non-bulkified trigger into the thin-trigger-fat-handler pattern:
564
+
565
+ ```apex
566
+ // AccountTrigger.trigger (thin)
567
+ trigger AccountTrigger on Account (
568
+ before insert, before update, after insert, after update
569
+ ) {
570
+ AccountTriggerHandler handler = new AccountTriggerHandler();
571
+ if (Trigger.isBefore && Trigger.isInsert) handler.onBeforeInsert(Trigger.new);
572
+ if (Trigger.isBefore && Trigger.isUpdate) handler.onBeforeUpdate(Trigger.new, Trigger.oldMap);
573
+ if (Trigger.isAfter && Trigger.isInsert) handler.onAfterInsert(Trigger.new);
574
+ if (Trigger.isAfter && Trigger.isUpdate) handler.onAfterUpdate(Trigger.new, Trigger.oldMap);
575
+ }
576
+ ```
577
+
578
+ ### Step 4 -- Test with Bulk Data
579
+
580
+ Run tests that exercise the refactored code with 200 records (the standard trigger batch size):
581
+
582
+ ```
583
+ /sf-apex-testing Run tests for OrderProcessor and AccountTriggerHandler with bulk data verification
584
+ ```
585
+
586
+ ```bash
587
+ sf apex run test --class-names OrderProcessorTest,AccountTriggerHandlerTest --target-org MyScratchOrg --code-coverage --result-format human --wait 10
588
+ ```
589
+
590
+ **Hook activity**:
591
+
592
+ - `governor-check.js` fires after each edit to the Apex files, confirming the SOQL/DML-in-loop patterns are resolved.
593
+ - `quality-gate.js` fires after edits, confirming anti-patterns are cleaned up.
594
+
595
+ ### Step 5 -- Re-Audit
596
+
597
+ ```
598
+ /sf-governor-limits Re-scan force-app/ to verify all governor limit risks are resolved
599
+ ```
600
+
601
+ **Expected output**:
602
+
603
+ ```
604
+ Governor Limit Audit
605
+ ====================
606
+ Files scanned: 42 (.cls + .trigger)
607
+ Test classes skipped: 18
608
+
609
+ CRITICAL: 0
610
+ HIGH: 0
611
+ MEDIUM: 1
612
+ ReportGenerator.cls:112 -- Loop nesting depth 3 (existing, deferred to future sprint)
613
+
614
+ All critical and high severity findings resolved.
615
+ ```
616
+
617
+ ### Step 6 -- Performance Validation
618
+
619
+ ```
620
+ /sf-governor-limits Run a comprehensive performance audit including SOQL query analysis
621
+ ```
622
+
623
+ **Agent invoked**: `sf-apex-agent`
624
+
625
+ **What it checks beyond governor limits**:
626
+
627
+ - Query selectivity (indexed fields in WHERE clauses)
628
+ - Large data volume considerations (millions of records)
629
+ - Batch size recommendations
630
+ - Heap size projections for large result sets
631
+ - CPU time estimates for complex loops
632
+
633
+ **Expected outcome**: Performance report with recommendations for indexing, query plan optimization, and batch processing strategies.
634
+
635
+ ---
636
+
637
+ ## Summary: Commands, Agents, and Hooks by Workflow
638
+
639
+ | Workflow | Primary Commands | Agents Invoked | Key Hooks |
640
+ |---|---|---|---|
641
+ | Apex TDD | `/sf-tdd-workflow`, `/sf-apex-best-practices`, `/sf-governor-limits` | sf-apex-agent, sf-review-agent, sf-apex-agent | governor-check, quality-gate, post-write |
642
+ | LWC Development | `/sf-lwc-development`, `/sf-deployment` | sf-lwc-agent, sf-architect | post-write, post-edit-console-warn, sfdx-validate |
643
+ | Deployment Pipeline | `/sf-deployment`, `/sf-apex-testing`, `/sf-deployment` | sf-architect, sf-architect, sf-review-agent | session-start, sfdx-validate, post-bash-build-complete |
644
+ | Security Audit | `/sf-security`, `/sf-apex-best-practices` | sf-review-agent, sf-review-agent | governor-check, quality-gate, sfdx-scanner-check |
645
+ | Performance Optimization | `/sf-governor-limits`, `/sf-soql-optimization`, `/sf-trigger-frameworks`, `/sf-governor-limits` | sf-apex-agent, sf-apex-agent, sf-architect | governor-check, quality-gate, sfdx-validate |