@salesforce/afv-skills 1.37.0 → 1.38.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 (247) hide show
  1. package/package.json +1 -1
  2. package/skills/agentforce-generate/README.md +20 -3
  3. package/skills/agentforce-generate/SKILL.md +253 -440
  4. package/skills/agentforce-generate/assets/agent-spec-template.md +6 -2
  5. package/skills/agentforce-generate/assets/agents/order-service.agent +16 -12
  6. package/skills/agentforce-generate/assets/agents/production-faq.agent +4 -4
  7. package/skills/agentforce-generate/assets/agents/router-first.agent +5 -5
  8. package/skills/agentforce-generate/assets/agents/template-single-subagent.agent +4 -4
  9. package/skills/agentforce-generate/assets/agents/verification-gate.agent +8 -6
  10. package/skills/agentforce-generate/assets/agents/voice-knowledge-grounded.agent +9 -9
  11. package/skills/agentforce-generate/assets/agents/voice-service-agent.agent +7 -7
  12. package/skills/agentforce-generate/assets/patterns/README.md +3 -3
  13. package/skills/agentforce-generate/assets/patterns/action-callbacks.agent +5 -5
  14. package/skills/agentforce-generate/assets/patterns/advanced-input-bindings.agent +6 -8
  15. package/skills/agentforce-generate/assets/patterns/bidirectional-routing.agent +11 -13
  16. package/skills/agentforce-generate/assets/patterns/critical-input-collection.agent +11 -16
  17. package/skills/agentforce-generate/assets/patterns/lifecycle-events.agent +2 -3
  18. package/skills/agentforce-generate/assets/patterns/llm-controlled-actions.agent +6 -7
  19. package/skills/agentforce-generate/assets/patterns/open-gate-routing.agent +3 -3
  20. package/skills/agentforce-generate/assets/patterns/prompt-template-action.agent +14 -19
  21. package/skills/agentforce-generate/assets/patterns/system-instruction-overrides.agent +11 -20
  22. package/skills/agentforce-generate/references/actions-reference.md +2 -2
  23. package/skills/agentforce-generate/references/agent-audit-and-repair.md +135 -0
  24. package/skills/agentforce-generate/references/agent-audit-candidate-verification.md +160 -0
  25. package/skills/agentforce-generate/references/agent-audit-diagnostic-catalog.md +156 -0
  26. package/skills/agentforce-generate/references/agent-audit-diagnostics-actions-state.md +176 -0
  27. package/skills/agentforce-generate/references/agent-audit-diagnostics-architecture-evaluation.md +68 -0
  28. package/skills/agentforce-generate/references/agent-audit-diagnostics-instructions-routing.md +283 -0
  29. package/skills/agentforce-generate/references/agent-audit-evaluation-loop.md +191 -0
  30. package/skills/agentforce-generate/references/agent-audit-repair-report.md +143 -0
  31. package/skills/agentforce-generate/references/agent-audit-scope-path-review.md +180 -0
  32. package/skills/agentforce-generate/references/agent-design-and-spec-creation.md +105 -59
  33. package/skills/agentforce-generate/references/agent-script-core-language.md +144 -61
  34. package/skills/agentforce-generate/references/agent-subagent-map-diagrams.md +33 -23
  35. package/skills/agentforce-generate/references/agent-validation-and-debugging.md +37 -11
  36. package/skills/agentforce-generate/references/agentscript-toolchain.md +112 -0
  37. package/skills/agentforce-generate/references/architecture-patterns.md +81 -18
  38. package/skills/agentforce-generate/references/common-control-flow-pitfalls.md +255 -0
  39. package/skills/agentforce-generate/references/control-flow-actions-sequencing.md +198 -0
  40. package/skills/agentforce-generate/references/control-flow-lifecycle-side-effects.md +87 -0
  41. package/skills/agentforce-generate/references/examples.md +22 -22
  42. package/skills/agentforce-generate/references/instruction-resolution.md +123 -83
  43. package/skills/agentforce-generate/references/known-issues.md +1 -2
  44. package/skills/agentforce-generate/references/optimization-pattern-1-data-flow.md +4 -0
  45. package/skills/agentforce-generate/references/optimization-pattern-2-deterministic-logic.md +33 -0
  46. package/skills/agentforce-generate/references/optimization-pattern-3-reference-syntax.md +32 -3
  47. package/skills/agentforce-generate/references/optimization-pattern-4-escalation.md +2 -2
  48. package/skills/agentforce-generate/references/patterns-by-requirement.md +3 -1
  49. package/skills/agentforce-generate/references/posture-and-determinism.md +103 -22
  50. package/skills/agentforce-generate/references/reference-map.md +19 -3
  51. package/skills/agentforce-generate/references/scoring-rubric.md +1 -1
  52. package/skills/agentforce-generate/references/voice-latency-heuristics.md +4 -0
  53. package/skills/agentforce-generate/references/voice-modality-reference.md +4 -4
  54. package/skills/agentforce-generate/references/zen-of-agentscript.md +139 -23
  55. package/skills/agentforce-generate/scripts/agentscript-sdk-loader.mjs +133 -0
  56. package/skills/agentforce-generate/scripts/index-agent.mjs +141 -0
  57. package/skills/agentforce-generate/scripts/setup-agentscript-sdk.mjs +337 -0
  58. package/skills/automation-sandbox-post-copy-config-generate/SKILL.md +1 -1
  59. package/skills/automation-sandbox-post-copy-configure/SKILL.md +433 -0
  60. package/skills/automation-sandbox-post-copy-configure/assets/api_request_templates.json +89 -0
  61. package/skills/automation-sandbox-post-copy-configure/examples/sample_config_input.json +40 -0
  62. package/skills/automation-sandbox-post-copy-configure/examples/sample_execution_summary.md +79 -0
  63. package/skills/automation-sandbox-post-copy-configure/references/api_endpoints.md +273 -0
  64. package/skills/automation-sandbox-post-copy-configure/references/authentication.md +94 -0
  65. package/skills/automation-sandbox-post-copy-configure/references/execution_phasing.md +93 -0
  66. package/skills/automation-sandbox-post-copy-configure/references/rules_gotchas.md +35 -0
  67. package/skills/automation-sandbox-post-copy-configure/scripts/classify-patch-result.mjs +88 -0
  68. package/skills/automation-sandbox-post-copy-configure/scripts/map-metadata-key.mjs +98 -0
  69. package/skills/automation-sandbox-post-copy-configure/scripts/plan-phases.mjs +98 -0
  70. package/skills/automation-sandbox-post-copy-configure/scripts/resolve-target-org.mjs +56 -0
  71. package/skills/design-systems-slds-validate/SKILL.md +14 -13
  72. package/skills/dx-code-analyzer-custom-rule-create/examples/xpath-examples.md +1 -1
  73. package/skills/dx-code-analyzer-custom-rule-create/references/xpath-patterns-security.md +1 -1
  74. package/skills/dx-org-devhub-configure/SKILL.md +268 -0
  75. package/skills/dx-org-devhub-configure/examples/status-output.md +39 -0
  76. package/skills/dx-org-devhub-configure/scripts/devhub.sh +650 -0
  77. package/skills/dx-org-devhub-configure/scripts/test-devhub.sh +116 -0
  78. package/skills/dx-org-manage/SKILL.md +135 -42
  79. package/skills/dx-org-manage/assets/derive-alias.sh +95 -0
  80. package/skills/dx-org-manage/assets/scratch-def.seed.json +6 -0
  81. package/skills/dx-org-manage/examples/README.md +1 -1
  82. package/skills/dx-org-manage/examples/scratch-orgs/delete_output.json +8 -0
  83. package/skills/dx-org-manage/examples/scratch-orgs/display_output.json +23 -0
  84. package/skills/dx-org-manage/examples/scratch-orgs/list_output.json +58 -0
  85. package/skills/dx-org-manage/examples/scratch-orgs/resume_output.json +38 -0
  86. package/skills/dx-org-manage/examples/scratch-orgs/success_definition_file.json +1 -1
  87. package/skills/dx-org-manage/examples/scratch-orgs/success_edition.json +1 -1
  88. package/skills/dx-org-manage/examples/scratch-orgs/success_shape.json +41 -0
  89. package/skills/dx-org-manage/examples/scratch-orgs/success_snapshot.json +1 -1
  90. package/skills/dx-org-manage/examples/snapshots/error_output.json +3 -3
  91. package/skills/dx-org-manage/references/creating-scratch-org.md +2 -2
  92. package/skills/dx-org-manage/references/creating-snapshot.md +1 -2
  93. package/skills/dx-org-manage/references/definition_file_options.md +24 -0
  94. package/skills/dx-org-manage/references/edition_types.md +10 -8
  95. package/skills/dx-org-manage/references/opening-org.md +11 -12
  96. package/skills/dx-org-manage/references/scratch-org-create.md +303 -0
  97. package/skills/dx-org-manage/references/scratch-org-operations.md +135 -0
  98. package/skills/experience-aura-lwc-migrate/SKILL.md +120 -0
  99. package/skills/experience-aura-lwc-migrate/references/aura-api-expert.md +170 -0
  100. package/skills/experience-aura-lwc-migrate/references/aura-data-expert.md +172 -0
  101. package/skills/experience-aura-lwc-migrate/references/aura-migration-guidelines.md +299 -0
  102. package/skills/experience-aura-lwc-migrate/references/aura-prd-framework.md +79 -0
  103. package/skills/experience-aura-lwc-migrate/references/aura-redundant-code-expert.md +24 -0
  104. package/skills/experience-aura-lwc-migrate/references/aura-reference-expert.md +140 -0
  105. package/skills/experience-aura-lwc-migrate/references/aura-resolver-expert.md +115 -0
  106. package/skills/experience-aura-lwc-migrate/references/aura-slots-expert.md +67 -0
  107. package/skills/experience-aura-lwc-migrate/references/aura-style-expert.md +62 -0
  108. package/skills/experience-aura-lwc-migrate/references/aura-to-lwc-completeness-checklist.md +188 -0
  109. package/skills/experience-aura-lwc-migrate/references/aura-values-expert.md +67 -0
  110. package/skills/experience-content-media-search/SKILL.md +17 -12
  111. package/skills/experience-content-media-stock-image-search/SKILL.md +192 -0
  112. package/skills/experience-content-media-stock-image-search/scripts/download-stock-image.py +102 -0
  113. package/skills/experience-lds-best-practices-apply/SKILL.md +245 -0
  114. package/skills/experience-lds-best-practices-apply/references/adapter-apis.md +1640 -0
  115. package/skills/experience-lds-best-practices-apply/references/lds-data-consistency.md +126 -0
  116. package/skills/experience-lds-best-practices-apply/references/lds-expert.md +429 -0
  117. package/skills/experience-lds-best-practices-apply/references/lds-referential-integrity.md +322 -0
  118. package/skills/experience-lds-best-practices-apply/references/wire-adapter-types.md +1511 -0
  119. package/skills/experience-lds-graphql-generate/SKILL.md +222 -0
  120. package/skills/experience-lds-graphql-generate/references/generation-guide.md +236 -0
  121. package/skills/experience-lds-graphql-generate/references/generation-mutation.md +277 -0
  122. package/skills/experience-lds-graphql-generate/references/generation-query.md +237 -0
  123. package/skills/experience-lds-graphql-generate/scripts/fetch-lds-graphql-schema.sh +230 -0
  124. package/skills/experience-lds-graphql-generate/scripts/test-lds-graphql-query.sh +128 -0
  125. package/skills/experience-lwc-accessibility-validate/SKILL.md +112 -0
  126. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-1-1-non-text-content.md +88 -0
  127. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-i-lists.md +52 -0
  128. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-ii-tables.md +106 -0
  129. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iii-form-labels.md +78 -0
  130. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-iv-regions.md +26 -0
  131. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-1-v-groups.md +66 -0
  132. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-3-5-identify-input.md +70 -0
  133. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-1-4-3-contrast.md +115 -0
  134. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-1-1-keyboard.md +47 -0
  135. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-4-link-purpose.md +39 -0
  136. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-4-6-headings-labels.md +50 -0
  137. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-1-pointer-gestures.md +54 -0
  138. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-2-pointer-cancellation.md +49 -0
  139. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-3-label-in-name.md +77 -0
  140. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-2-5-7-dragging-movement.md +45 -0
  141. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-1-on-focus.md +55 -0
  142. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-2-2-on-input.md +51 -0
  143. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-1-error-identification.md +84 -0
  144. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-2-labels-instructions.md +50 -0
  145. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-3-3-3-error-suggestion.md +64 -0
  146. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-i-name.md +105 -0
  147. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-ii-role.md +99 -0
  148. package/skills/experience-lwc-accessibility-validate/references/reviewers/sc-4-1-2-iii-value.md +97 -0
  149. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-1-1-non-text-content.md +83 -0
  150. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-1-use-of-color.md +62 -0
  151. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-10-resize-reflow.md +18 -0
  152. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-11-non-text-contrast.md +43 -0
  153. package/skills/experience-lwc-accessibility-validate/references/vision/sc-1-4-3-contrast.md +25 -0
  154. package/skills/experience-lwc-accessibility-validate/scripts/contrast-ratio.py +153 -0
  155. package/skills/experience-lwc-design-generate/SKILL.md +261 -0
  156. package/skills/experience-lwc-design-generate/references/figma-to-prd-blueprint.md +66 -0
  157. package/skills/experience-lwc-design-generate/references/prd-analysis-template.md +17 -0
  158. package/skills/experience-lwc-design-generate/scripts/check-component-name.sh +75 -0
  159. package/skills/experience-lwc-design-generate/scripts/detect-project-tools.sh +97 -0
  160. package/skills/experience-lwc-runtime-observe/SKILL.md +244 -0
  161. package/skills/experience-lwc-runtime-observe/examples/component-preview-and-dom.md +41 -0
  162. package/skills/experience-lwc-runtime-observe/scripts/extract-dom.sh +79 -0
  163. package/skills/experience-lwc-runtime-observe/scripts/open-frontdoor.sh +46 -0
  164. package/skills/experience-lwc-runtime-observe/scripts/verify-toolchain.sh +48 -0
  165. package/skills/experience-lwc-security-validate/SKILL.md +151 -0
  166. package/skills/experience-lwc-security-validate/examples/review-report.md +6 -0
  167. package/skills/experience-lwc-security-validate/examples/score-report.sarif.json +32 -0
  168. package/skills/experience-lwc-security-validate/references/lws-security-expert.md +986 -0
  169. package/skills/experience-lwc-security-validate/references/security-analysis.md +611 -0
  170. package/skills/experience-lwc-security-validate/scripts/check-lwc-import.sh +166 -0
  171. package/skills/experience-lwc-security-validate/scripts/validate-sarif.sh +131 -0
  172. package/skills/experience-ui-bundle-2gp-deploy/SKILL.md +454 -0
  173. package/skills/experience-ui-bundle-2gp-deploy/assets/CustomApplication.app-meta.xml +12 -0
  174. package/skills/experience-ui-bundle-2gp-deploy/assets/PermissionSet.permissionset-meta.xml +9 -0
  175. package/skills/experience-ui-bundle-2gp-deploy/scripts/find-bundle-package-dir.sh +53 -0
  176. package/skills/experience-ui-bundle-agentforce-client-generate/SKILL.md +104 -26
  177. package/skills/experience-ui-bundle-agentforce-client-generate/references/constraints.md +35 -24
  178. package/skills/experience-ui-bundle-agentforce-client-generate/references/examples.md +92 -1
  179. package/skills/experience-ui-bundle-agentforce-client-generate/references/style-tokens.md +2 -0
  180. package/skills/experience-ui-bundle-agentforce-client-generate/references/troubleshooting.md +14 -1
  181. package/skills/experience-ui-bundle-agentforce-client-generate/scripts/detect-framework.sh +67 -0
  182. package/skills/experience-ui-bundle-deploy/SKILL.md +83 -14
  183. package/skills/experience-ui-bundle-deploy/assets/Communities.settings-meta.xml +19 -0
  184. package/skills/experience-ui-bundle-deploy/assets/org-setup.config.template.json +5 -0
  185. package/skills/experience-ui-bundle-deploy/assets/social-login-auth-providers.apex +158 -0
  186. package/skills/experience-ui-bundle-deploy/references/config-scaffold.md +13 -1
  187. package/skills/experience-ui-bundle-deploy/references/social-login.md +179 -0
  188. package/skills/experience-ui-bundle-frontend-generate/SKILL.md +14 -0
  189. package/skills/experience-ui-bundle-mfa-configure/SKILL.md +6 -5
  190. package/skills/experience-ui-bundle-mfa-configure/references/social-login.md +15 -7
  191. package/skills/experience-ui-bundle-salesforce-data-access/SKILL.md +41 -5
  192. package/skills/experience-ui-bundle-salesforce-data-access/references/caching.md +10 -22
  193. package/skills/experience-ui-bundle-salesforce-data-access/references/graphql-hand-authoring.md +4 -19
  194. package/skills/experience-ui-bundle-salesforce-data-access/references/migration.md +5 -0
  195. package/skills/experience-ui-bundle-salesforce-data-access/references/sdk-api.md +33 -150
  196. package/skills/mobile-platform-native-capabilities-integrate/references/nfc.md +35 -0
  197. package/skills/platform-apex-generate/SKILL.md +8 -7
  198. package/skills/platform-apex-test-generate/SKILL.md +3 -1
  199. package/skills/platform-apex-test-run/SKILL.md +9 -8
  200. package/skills/platform-lightning-type-widget-coordinate/SKILL.md +1 -1
  201. package/skills/platform-lightning-type-widget-coordinate/examples/existing-lightning-type-with-widget-prompt.md +1 -1
  202. package/skills/platform-lightning-type-widget-coordinate/examples/new-lightning-type-with-widget-prompt.md +1 -1
  203. package/skills/platform-lightning-type-widget-coordinate/references/validation-gates.md +3 -3
  204. package/skills/platform-mcp-tool-widget-coordinate/SKILL.md +43 -67
  205. package/skills/platform-mcp-tool-widget-coordinate/examples/action-name-source-prompt.md +1 -2
  206. package/skills/platform-mcp-tool-widget-coordinate/examples/apex-invocable-source-prompt.md +2 -3
  207. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-list-source-prompt.md +163 -0
  208. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-single-source-prompt.md +198 -0
  209. package/skills/platform-mcp-tool-widget-coordinate/examples/pasted-tool-output-prompt.md +0 -1
  210. package/skills/platform-mcp-tool-widget-coordinate/references/build-plan-format.md +17 -11
  211. package/skills/platform-mcp-tool-widget-coordinate/references/mcp-tool-output-discovery.md +48 -15
  212. package/skills/platform-mcp-tool-widget-coordinate/references/two-clt-modeling.md +73 -10
  213. package/skills/platform-mcp-tool-widget-coordinate/references/validation-gates.md +48 -8
  214. package/skills/platform-policy-rule-generate/SKILL.md +22 -12
  215. package/skills/platform-policy-rule-generate/references/deploy-errors.md +1 -1
  216. package/skills/platform-policy-rule-generate/references/policy-schema-full.md +8 -29
  217. package/skills/platform-policy-rule-generate/references/templates-advanced.md +1 -1
  218. package/skills/platform-sharing-owd-configure/SKILL.md +20 -8
  219. package/skills/platform-sharing-owd-configure/references/access_levels.md +14 -1
  220. package/skills/platform-sharing-rules-generate/SKILL.md +67 -35
  221. package/skills/platform-sharing-rules-generate/examples/create-cases.md +16 -17
  222. package/skills/platform-sharing-rules-generate/examples/delete-cases.md +34 -79
  223. package/skills/platform-sharing-rules-generate/examples/edit-cases.md +13 -26
  224. package/skills/platform-sharing-rules-generate/scripts/count-remaining-rules.sh +33 -0
  225. package/skills/platform-widget-generate/SKILL.md +3 -5
  226. package/skills/platform-widget-generate/examples/conditional.json +18 -13
  227. package/skills/platform-widget-generate/examples/list-with-foreach.json +2 -2
  228. package/skills/platform-widget-generate/examples/single-object.json +2 -2
  229. package/skills/platform-widget-generate/references/schema-from-lightning-type.md +27 -6
  230. package/skills/platform-widget-generate/references/widget-bundle-layout.md +4 -3
  231. package/skills/service-itsm-agentic-setup-cmdb-access-assign/SKILL.md +287 -0
  232. package/skills/service-itsm-agentic-setup-cmdb-access-assign/references/mcp-invocation.md +260 -0
  233. package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/SKILL.md +252 -0
  234. package/skills/service-itsm-agentic-setup-cmdb-bundle-deploy/references/mcp-invocation.md +204 -0
  235. package/skills/service-itsm-agentic-setup-cmdb-configure/SKILL.md +259 -0
  236. package/skills/service-itsm-agentic-setup-cmdb-configure/references/mcp-invocation.md +188 -0
  237. package/skills/service-itsm-agentic-setup-cmdb-coordinate/SKILL.md +197 -0
  238. package/skills/service-itsm-agentic-setup-cmdb-coordinate/examples/output-templates.md +77 -0
  239. package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/SKILL.md +316 -0
  240. package/skills/service-itsm-agentic-setup-cmdb-discovery-configure/references/mcp-invocation.md +221 -0
  241. package/skills/service-itsm-incident-priority-configure/SKILL.md +168 -0
  242. package/skills/service-itsm-incident-priority-configure/examples/matrix-operations.md +200 -0
  243. package/skills/service-itsm-incident-priority-configure/examples/render-matrix.md +54 -0
  244. package/skills/service-itsm-incident-priority-configure/examples/seed-full-matrix.md +52 -0
  245. package/skills/service-itsm-incident-priority-configure/references/sf-cli-invocation.md +264 -0
  246. package/skills/platform-mcp-tool-widget-coordinate/examples/nested-object-source-prompt.md +0 -191
  247. package/skills/platform-policy-rule-generate/references/fixtures-index.md +0 -29
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: agentforce-generate
3
- description: "Build, modify, optimize, debug, and deploy agents with Agentforce Agent Script. TRIGGER when: user creates, modifies, optimizes, or asks about .agent files or aiAuthoringBundle metadata; changes agent behavior, responses, or conversation logic; designs agent actions, tools, subagents, or flow control; writes or reviews an Agent Spec; wants to optimize, improve, or refactor an agent; previews, debugs, deploys, publishes, or tests agents; uses Agent Script CLI commands (sf agent generate/preview/publish/test); registers/creates/lists/updates/deletes MCP servers, whitelists/approves MCP tools, fetches MCP assets, or configures MCP authentication (sf agent mcp). DO NOT TRIGGER when: Apex development, Flow building, Prompt Template authoring, Experience Cloud configuration, or general Salesforce CLI tasks unrelated to Agent Script."
3
+ description: "Build, modify, audit, repair, optimize, debug, and deploy agents with Agentforce Agent Script. TRIGGER when: user creates, reviews, or changes .agent files or aiAuthoringBundle metadata; asks to fix AgentScript, audit an existing agent, run an AgentScript health check, common-pitfall review, or baseline-versus-candidate repair loop; changes a response, action, subagent, route, state flow, or Agent Spec; previews, debugs, deploys, publishes, or tests agents; uses sf agent generate/preview/publish/test; or manages Agentforce MCP servers, tools, assets, or authentication. DO NOT TRIGGER when: Apex, Flow, Prompt Template, Experience Cloud, or general Salesforce CLI work is unrelated to Agent Script; or the primary input is a production session or trace ID rather than an agent artifact."
4
4
  metadata:
5
5
  version: "0.11"
6
6
  minApiVersion: "66.0"
@@ -12,12 +12,20 @@ metadata:
12
12
  - "platform-apex-generate"
13
13
  - "platform-metadata-deploy"
14
14
  cliTools:
15
+ - tool: ["corepack"]
16
+ semver: ">=0.25.0"
15
17
  - tool: ["curl"]
16
18
  semver: ">=7.0.0"
19
+ - tool: ["git"]
20
+ semver: ">=2.0.0"
17
21
  - tool: ["jq"]
18
22
  semver: ">=1.6.0"
23
+ - tool: ["node"]
24
+ semver: ">=20.0.0"
19
25
  - tool: ["npm"]
20
26
  semver: ">=9.0.0"
27
+ - tool: ["pnpm"]
28
+ semver: ">=8.0.0"
21
29
  - tool: ["python3"]
22
30
  semver: ">=3.10.0"
23
31
  - tool: ["sf"]
@@ -37,7 +45,12 @@ Einstein Agent User. Static authoring and review can proceed without org access.
37
45
  language. Do NOT confuse Agent Script syntax or semantics with any other
38
46
  language you have been trained on.
39
47
 
40
- Agent Script agents are defined by `AiAuthoringBundle` metadata: a `.agent` file (agent behavior) plus `bundle-meta.xml` (bundle metadata). Actions can be implemented with invocable Apex, autolaunched Flows, Prompt Templates, and other supported types.
48
+ Agent Script agents are defined by `AiAuthoringBundle` metadata: an
49
+ `<ApiName>.agent` file (agent behavior) plus a sibling
50
+ `<ApiName>.bundle-meta.xml` file (bundle metadata). The directory and both
51
+ filenames must use the same case-sensitive API name; a literal
52
+ `bundle-meta.xml` filename is not deployable. Actions can be implemented with
53
+ invocable Apex, autolaunched Flows, Prompt Templates, and other supported types.
41
54
 
42
55
  This skill covers the full Agent Script lifecycle: designing agents,
43
56
  writing Agent Script code, validating and debugging, deploying and
@@ -52,29 +65,46 @@ required by the active step or needed for the current decision. Every
52
65
  **Reference Files** section is a lookup index, not a preload list; do not load
53
66
  files for later or inapplicable steps.
54
67
 
68
+ For a comprehensive health check, common-pitfall audit, or audit-fix-evaluate
69
+ loop over an existing agent, use the **Audit and Repair an Existing Agent**
70
+ task domain below as part of the same authoring lifecycle.
71
+
55
72
  ## Rules That Always Apply
56
73
 
57
74
  1. **Always `--json`.** ALWAYS include `--json` on EVERY `sf` CLI command. Do NOT pipe CLI output through `jq` or `2>/dev/null`. Read the full JSON response directly — LLMs parse JSON natively.
58
75
 
59
76
  2. **Verify target org.** Before any org interaction, run `sf config get target-org --json` to confirm a target org is set. If none configured, ask the user to set one with `sf config set target-org <alias>`.
60
77
 
61
- 3. **Diagnose before you fix.** When validating/debugging agent behavior,
62
- ALWAYS `--use-live-actions` to preview authoring bundles. Send utterances
63
- then read resulting session traces to ground your understanding of the
64
- agent's behavior. Trace files reveal subagent selection, action I/O, and
65
- LLM reasoning. DO NOT modify `.agent` files or action implementations without
66
- this grounding. See [Validation & Debugging](references/agent-validation-and-debugging.md)
67
- for trace file locations and diagnostic patterns.
68
-
69
- 4. **Spec approval is a hard gate.** Never proceed past Agent Spec
70
- creation without explicit user approval.
78
+ 3. **Diagnose in proportion to the change.** For syntax or local static defects,
79
+ run the supported local parser/compiler first, then add target-org validation
80
+ when available.
81
+ For behavioral defects, preserve a baseline and use preview plus traces.
82
+ For a Surface repair, freeze the exact accepted edit list, then inspect the
83
+ final diff and revert every other hunk, including block-scalar or metadata
84
+ normalization. In a smallest-change repair, keep optional cosmetic findings
85
+ advisory unless the user explicitly includes cleanup in scope; valid syntax
86
+ with no diagnostic or use-case consequence is not an extra repair.
87
+ Simulation can establish routing and action selection; use
88
+ `--use-live-actions` only with explicit approval, a verified non-production
89
+ environment, and safe test data. Do not claim an external effect from
90
+ simulation or response text. See
91
+ [Validation & Debugging](references/agent-validation-and-debugging.md).
92
+
93
+ 4. **Use a proportionate spec gate.** Obtain explicit Agent Spec approval for
94
+ greenfield agents and Structural or Rewrite changes. A user-authorized,
95
+ well-specified local repair does not require recreating or reapproving the
96
+ entire spec; record the affected use case and preserve the existing design.
97
+ When the user supplies a sufficiently detailed design and explicitly says it
98
+ is already approved, treat that as the approved spec: do not recreate it or
99
+ stop for another approval unless requirements are missing or materially change.
71
100
 
72
101
  5. **Don't stall.** After a step completes successfully, announce the
73
102
  next step and start it. Do not wait for the user to say "what's next"
74
- or "ok, continue." The only checkpoints that require explicit user
75
- approval are: (a) Agent Spec approval, (b) the pre-Publish CHECKPOINT,
76
- (c) any A/B branch the skill explicitly surfaces (e.g., Data Cloud
77
- not provisioned during ADL setup). Long-running async work like ADL
103
+ or "ok, continue." Checkpoints that require explicit user approval include:
104
+ (a) Agent Spec approval when required by Rule 4, (b) the pre-Publish
105
+ CHECKPOINT, (c) destructive or consequential external operations, and (d)
106
+ any A/B branch the skill explicitly surfaces (e.g., Data Cloud not
107
+ provisioned during ADL setup). Long-running async work like ADL
78
108
  indexing should run in the background while the skill continues with
79
109
  work that doesn't depend on the result.
80
110
 
@@ -114,457 +144,220 @@ files for later or inapplicable steps.
114
144
  4 spaces per level. Preserve a consistently indented legacy file during a
115
145
  surgical edit, or normalize the whole file as a separate validated change.
116
146
 
147
+ 12. **Do not let prompt formatting impersonate control flow.** Indentation,
148
+ numbered steps, and words such as `Show`, `Ask`, `Call`, `Set`, or `STOP`
149
+ inside `|` text are model instructions, not executable scope. Gate actions
150
+ independently. Use one `|` per contiguous prompt block; repeated adjacent
151
+ markers do not create stages or priority. Do not use
152
+ `@utils.setVariables` to force a turn boundary or another reasoning
153
+ iteration. Apply the checklist in
154
+ [Common Control-Flow Pitfalls](references/common-control-flow-pitfalls.md).
155
+
156
+ 13. **Choose who owns each decision.** Use runtime predicates when an exact
157
+ machine-known fact has a consequence that must remain stable. Use model
158
+ instructions when semantic intent, ambiguity, recovery, or
159
+ situation-aware judgment makes flexibility more valuable. A model cannot
160
+ read stored variable values unless prompt text injects them with
161
+ `{!@variables.X}`; interpolation reveals a value but does not make the
162
+ model's comparison deterministic. Apply the tradeoff test in
163
+ [Posture & Determinism](references/posture-and-determinism.md).
164
+
165
+ 14. **Compile AgentScript locally first, cheaply, and visibly.** For every
166
+ authoring, repair, or audit task with an existing `.agent` file, attempt the
167
+ bundled local index/compiler before org-side validation or a completion
168
+ report. Run
169
+ `node <skill-directory>/scripts/index-agent.mjs <agent-file>`. If the SDK
170
+ cannot load, follow
171
+ [AgentScript Compiler Setup](references/agentscript-toolchain.md), retry,
172
+ and use its bounded npm/source fallback. Fix every severity-1 diagnostic
173
+ and rerun until clean. Report the provider and exact version or commit.
174
+ Org access does not replace this cheap local pass. If both local setup paths
175
+ fail, continue with target-org validation or a bounded static review and
176
+ state **compiler not used** with the cause; do not stall the task or imply
177
+ that a suggested future command was validation. **Offline** or
178
+ **non-interactive** mode does not waive this step: it prohibits network and
179
+ org operations, not the bundled local compiler.
180
+
181
+ 15. **Keep the authoring-bundle shape deployable.** Under
182
+ `aiAuthoringBundles/<ApiName>/`, require exactly the matching pair
183
+ `<ApiName>.agent` and `<ApiName>.bundle-meta.xml`. Do not shorten the
184
+ metadata filename to `bundle-meta.xml`. Preserve scaffolded or retrieved
185
+ metadata rather than rewriting its schema. A new CLI-scaffolded bundle
186
+ normally uses `<bundleType>AGENT</bundleType>`; an existing descriptor can
187
+ instead use the established `fullName`/`type`/`status` shape, with optional
188
+ `label` and `description`. Do not create a partial hybrid or invent fields.
189
+ Local compilation of the `.agent` file does not verify the metadata
190
+ filename or XML, so check both before reporting validation success.
191
+
117
192
  ## Task Domains
118
193
 
119
- Every task domain below has **Required Steps**. Follow verbatim, in order. The default path is: design -> draft implementation loop -> validation/preview loop -> explicit user-approved release.
194
+ Choose the domain that matches the user's current objective. Read its named
195
+ references before acting; the links are load instructions, not an optional
196
+ bibliography. Follow only the applicable workflow and preserve any satisfied
197
+ prerequisites. The normal lifecycle is design -> draft -> validate/preview ->
198
+ explicitly approved release.
120
199
 
121
200
  ### Create an Agent
122
201
 
123
- User wants to build new agent from scratch. ALWAYS use Agent Script. Work with User to understand the agent's purpose, subagents, and actions using plain language without Salesforce-specific terminology.
124
-
125
- #### Required Steps
126
-
127
- Before running an `sf` command, read only the applicable command section in
128
- [CLI for Agents](references/salesforce-cli-for-agents.md). Do not preload the
129
- CLI reference during design-only work.
130
-
131
- 1. **Design** — Read [Design & Agent Spec](references/agent-design-and-spec-creation.md) to draft an Agent Spec. Default all new actions to `NEEDS STUB` placeholders during planning. Ask the user which implementation path they want before implementation work:
132
- - Path A: Keep placeholders only (no implementation now)
133
- - Path B: Scan for existing actions to reuse
134
- - Path C: Generate new actions
135
- Only run scans (reading `sfdx-project.json`, searching `@InvocableMethod`, `AutoLaunchedFlow`, prompt templates, external service registrations, standard invocable actions, and custom objects) if the user explicitly chooses Path B or C.
136
- **If the agent's purpose involves answering from documents** (e.g., "answer customer questions from our product manual", "respond based on a policy guide", "FAQ from a PDF"), ask the user: *"Will this agent answer questions from a document corpus (PDF/DOCX/TXT)? If so, what file path?"* Capture the path in the Spec under a **"Knowledge Grounding"** section. Asking now — during requirements capture — is critical: ADL indexing takes minutes, so we want the file path captured pre-Spec-approval and provisioning kicked off as early as possible.
137
- **If the agent will handle voice/telephony** (e.g., "phone agent", "voice bot", "IVR replacement", "call center agent"), confirm it's a voice agent and capture a **"Voice Configuration"** section in the Spec. **Do not ask the user for a voice_id** — there is no reliable way to enumerate voice IDs and tuning values from the CLI. Always start with the platform default voice (`UgBBYS2sOqTuMpoF3BR0` — "Mark", en_US; `outbound_speed: 1`, `outbound_stability: 0.65`, `outbound_similarity: 0.75`) and tell the user they can customize the voice later in the Agent Builder UI (open the agent → **Connections → Voice**, click **Continue** to pick a different voice and tune speed/stability). See [Voice Modality Reference](references/voice-modality-reference.md) for the `modality voice:` block syntax and voice-specific authoring guidance.
138
- **Voice service agents are almost always knowledge-backed** (callers ask FAQ/policy/troubleshooting questions). When you detect a voice agent, proactively ask the Knowledge Grounding question above — do not wait for the user to mention documents. This pairing (voice + knowledge grounding) is the Project Codey "Steel Thread 2" shape, and grounding on an ADL/Salesforce Knowledge corpus is what keeps a voice agent from hallucinating spoken answers. If the user has a document corpus, capture the file path and provision the ADL as usual; the `assets/agents/voice-knowledge-grounded.agent` template shows the combined wiring.
139
- **Always save Agent Spec as file.**
140
- 2. **STOP for user approval of Agent Spec.** Present to user (including the Knowledge Grounding section if present). Ask for approval or feedback. **Do not proceed** without approval. Once approved, proceed without stopping unless a step fails.
141
- 3. **Validate environment prerequisites** — Read [Design & Agent Spec](references/agent-design-and-spec-creation.md), Section 3 (Environment Prerequisites). Based on agent type from design, validate org environment:
142
- - **Employee agent**: Confirm the file normally omits `access.default_agent_user`, `connection messaging:`, and MessagingSession linked variables. Remove them if present. **Exception:** If the agent has a `knowledge:` block (uses `AnswerQuestionsWithKnowledge`), `access.default_agent_user` IS required even for employee agents — the platform treats knowledge-grounded agents as requiring an Einstein Agent User context at runtime. Query for the agent user and include it. See [Examples](references/examples.md) for a complete employee agent example.
143
- - **Service agent**: Query org for Einstein Agent User. If one exists, confirm username with user. If none, guide user through creation. See [CLI for Agents](references/salesforce-cli-for-agents.md), Section 12 for creation steps and [Agent User Setup](references/agent-user-setup.md) for required permissions.
144
- **3b. Kick off ADL provisioning (only if the Spec has a Knowledge Grounding section).** Read [Data Library Reference](references/data-library-reference.md). Run the Step 0 preflight: `SELECT COUNT() FROM DataKnowledgeSpace` (DC provisioned check), then `sf agent adl list` (ADL service health check). If DC is not provisioned, present the A/B choice from that reference. If DC is provisioned but the ADL service returns `400 INTERNAL_ERROR`, surface the "DC up, ADL broken" path and skip grounding for this run. If both checks pass, run `sf agent adl create` (reference Step 1) to capture `libraryId`. Compute `rag_feature_config_id = "ARFPC_<libraryId>"` from the `libraryId` alone — that's enough to author the bundle. Then start the upload + indexing flow (reference Steps 2–6) **in the background** while authoring continues. Per Rule 5, do not block on async indexing; `retrieverId` is only needed for runtime queries (gated in Step 8). Also kick off the Data Cloud permset assignment for the agent user — see [Agent User Setup](references/agent-user-setup.md), Step 3b for the discovery-then-assign procedure, which now ends with Step 3b.5 pinned post-assignment verification (against the resolved running-user and Einstein Agent User IDs) so callers can treat "Step 3b passed" as an authoritative Data Cloud grounding gate without re-running inline SOQL.
145
- **Do not proceed to code generation until environment is validated** (ADL provisioning may continue running in background).
146
- 4. **Generate authoring bundle** —
147
- `sf agent generate authoring-bundle --json --no-spec --name "<Label>" --api-name <Developer_Name>`
148
- 5. **Write code** — Read [Core Language](references/agent-script-core-language.md) for syntax, block structure, and anti-patterns. Read [Instruction Resolution](references/instruction-resolution.md) for instruction patterns, recommended instruction order, and anti-patterns (especially Anti-Pattern 7: prose-based conditional logic). Edit generated `.agent` file using reference files and templates. Do not create `.agent` or `bundle-meta.xml` files manually. If Step 3b produced a `libraryId`, include the top-level `knowledge:` block and the `AnswerQuestionsWithKnowledge` action wiring per [Data Library Reference](references/data-library-reference.md), section "Wiring the ADL into Agent Script". The template at `assets/agents/knowledge-grounded.agent` is a copy-modify starting point. **If the Spec has a Voice Configuration section**, include the `modality voice:` block (using the default `voice_id` and tuning values) and `language:` block per [Voice Modality Reference](references/voice-modality-reference.md). Keep the standard `agent_type` (e.g. `AgentforceServiceAgent`) — do NOT set an `Atlas__VoiceAgent` template in the bundle; that is a runtime planner_type, not an authored field. Also add the `VoiceCallId: linked string` variable bound to `@VoiceCall.Id` and add `connection customer_web_client:` (ECv2 — the voice-capable surface) with `adaptive_response_allowed: True`. Keep the `modality voice:` block minimal (voice_id + speed/stability/similarity); advanced settings (filler-word detection, speak-up, endpointing) are optional — add only if the Spec calls for them. `connection messaging:` is additive — include it only if the agent escalates to a human (`@utils.escalate`). Write concise voice instructions with the high-value guards: read back critical data (IDs/amounts/dates) before acting, and never read out URLs/citations/visual formatting. Also add the spoken-delivery instruction rules from [Voice Modality Reference](references/voice-modality-reference.md) "Instructions for Voice Agents" — ack/filler phrases before slow actions, spoken-form numbers, ASR repair prompts, and empty-result fallbacks. When wiring actions into a voice agent, apply the voice-safe action rules in [actions-reference.md](references/actions-reference.md) "Voice-Safe Action Authoring" (plain-English descriptions, speakable parameter names, enums, lookup-step for internal IDs, voice-friendly error shapes) and check the actions against [voice-latency-heuristics.md](references/voice-latency-heuristics.md) — flag (don't silently rewrite) sync writes, bulky retrieval, and chained callouts on the live-call path. The template at `assets/agents/voice-service-agent.agent` is a copy-modify starting point. **If the Spec has both a Voice Configuration and a Knowledge Grounding section**, start from `assets/agents/voice-knowledge-grounded.agent` instead — it combines `modality voice:`, the voice wiring, and the `knowledge:` block + `AnswerQuestionsWithKnowledge` action with spoken-answer anti-hallucination guards.
149
- 6. **Validate compilation** —
150
- `sf agent validate authoring-bundle --json --api-name <Developer_Name>`
151
- If validation fails, read [Validation & Debugging](references/agent-validation-and-debugging.md) to diagnose and fix, then re-validate. ALWAYS fix syntax and structural errors before generating action implementations.
152
- 7. **Generate action implementations (explicit user-requested path only)** — Only run this step if the user explicitly asked to generate new implementations (Path C in Step 1). For each action marked NEEDS STUB:
153
- `sf template generate apex class --name <ClassName> --output-dir <PACKAGE_DIR>/main/default/classes`
154
- Replace class body with invocable pattern from [Design & Agent Spec](references/agent-design-and-spec-creation.md). ALWAYS deploy:
155
- `sf project deploy start --json --metadata ApexClass:<ClassName>`
156
- ALWAYS fix deploy errors BEFORE generating and deploying next stub.
157
- 8. **Validate behavior** — Read [Validation & Debugging](references/agent-validation-and-debugging.md) for preview workflow and session trace analysis.
158
- **If Step 3b provisioned an ADL**, before sending any grounded test utterances confirm the library is queryable: run `sf agent adl get -i $LIBRARY_ID` and check that `retrieverId` is present ([Data Library Reference](references/data-library-reference.md), Step 6). If still null, wait and re-poll — do not preview yet, the agent will return empty `knowledgeSummary` and the anti-hallucination guard will refuse on every utterance.
159
- `sf agent preview start --json --use-live-actions --authoring-bundle <Developer_Name>`
160
- If actions query data, ground test utterances with:
161
- `sf data query --json -q "SELECT <Relevant_Fields> FROM <SObject> LIMIT 100"`
162
- Send test utterances with:
163
- `sf agent preview send --json --authoring-bundle <Developer_Name> --session-id <ID> -u "<message>"`
164
- **Smoke testing requirements** (see [Validation & Debugging](references/agent-validation-and-debugging.md), Utterance Derivation):
165
- - Test ALL routing branches, not just the happy path. Multiple phrasings per branch.
166
- - Use realistic utterances — write what a human would actually type, not keywords.
167
- - After EVERY utterance, read the trace to confirm actions actually fired (`FunctionStep`). Do not trust the agent's text response alone — agents can claim they performed actions without calling them.
168
- - Evaluate against the Agent Spec like a human tester: check conversation flow, instruction adherence, unnecessary repetition, and response quality. If the spec says "confirm once" and the agent confirms twice, that's a bug — fix it.
169
- If behavior diverges from the Agent Spec, fix the `.agent` file and re-preview. For complex issues, switch to **Diagnose Behavioral Issues** workflow. Return AFTER correcting issues.
170
- **CHECKPOINT — Stay in draft iteration unless user explicitly asks to release.**
171
- **If user requests release, do NOT proceed to Publish unless ALL are true:**
172
- - `validate authoring-bundle` passes with zero errors
173
- - Live preview (`--use-live-actions`) tested with realistic utterances covering all routing branches
174
- - Traces confirm correct subagent routing, action invocation (`FunctionStep` present), and spec-compliant behavior
175
- - User explicitly approves deployment
176
- - **If the agent has a `knowledge:` block**: the Einstein Agent User has a Data Cloud permset/PSL assigned. Verify both:
177
- ```bash
178
- sf data query --json -q "SELECT PermissionSet.Name FROM PermissionSetAssignment WHERE Assignee.Username='<agent_user>'"
179
- sf data query --json -q "SELECT PermissionSetLicense.DeveloperName FROM PermissionSetLicenseAssign WHERE Assignee.Username='<agent_user>'"
180
- ```
181
- One of `GenieDataPlatformStarterPsl`, `GenieUserEnhancedSecurity`, `DataCloudUser`, or `DataCloudArchitect` must appear in the combined results. If none does, run [Agent User Setup, Step 3b](references/agent-user-setup.md) discovery-then-assign and re-verify before proceeding. If a Data Cloud permset is assigned but a smoke-test grounded query returns empty `knowledgeSummary`, the **Data Space scope** also needs to be granted on that permset — UI-only, see [Agent User Setup, Step 3b.4](references/agent-user-setup.md).
182
- 9. **Publish (explicit release step)** — Only after the user confirms they are ready to commit this draft to metadata. Publish validates metadata structure, not agent behavior. Every publish creates permanent version number.
183
- `sf agent publish authoring-bundle --json --api-name <Developer_Name>`
184
- If publish fails, follow troubleshooting checklist in [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md), Section 5 before retrying.
185
- 10. **Activate (explicit release step)** — Makes new version available to users after publish.
186
- `sf agent activate --json --api-name <Developer_Name>`
187
- 11. **Verify published agent** — Preview user-facing behavior AFTER activation with
188
- `sf agent preview start --json --api-name <Developer_Name>`
189
- Use `--api-name`, not `--authoring-bundle`.
190
- 12. **Configure end-user access** — ONLY for employee agents. Read [Agent Access Guide](references/agent-access-guide.md) to configure perms and assign access.
191
-
192
- #### Reference Files
193
-
194
- 1. [CLI for Agents](references/salesforce-cli-for-agents.md) — exact
195
- command syntax for generate, validate, deploy, publish, activate;
196
- Section 12 for Einstein Agent User creation
197
- 2. [Core Language](references/agent-script-core-language.md) — execution
198
- model, syntax, block structure, anti-patterns
199
- 3. [Design & Agent Spec](references/agent-design-and-spec-creation.md) —
200
- subagent graph design, flow control patterns, Agent Spec production,
201
- action implementation analysis; Section 3 for environment prerequisites
202
- 4. [Subagent Map Diagrams](references/agent-subagent-map-diagrams.md) —
203
- Mermaid diagram conventions for visualizing the agent's subagent graph
204
- 5. [Posture & Determinism](references/posture-and-determinism.md) —
205
- default agentic posture, deterministic controls with cause
206
- 6. [Agent User Setup & Permissions](references/agent-user-setup.md) —
207
- permission set assignment, object permissions, cross-subagent validation
208
- 7. [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md) —
209
- directory structure, bundle metadata; publish troubleshooting
210
- 8. [Validation & Debugging](references/agent-validation-and-debugging.md) —
211
- validate the agent compiles, preview to confirm behavior
212
- 9. [Agent Access Guide](references/agent-access-guide.md) — end-user
213
- access permissions, visibility troubleshooting
214
- 10. [Known Issues](references/known-issues.md) — only load when errors
215
- persist after code fixes
216
- 11. [Patterns by Requirement](references/patterns-by-requirement.md) — scenario-to-pattern mapping for architecture and flow choices
217
- 12. [Architecture Patterns](references/architecture-patterns.md) — router-first mechanics, verification gates, workflow-local linear patterns
218
- 13. [Complex Data Types](references/complex-data-types.md) — type mapping decision tree
219
- 14. [Safety Review](references/safety-review-reference.md) — 7-category safety review
220
- 15. [Discover Reference](references/discover-reference.md) — target discovery CLI
221
- 16. [Scaffold Reference](references/scaffold-reference.md) — stub generation CLI
222
- 17. [Deploy Reference](references/deploy-reference.md) — deployment lifecycle, error recovery
223
- 18. [Data Library Reference](references/data-library-reference.md) — provision a SFDRIVE Agentforce Data Library and wire it into the `.agent` via the `knowledge:` block + `AnswerQuestionsWithKnowledge` action
202
+ Use for a new agent or authoring bundle.
203
+
204
+ 1. Read [Design & Agent Spec](references/agent-design-and-spec-creation.md),
205
+ then use an already-approved, sufficiently detailed supplied design as the
206
+ build contract without regenerating or reapproving it. Otherwise capture the
207
+ requirements in a saved Agent Spec and obtain explicit approval. Keep new
208
+ action implementations as `NEEDS STUB` until the user chooses whether to
209
+ reuse implementations, generate them, or leave placeholders.
210
+ 2. Read the applicable sections of [CLI for Agents](references/salesforce-cli-for-agents.md)
211
+ and validate the target-org prerequisites before org work. For document
212
+ grounding, read [Data Library](references/data-library-reference.md). For a
213
+ voice agent, read [Voice Modality](references/voice-modality-reference.md)
214
+ and [Voice Latency](references/voice-latency-heuristics.md).
215
+ 3. Generate the authoring bundle with Salesforce CLI. Edit the scaffolded
216
+ `<ApiName>.agent` and preserve the matching `<ApiName>.bundle-meta.xml`.
217
+ Read [Core Language](references/agent-script-core-language.md),
218
+ [Instruction Resolution](references/instruction-resolution.md), and the
219
+ applicable templates before writing.
220
+ 4. Run the local compiler required by Rule 14. When an authenticated target org
221
+ is available, also validate the authoring bundle in the org. Fix blocking
222
+ diagnostics before implementing or deploying action dependencies.
223
+ 5. Generate action implementations only when the user selected that path.
224
+ Validate and deploy one dependency at a time.
225
+ 6. Preview the draft and inspect traces using
226
+ [Validation & Debugging](references/agent-validation-and-debugging.md).
227
+ Cover realistic happy, adjacent, recovery, and cancellation paths.
228
+ 7. Stay in the draft loop. Publish and activate only after the release gates in
229
+ **Deploy, Publish, and Activate** pass and the user explicitly approves.
224
230
 
225
231
  ### Comprehend an Existing Agent
226
232
 
227
- User wants to understand Agent Script agent they didn't write or need to revisit. May point to `AiAuthoringBundle` directory or ask "what does this agent do?" or "I need to fix this agent but I don't understand how it works.".
228
-
229
- #### Required Steps
230
-
231
- 1. **Locate agent** — Read `sfdx-project.json` to identify package directories. Find `AiAuthoringBundle` directory within them. Read `.agent` file and `bundle-meta.xml`.
232
- 2. **Read code** — Read [Core Language](references/agent-script-core-language.md) for syntax and execution model BEFORE parsing `.agent` file.
233
- 3. **Map action implementations** — For each action with `target`, locate implementation (Apex class, Flow, Prompt Template) in project. Note input/output contracts.
234
- 4. **Reverse-engineer Agent Spec** — Read [Design & Agent Spec](references/agent-design-and-spec-creation.md) for Agent Spec structure. Produce Agent Spec from code and save as file.
235
- 5. **Produce Subagent Map diagram** — Read [Subagent Map Diagrams](references/agent-subagent-map-diagrams.md) for Mermaid conventions. Generate flowchart of subagent graph showing transitions, gates, and action associations.
236
- 6. **Annotate source** — Ask if user wants Agent Script source annotated with explanations. If requested, add inline comments to `.agent` file explaining flow control decisions, gating rationale, and subagent relationships.
237
- 7. **Present to user** — Share Agent Spec, Subagent Map, and annotated source if produced. Check Anti-Patterns section in Core Language reference and flag any matches found in code.
238
-
239
- #### Reference Files
240
-
241
- 1. [Core Language](references/agent-script-core-language.md) — syntax,
242
- execution model, anti-patterns
243
- 2. [Design & Agent Spec](references/agent-design-and-spec-creation.md) —
244
- Agent Spec structure, flow control pattern recognition
245
- 3. [Subagent Map Diagrams](references/agent-subagent-map-diagrams.md) —
246
- Mermaid conventions for subagent graph visualization
247
- 4. [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md) —
248
- directory conventions, bundle metadata
249
- 5. [Known Issues](references/known-issues.md) — only load when code
250
- contains unexplained workaround patterns
233
+ Use when the user wants to understand an existing bundle.
234
+
235
+ 1. Locate the package and matching authoring-bundle files.
236
+ 2. Read [Core Language](references/agent-script-core-language.md), then map the
237
+ subagent graph, deterministic blocks, model instructions, actions, variables,
238
+ and action implementations.
239
+ 3. Read [Design & Agent Spec](references/agent-design-and-spec-creation.md) and
240
+ reverse-engineer a saved Agent Spec. Use
241
+ [Subagent Map Diagrams](references/agent-subagent-map-diagrams.md) for the
242
+ graph. Annotate source only when the user requests it.
243
+ 4. Flag supported anti-patterns, distinguishing observed behavior from static
244
+ inference. Load [Known Issues](references/known-issues.md) only for an
245
+ otherwise unexplained workaround.
246
+
247
+ ### Audit and Repair an Existing Agent
248
+
249
+ Use for “fix my AgentScript,” health checks, common-pitfall reviews, and
250
+ baseline-versus-candidate repair loops.
251
+
252
+ 1. Read [Audit and Repair](references/agent-audit-and-repair.md), then follow its
253
+ linked scope/path-review and repair/report workflow in order.
254
+ 2. Use the [Diagnostic Catalog](references/agent-audit-diagnostic-catalog.md)
255
+ and its focused diagnostic references only for categories present in the
256
+ artifact. Use [Common Control-Flow Pitfalls](references/common-control-flow-pitfalls.md)
257
+ and its focused references for suspected prompt/control-flow defects.
258
+ 3. Freeze accepted Surface edits before changing the artifact. For Structural
259
+ or Rewrite work, obtain the approval required by Rule 4.
260
+ 4. Compile locally, compare the unchanged baseline and candidate against the
261
+ same use cases, and follow
262
+ [Audit Evaluation Loop](references/agent-audit-evaluation-loop.md).
263
+ 5. Report Surface, Structural, and Rewrite assessments separately. Stay
264
+ draft-only unless the user separately requests a release operation.
265
+
266
+ #### Audit Reference Files
267
+
268
+ - [Audit Scope and Path Review](references/agent-audit-scope-path-review.md)
269
+ - [Audit Repair and Report](references/agent-audit-repair-report.md)
270
+ - [Audit Candidate Verification](references/agent-audit-candidate-verification.md)
271
+ - [Instruction and Routing Diagnostics](references/agent-audit-diagnostics-instructions-routing.md)
272
+ - [Action and State Diagnostics](references/agent-audit-diagnostics-actions-state.md)
273
+ - [Architecture and Evaluation Diagnostics](references/agent-audit-diagnostics-architecture-evaluation.md)
274
+ - [Action and Sequencing Pitfalls](references/control-flow-actions-sequencing.md)
275
+ - [Lifecycle and Side-Effect Pitfalls](references/control-flow-lifecycle-side-effects.md)
276
+ - [AgentScript Compiler Setup](references/agentscript-toolchain.md)
251
277
 
252
278
  ### Modify an Existing Agent
253
279
 
254
- User wants to add, remove, or change subagents, actions, instructions, or flow control on existing agent. May describe change in plain language ("add a billing subagent") or reference specific Agent Script constructs.
255
-
256
- #### Required Steps
257
-
258
- Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command syntax.
259
-
260
- 1. **Comprehend** — If no Agent Spec exists, reverse-engineer first by following "Comprehend an Existing Agent" workflow above.
261
- 2. **Update Agent Spec** — Read [Design & Agent Spec](references/agent-design-and-spec-creation.md) for flow control patterns and existing action analysis. Modify Agent Spec to reflect intended changes. Default new actions to `NEEDS STUB` placeholders. Ask the user which path they want:
262
- - Path A: Keep placeholders only
263
- - Path B: Scan for existing actions to reuse
264
- - Path C: Generate new actions
265
- Only run scans if the user explicitly chooses Path B or C.
266
- **If the modification involves adding, replacing, or removing knowledge grounding**, ask: *"Will this agent answer questions from a document corpus (PDF/DOCX/TXT)? If so, what file path?"* Capture the path in the updated Spec under a **"Knowledge Grounding"** section. Asking now — during Spec update — surfaces ADL changes for the user's approval and lets us kick off provisioning right after.
267
- **Always save updated Agent Spec as file.**
268
- 3. **STOP for user approval of updated Agent Spec.** Present to user (including the Knowledge Grounding section if present). Ask for approval or feedback. **Do not proceed** without approval. Once approved, proceed without stopping unless a step fails.
269
- 4. **Kick off ADL provisioning (only if the Spec has a Knowledge Grounding section).**
270
- - If the `.agent` already has a `knowledge:` block with a populated `rag_feature_config_id` AND the user is keeping the same library, reuse it. Skip provisioning. (No need to confirm `retrieverId` here — that gate moves to Step 8.)
271
- - If a new ADL is needed, follow the same flow as the create workflow: read [Data Library Reference](references/data-library-reference.md), run the Step 0 preflight (`sf agent adl list`), and (if DC is ready) run `sf agent adl create` (Step 1) to capture `libraryId`. Compute `rag_feature_config_id = "ARFPC_<libraryId>"` from `libraryId` alone — that's enough to author the bundle. Start the upload + indexing flow (reference Steps 2–6) **in the background** while you continue to Step 5 (Edit code). Per Rule 5, do not block on async indexing. Also kick off the Data Cloud permset assignment for the agent user — see [Agent User Setup](references/agent-user-setup.md), Step 3b, which now ends with Step 3b.5 pinned post-assignment verification (against the resolved running-user and Einstein Agent User IDs) so callers can treat "Step 3b passed" as an authoritative Data Cloud grounding gate without re-running inline SOQL.
272
- - If grounding is not part of the modification, skip this step.
273
- 5. **Edit code** — Read [Core Language](references/agent-script-core-language.md) for syntax and anti-patterns. Edit `.agent` file to implement approved changes. If Step 4 produced a `libraryId`, include or update the `knowledge:` block and the `AnswerQuestionsWithKnowledge` action per [Data Library Reference](references/data-library-reference.md).
274
- 6. **Validate compilation** —
275
- `sf agent validate authoring-bundle --json --api-name <Developer_Name>`
276
- If validation fails, read [Validation & Debugging](references/agent-validation-and-debugging.md) to diagnose and fix, then re-validate.
277
- 7. **Generate new action implementations (explicit user-requested path only)** — Only run this step if the user explicitly asked to generate new implementations (Path C in Step 2). For each new action marked NEEDS STUB:
278
- `sf template generate apex class --name <ClassName> --output-dir <PACKAGE_DIR>/main/default/classes`
279
- Replace class body with invocable pattern from [Design & Agent Spec](references/agent-design-and-spec-creation.md). ALWAYS deploy:
280
- `sf project deploy start --json --metadata ApexClass:<ClassName>`
281
- ALWAYS fix deploy errors BEFORE generating and deploying next stub. Skip if no new actions added.
282
- 8. **Validate behavior** — Read [Validation & Debugging](references/agent-validation-and-debugging.md) for preview workflow and session trace analysis.
283
- **If Step 4 provisioned a new ADL**, before sending any grounded test utterances confirm the library is queryable: run `sf agent adl get -i $LIBRARY_ID` and check that `retrieverId` is present ([Data Library Reference](references/data-library-reference.md), Step 6). If still null, wait and re-poll — do not preview yet, the agent will return empty `knowledgeSummary` and the anti-hallucination guard will refuse on every utterance.
284
- `sf agent preview start --json --use-live-actions --authoring-bundle <Developer_Name>`
285
- If actions query data, ground test utterances with:
286
- `sf data query --json -q "SELECT <Relevant_Fields> FROM <SObject> LIMIT 100"`
287
- Send test utterances with:
288
- `sf agent preview send --json --authoring-bundle <Developer_Name> --session-id <ID> -u "<message>"`
289
- **Smoke testing requirements** (see [Validation & Debugging](references/agent-validation-and-debugging.md), Utterance Derivation):
290
- - Test changed paths first, then adjacent paths to catch regressions.
291
- - Test ALL routing branches affected by the change. Multiple phrasings per branch.
292
- - Use realistic utterances — write what a human would actually type, not keywords.
293
- - After EVERY utterance, read the trace to confirm actions actually fired (`FunctionStep`). Do not trust the agent's text response alone.
294
- - Evaluate against the Agent Spec: conversation flow, instruction adherence, unnecessary repetition, response quality.
295
- If behavior diverges from the Agent Spec, fix the `.agent` file and re-preview. For complex issues, switch to **Diagnose Behavioral Issues** workflow.
296
- **CHECKPOINT — Stay in draft iteration unless user explicitly asks to release.**
297
- **If user requests release, do NOT proceed to Publish unless ALL are true:**
298
- - `validate authoring-bundle` passes with zero errors
299
- - Live preview (`--use-live-actions`) tested with realistic utterances covering all routing branches
300
- - Traces confirm correct subagent routing, action invocation (`FunctionStep` present), and spec-compliant behavior
301
- - User explicitly approves deployment
302
- - **If the agent has a `knowledge:` block**: the Einstein Agent User has a Data Cloud permset/PSL assigned. Verify both:
303
- ```bash
304
- sf data query --json -q "SELECT PermissionSet.Name FROM PermissionSetAssignment WHERE Assignee.Username='<agent_user>'"
305
- sf data query --json -q "SELECT PermissionSetLicense.DeveloperName FROM PermissionSetLicenseAssign WHERE Assignee.Username='<agent_user>'"
306
- ```
307
- One of `GenieDataPlatformStarterPsl`, `GenieUserEnhancedSecurity`, `DataCloudUser`, or `DataCloudArchitect` must appear in the combined results. If none does, run [Agent User Setup, Step 3b](references/agent-user-setup.md) discovery-then-assign and re-verify before proceeding. If a Data Cloud permset is assigned but a smoke-test grounded query returns empty `knowledgeSummary`, the **Data Space scope** also needs to be granted on that permset — UI-only, see [Agent User Setup, Step 3b.4](references/agent-user-setup.md).
308
- 9. **Publish (explicit release step)** — Only after the user confirms they are ready to commit this draft to metadata. Publish validates metadata structure, not agent behavior. Every publish creates permanent version number.
309
- `sf agent publish authoring-bundle --json --api-name <Developer_Name>`
310
- If publish fails, follow troubleshooting checklist in [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md), Section 5 before retrying.
311
- 10. **Activate (explicit release step)** — Makes new version available to users after publish.
312
- `sf agent activate --json --api-name <Developer_Name>`
313
- 11. **Verify published agent** — Preview user-facing behavior AFTER activation with
314
- `sf agent preview start --json --api-name <Developer_Name>`
315
- Use `--api-name`, not `--authoring-bundle`.
316
-
317
- #### Reference Files
318
-
319
- 1. [CLI for Agents](references/salesforce-cli-for-agents.md) — exact
320
- command syntax for validate, deploy, preview, publish, activate
321
- 2. [Core Language](references/agent-script-core-language.md) — syntax,
322
- anti-patterns
323
- 3. [Design & Agent Spec](references/agent-design-and-spec-creation.md) —
324
- Agent Spec updates, action implementation analysis
325
- 4. [Validation & Debugging](references/agent-validation-and-debugging.md) —
326
- compilation diagnosis, preview workflow, session trace analysis
327
- 5. [Data Library Reference](references/data-library-reference.md) —
328
- provisioning and Agent Script wiring for ADL grounding
329
- 6. [Known Issues](references/known-issues.md) — only load when errors
330
- persist after code fixes
280
+ Use for an approved change to an existing response, route, action, subagent,
281
+ state flow, grounding source, or modality.
282
+
283
+ 1. Comprehend the affected paths first. For a material design change, update the
284
+ Agent Spec and obtain approval; for a narrow specified repair, record the
285
+ affected use case without forcing a full spec rewrite.
286
+ 2. Read [Core Language](references/agent-script-core-language.md) and only the
287
+ feature references needed for the change. Preserve unrelated metadata,
288
+ contracts, formatting, and behavior.
289
+ 3. Edit the existing bundle in place. Generate action implementations only when
290
+ explicitly requested.
291
+ 4. Compile locally and, when available, validate against the target org. Preview
292
+ every changed and adjacent path and inspect traces. Iterate in draft.
293
+ 5. Use the release workflow only if the user separately requests release.
331
294
 
332
295
  ### Diagnose Compilation Errors
333
296
 
334
- User has Agent Script that won't compile. Errors surface from `sf agent validate` or `sf agent preview start`, or User describes symptoms like "I'm getting a validation error."
335
-
336
- #### Required Steps
337
-
338
- Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command syntax.
339
-
340
- 1. **Capture concrete errors first, then reproduce** — If the user already shared error output, extract and list the exact error messages first. Then run
341
- `sf agent validate authoring-bundle --json --api-name <Developer_Name>`
342
- to capture basic compile errors. If no errors, run
343
- `sf agent preview start --json --use-live-actions --authoring-bundle <Developer_Name>`
344
- to capture complex compile errors. If reproduction differs from user-provided errors, call out both and continue with the current reproducible errors.
345
- 2. **Classify error** — Read [Validation & Debugging](references/agent-validation-and-debugging.md) for error taxonomy. Map each exact error message to a root cause category.
346
- 3. **Locate fault** — Read [Core Language](references/agent-script-core-language.md) to understand correct syntax. Find specific line(s) in `.agent` file that cause each error.
347
- 4. **Fix code** — Apply targeted fixes. Check Anti-Patterns section in Core Language reference to ensure you're not introducing known bad pattern.
348
- 5. **Re-validate** — Run
349
- `sf agent validate authoring-bundle --json --api-name <Developer_Name>`
350
- then run
351
- `sf agent preview start --json --use-live-actions --authoring-bundle <Developer_Name>`
352
- Repeat steps 2–5 if errors persist.
353
- 6. **Explain fix** — Tell user what was wrong and what you changed. Explain root cause in terms of *Core Language* agent execution model.
354
-
355
- #### Reference Files
356
-
357
- 1. [Core Language](references/agent-script-core-language.md) — syntax,
358
- block structure, anti-patterns
359
- 2. [Validation & Debugging](references/agent-validation-and-debugging.md) —
360
- error taxonomy, error-to-root-cause mapping
361
- 3. [Known Issues](references/known-issues.md) — only load when error
362
- doesn't match user code; may be a platform bug
363
- 4. [Production Gotchas](references/production-gotchas.md) — only load
364
- when error involves reserved keywords or lifecycle hook syntax
365
-
366
- ### Diagnose Behavioral Issues
367
-
368
- Agent compiles, preview can start and `--use-live-actions`, but agent does not behave as expected. User describes symptoms like "the agent keeps going to the wrong subagent" or "the action isn't being called." Fundamentally different from `validate` or `preview start` errors — code is valid but behavior is wrong.
369
-
370
- #### Required Steps
371
-
372
- Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command syntax.
373
-
374
- 1. **Establish baseline** — Read Agent Spec. If no Agent Spec exists, follow *Comprehend an Existing Agent* workflow to reverse-engineer one, then continue.
375
- 2. **Form hypotheses** — Read [Core Language](references/agent-script-core-language.md) for execution model. Based on user's description, list candidate root causes. Think through: subagent routing, gating conditions, action availability, instruction clarity, variable state, and transition timing.
376
- 3. **Reproduce in preview** — Read [Validation & Debugging](references/agent-validation-and-debugging.md) for preview workflow and session trace analysis. Start preview session:
377
- `sf agent preview start --json --use-live-actions --authoring-bundle <Developer_Name>`
378
- then send test messages covering EACH subagent with `sf agent preview send`. One message is not enough — confirm behavior per subagent before proceeding.
379
- 4. **Analyze session traces** — Examine trace output to confirm subagent selection, action availability/execution, LLM reasoning, and where behavior diverges from Agent Spec. Do NOT skip this step — preview output alone is insufficient for diagnosis.
380
- 5. **Identify root cause** — Match trace evidence to hypotheses. Consult *Core Language reference and Gating Patterns* in [Design & Agent Spec](references/agent-design-and-spec-creation.md) reference to confirm absence of anti-patterns.
381
- 6. **Fix code** — Apply targeted fix. If fix involves flow control changes, update Agent Spec to match.
382
- 7. **Re-validate and re-preview** — Repeat steps 3–6 until behavior matches Agent Spec or you confirm a platform limitation. Run `validate authoring-bundle`, then `preview start --use-live-actions` to verify fix using same utterances. Then test adjacent paths that might be affected by your changes.
383
- 8. **Explain fix** — Tell user what was wrong and what you changed. Explain root cause in terms of *Core Language* agent execution model.
384
-
385
- #### Reference Files
386
-
387
- 1. [Core Language](references/agent-script-core-language.md) — execution
388
- model, anti-patterns
389
- 2. [Design & Agent Spec](references/agent-design-and-spec-creation.md) —
390
- Agent Spec as behavioral baseline, gating patterns
391
- 3. [Validation & Debugging](references/agent-validation-and-debugging.md) —
392
- preview workflow, session trace analysis
393
- 4. [Known Issues](references/known-issues.md) — only load when behavior
394
- is wrong but code logic is correct
395
-
396
- ### Deploy, Publish, and Activate
397
-
398
- User wants to take working agent from local development to running state in Salesforce org. Involves deploying `AiAuthoringBundle` and its dependencies, publishing to commit version, then activating to make it live.
399
-
400
- #### Required Steps
401
-
402
- Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command syntax.
403
-
404
- 1. **Validate compilation** —
405
- `sf agent validate authoring-bundle --json --api-name <Developer_Name>`
406
- Do not proceed if validation fails.
407
- 2. **Deploy bundle and dependencies** — Read [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md) for dependency management and deploy commands. Deploy `AiAuthoringBundle` and all action implementations (Apex classes, Flows, Prompt Templates) and dependencies to org.
408
- 3. **Live preview** — Read [Validation & Debugging](references/agent-validation-and-debugging.md) for preview workflow and session trace analysis.
409
- `sf agent preview start --json --use-live-actions --authoring-bundle <Developer_Name>`
410
- then send test utterances with:
411
- `sf agent preview send --json --authoring-bundle <Developer_Name> --session-id <ID> -u "<message>"`
412
- Test key conversation paths to validate agent behavior when backed by live actions.
413
- **CHECKPOINT — Do NOT proceed to Publish unless ALL are true:**
414
- - `validate authoring-bundle` passes with zero errors
415
- - Live preview (`--use-live-actions`) tested with realistic utterances covering all routing branches
416
- - Traces confirm correct subagent routing, action invocation (`FunctionStep` present), and spec-compliant behavior
417
- - User explicitly approves deployment
418
- 4. **Publish (explicit release step)** — Publish validates metadata structure, not agent behavior. DO NOT publish as part of a dev/test inner loop. ONLY publish as the FINAL step after user confirmation to commit this draft and prior to activation.
419
- `sf agent publish authoring-bundle --json --api-name <Developer_Name>`
420
- If publish fails, follow *Troubleshooting Publish Failures* in [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md) before retrying.
421
- 5. **Activate** — Makes new version available to users.
422
- `sf agent activate --json --api-name <Developer_Name>`
423
- 6. **Verify published agent** — Preview user-facing behavior AFTER activation with
424
- `sf agent preview start --json --api-name <Developer_Name>`
425
- Use `--api-name`, not `--authoring-bundle`.
426
- 7. **Configure end-user access** — ONLY for employee agents. Read [Agent Access Guide](references/agent-access-guide.md) to configure perms and assign access.
427
-
428
- #### Reference Files
429
-
430
- 1. [CLI for Agents](references/salesforce-cli-for-agents.md) — exact
431
- command syntax for deploy, publish, activate, deactivate
432
- 2. [Validation & Debugging](references/agent-validation-and-debugging.md) —
433
- compilation validation, preview workflow
434
- 3. [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md) —
435
- dependency management, deploy commands; publish troubleshooting
436
- 4. [Agent Access Guide](references/agent-access-guide.md) — end-user
437
- access permissions, visibility troubleshooting
438
- 5. [Known Issues](references/known-issues.md) — only load when deploy
439
- hangs, publish fails, or activate fails unexpectedly
440
-
441
- ### Diagnose Production Issues
442
-
443
- User's agent is published and active but experiencing issues not caught during preview. Includes credit overconsumption, token or size limit failures, loop guardrail interruptions, reserved keyword runtime errors, VS Code sync failures, or unexpected behavioral differences between preview and production.
444
-
445
- #### Required Steps
446
-
447
- Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command syntax.
448
-
449
- 1. **Classify issue** — Determine whether this is billing/cost concern, runtime limit, naming conflict, tooling issue, or behavioral difference between preview and production.
450
- 2. **Check known production gotchas** — Read [Production Gotchas](references/production-gotchas.md) for credit consumption, token limits, loop guardrails, reserved keywords, lifecycle hooks, and VS Code workarounds.
451
- 3. **Compare preview vs production behavior** — If issue is behavioral, preview published agent with
452
- `sf agent preview start --json --api-name <Developer_Name>`
453
- (not `--authoring-bundle`). Compare against live-actions authoring bundle preview `--authoring-bundle <Developer_Name> --use-live-actions` to isolate preview-vs-production differences.
454
- 4. **Check known issues** — Read [Known Issues](references/known-issues.md) for platform bugs that may explain production-only failures.
455
- 5. **Fix and republish** — Apply fixes, validate, re-preview, publish, activate, verify. Follow Deploy, Publish, and Activate steps.
456
- 6. **Explain diagnosis** — Tell user what was happening and what you changed. Explain root cause.
457
-
458
- #### Reference Files
459
-
460
- 1. [Production Gotchas](references/production-gotchas.md) — credit
461
- consumption, token limits, loop guardrails, reserved keywords,
462
- lifecycle hooks, VS Code workarounds
463
- 2. [CLI for Agents](references/salesforce-cli-for-agents.md) — command
464
- syntax for preview, publish, activate
465
- 3. [Validation & Debugging](references/agent-validation-and-debugging.md) —
466
- preview workflow, session trace analysis
467
- 4. [Known Issues](references/known-issues.md) — only load when issue may
468
- be a platform bug
297
+ 1. Capture the exact reported errors and run the Rule 14 local compiler.
298
+ 2. When an authenticated target org is available, run org validation; use live
299
+ preview only when compilation succeeds but runtime preparation still fails.
300
+ 3. Classify and repair each concrete error using
301
+ [Validation & Debugging](references/agent-validation-and-debugging.md) and
302
+ [Core Language](references/agent-script-core-language.md).
303
+ 4. Rerun the surfaces that exposed the error. Report exact executed checks,
304
+ remaining limitations, and no unexecuted command as validation evidence.
469
305
 
470
- ### Delete or Rename an Agent
306
+ ### Diagnose Behavioral or Production Issues
471
307
 
472
- User wants to remove agent or change its name. Maintenance tasks complicated by `AiAuthoringBundle` versioning and published version dependencies.
308
+ For a local behavioral problem, preserve a baseline, preview with realistic
309
+ utterances, and inspect traces using
310
+ [Validation & Debugging](references/agent-validation-and-debugging.md). Confirm
311
+ which subagent, action calls, action results, state changes, and final response
312
+ actually occurred before editing.
473
313
 
474
- #### Required Steps
314
+ For a production session or trace ID, use **agentforce-observe** for retrieval
315
+ and reconstruction. Return here only when evidence identifies an AgentScript
316
+ change. Never invent unavailable action inputs, outputs, or model reasoning.
475
317
 
476
- Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command syntax.
318
+ ### Deploy, Publish, and Activate
477
319
 
478
- 1. **Understand current state** — Read [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md) for versioning, delete mechanics, and rename mechanics. Identify whether agent has been published, how many versions exist, and whether it's currently active.
479
- 2. **Deactivate if active** —
480
- `sf agent deactivate --json --api-name <Developer_Name>`
481
- Active agent cannot be deleted or renamed.
482
- 3. **Execute operation** — For delete: follow delete mechanics in Metadata & Lifecycle reference. For rename: follow rename mechanics in same reference.
483
- 4. **Clean up orphans** — Check for and remove orphaned metadata: Bot, BotVersion, GenAiPlannerBundle, GenAiPlugin, GenAiFunction. Metadata & Lifecycle reference details what to look for.
484
- 5. **Validate** — Confirm operation completed cleanly. For rename, validate new bundle compiles and preview to confirm behavior.
320
+ 1. Read [CLI for Agents](references/salesforce-cli-for-agents.md),
321
+ [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md), and
322
+ [Deploy](references/deploy-reference.md).
323
+ 2. Compile locally and validate against the target org. Deploy the bundle and
324
+ dependencies, then run live preview with realistic coverage and inspect
325
+ traces. Do not proceed through a blocking result.
326
+ 3. Present the exact target org and version state. Obtain explicit user approval
327
+ before publishing or activating.
328
+ 4. Publish, activate, and verify the user-facing agent only after approval.
485
329
 
486
- #### Reference Files
330
+ ### Delete or Rename an Agent
487
331
 
488
- 1. [CLI for Agents](references/salesforce-cli-for-agents.md) — exact
489
- command syntax for delete, deactivate, retrieve
490
- 2. [Validation & Debugging](references/agent-validation-and-debugging.md) —
491
- compilation validation, preview workflow
492
- 3. [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md) —
493
- delete mechanics, rename mechanics, orphan cleanup
332
+ Read the delete/rename sections of [CLI for Agents](references/salesforce-cli-for-agents.md)
333
+ and [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md). Enumerate
334
+ references and dependencies, show the exact affected bundle, and obtain explicit
335
+ confirmation before deletion. For rename, create and validate the replacement
336
+ before deleting the original; verify orphaned metadata afterward.
494
337
 
495
338
  ### Test an Agent
496
339
 
497
- User wants to create automated tests for Agent Script agent. Involves writing `AiEvaluationDefinition` test specs in YAML format that define test scenarios, expected behaviors, and quality metrics.
498
-
499
- #### Required Steps
500
-
501
- Read [CLI for Agents](references/salesforce-cli-for-agents.md) for exact command syntax.
502
-
503
- 1. **Establish coverage baseline** — Read Agent Spec. If no Agent Spec exists, reverse-engineer first by following Comprehend steps. Map every subagent, action, and flow control path to identify what needs test coverage.
504
- 2. **Design test scenarios** — For test design methodology, expectations, metrics, test spec YAML format, and templates, use **agentforce-test** skill. That skill owns all testing content. For each coverage target, write one or more test scenarios: user utterance, expected subagent routing, expected action invocations, and expected agent response. Include both happy paths and edge cases.
505
- 3. **Offer security coverage** — Security testing is part of the ADLC test flow, not a separate step. Treat OWASP LLM Top 10 resistance as a first-class coverage dimension alongside functional scenarios. **Confirm with the user before generating security test cases**, then use **agentforce-test** skill **Mode C1-author** to write a Testing Center security suite from the agent's own `.agent` file (method: `skills/agentforce-test/references/security-test-design.md`) that ships alongside the functional test spec. `C1-author` validates the spec locally with `sf agent test create --preview` and deploys nothing; deploying and running it (`C1-run`) is a separate decision the user makes in `/agentforce-test`, because `sf agent test run` has no simulated-action mode and executes the agent's real actions. Skip only if the user declines.
506
- 4. **Write test spec YAML** — Use template and reference files from **agentforce-test** skill. Save to `specs/<Agent_API_Name>-testSpec.yaml` in SFDX project.
507
- 5. **Create test metadata** — Generate `AiEvaluationDefinition` from test spec using CLI.
508
- 6. **Deploy test** — Deploy `AiEvaluationDefinition` to org.
509
- 7. **Run tests** — Execute test run using CLI. Capture results.
510
- 8. **Analyze results** — Compare actual outcomes against expectations. For failures, identify whether issue is in agent code, action implementations, or test spec itself.
511
- 9. **Iterate** — Fix agent code or test spec as needed, redeploy, and re-run until coverage targets are met.
512
-
513
- #### Reference Files
514
-
515
- 1. [CLI for Agents](references/salesforce-cli-for-agents.md) — exact
516
- command syntax for test create, test run, test results
517
- 2. [Core Language](references/agent-script-core-language.md) — agent
518
- structure for designing meaningful tests
519
- 3. [Design & Agent Spec](references/agent-design-and-spec-creation.md) —
520
- Agent Spec as test coverage baseline
521
- 4. **agentforce-test** skill — test spec YAML format, expectations,
522
- metrics, test design methodology, and test spec template
340
+ Use **agentforce-test** for test-spec design, security coverage, metadata
341
+ creation, execution, and result analysis. First map the Agent Spec and all
342
+ reachable routes/actions into coverage targets. Confirm before adding security
343
+ tests or running tests that can invoke live actions.
523
344
 
524
345
  ### Optimize an Agent
525
346
 
526
- User wants to improve an existing Agent Script agent by scanning for common optimization patterns and applying fixes. May say "optimize my agent", "improve my agent", "clean up this agent", "refactor agent", or mention the agent feels inefficient or has redundancies. Also appropriate to suggest proactively after complex editing sessions with many incremental changes.
527
-
528
- #### Required Steps
529
-
530
- 1. **Read and analyze the agent file** — Read the current `.agent` file. Read [Core Language](references/agent-script-core-language.md) for syntax rules and valid constructs as validation reference during optimization.
531
- 2. **Scan for optimization patterns** — For EACH subagent, systematically apply patterns 1–4 (and Pattern 5 if the agent has a `modality voice:` block). Each pattern's reference file has the detection heuristics and detailed fix instructions — read the ones that apply:
532
- - **Pattern 1 — Wire action outputs to deterministic consumers.** [Data Flow](references/optimization-pattern-1-data-flow.md). Persist a producer output only when a later deterministic consumer needs that exact trusted value; do not replace `...` slot filling that legitimately draws from the current turn.
533
- - **Pattern 2 — Extract requirement-backed deterministic logic.** [Deterministic Logic](references/optimization-pattern-2-deterministic-logic.md). Extract only when the condition is machine-known and protects regulation, authorization, an irreversible consequence, ordering, exact data flow, or an observed trace failure. Leave unstructured judgment to the model.
534
- - **Pattern 3 — Fix variable/action reference syntax in instructions.** [Reference Syntax](references/optimization-pattern-3-reference-syntax.md). `{!@variables.X}` and `{!@actions.X}` instead of bare `@variables.X` / use-case phrasing.
535
- - **Pattern 4 — Repair promised human handoff.** [Human Handoff](references/optimization-pattern-4-escalation.md). Apply only when requirements specify live handoff; never add escalation as default boilerplate.
536
- - **Pattern 5 — Voice-readiness (voice agents only).** Instructional fixes are auto-apply candidates; voice-unsafe action authoring and latency issues are flag-only. See [Voice Modality Reference](references/voice-modality-reference.md) "Instructions for Voice Agents", [Actions Reference](references/actions-reference.md) "Voice-Safe Action Authoring", and [Voice Latency Heuristics](references/voice-latency-heuristics.md). **Never auto-change** escalation numbers/queues, SLA/pricing/legal wording, or PII handling — surface a suggested rewrite and require explicit approval.
537
- 3. **Report findings** — Present all findings as a concise `## Optimization Report` with per-improvement, actionable edit instructions (subagent + line, the variable/`set`/binding or logic-extraction change to make), then ask: *"Would you like me to apply these [N] improvements?"*
538
- 4. **STOP for user approval.** Do not apply changes without explicit approval.
539
- 5. **Apply improvements (if approved)** — Edit the `.agent` file directly for each approved improvement. Track successes and failures.
540
- 6. **Validate compilation** — `sf agent validate authoring-bundle --json --api-name <Developer_Name>`. If validation fails, fix introduced errors and re-validate.
541
- 7. **Report results** — Summarize which improvements were applied and which failed (with the reason).
542
-
543
- #### Reference Files
544
-
545
- - [Core Language](references/agent-script-core-language.md) — validation reference during optimization
546
- - [Optimization Pattern 1–4](references/optimization-pattern-1-data-flow.md) — data flow, [deterministic logic](references/optimization-pattern-2-deterministic-logic.md), [reference syntax](references/optimization-pattern-3-reference-syntax.md), [human handoff](references/optimization-pattern-4-escalation.md) (detection heuristics + fix instructions per pattern)
547
- - [Voice Modality Reference](references/voice-modality-reference.md) + [Voice Latency Heuristics](references/voice-latency-heuristics.md) + [Actions Reference](references/actions-reference.md) "Voice-Safe Action Authoring" — Pattern 5 voice-readiness
548
- - [Validation & Debugging](references/agent-validation-and-debugging.md) — compilation validation after applying optimizations
347
+ 1. Read [Core Language](references/agent-script-core-language.md) and scan every
348
+ reachable path using [Common Control-Flow Pitfalls](references/common-control-flow-pitfalls.md).
349
+ 2. Load only applicable optimization references: data flow, deterministic
350
+ logic, reference syntax, human handoff, and voice readiness.
351
+ 3. Report evidence-backed improvements and obtain approval before editing.
352
+ 4. Apply only approved changes, compile locally, validate against the org when
353
+ available, and report the resulting evidence.
549
354
 
550
355
  ### Manage MCP Servers
551
356
 
552
- User wants to register, configure, or manage Model Context Protocol (MCP) servers in the Salesforce API Catalog so their assets (tools, prompts, resources) become available as agent actions. May say "register an MCP server", "create MCP server", "list MCP servers", "whitelist MCP tools", "approve tools", "fetch MCP assets", "update MCP server", "delete MCP server", or mention MCP authentication. Uses `sf agent mcp` CLI commands. This is distinct from general MCP development or MCP protocol design.
553
-
554
- #### Required Steps
555
-
556
- Read [MCP Server Management](references/mcp-management-reference.md) for exact command syntax, response structures, the interactive whitelisting flow, security best practices, error handling, and complete examples. In brief:
557
-
558
- 1. **Verify target org** — `sf config get target-org --json` (Rule 2). If none is set, ask the user to set one first.
559
- 2. **Identify the operation** and map it to a workflow in the reference (register, list, get details, fetch + whitelist assets, list assets, update, delete). Gather any missing required inputs; handle client secrets via **stdin piping, never on the command line**.
560
- 3. **Execute the `sf agent mcp` command** with `--json` (Rule 1). After create, read the server ID from `result.server.id` (not `result.id`). These commands are developer preview, so every response carries a `warnings` preview notice.
561
- 4. **Whitelist interactively** — display each asset's metadata and wait for explicit yes/no/skip per tool. `sf agent mcp asset replace` is a FULL replacement — send the complete desired state.
562
- 5. **Apply security review before activating** — flag destructive, broadly-scoped, or auth-requiring tools; warn on production orgs; require explicit confirmation for destructive operations and deletions.
563
- 6. **Confirm results** and clean up any temp allowlist files.
564
-
565
- #### Reference Files
566
-
567
- - [MCP Server Management](references/mcp-management-reference.md) — `sf agent mcp` command reference, response structures, interactive whitelisting flow, security best practices, error handling, and complete examples
357
+ Read [MCP Server Management](references/mcp-management-reference.md) before any
358
+ MCP operation. Verify the target org, use `--json`, keep secrets off command
359
+ lines, review tools before allowlisting, and require confirmation for destructive
360
+ or consequential changes.
568
361
 
569
362
  ## The Agent Spec
570
363
 
@@ -572,7 +365,10 @@ Read [MCP Server Management](references/mcp-management-reference.md) for exact c
572
365
 
573
366
  Agent Specs evolve with the agent. Sparse during agent creation (purpose, use cases, planned placeholders). Fleshed out during agent build (flowchart, action implementations mapped, posture choices documented, deterministic controls added only where justified). Reverse-engineered when comprehending existing agents. Critical for advanced troubleshooting, providing reference to compare expected vs. actual behavior. During testing, test coverage maps against it.
574
367
 
575
- Always produce or update Agent Spec as first step of any operation that changes or analyzes agent. It is consistent grounding to work from, and a durable artifact a developer can review.
368
+ Produce or update an Agent Spec for greenfield work, material design changes,
369
+ or analysis whose result changes the documented contract. For a narrow,
370
+ already-specified repair, record the affected use case and evidence without
371
+ forcing a full spec rewrite.
576
372
 
577
373
  Read [Design & Agent Spec](references/agent-design-and-spec-creation.md) for Agent Spec structure and production methodology.
578
374
 
@@ -588,12 +384,29 @@ The `assets/` directory contains templates and examples. Read when you need a st
588
384
 
589
385
  - **`assets/agents/template-multi-subagent.agent`** — Minimal agent with multiple subagents and transitions. Copy and modify for complex agents.
590
386
 
387
+ - **`assets/agents/router-first.agent`** — Transition-only router example with
388
+ HyperClassifier and concise router instructions.
389
+
390
+ - **`assets/agents/verification-gate.agent`** — Identity/authorization gate
391
+ with protected action availability.
392
+
393
+ - **`assets/agents/simple-qa.agent`**, **`production-faq.agent`**, and
394
+ **`order-service.agent`** — Complete examples at increasing behavioral and
395
+ action complexity.
396
+
397
+ - **`assets/patterns/README.md`** — Route to focused complete patterns for
398
+ callbacks, input binding, lifecycle, delegation, and multi-step workflows.
399
+ Use a pattern only when its stated use-case preconditions apply.
400
+
591
401
  - **`assets/invocable-apex-template.cls`** — Reference for invocable Apex
592
402
  classes. Copy and modify when complex Apex action implementations are desired.
593
403
 
594
404
  ## Important Constraints
595
405
 
596
- - **Use only Salesforce CLI and Salesforce org.** Do not reference or depend on other skills, MCP servers, or external tooling. All commands use `sf` (Salesforce CLI).
406
+ - **Use supported tooling for the evidence needed.** Use Salesforce CLI and the
407
+ target org for org-backed validation and release operations. Use the published
408
+ AgentScript SDK for local parse/compile checks, and invoke related skills only
409
+ within their documented boundaries.
597
410
 
598
411
  - **Only certain implementation types are valid for actions.** For example, only invocable Apex (not arbitrary Apex classes) can back an action. Similar constraints may apply to Flows and Prompt Templates. When wiring actions to implementations, consult Design & Agent Spec reference file for valid types and stubbing methodology.
599
412
 
@@ -635,7 +448,7 @@ The Einstein Agent User lacks Data Cloud access. Two things to check, in order:
635
448
  - Posture dial (agentic vs deterministic): [Posture & Determinism](references/posture-and-determinism.md)
636
449
  - Concrete authoring invariants: [The Zen of AgentScript](references/zen-of-agentscript.md)
637
450
  - Pattern selection by scenario: [Patterns by Requirement](references/patterns-by-requirement.md)
638
- - Architecture mechanics and migration: [Architecture Patterns](references/architecture-patterns.md)
451
+ - Architecture mechanics, HyperClassifier routing, and migration: [Architecture Patterns](references/architecture-patterns.md)
639
452
  - Validation, preview, and traces: [Validation & Debugging](references/agent-validation-and-debugging.md)
640
453
  - Deploy/publish/activate lifecycle: [Deploy Reference](references/deploy-reference.md)
641
454
  - Metadata lifecycle and publish troubleshooting: [Metadata & Lifecycle](references/agent-metadata-and-lifecycle.md)