@salesforce/afv-skills 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/package.json +4 -4
  2. package/skills/agentforce-development/SKILL.md +427 -0
  3. package/skills/agentforce-development/assets/README-legacy.md +89 -0
  4. package/skills/agentforce-development/assets/agent-spec-template.md +90 -0
  5. package/skills/agentforce-development/assets/agents/README.md +45 -0
  6. package/skills/agentforce-development/assets/agents/hello-world.agent +60 -0
  7. package/skills/agentforce-development/assets/agents/multi-topic.agent +105 -0
  8. package/skills/agentforce-development/assets/agents/production-faq.agent +101 -0
  9. package/skills/agentforce-development/assets/agents/production-faq.bundle-meta.xml +4 -0
  10. package/skills/agentforce-development/assets/agents/simple-qa.agent +72 -0
  11. package/skills/agentforce-development/assets/apex/models-api-queueable.cls +225 -0
  12. package/skills/agentforce-development/assets/bundle-meta.xml +23 -0
  13. package/skills/agentforce-development/assets/components/apex-action.agent +52 -0
  14. package/skills/agentforce-development/assets/components/error-handling.agent +58 -0
  15. package/skills/agentforce-development/assets/components/escalation-setup.agent +169 -0
  16. package/skills/agentforce-development/assets/components/flow-action.agent +66 -0
  17. package/skills/agentforce-development/assets/components/n-ary-conditions.agent +110 -0
  18. package/skills/agentforce-development/assets/components/topic-with-actions.agent +40 -0
  19. package/skills/agentforce-development/assets/deterministic-routing.agent +166 -0
  20. package/skills/agentforce-development/assets/escalation-pattern.agent +209 -0
  21. package/skills/agentforce-development/assets/flow-action-lookup.agent +115 -0
  22. package/skills/agentforce-development/assets/hub-and-spoke.agent +104 -0
  23. package/skills/agentforce-development/assets/invocable-apex-template.cls +187 -0
  24. package/skills/agentforce-development/assets/local-info-agent-annotated.agent +355 -0
  25. package/skills/agentforce-development/assets/metadata/basic-prompt-template.promptTemplate-meta.xml +109 -0
  26. package/skills/agentforce-development/assets/metadata/genai-function-apex.xml +92 -0
  27. package/skills/agentforce-development/assets/metadata/genai-function-flow.xml +57 -0
  28. package/skills/agentforce-development/assets/metadata/genai-plugin.xml +72 -0
  29. package/skills/agentforce-development/assets/metadata/http-callout-flow.flow-meta.xml +348 -0
  30. package/skills/agentforce-development/assets/metadata/record-grounded-prompt.promptTemplate-meta.xml +136 -0
  31. package/skills/agentforce-development/assets/minimal-starter.agent +42 -0
  32. package/skills/agentforce-development/assets/patterns/README.md +254 -0
  33. package/skills/agentforce-development/assets/patterns/action-callbacks.agent +178 -0
  34. package/skills/agentforce-development/assets/patterns/advanced-input-bindings.agent +141 -0
  35. package/skills/agentforce-development/assets/patterns/bidirectional-routing.agent +156 -0
  36. package/skills/agentforce-development/assets/patterns/critical-input-collection.agent +244 -0
  37. package/skills/agentforce-development/assets/patterns/delegation-routing.agent +89 -0
  38. package/skills/agentforce-development/assets/patterns/lifecycle-events.agent +127 -0
  39. package/skills/agentforce-development/assets/patterns/llm-controlled-actions.agent +184 -0
  40. package/skills/agentforce-development/assets/patterns/multi-step-workflow.agent +282 -0
  41. package/skills/agentforce-development/assets/patterns/open-gate-routing.agent +286 -0
  42. package/skills/agentforce-development/assets/patterns/procedural-instructions.agent +273 -0
  43. package/skills/agentforce-development/assets/patterns/prompt-template-action.agent +188 -0
  44. package/skills/agentforce-development/assets/patterns/system-instruction-overrides.agent +293 -0
  45. package/skills/agentforce-development/assets/prompt-rag-search.agent +131 -0
  46. package/skills/agentforce-development/assets/template-multi-topic.agent +160 -0
  47. package/skills/agentforce-development/assets/template-single-topic.agent +81 -0
  48. package/skills/agentforce-development/assets/verification-gate.agent +208 -0
  49. package/skills/agentforce-development/references/action-prompt-templates.md +164 -0
  50. package/skills/agentforce-development/references/actions-reference.md +592 -0
  51. package/skills/agentforce-development/references/agent-access-guide.md +72 -0
  52. package/skills/agentforce-development/references/agent-design-and-spec-creation.md +1010 -0
  53. package/skills/agentforce-development/references/agent-metadata-and-lifecycle.md +575 -0
  54. package/skills/agentforce-development/references/agent-script-core-language.md +1218 -0
  55. package/skills/agentforce-development/references/agent-topic-map-diagrams.md +323 -0
  56. package/skills/agentforce-development/references/agent-user-setup.md +526 -0
  57. package/skills/agentforce-development/references/agent-validation-and-debugging.md +803 -0
  58. package/skills/agentforce-development/references/known-issues.md +353 -0
  59. package/skills/agentforce-development/references/minimal-examples.md +67 -0
  60. package/skills/agentforce-development/references/production-gotchas.md +279 -0
  61. package/skills/agentforce-development/references/salesforce-cli-for-agents.md +393 -0
  62. package/skills/agentforce-development/references/version-history.md +23 -0
  63. package/skills/generate-permission-set/SKILL.md +174 -0
  64. package/skills/salesforce-custom-application/SKILL.md +1 -2
  65. package/skills/salesforce-custom-field/SKILL.md +0 -4
  66. package/skills/salesforce-custom-tab/SKILL.md +84 -8
  67. package/skills/salesforce-experience-lwr-site/SKILL.md +196 -0
  68. package/skills/salesforce-experience-lwr-site/docs/bootstrap-template-byo-lwr.md +224 -0
  69. package/skills/salesforce-experience-lwr-site/docs/configure-content-brandingSet.md +131 -0
  70. package/skills/salesforce-experience-lwr-site/docs/configure-content-route.md +232 -0
  71. package/skills/salesforce-experience-lwr-site/docs/configure-content-themeLayout.md +141 -0
  72. package/skills/salesforce-experience-lwr-site/docs/configure-content-view.md +233 -0
  73. package/skills/salesforce-experience-lwr-site/docs/configure-guest-sharing-rules.md +42 -0
  74. package/skills/salesforce-experience-lwr-site/docs/handle-component-and-region-ids.md +27 -0
  75. package/skills/salesforce-experience-lwr-site/docs/handle-ui-components.md +215 -0
  76. package/skills/salesforce-flow/SKILL.md +2 -2
  77. package/skills/salesforce-fragment/SKILL.md +85 -10
  78. package/skills/salesforce-lightning-app-build/SKILL.md +102 -10
  79. package/skills/apex-class/SKILL.md +0 -253
  80. package/skills/apex-class/examples/AccountDeduplicationBatch.cls +0 -148
  81. package/skills/apex-class/examples/AccountSelector.cls +0 -193
  82. package/skills/apex-class/examples/AccountService.cls +0 -201
  83. package/skills/apex-class/templates/abstract.cls +0 -128
  84. package/skills/apex-class/templates/batch.cls +0 -125
  85. package/skills/apex-class/templates/domain.cls +0 -102
  86. package/skills/apex-class/templates/dto.cls +0 -108
  87. package/skills/apex-class/templates/exception.cls +0 -51
  88. package/skills/apex-class/templates/interface.cls +0 -25
  89. package/skills/apex-class/templates/queueable.cls +0 -92
  90. package/skills/apex-class/templates/schedulable.cls +0 -75
  91. package/skills/apex-class/templates/selector.cls +0 -92
  92. package/skills/apex-class/templates/service.cls +0 -69
  93. package/skills/apex-class/templates/utility.cls +0 -97
  94. package/skills/apex-test-class/SKILL.md +0 -101
  95. package/skills/apex-test-class/references/assertion-patterns.md +0 -209
  96. package/skills/apex-test-class/references/async-testing.md +0 -276
  97. package/skills/apex-test-class/references/mocking-patterns.md +0 -219
  98. package/skills/apex-test-class/references/test-data-factory.md +0 -176
  99. package/skills/deployment-readiness-check/SKILL.md +0 -257
  100. package/skills/deployment-readiness-check/assets/deployment_checklist.md +0 -286
  101. package/skills/deployment-readiness-check/references/rollback_procedures.md +0 -308
  102. package/skills/deployment-readiness-check/scripts/check_metadata.sh +0 -207
  103. package/skills/salesforce-experience-site/SKILL.md +0 -178
@@ -0,0 +1,279 @@
1
+ # Production Gotchas: Billing, Determinism & Performance
2
+ Credit consumption, lifecycle hooks, determinism patterns, and performance guardrails in Agentforce.
3
+ ---
4
+
5
+ ## Credit Consumption Table
6
+
7
+ | Operation | Credits | Notes |
8
+ |-----------|---------|-------|
9
+ | `@utils.transition` | FREE | Framework navigation |
10
+ | `@utils.setVariables` | FREE | Framework state management |
11
+ | `@utils.escalate` | FREE | Framework escalation |
12
+ | `if`/`else` control flow | FREE | Deterministic resolution |
13
+ | `before_reasoning` | FREE | Deterministic pre-processing (see note below) |
14
+ | `after_reasoning` | FREE | Deterministic post-processing (see note below) |
15
+ | `reasoning` (LLM turn) | FREE | LLM reasoning itself is not billed |
16
+ | Prompt Templates | 2-16 | Per invocation (varies by complexity) |
17
+ | Flow actions | 20 | Per action execution |
18
+ | Apex actions | 20 | Per action execution |
19
+ | Any other action | 20 | Per action execution |
20
+
21
+ The `before_reasoning:` and `after_reasoning:` lifecycle hooks are validated. Content goes **directly** under the block (no `instructions:` wrapper). See "Lifecycle Hooks" section below for correct syntax.
22
+
23
+ ### Cost Optimization Pattern
24
+
25
+ Fetch data once in `before_reasoning:`, cache in variables, reuse across topics.
26
+
27
+ ## Lifecycle Hooks
28
+
29
+ ```yaml
30
+ topic main:
31
+ description: "Topic with lifecycle hooks"
32
+
33
+ # BEFORE: Runs deterministically BEFORE LLM sees instructions
34
+ before_reasoning:
35
+ # Content goes DIRECTLY here (NO instructions: wrapper!)
36
+ set @variables.pre_processed = True
37
+ set @variables.customer_tier = "gold"
38
+
39
+ # LLM reasoning phase
40
+ reasoning:
41
+ instructions: ->
42
+ | Customer tier: {!@variables.customer_tier}
43
+ | How can I help you today?
44
+
45
+ # AFTER: Runs deterministically AFTER LLM finishes reasoning
46
+ after_reasoning:
47
+ # Content goes DIRECTLY here (NO instructions: wrapper!)
48
+ set @variables.interaction_logged = True
49
+ if @variables.needs_audit == True:
50
+ set @variables.audit_flag = True
51
+ ```
52
+
53
+ **Key Points:**
54
+ - Content goes **directly** under `before_reasoning:` / `after_reasoning:` (NO `instructions:` wrapper)
55
+ - Reliable primitives: `set`, `if`/`else`, `transition to`. `run` has inconsistent runtime behavior across bundle types — use it in `reasoning.actions:` or `instructions: ->` instead
56
+ - `before_reasoning:` is FREE (no credit cost) - use for data prep
57
+ - `after_reasoning:` is FREE (no credit cost) - use for logging, cleanup
58
+ - `transition to` works in `after_reasoning:` — but if a topic transitions mid-reasoning, the original topic's `after_reasoning:` does NOT run
59
+
60
+ **❌ WRONG Syntax (causes compile error):**
61
+ ```yaml
62
+ before_reasoning:
63
+ instructions: -> # ❌ NO! Don't wrap with instructions:
64
+ set @variables.x = True
65
+ ```
66
+
67
+ **✅ CORRECT Syntax:**
68
+ ```yaml
69
+ before_reasoning:
70
+ set @variables.x = True # ✅ Direct content under the block
71
+ ```
72
+
73
+ ## Supervision vs Handoff
74
+
75
+ | Term | Syntax | Behavior | Use When |
76
+ |------|--------|----------|----------|
77
+ | **Handoff** | `@utils.transition to @topic.X` | Control transfers completely, child generates final response | Checkout, escalation, terminal states |
78
+ | **Supervision** | `@topic.X` (as action reference) | Parent orchestrates, child returns, parent synthesizes | Expert consultation, sub-tasks |
79
+
80
+ ```yaml
81
+ # HANDOFF - child topic takes over completely:
82
+ checkout: @utils.transition to @topic.order_checkout
83
+ description: "Proceed to checkout"
84
+ # → @topic.order_checkout generates the user-facing response
85
+
86
+ # SUPERVISION - parent remains in control:
87
+ get_advice: @topic.product_expert
88
+ description: "Consult product expert"
89
+ # → @topic.product_expert returns, parent topic synthesizes final response
90
+ ```
91
+
92
+ **KNOWN BUG**: Adding ANY new action in Canvas view may inadvertently change Supervision references to Handoff transitions.
93
+
94
+ ## Action Output Flags for Zero-Hallucination Routing
95
+
96
+ Control what the LLM can see and say.
97
+
98
+ When defining actions in Agentforce Assets, use these output flags:
99
+
100
+ | Flag | Effect | Use When |
101
+ |------|--------|----------|
102
+ | `filter_from_agent: True` | LLM **cannot** show this value to user | Preventing hallucinated responses (GA standard) |
103
+ | `is_used_by_planner: True` | LLM **can** reason about this value | Decision-making, routing |
104
+
105
+ **Zero-Hallucination Intent Classification Pattern:**
106
+ ```yaml
107
+ # In Agentforce Assets - Action Definition outputs:
108
+ outputs:
109
+ intent_classification: string
110
+ filter_from_agent: True # LLM cannot show this to user (GA standard)
111
+ is_used_by_planner: True # LLM can use for routing decisions
112
+
113
+ # In Agent Script - LLM routes but cannot hallucinate:
114
+ topic intent_router:
115
+ reasoning:
116
+ instructions: ->
117
+ run @actions.classify_intent
118
+ set @variables.intent = @outputs.intent_classification
119
+
120
+ if @variables.intent == "refund":
121
+ transition to @topic.refunds
122
+ if @variables.intent == "order_status":
123
+ transition to @topic.orders
124
+ ```
125
+
126
+ ## Action I/O Metadata Properties
127
+
128
+ Complete reference for all metadata properties available on action definitions, inputs, and outputs.
129
+
130
+ **Action-Level Properties:**
131
+
132
+ | Property | Type | Effect |
133
+ |----------|------|--------|
134
+ | `label` | String | Display name in UI |
135
+ | `description` | String | LLM reads this for decision-making |
136
+ | `require_user_confirmation` | Boolean | Request user confirmation before execution (compiles; runtime no-op per Issue 6) |
137
+ | `include_in_progress_indicator` | Boolean | Show spinner during execution |
138
+ | `progress_indicator_message` | String | Custom spinner text |
139
+
140
+ **Input Properties:**
141
+
142
+ | Property | Type | Effect |
143
+ |----------|------|--------|
144
+ | `description` | String | Explains parameter to LLM |
145
+ | `label` | String | Display name in UI |
146
+ | `is_required` | Boolean | Marks input as mandatory for LLM |
147
+ | `is_user_input` | Boolean | LLM extracts value from conversation |
148
+ | `complex_data_type_name` | String | Lightning type mapping |
149
+
150
+ **Output Properties:**
151
+
152
+ | Property | Type | Effect |
153
+ |----------|------|--------|
154
+ | `description` | String | Explains output to LLM |
155
+ | `label` | String | Display name in UI |
156
+ | `filter_from_agent` | Boolean | `True` = hide from user display (GA standard) |
157
+ | `is_displayable` | Boolean | `False` = hide from user (compile-valid alias) |
158
+ | `is_used_by_planner` | Boolean | `True` = LLM can reason about value |
159
+ | `developer_name` | String | Overrides the parameter's developer name |
160
+ | `complex_data_type_name` | String | Lightning type mapping |
161
+
162
+ `filter_from_agent: True` is the GA standard name. `is_displayable: False` is a compile-valid alias.
163
+
164
+ ### User Input Pattern
165
+
166
+ With `is_user_input: True`:
167
+ ```yaml
168
+ inputs:
169
+ customer_name: string
170
+ description: "Customer's full name"
171
+ is_user_input: True # LLM pulls from what user already said
172
+ is_required: True # Must have a value before action executes
173
+ ```
174
+
175
+ ## Action Chaining with `run` Keyword
176
+
177
+ Parent action may complain about inputs needed by chained action - this is expected.
178
+
179
+ ```yaml
180
+ process_order: @actions.create_order
181
+ with customer_id = @variables.customer_id
182
+ run @actions.send_confirmation # Chains after create_order completes
183
+ set @variables.order_id = @outputs.id
184
+ ```
185
+
186
+ KNOWN BUG: Chained actions with Prompt Templates don't properly map inputs using `Input:Query` format.
187
+
188
+ For prompt template action definitions, input binding syntax, and grounded data patterns, see [references/action-prompt-templates.md](../references/action-prompt-templates.md).
189
+
190
+ ## Latch Variable Pattern for Topic Re-entry
191
+
192
+ Topic selector doesn't properly re-evaluate after user provides missing input. Use a "latch" variable to force re-entry:
193
+
194
+ ```yaml
195
+ variables:
196
+ verification_in_progress: mutable boolean = False
197
+
198
+ start_agent topic_selector:
199
+ reasoning:
200
+ instructions: ->
201
+ if @variables.verification_in_progress == True:
202
+ transition to @topic.verification
203
+ | How can I help you today?
204
+ actions:
205
+ start_verify: @topic.verification
206
+ description: "Start identity verification"
207
+ set @variables.verification_in_progress = True
208
+
209
+ topic verification:
210
+ reasoning:
211
+ instructions: ->
212
+ | Please provide your email to verify your identity.
213
+ actions:
214
+ verify: @actions.verify_identity
215
+ with email = ...
216
+ set @variables.verified = @outputs.success
217
+ set @variables.verification_in_progress = False
218
+ ```
219
+
220
+ ## Loop Protection Guardrail
221
+
222
+ Agent Scripts have a built-in guardrail that limits iterations to approximately **3-4 loops** before breaking out and returning to the Topic Selector.
223
+
224
+ **Best Practice**: Map out your execution paths and test for unintended circular references between topics.
225
+
226
+ ## Token & Size Limits
227
+
228
+ | Limit Type | Value | Notes |
229
+ |------------|-------|-------|
230
+ | Max response size | 1,048,576 bytes (1MB) | Per agent response |
231
+ | Plan trace limit (Frontend) | 1M characters | For debugging UI |
232
+ | Transformed plan trace (Backend) | 32k tokens | Internal processing |
233
+ | Active/Committed Agents per org | 100 max | Org limit |
234
+
235
+ ## Progress Indicators
236
+
237
+ ```yaml
238
+ actions:
239
+ fetch_data: @actions.get_customer_data
240
+ description: "Fetch customer information"
241
+ include_in_progress_indicator: True
242
+ progress_indicator_message: "Fetching your account details..."
243
+ ```
244
+
245
+ ## VS Code Pull/Push NOT Supported
246
+
247
+ ```bash
248
+ # ❌ ERROR when using source tracking:
249
+ Failed to retrieve components using source tracking:
250
+ [SfError [UnsupportedBundleTypeError]: Unsupported Bundle Type: AiAuthoringBundle
251
+
252
+ # ✅ WORKAROUND - Use CLI directly:
253
+ sf project retrieve start -m AiAuthoringBundle:MyAgent
254
+ sf agent publish authoring-bundle --api-name MyAgent -o TARGET_ORG
255
+ ```
256
+
257
+ ## Reserved `@InvocableVariable` Keywords
258
+
259
+ Certain common words cannot be used as `@InvocableVariable` names in Apex classes called by Agent Script. Using them causes "SyntaxError: Unexpected '{keyword}'" during agent script compilation. (Validated March 2026)
260
+
261
+ **Reserved names (cannot use as `@InvocableVariable`):**
262
+
263
+ | Reserved Name | Workaround | Example |
264
+ |---------------|------------|---------|
265
+ | `model` | `vehicle_model`, `data_model`, `model_name` | `@InvocableVariable public String vehicle_model;` |
266
+ | `description` | `issue_description`, `desc_text`, `description_field` | `@InvocableVariable public String issue_description;` |
267
+ | `label` | `label_text`, `display_label`, `label_field` | `@InvocableVariable public String label_text;` |
268
+
269
+ **How it manifests:**
270
+ - Apex compiles and deploys successfully (these are valid Apex identifiers)
271
+ - Error only appears when the Agent Script compiler processes the action's I/O schema
272
+ - Error message: `SyntaxError: Unexpected 'model'` (or `description`, `label`)
273
+ - Fix: Rename the `@InvocableVariable` in Apex, redeploy, then republish the agent
274
+
275
+ ## Language Block Quirks
276
+
277
+ - Hebrew and Indonesian appear **twice** in the language dropdown
278
+ - Selecting from the second set causes save errors
279
+ - Use `adaptive_response_allowed: True` for automatic language adaptation
@@ -0,0 +1,393 @@
1
+ # Salesforce CLI for Agents Reference
2
+
3
+ Command-by-command reference for Salesforce CLI `sf` commands covering agent generation, validation, preview, deployment, publishing, activationt/deactivation, testing, and Einstein Agent User setup.
4
+
5
+ ---
6
+
7
+ ## 1. Global Rules
8
+
9
+ Always include `--json` as the FIRST flag after the base command. This ensures machine-readable output and prevents mid-tier LLMs from dropping the flag.
10
+
11
+ ```bash
12
+ # CORRECT — --json first
13
+ sf agent validate authoring-bundle --json --api-name Local_Info_Agent
14
+
15
+ # WRONG — --json at the end or missing
16
+ sf agent validate authoring-bundle --api-name Local_Info_Agent --json
17
+ sf agent validate authoring-bundle --api-name Local_Info_Agent
18
+ ```
19
+
20
+ Multiple metadata types in `--metadata` are space-separated arguments, NOT comma-separated. Wildcard patterns must be quoted.
21
+
22
+ ```bash
23
+ # CORRECT
24
+ sf project deploy start --json --metadata ApexClass Flow
25
+ sf project retrieve start --json --metadata "AiAuthoringBundle:Local_Info_Agent_*"
26
+
27
+ # WRONG
28
+ sf project deploy start --json --metadata ApexClass,Flow
29
+ sf project retrieve start --json --metadata AiAuthoringBundle:Local_Info_Agent_*
30
+ ```
31
+
32
+ ---
33
+
34
+ ## 2. Generate
35
+
36
+ Create a new AiAuthoringBundle directory with boilerplate `.agent` and `.bundle-meta.xml` files.
37
+
38
+ ```bash
39
+ sf agent generate authoring-bundle --json --no-spec --name "Agent Label" --api-name Agent_API_Name
40
+ ```
41
+
42
+ - `--name`: Human-readable label (quoted if it contains spaces).
43
+ - `--api-name`: Developer name. Must be a valid Salesforce API name (letters, numbers, underscores). This becomes the directory name under `aiAuthoringBundles/`.
44
+ - `--no-spec`: Skip interactive agent spec generation. Always include this flag — the interactive spec generator cannot be used programmatically.
45
+
46
+ The generated directory is placed at `<default_package_directory>/main/default/aiAuthoringBundles/<api-name>/`. Read `sfdx-project.json` to find the default package directory path.
47
+
48
+ - `--force-overwrite`: Overwrites an existing bundle without interactive confirmation. DO NOT use unless intending to overwrite an existing authoring bundle.
49
+
50
+ ### Generated Output
51
+
52
+ The generate command creates this structure:
53
+
54
+ ```
55
+ force-app/main/default/aiAuthoringBundles/
56
+ └── Agent_API_Name/
57
+ ├── Agent_API_Name.agent # Agent Script file
58
+ └── Agent_API_Name.bundle-meta.xml # Metadata XML
59
+ ```
60
+
61
+ **Naming rules:** The folder name, `.agent` filename, and `.bundle-meta.xml` filename must always match `--api-name` exactly (case-sensitive).
62
+
63
+ ---
64
+
65
+ ## 3. Validate
66
+
67
+ Check Agent Script for syntax errors, structural issues, and missing declarations. Always validate before deploying.
68
+
69
+ ```bash
70
+ sf agent validate authoring-bundle --json --api-name Agent_API_Name
71
+ ```
72
+
73
+ - `--api-name`: The AiAuthoringBundle directory name (same as `config.developer_name` in the `.agent` file).
74
+ - Validates against local files only. Does not contact the org.
75
+
76
+ ---
77
+
78
+ ## 4. Deploy
79
+
80
+ ### Deploy Apex, Flow, or other backing logic
81
+
82
+ ```bash
83
+ sf project deploy start --json --metadata ApexClass:ClassName
84
+ ```
85
+
86
+ Deploy backing logic BEFORE deploying the AiAuthoringBundle. The bundle's action targets reference these components, and the platform validates they exist during bundle deploy.
87
+
88
+ ALWAYS deploy each stub class IMMEDIATELY after customizing it. ALWAYS fix deploy errors BEFORE generating and deploying the next stub.
89
+
90
+ ### Deploy the AiAuthoringBundle
91
+
92
+ ```bash
93
+ sf project deploy start --json --metadata AiAuthoringBundle:Agent_API_Name
94
+ ```
95
+
96
+ This deploys ONLY the AiAuthoringBundle. A bare `sf project deploy start` (no `--metadata`) deploys ALL changed metadata in the project, which can inadvertently deploy agent metadata during routine development. Always scope deploys explicitly.
97
+
98
+ ### Safe routine deploy (non-agent metadata)
99
+
100
+ ```bash
101
+ sf project deploy start --json --metadata ApexClass Flow
102
+ ```
103
+
104
+ Explicitly list the metadata types to deploy. This avoids accidentally deploying AiAuthoringBundle changes.
105
+
106
+ ---
107
+
108
+ ## 5. Publish
109
+
110
+ Convert a deployed AiAuthoringBundle into a running agent. Publishing creates the runtime entity graph (Bot, BotVersion, GenAiPlannerBundle) from the authoring bundle.
111
+
112
+ ```bash
113
+ sf agent publish authoring-bundle --json --api-name Agent_API_Name
114
+ ```
115
+
116
+ - `--api-name`: The AiAuthoringBundle directory name.
117
+ - The agent must be deployed before it can be published.
118
+ - The `default_agent_user` in the `.agent` file must exist in the target org and have the Einstein Agent license. An invalid user produces a misleading "Internal Error, try again later" message. See Section 12 for creation steps and [Agent User Setup & Permissions](agent-user-setup.md) for required permissions.
119
+ - **Publishing does NOT activate.** Agents are published as `Inactive`. Tests, preview using `--api-name`, and access by end users continue using the previously active version until you explicitly run `sf agent activate`.
120
+
121
+ ---
122
+
123
+ ## 6. Activate and Deactivate
124
+
125
+ Activation makes a published agent available for conversations and test execution.
126
+
127
+ ```bash
128
+ sf agent activate --json --api-name Bot_API_Name
129
+ ```
130
+
131
+ ```bash
132
+ sf agent deactivate --json --api-name Bot_API_Name
133
+ ```
134
+
135
+ - `--api-name` here is the Bot API name (same as the agent's `config.developer_name`).
136
+ - Only published agents can be activated. DRAFT-only agents cannot be activated.
137
+ - Agent tests require an activated agent.
138
+
139
+ ---
140
+
141
+ ## 7. Retrieve
142
+
143
+ ### Retrieve the authoring bundle (editable source)
144
+
145
+ ```bash
146
+ sf project retrieve start --json --metadata AiAuthoringBundle:Agent_API_Name
147
+ ```
148
+
149
+ ### Retrieve all version-suffixed snapshots (read-only)
150
+
151
+ ```bash
152
+ sf project retrieve start --json --metadata "AiAuthoringBundle:Agent_API_Name_*"
153
+ ```
154
+
155
+ Wildcard must be quoted. Version-suffixed bundles (e.g., `Local_Info_Agent_v1`) are immutable snapshots of published versions. They are read-only reference copies.
156
+
157
+ ### Retrieve the runtime entity graph
158
+
159
+ ```bash
160
+ sf project retrieve start --json --metadata Agent:Agent_API_Name
161
+ ```
162
+
163
+ The `Agent:` pseudo-type retrieves the runtime entities (Bot, BotVersion, GenAiPlannerBundle) created by publish. This does NOT include AiAuthoringBundle — use `AiAuthoringBundle:` for that.
164
+
165
+ #### Caution! Metadata types are NOT sObjects
166
+
167
+ `GenAiPlannerBundle`, `AiAuthoringBundle`, and `GenAiFunction` are **metadata types**. SOQL queries against them return `INVALID_TYPE`. Always use `sf project retrieve start --metadata` instead.
168
+
169
+ ```bash
170
+ # WRONG — these are not sObjects
171
+ sf data query --json -q "SELECT Id FROM GenAiPlannerBundle"
172
+ sf data query --json -q "SELECT Id FROM AiAuthoringBundle"
173
+
174
+ # CORRECT — use the Metadata API
175
+ sf project retrieve start --json --metadata "GenAiPlannerBundle:AgentName"
176
+ sf project retrieve start --json --metadata "AiAuthoringBundle:AgentName"
177
+ ```
178
+
179
+ ---
180
+
181
+ ## 8. Delete
182
+
183
+ ```bash
184
+ sf project delete source --json --metadata AiAuthoringBundle:Agent_API_Name
185
+ ```
186
+
187
+ - Deletes the AiAuthoringBundle from the org AND removes local source files.
188
+ - Published agents cannot be fully deleted via CLI. The platform returns dependency errors. Use Salesforce Setup UI for published agent deletion.
189
+
190
+ ---
191
+
192
+ ## 9. Preview
193
+
194
+ Preview runs the agent in a simulated or live environment for testing behavior before publishing.
195
+
196
+ ### Start a preview session
197
+
198
+ ```bash
199
+ sf agent preview start --json --authoring-bundle Agent_API_Name
200
+ ```
201
+
202
+ Returns a `sessionId` for subsequent send/end commands.
203
+
204
+ ### Send a message
205
+
206
+ ```bash
207
+ sf agent preview send --json --authoring-bundle Agent_API_Name --session-id SESSION_ID -u "User message here"
208
+ ```
209
+
210
+ - `--session-id`: From the `start` response.
211
+ - `-u`: The user utterance (quoted).
212
+
213
+ ### End a preview session
214
+
215
+ ```bash
216
+ sf agent preview end --json --authoring-bundle Agent_API_Name --session-id SESSION_ID
217
+ ```
218
+
219
+ ### Live preview (with real action execution)
220
+
221
+ ```bash
222
+ sf agent preview start --json --authoring-bundle Agent_API_Name --use-live-actions
223
+ ```
224
+
225
+ Add `--use-live-actions` to execute real backing logic instead of simulated responses. Live preview executes real Apex, Flows, and Prompt Templates in the org.
226
+
227
+ ### Anti-pattern: bare preview command
228
+
229
+ ```bash
230
+ # WRONG — interactive REPL, hangs in automation
231
+ sf agent preview --authoring-bundle Agent_API_Name
232
+
233
+ # CORRECT — programmatic start/send/end
234
+ sf agent preview start --json --authoring-bundle Agent_API_Name
235
+ ```
236
+
237
+ The bare `sf agent preview` command is an interactive REPL designed for humans. It cannot be used programmatically because automation cannot send the ESC key to exit.
238
+
239
+ ### Anti-pattern: context variable injection in preview
240
+
241
+ `sf agent preview` does NOT support context or session variable injection. There are no `--context`, `--session-var`, or `--variables` flags.
242
+
243
+ ---
244
+
245
+ ## 10. Test
246
+
247
+ ### Create a test from a spec
248
+
249
+ ```bash
250
+ sf agent test create --json --spec specs/Agent_API_Name-testSpec.yaml --api-name Test_Definition_Name --force-overwrite
251
+ ```
252
+
253
+ - `--spec`: Path to the local YAML test spec file.
254
+ - `--api-name`: The name for the AiEvaluationDefinition in the org.
255
+ - `--force-overwrite`: Prevents interactive mode if the AiEvaluationDefinition already exists. Always include this flag.
256
+ - This command automatically deploys the AiEvaluationDefinition to the org. Use `--preview` to generate locally without deploying.
257
+
258
+ ### Run a test
259
+
260
+ ```bash
261
+ sf agent test run --json --api-name Test_Definition_Name --wait 5
262
+ ```
263
+
264
+ - `--api-name`: The AiEvaluationDefinition name (set by `--api-name` during `test create`). NOT the Bot name.
265
+ - `--wait 5`: Synchronous execution with 5-minute timeout. Without `--wait`, returns a job ID immediately.
266
+ - Tests run against activated published agents only.
267
+
268
+ ### Check test results (async fallback)
269
+
270
+ ```bash
271
+ sf agent test results --json --job-id JOB_ID
272
+ ```
273
+
274
+ Only needed if `--wait` was not used or timed out.
275
+
276
+ ### Generate a test spec from existing metadata
277
+
278
+ ```bash
279
+ sf agent generate test-spec --from-definition path/to/AiEvaluationDefinition-meta.xml --output-file specs/Agent_API_Name-testSpec.yaml
280
+ ```
281
+
282
+ Reverse-engineers a YAML test spec from an existing AiEvaluationDefinition. Do NOT use `sf agent generate test-spec` without `--from-definition` — the bare command is interactive and cannot be used programmatically.
283
+
284
+ ---
285
+
286
+ ## 11. Open in Browser
287
+
288
+ These commands open Agentforce Studio in the user's default browser. Do NOT use `--json` with these commands — JSON mode outputs the target URL but does not open the browser.
289
+
290
+ ### View all authoring bundles
291
+
292
+ ```bash
293
+ sf org open authoring-bundle
294
+ ```
295
+
296
+ ### View a specific published agent
297
+
298
+ ```bash
299
+ sf org open agent --api-name Bot_API_Name
300
+ ```
301
+
302
+ Only works for published agents. DRAFT-only bundles must be opened via `sf org open authoring-bundle`.
303
+
304
+ ---
305
+
306
+ ## 12. Einstein Agent User Setup
307
+
308
+ **⚠️ This section applies only to `AgentforceServiceAgent`. Employee agents (`AgentforceEmployeeAgent`) must NOT have `default_agent_user` set.**
309
+
310
+ ### Check for an Existing Einstein Agent User
311
+
312
+ ```bash
313
+ sf data query --json -q "SELECT Username, Name, IsActive FROM User WHERE Profile.UserLicense.Name = 'Einstein Agent' AND IsActive = true LIMIT 5"
314
+ ```
315
+
316
+ If results are returned, confirm the correct username with the human before using it in the agent's config block.
317
+
318
+ ### Check Einstein Agent License Availability
319
+
320
+ If no users are found, check whether the org has Einstein Agent licenses available:
321
+
322
+ ```bash
323
+ sf data query --json -q "SELECT TotalLicenses, UsedLicenses FROM UserLicense WHERE Name = 'Einstein Agent'"
324
+ ```
325
+
326
+ If `TotalLicenses` is 0, the org does not have the Einstein Agent add-on. **Stop and inform the human.**
327
+
328
+ If `TotalLicenses > UsedLicenses`, a license is available and a new Einstein Agent User can be created.
329
+
330
+ ### Creating an Einstein Agent User
331
+
332
+ #### Step 1: Query for the Einstein Agent User profile ID
333
+
334
+ ```bash
335
+ sf data query --json -q "SELECT Id FROM Profile WHERE Name = 'Einstein Agent User'"
336
+ ```
337
+
338
+ #### Step 2: Create a User import JSON file (e.g., `data-import/User.json`)
339
+
340
+ ```json
341
+ {
342
+ "records": [
343
+ {
344
+ "attributes": {
345
+ "type": "User",
346
+ "referenceId": "AgentUserRef1"
347
+ },
348
+ "ProfileId": "<PROFILE_ID_FROM_STEP_1>",
349
+ "Username": "<UNIQUE_USERNAME>",
350
+ "Alias": "AgntUsr",
351
+ "CommunityNickname": "Agent User<UNIQUE_STRING>",
352
+ "Email": "noreply@example.com",
353
+ "FirstName": "Agent",
354
+ "LastName": "User",
355
+ "IsActive": true,
356
+ "ForecastEnabled": false,
357
+ "EmailEncodingKey": "UTF-8",
358
+ "LanguageLocaleKey": "en_US",
359
+ "LocaleSidKey": "en_US",
360
+ "TimeZoneSidKey": "America/Los_Angeles"
361
+ }
362
+ ]
363
+ }
364
+ ```
365
+
366
+ #### Step 3: Import the user record
367
+
368
+ ```bash
369
+ sf data import tree --json --files data-import/User.json
370
+ ```
371
+
372
+ #### Step 4: Verify the user was created
373
+
374
+ ```bash
375
+ sf data query --json -q "SELECT Username FROM User WHERE Profile.UserLicense.Name = 'Einstein Agent' AND IsActive = true LIMIT 5"
376
+ ```
377
+
378
+ After creating the user, continue with permission setup in [Agent User Setup & Permissions](agent-user-setup.md).
379
+
380
+ ---
381
+
382
+ ## 13. CI/CD Pipeline
383
+
384
+ The individual commands in this guide compose into a standard deployment pipeline:
385
+
386
+ 1. **Retrieve from Sandbox** — `sf project retrieve start --json --metadata AiAuthoringBundle:AgentName`
387
+ 2. **Validate Syntax** — `sf agent validate authoring-bundle --json --api-name AgentName`
388
+ 3. **Run Tests** — `sf agent test run --json --api-name TestDefName --wait 5`
389
+ 4. **Code Review** — Review `.agent` file changes in version control
390
+ 5. **Deploy to Production** — `sf project deploy start --json --metadata AiAuthoringBundle:AgentName`
391
+ 6. **Publish** — `sf agent publish authoring-bundle --json --api-name AgentName`
392
+ 7. **Activate** — `sf agent activate --json --api-name AgentName`
393
+ 8. **Verify Active Agent** — `sf agent preview start --json --api-name AgentName`
@@ -0,0 +1,23 @@
1
+ # Version History
2
+
3
+ Skill version changelog for agentforce-development.
4
+
5
+ ---
6
+
7
+ ## Current Skill (agentforce-development)
8
+
9
+ | Version | Date | Changes |
10
+ |---------|------|---------|
11
+ | 0.4.8 | 2026-03-17 | **Agent access guide + merge cleanup**: Adopted `agent-access-guide.md` from sf-permissions (import rules applied). Routed post-activation access step in Create and Deploy domains. Merged `preview-test-loop.md` content (jq trace diagnostics, fix strategies table, context variable limitations, utterance derivation) into `agent-validation-and-debugging.md`. Deleted orphaned `preview-test-loop.md`. Added custom object scanning guidance to Agent Spec creation. Refined post-action output field instructions. |
12
+ | 0.4.7 | 2026-03-15 | **Post-action session state fix**: Added explicit post-action instructions to prevent session state corruption by specifying output fields the agent must reference. Driven by T02 run-2026-03-15-vc-02 finding. |
13
+ | 0.4.6 | 2026-03-15 | **USER_MODE P0-1 fix**: Added static vs. dynamic SOQL guidelines to backing logic sections in `agent-design-and-spec-creation.md` and invocable Apex template. `AccessLevel.USER_MODE` required for dynamic SOQL. Added "Rules That Always Apply" cardinal rules block to SKILL.md (`--json` first, diagnose before fix, spec approval gate). |
14
+ | 0.4.5 | 2026-03-15 | **Full editorial pass + spec approval gate**: Conciseness pass across all 9 SKILL.md domains. Added spec approval hard gate (user must approve Agent Spec before implementation). Added `filter_from_agent` output visibility to Agent Spec template. Restructured Agent Spec inputs/outputs sections. Step 8 redirect to Diagnose Behavioral Issues workflow. |
15
+ | 0.4.4 | 2026-03-13 | **Staging + cleanup**: Moved unmerged reference files to `staging/` folder. Clarified live actions command syntax. Refined `agent-user-setup.md` license requirements and USER_MODE documentation. |
16
+ | 0.4.3 | 2026-03-12 | **sf-skills merge: production-gotchas + new domain**: Added "Diagnose Production Issues" task domain to SKILL.md (9 domains total). Routed `production-gotchas.md` as primary reference. Added `production-gotchas.md` as secondary reference in Diagnose Compilation (reserved keywords trigger). Added `WITH USER_MODE` object permissions warning to `agent-user-setup.md` Section 6.2. Archived orphan `agent-user-setup-and-perms.md`. Fixed stale SKILL.md reference (Section 2 → Section 6.2). |
17
+ | 0.4.2 | 2026-03-12 | **sf-skills merge: known-issues + one-at-a-time deploy**: Integrated `known-issues.md` into 6 of 8 SKILL.md domains with domain-specific loading triggers. Added one-at-a-time Apex stub deploy instruction to SKILL.md Create/Modify domains, `agent-design-and-spec-creation.md`, and `salesforce-cli-for-agents.md`. Moved Issue 16 (`connections:` → `connection messaging:`) to Resolved. |
18
+ | 0.4.0 | 2026-03-11 | **T03 test run + type mapping restructure**: Restructured Section 5 type mapping in `agent-design-and-spec-creation.md` into Primitive + Complex tables keyed by `target` type. Added steps 10 (Activate) and 11 (Verify published agent) to Create, Modify, and Deploy domains. |
19
+ | 0.3.2 | 2026-03-10 | **T02 post-fix run**: Platform-injected `show_command` tool diagnostic pattern added to `agent-validation-and-debugging.md`. Post-publish preview language strengthened in SKILL.md. |
20
+ | 0.3.0 | 2026-03-10 | **T02 first run + test framework**: Created testing framework (README, run structure, scoring rubric). First T02 run: 13/13 SUCCESS. |
21
+ | 0.2.0 | 2026-03-09 | **T01 first run**: Created T01 test scenario. First end-to-end test of skill. Identified `agent_type` inference gap. |
22
+ | 0.1.0 | 2026-03-08 | **Initial skill**: SKILL.md router with 8 task domains. 7 reference files. Agent Spec template. Asset library. |
23
+