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,264 @@
1
+ ---
2
+ name: continuous-agent-loop
3
+ origin: SCC
4
+ user-invocable: true
5
+ description: >-
6
+ Use when building autonomous Claude Code loops for Salesforce Apex and LWC
7
+ projects. Patterns from sequential pipelines to RFC-driven multi-agent DAG
8
+ systems with quality gates. Do NOT use for single-shot Apex tasks.
9
+ ---
10
+
11
+ # Continuous Agent Loop
12
+
13
+ Patterns, architectures, and reference implementations for running Claude Code autonomously in loops on Salesforce projects. Covers sequential `claude -p` pipelines through RFC-driven multi-agent DAG orchestration with Apex test gates.
14
+
15
+ ## When to Use
16
+
17
+ - Setting up autonomous Salesforce development workflows (Apex TDD cycles, LWC iteration)
18
+ - Choosing the right loop architecture for your problem (simple deploy vs complex feature)
19
+ - Building CI/CD-style continuous development pipelines with SF CLI gates
20
+ - Running parallel agents for multi-layer Salesforce work (Apex + LWC + Integration)
21
+ - Adding quality gates (governor limits, coverage thresholds) to autonomous workflows
22
+
23
+ ## Loop Selection Flow
24
+
25
+ ```text
26
+ Start
27
+ |
28
+ +-- Need strict CI/PR control? -- yes --> continuous-pr
29
+ |
30
+ +-- Need RFC decomposition? -- yes --> rfc-dag
31
+ |
32
+ +-- Need exploratory parallel generation? -- yes --> infinite
33
+ |
34
+ +-- default --> sequential
35
+ ```
36
+
37
+ ## Loop Pattern Spectrum
38
+
39
+ | Pattern | Complexity | Best For |
40
+ |---------|-----------|----------|
41
+ | [Sequential Pipeline](#1-sequential-pipeline) | Low | Daily Apex dev steps, scripted SFDX workflows |
42
+ | [Infinite Agentic Loop](#2-infinite-agentic-loop) | Medium | Parallel Apex/LWC generation from a spec |
43
+ | [Continuous Claude PR Loop](#3-continuous-claude-pr-loop) | Medium | Multi-day Apex TDD iterations with CI gates |
44
+ | [De-Sloppify Pattern](#4-the-de-sloppify-pattern) | Add-on | Quality cleanup after any Implementer step |
45
+ | [Ralphinho / RFC-Driven DAG](#5-ralphinho--rfc-driven-dag) | High | Large Salesforce features with parallel units and merge queue |
46
+
47
+ ---
48
+
49
+ ## 1. Sequential Pipeline
50
+
51
+ **The simplest loop.** Chain `claude -p` calls — each is a focused step with a clear prompt.
52
+
53
+ ```bash
54
+ #!/bin/bash
55
+ set -e
56
+
57
+ # Step 1: Implement with TDD
58
+ claude -p "Read docs/order-service-spec.md. Implement OrderService.cls with TDD.
59
+ Target 85% coverage. No SOQL or DML inside for loops."
60
+
61
+ # Step 2: De-sloppify
62
+ claude -p "Review changes. Remove: unnecessary null checks, tests verifying platform
63
+ behavior, System.debug statements, commented-out code.
64
+ Run 'sf apex run test --class-names OrderServiceTest' after cleanup."
65
+
66
+ # Step 3: Verify
67
+ claude -p "Run 'sf project deploy start --dry-run --source-dir force-app/main/default/classes'.
68
+ Fix any failures. Do not add new features."
69
+
70
+ # Step 4: Commit
71
+ claude -p "Commit with message: feat: add order service with test coverage"
72
+ ```
73
+
74
+ **Variations:** Use `--model opus` for architecture analysis, `--model haiku` for simple fixes. Use `--allowedTools "Read,Grep,Glob"` for read-only analysis passes.
75
+
76
+ ---
77
+
78
+ ## 2. Infinite Agentic Loop
79
+
80
+ **Two-prompt system** for parallel sub-agents. Useful for generating multiple Apex test class variants or LWC component iterations from a spec.
81
+
82
+ ```
83
+ PROMPT 1 (Orchestrator) PROMPT 2 (Sub-Agents)
84
+ ┌─────────────────────┐ ┌──────────────────────┐
85
+ │ Parse spec file │ │ Receive full context │
86
+ │ Scan output dir │ deploys │ Read assigned number │
87
+ │ Plan iteration │────────────│ Follow spec exactly │
88
+ │ Assign creative dirs │ N agents │ Generate unique output │
89
+ └─────────────────────┘ └──────────────────────┘
90
+ ```
91
+
92
+ ### Key Insight: Uniqueness via Assignment
93
+
94
+ Don't rely on agents to self-differentiate. The orchestrator **assigns** each agent a specific test scenario and iteration number. Batching: 1-5 simultaneously, 6-20 in batches of 5, infinite in waves of 3-5.
95
+
96
+ ---
97
+
98
+ ## 3. Continuous Claude PR Loop
99
+
100
+ **Production-grade shell script** that runs Claude Code in a continuous loop, creating PRs, waiting for CI (including Apex test runs), and merging automatically.
101
+
102
+ ```
103
+ ┌─────────────────────────────────────────────────────┐
104
+ │ 1. Create branch (continuous-claude/iteration-N) │
105
+ │ 2. Run claude -p with Apex TDD prompt │
106
+ │ 3. (Optional) Reviewer pass │
107
+ │ 4. Commit + Push + Create PR │
108
+ │ 5. Wait for CI (sf apex run test --code-coverage) │
109
+ │ 6. CI failure? → Auto-fix pass (claude -p) │
110
+ │ 7. Merge PR (squash) → Return to main → repeat │
111
+ │ Limit by: --max-runs N | --max-cost $X │
112
+ └─────────────────────────────────────────────────────┘
113
+ ```
114
+
115
+ ### Cross-Iteration Context: SHARED_TASK_NOTES.md
116
+
117
+ The critical innovation — a file that persists across iterations:
118
+
119
+ ```markdown
120
+ ## Progress
121
+ - [x] OrderService.cls — 82% coverage (iteration 1)
122
+ - [ ] OrderController.cls — 45% coverage, needs work
123
+
124
+ ## Next Steps
125
+ - Focus on OrderController.cls
126
+ - Named credential for external API is set up
127
+ ```
128
+
129
+ Claude reads this at iteration start, updates at iteration end.
130
+
131
+ ---
132
+
133
+ ## 4. The De-Sloppify Pattern
134
+
135
+ **Add-on for any loop.** When you ask an LLM to implement Apex with TDD, it over-tests:
136
+
137
+ - Tests verifying Salesforce platform behavior
138
+ - Defensive null checks for schema-guaranteed fields
139
+ - Excessive try/catch blocks
140
+
141
+ **Solution:** Don't constrain the Implementer — let it be thorough. Then add a focused cleanup pass:
142
+
143
+ ```bash
144
+ # Implement (thorough)
145
+ claude -p "Implement OrderService.cls with full TDD."
146
+
147
+ # De-sloppify (separate context)
148
+ claude -p "Review changes. Remove tests for platform behavior, redundant null checks,
149
+ System.debug statements, commented-out code. Run 'sf apex run test' after cleanup."
150
+ ```
151
+
152
+ > Two focused agents outperform one constrained agent.
153
+
154
+ ---
155
+
156
+ ## 5. Ralphinho / RFC-Driven DAG
157
+
158
+ **Most sophisticated.** RFC-driven pipeline that decomposes a Salesforce feature into a dependency DAG, runs each unit through quality stages, and lands via merge queue.
159
+
160
+ ```
161
+ Salesforce RFC/PRD
162
+
163
+ DECOMPOSITION (sf-architect)
164
+ Break into: Apex → LWC → Integration → Metadata layers
165
+
166
+ ┌──────────────────────────────────────────────────┐
167
+ │ For each DAG layer (sequential, by dependency): │
168
+ │ │
169
+ │ Quality Pipelines (parallel per unit): │
170
+ │ Research → Plan → Implement → Test → Review │
171
+ │ Apex: governor check + ≥75% coverage gate │
172
+ │ LWC: Jest tests + accessibility check │
173
+ │ │
174
+ │ Merge Queue: │
175
+ │ Rebase → sf deploy validate → Apex tests → │
176
+ │ Pass → Land | Fail → Evict + re-enter │
177
+ └──────────────────────────────────────────────────┘
178
+ ```
179
+
180
+ ### Complexity Tiers
181
+
182
+ | Tier | Pipeline Stages |
183
+ |------|----------------|
184
+ | **trivial** | implement → sf deploy validate |
185
+ | **small** | implement → apex test → code-review |
186
+ | **medium** | research → plan → implement → apex test → governor-check → review-fix |
187
+ | **large** | + sf-architect final review |
188
+
189
+ ### When to Use Ralphinho vs SCC-Native
190
+
191
+ | Signal | Ralphinho | SCC-Native |
192
+ |--------|----------|------------|
193
+ | 10+ interdependent work units | Yes | No |
194
+ | Need worktree isolation | Yes | No |
195
+ | Single feature with 3 layers | No | Yes |
196
+ | Quick Apex + LWC iteration | No | Yes |
197
+
198
+ ---
199
+
200
+ ## Salesforce Loop Patterns
201
+
202
+ | Pattern | Loop Type | Stop Condition |
203
+ |---------|-----------|---------------|
204
+ | **Governor Fix** | sequential | No more governor violations |
205
+ | **Coverage Ramp** | sequential | All classes at 75%+ (85% target) |
206
+ | **PB→Flow Migration** | continuous-pr | All Process Builders converted |
207
+ | **Trigger Framework Migration** | sequential | All triggers use handler pattern |
208
+ | **Deployment Monitor** | infinite (30s) | Deploy succeeds/fails/cancelled |
209
+
210
+ ### SF-Specific Checkpoint Format
211
+
212
+ ```
213
+ ── SF Checkpoint #N ────────────────────────
214
+ Apex Tests: 142/145 passing (+3)
215
+ Coverage: 78% → 82% (target: 85%)
216
+ Governor: 2 violations remaining (was 8)
217
+ Deploy: Validates against scratch org
218
+ Iteration: N/max
219
+ ────────────────────────────────────────────
220
+ ```
221
+
222
+ ---
223
+
224
+ ## Choosing the Right Pattern
225
+
226
+ ```
227
+ Is the task a single focused Salesforce change?
228
+ ├─ Yes → Sequential Pipeline
229
+ └─ No → Is there a written RFC/spec?
230
+ ├─ Yes → Need parallel layers?
231
+ │ ├─ Yes → RFC-Driven DAG
232
+ │ └─ No → Continuous Claude PR Loop
233
+ └─ No → Need many variants from a spec?
234
+ ├─ Yes → Infinite Agentic Loop
235
+ └─ No → Sequential + De-Sloppify
236
+ ```
237
+
238
+ ### Combining Patterns
239
+
240
+ 1. **Sequential + De-Sloppify** — Most common. Every Apex implement step gets a cleanup pass.
241
+ 2. **Continuous Claude + De-Sloppify** — Add `--review-prompt` with de-sloppify directive.
242
+ 3. **Any loop + Quality Gates** — Use the `sf-review-agent` agent as a gate before commits.
243
+ 4. **Model routing** — `--model haiku` for simple fixes, `--model opus` for architecture.
244
+
245
+ ## Anti-Patterns
246
+
247
+ 1. **Infinite loops without exit conditions** — Always have max-runs, max-cost, or completion signal.
248
+ 2. **No context bridge** — Use `SHARED_TASK_NOTES.md` to bridge `claude -p` invocations.
249
+ 3. **Retrying same failure** — Capture failure output and feed to next attempt.
250
+ 4. **Negative instructions instead of cleanup** — Don't say "don't add System.debug." Add a separate de-sloppify pass.
251
+ 5. **All agents in one context** — Separate concerns into different agent processes.
252
+ 6. **Ignoring deploy dependency order** — Apex before LWC before metadata.
253
+
254
+ ## References
255
+
256
+ | Project | Author | SCC Context |
257
+ |---------|--------|-------------|
258
+ | Ralphinho | enitrat | Adapted for Salesforce layers |
259
+ | Infinite Agentic Loop | disler | Useful for Apex test generation |
260
+ | Continuous Claude | AnandChowdhary | Use with sf apex run test as CI gate |
261
+
262
+ ## Related
263
+
264
+ - **Agent**: `loop-operator` — For monitoring and managing autonomous agent loops
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: mcp-server-patterns
3
+ origin: SCC
4
+ user-invocable: false
5
+ description: >-
6
+ Use when building MCP servers for Salesforce Apex or org integration.
7
+ Node/TypeScript SDK patterns — tools, resources, prompts, Zod validation,
8
+ stdio vs Streamable HTTP. Do NOT use for Apex class writing or deployment.
9
+ ---
10
+
11
+ # MCP Server Patterns
12
+
13
+ The Model Context Protocol (MCP) lets AI assistants call tools, read resources, and use prompts from your server. Use this skill when building or maintaining MCP servers, or integrating with the official Salesforce MCP server. The SDK API evolves; check Context7 (query-docs for "MCP") or the official MCP documentation for current method names and signatures.
14
+
15
+ ## When to Use
16
+
17
+ Use when: implementing a new MCP server, adding tools or resources, choosing stdio vs HTTP, integrating with `@salesforce/mcp`, upgrading the SDK, or debugging MCP registration and transport issues.
18
+
19
+ ## How It Works
20
+
21
+ ### Core Concepts
22
+
23
+ - **Tools**: Actions the model can invoke (e.g. search, run a command). Register with `registerTool()` or `tool()` depending on SDK version.
24
+ - **Resources**: Read-only data the model can fetch (e.g. file contents, API responses). Register with `registerResource()` or `resource()`. Handlers typically receive a `uri` argument.
25
+ - **Prompts**: Reusable, parameterised prompt templates the client can surface (e.g. in Claude Desktop). Register with `registerPrompt()` or equivalent.
26
+ - **Transport**: stdio for local clients (e.g. Claude Desktop); Streamable HTTP is preferred for remote (Cursor, cloud). Legacy HTTP/SSE is for backward compatibility.
27
+
28
+ The Node/TypeScript SDK may expose `tool()` / `resource()` or `registerTool()` / `registerResource()`; the official SDK has changed over time. Always verify against the current [MCP docs](https://modelcontextprotocol.io) or Context7.
29
+
30
+ ### Transport Decision Guide
31
+
32
+ | Transport | Use When | Examples |
33
+ |-----------|----------|---------|
34
+ | **stdio** | Local client, same machine, Claude Desktop/Code | Development, local testing |
35
+ | **Streamable HTTP** | Remote clients, cloud deployment, multi-user | Cursor, production APIs |
36
+ | **Legacy HTTP/SSE** | Backward compatibility only | Older clients |
37
+
38
+ Keep server logic (tools + resources) independent of transport so you can plug in stdio or HTTP in the entrypoint.
39
+
40
+ ## Examples
41
+
42
+ ### Install and Server Setup
43
+
44
+ ```bash
45
+ npm install @modelcontextprotocol/sdk zod
46
+ ```
47
+
48
+ ```typescript
49
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
50
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
51
+ import { z } from "zod";
52
+
53
+ const server = new McpServer({ name: "my-server", version: "1.0.0" });
54
+
55
+ // Register a tool
56
+ server.tool(
57
+ "search-records",
58
+ "Search Salesforce records by keyword",
59
+ { query: z.string(), objectType: z.string().default("Account") },
60
+ async ({ query, objectType }) => {
61
+ // Your implementation here
62
+ return { content: [{ type: "text", text: JSON.stringify(results) }] };
63
+ }
64
+ );
65
+
66
+ // Connect via stdio
67
+ const transport = new StdioServerTransport();
68
+ await server.connect(transport);
69
+ ```
70
+
71
+ > **Note:** Registration API varies by SDK version — some versions use positional args `server.tool(name, description, schema, handler)`, others use object syntax. Check the official MCP docs or Context7 for current `@modelcontextprotocol/sdk` signatures.
72
+
73
+ Use **Zod** (or the SDK's preferred schema format) for input validation.
74
+
75
+ ## Salesforce MCP Integration
76
+
77
+ ### Official @salesforce/mcp Server
78
+
79
+ MCP config is auto-installed by `npx scc install` (`.mcp.json` for Claude Code, `.cursor/mcp.json` for Cursor). The official `@salesforce/mcp` server provides these toolsets:
80
+
81
+ | Toolset | What It Does |
82
+ |---------|-------------|
83
+ | `orgs` | Org management, auth, user info |
84
+ | `metadata` | Deploy, retrieve, list metadata types |
85
+ | `data` | SOQL queries, record CRUD, bulk operations |
86
+ | `users` | User management, permission sets |
87
+ | `testing` | Run Apex tests, get coverage results |
88
+ | `code-analysis` | PMD/scanner, code quality checks |
89
+ | `lwc-experts` | LWC development guidance |
90
+ | `devops` | Source tracking, scratch org operations |
91
+
92
+ ### Using @salesforce/mcp in Claude Code
93
+
94
+ ```json
95
+ {
96
+ "mcpServers": {
97
+ "salesforce": {
98
+ "command": "npx",
99
+ "args": ["-y", "@salesforce/mcp@latest"],
100
+ "env": {
101
+ "SF_ORG_ALIAS": "my-org"
102
+ }
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ ### Building Custom Salesforce MCP Tools
109
+
110
+ When `@salesforce/mcp` doesn't cover your use case (org-specific business logic, custom validation rules, internal APIs), build a custom MCP server:
111
+
112
+ ```typescript
113
+ import { execFileSync } from "child_process";
114
+
115
+ server.tool(
116
+ "validate-account-hierarchy",
117
+ "Check account hierarchy depth and circular references",
118
+ { accountId: z.string().regex(/^[a-zA-Z0-9]{15,18}$/, "Must be a valid 15- or 18-char Salesforce ID") },
119
+ async ({ accountId }) => {
120
+ const result = execFileSync("sf", [
121
+ "data", "query",
122
+ "--sobject", "Account",
123
+ "--where", `Id='${accountId}'`,
124
+ "--fields", "Id,ParentId",
125
+ "--json"
126
+ ], { timeout: 30000, encoding: "utf-8" });
127
+ return { content: [{ type: "text", text: result }] };
128
+ }
129
+ );
130
+ ```
131
+
132
+ ## Best Practices
133
+
134
+ - **Schema first**: Define input schemas with Zod for every tool; document parameters and return shape.
135
+ - **Input validation**: Validate and sanitize all inputs before passing to SF CLI or SOQL. Never interpolate raw user input into shell commands or queries.
136
+ - **Errors**: Return structured errors or messages the model can interpret; avoid raw stack traces.
137
+ - **Idempotency**: Prefer idempotent tools where possible so retries are safe.
138
+ - **Timeouts**: Set explicit timeouts on `execSync`/`exec` calls (e.g., `{ timeout: 30000 }`) and on HTTP requests.
139
+ - **Security**: Never pass raw user input to SOQL queries — use bind variables or parameterized queries. Use Named Credentials for external callouts. Validate Salesforce IDs with Zod regex (`/^[a-zA-Z0-9]{15,18}$/`) before passing to SF CLI.
140
+
141
+ ## Official SDKs and Docs
142
+
143
+ - **JavaScript/TypeScript**: `@modelcontextprotocol/sdk` (npm). Use Context7 with library name "MCP" for current registration and transport patterns.
144
+ - **Go**: Official Go SDK on GitHub (`modelcontextprotocol/go-sdk`).
145
+ - **C#**: Official C# SDK for .NET.
146
+ - **Salesforce MCP**: `@salesforce/mcp` (npm) — official Salesforce MCP server.
@@ -0,0 +1,84 @@
1
+ ---
2
+ name: model-route
3
+ description: >-
4
+ Use when selecting Claude model tier for Salesforce development tasks. Recommend haiku, sonnet,
5
+ or opus based on Apex complexity, deploy risk, and budget.
6
+ origin: SCC
7
+ user-invocable: true
8
+ ---
9
+
10
+ # Model Route — Task-to-Model Tier Recommendation
11
+
12
+ Recommend the best model tier for the current task by complexity and budget.
13
+
14
+ ## When to Use
15
+
16
+ - Before starting a task where model choice significantly affects quality or cost
17
+ - When deciding between haiku, sonnet, and opus for a Salesforce development task
18
+ - When the user wants cost-conscious model selection guidance
19
+ - When routing sub-agent work to the appropriate model tier
20
+
21
+ ## Usage
22
+
23
+ `/model-route [task-description] [--budget low|med|high]`
24
+
25
+ ## Routing Heuristic
26
+
27
+ - `haiku`: deterministic, low-risk mechanical changes
28
+ - `sonnet`: default for implementation and refactors
29
+ - `opus`: architecture, deep review, ambiguous requirements
30
+
31
+ > Model names (haiku, sonnet, opus) refer to the current Claude model mapped to that tier in your Claude Code configuration.
32
+
33
+ ## Output Format
34
+
35
+ - recommended model
36
+ - confidence level
37
+ - why this model fits
38
+ - fallback model if first attempt fails
39
+
40
+ ## Salesforce Routing Examples
41
+
42
+ ### Opus — Complex Reasoning Tasks
43
+
44
+ Use `opus` when the task requires deep understanding of Salesforce architecture, security implications, or governor limit analysis across multiple execution paths.
45
+
46
+ | Task | Why Opus |
47
+ |------|----------|
48
+ | Governor limit audit across trigger/flow/batch chains | Must trace cumulative DML/SOQL across async boundaries, understand order of execution, and reason about worst-case heap/CPU scenarios |
49
+ | Security review of `@RestResource` or `with sharing`/`without sharing` decisions | Requires nuanced reasoning about record access, CRUD/FLS enforcement, SOQL injection vectors, and org-wide defaults |
50
+ | Architecture review for large-scale data model changes | Must evaluate cascade effects on triggers, flows, validation rules, sharing rules, and downstream integrations |
51
+
52
+ ### Haiku — Mechanical / Low-Risk Tasks
53
+
54
+ Use `haiku` when the task is deterministic, well-scoped, and unlikely to have subtle correctness issues.
55
+
56
+ | Task | Why Haiku |
57
+ |------|-----------|
58
+ | Formatting LWC components (fix indentation, add missing `@api` decorators) | Purely mechanical — no logic changes, just style compliance |
59
+ | Simple Apex fixes (rename a variable, fix a typo in a label, add a missing null check) | Single-line or few-line changes with obvious correctness |
60
+ | Adding `<meta.xml>` boilerplate or updating `apiVersion` across components | Repetitive, pattern-based edits with no ambiguity |
61
+
62
+ ### Sonnet — Balanced Implementation Tasks
63
+
64
+ Use `sonnet` (default) for standard development work that requires understanding but follows well-known patterns.
65
+
66
+ | Task | Why Sonnet |
67
+ |------|------------|
68
+ | Code review of an Apex trigger handler or service class | Needs to understand patterns and spot issues, but follows standard review criteria |
69
+ | Generating Apex test classes with `@TestSetup`, mocking, and assertions | Requires understanding the class under test, but test generation follows repeatable patterns |
70
+ | Implementing a new LWC component with wire adapters and error handling | Standard implementation work — needs context awareness but not deep architectural reasoning |
71
+
72
+ ## Arguments
73
+
74
+ - `[task-description]` optional free-text
75
+ - `--budget low|med|high` optional
76
+
77
+ ## Examples
78
+
79
+ ```
80
+ /model-route Review the sharing model for the new Patient__c object hierarchy
81
+ /model-route Fix the CSS alignment on the accountDashboard LWC --budget low
82
+ /model-route Generate test coverage for OpportunityTriggerHandler
83
+ /model-route Audit all SOQL queries in force-app for governor limit risks --budget high
84
+ ```