- Skill ID
- jaganpro/sf-skills/sf-ai-agentscript
- Publisher
- jaganpro
- Repository
- sf-skills
- Installs
- 0
- Files
- 81
- License
- MIT
- Requires
- Requires Agentforce license and API v66.0+; Einstein Agent User is required for Service Agents only
- Synced
- Sep 23, 2026
Open any RiverX project, open the Skills panel in the chat, and search for this identifier. The files are fetched from the source repository at install time.
jaganpro/sf-skills/sf-ai-agentscriptInstalls these files- CREDITS.md
- LICENSE
- README.md
- SKILL.md
- VALIDATION.md
- assets/README.md
- assets/agents/README.md
- assets/agents/hello-world-employee.agent
- assets/agents/hello-world.agent
- assets/agents/multi-topic.agent
- assets/agents/production-faq.agent
- assets/agents/production-faq.bundle-meta.xml
- assets/agents/simple-qa.agent
- assets/apex/models-api-queueable.cls
- assets/bundle-meta.xml
- assets/components/apex-action.agent
- assets/components/error-handling.agent
- assets/components/escalation-setup.agent
- assets/components/flow-action.agent
- assets/components/n-ary-conditions.agent
- assets/components/topic-with-actions.agent
- assets/deterministic-routing.agent
- assets/escalation-pattern.agent
- assets/flow-action-lookup.agent
- assets/hub-and-spoke.agent
- assets/metadata/basic-genai-prompt-template.genAiPromptTemplate-meta.xml
- assets/metadata/genai-function-apex.xml
- assets/metadata/genai-function-flow.xml
- assets/metadata/genai-plugin.xml
- assets/metadata/http-callout-flow.flow-meta.xml
- assets/metadata/record-grounded-genai-prompt-template.genAiPromptTemplate-meta.xml
- assets/minimal-starter.agent
- assets/patterns/README.md
- assets/patterns/action-callbacks.agent
- assets/patterns/advanced-input-bindings.agent
- assets/patterns/bidirectional-routing.agent
- assets/patterns/critical-input-collection.agent
- assets/patterns/delegation-routing.agent
- assets/patterns/lifecycle-events.agent
- assets/patterns/llm-controlled-actions.agent
- assets/patterns/multi-step-workflow.agent
- assets/patterns/open-gate-routing.agent
- assets/patterns/procedural-instructions.agent
- assets/patterns/prompt-template-action.agent
- assets/patterns/system-instruction-overrides.agent
- assets/prompt-rag-search.agent
- assets/validation-profiles.json
- assets/verification-gate.agent
- hooks/scripts/agentscript-syntax-validator.py
- references/action-patterns.md
- references/action-prompt-templates.md
- references/actions-reference.md
- references/activation-checklist.md
- references/agent-user-setup.md
- references/architecture-patterns.md
- references/asset-validation-profiles.md
- references/cli-guide.md
- references/complex-data-types.md
- references/customer-web-client.md
- references/debugging-guide.md
- references/feature-validity.md
- references/fsm-architecture.md
- references/grounding-multiagent.md
- references/instruction-resolution.md
- references/known-issues.md
- references/metadata-lifecycle.md
- references/migration-guide.md
- references/minimal-examples.md
- references/official-sources.md
- references/patterns-quick-ref.md
- references/preview-test-loop.md
- references/production-gotchas.md
- references/scoring-rubric.md
- references/sources.md
- references/syntax-reference.md
- references/testing-guide.md
- references/upstream-recipes-audit.md
- references/validator-rule-catalog.md
- references/validator-test-matrix.md
- references/version-history.md
- scripts/validate-asset-profiles.py
What this skill tells the agent
SF-AI-AgentScript Skill
Agent Script is the code-first path for deterministic Agentforce agents. Use this skill when the user is authoring .agent files, building finite-state topic flows, or needs repeatable control over routing, variables, actions, and publish behavior.
Start with the shortest guide first: references/activation-checklist.md Migrating from the Builder UI? Use references/migration-guide.md
When This Skill Owns the Task
Use sf-ai-agentscript when the work involves:
- creating or editing
.agentfiles - deterministic topic routing, guards, and transitions
- Agent Script CLI workflows (
sf agent generate authoring-bundle,sf agent validate authoring-bundle,sf agent preview,sf agent publish authoring-bundle,sf agent activate) - slot filling, instruction resolution, post-action loops, or FSM design
Delegate elsewhere when the user is:
- maintaining Builder metadata agents (
GenAiFunction,GenAiPlugin,GenAiPromptTemplate, Models API, custom Lightning types) → sf-ai-agentforce - designing persona / tone / voice → sf-ai-agentforce-persona
- building formal test plans or coverage loops → sf-ai-agentforce-testing
If the user is in Builder Script / Canvas view but the outcome is a .agent authoring bundle, keep the work in sf-ai-agentscript.
Right-Size Determinism
- Determinism is a dial, not a destination.
- Use Agent Script when “mostly right” is not acceptable: gates, mandatory sequencing, explicit state transitions, compliance, or drift control.
- If a workflow is fully static and linear, use Flow or Apex instead of scripting the conversation.
- Prefer a deterministic envelope: deterministic entry/gate → flexible middle → deterministic closeout.
- More determinism is not automatically better. Start minimal, then harden only the parts that show routing drift, sequencing failures, or compliance risk.
Required Context to Gather First
Ask for or infer:
- agent purpose and whether Agent Script is truly the right fit
- Service Agent vs Employee Agent
- target org and publish intent
- expected actions / targets (Flow, Apex, PromptTemplate, etc.)
- whether the request is authoring, validation, preview, or publish troubleshooting
Activation Checklist
Before you author or fix any .agent file, verify these first:
- Exactly one `start_agent` block
- No mixed tabs and spaces
- Booleans are `True` / `False`
- No `else if` and no nested `if`
- No top-level `actions:` block
- No `@inputs` in `set` expressions
- `linked` variables have no defaults
- `linked` variables do not use `object` / `list` types
- Use explicit `agent_type`
- Use `@actions.` prefixes consistently
- Use `run @actions.X` only when `X` is a topic-level action definition with `target:`
- Do not branch directly on raw `@system_variables.user_input contains/startswith/endswith` for intent routing
- On prompt-template outputs, prefer `is_displayable: False` + `is_used_by_planner: True`
- Do not assume `@outputs.X` is scalar — inspect the output schema before branching or assignment
For the expanded version, use references/activation-checklist.md.
Non-Negotiable Rules
1) Service Agent vs Employee Agent
| Agent type | Required | Forbidden / caution |
|---|---|---|
AgentforceServiceAgent | Valid default_agent_user, correct permissions, target-org checks, prefer sf org create agent-user | Publishing without a real Einstein Agent User |
AgentforceEmployeeAgent | Explicit agent_type | Supplying default_agent_user |
Full details: references/agent-user-setup.md
2) Recommended top-level block convention
Use this order for consistency in this skill's examples and reviews:
config:
variables:
system:
connection:
knowledge:
language:
start_agent:
topic:Official Salesforce materials present top-level blocks in differing sequences, and local validation evidence indicates multiple orderings compile. Treat this as a style convention, not a standalone correctness or publish blocker.
3) Critical config fields
| Field | Rule |
|---|---|
developer_name | Must match folder / bundle name |
description | Public docs/examples should use this config field |
agent_type | Set explicitly every time |
default_agent_user | Service Agents only |
Local tooling also accepts agent_description: for compatibility, but this skill's public docs and examples should prefer description:.
4) Syntax blockers you should treat as immediate failures
else if- nested
if - comment-only
ifbodies - top-level
actions: - invocation-level
inputs:/outputs:blocks - reserved variable / field names like
descriptionandlabel
Canonical rule set: references/syntax-reference.md and references/validator-rule-catalog.md
Recommended Workflow
Recommended Authoring Workflow
Phase 1 — design the agent
- decide whether the problem is actually deterministic enough for Agent Script
- model topics as states and transitions as edges
- define only the variables you truly need
Phase 2 — author the .agent
- create
config,system,start_agent, and topics first - add target-backed actions with full
inputs:andoutputs: - use
available whenfor deterministic tool visibility - normalize raw intent/validation signals into booleans or enums before branching; avoid direct substring checks on raw user utterances for critical control flow
- keep post-action checks at the top of
instructions: ->
Default authoring stance
- Default to direct
.agentauthoring and edits in source control. - Use
sf agent generate authoring-bundle --no-speconly when the user wants local bundle scaffolding. - Treat
sf agent generate agent-specas optional ideation / topic bootstrap, not the default workflow. - Do not route Agent Script users toward
sf agent createorsf agent generate template.
Phase 3 — validate continuously
Validation already runs automatically on write/edit. Use the CLI before publish:
sf agent validate authoring-bundle --api-name MyAgent -o TARGET_ORG --jsonThe validator covers structure, runtime gotchas, target readiness, and org-aware Service Agent checks. Rule IDs live in references/validator-rule-catalog.md.
Phase 4 — preview smoke test
Use the preview loop before publish:
- derive 3–5 smoke utterances
- start preview with the
start/send/endsubcommands, not baresf agent preview - if you use
--authoring-bundle, always choose a mode explicitly:--simulate-actionsor--use-live-actions - inspect topic routing / action invocation / safety / grounding
- fix and rerun up to 3 times
Full loop: references/preview-test-loop.md
Phase 5 — publish and activate
sf agent publish authoring-bundle --api-name MyAgent -o TARGET_ORG --json
# Manual activation
sf agent activate --api-name MyAgent -o TARGET_ORG
# CI / deterministic activation of a known BotVersion
sf agent activate --api-name MyAgent --version <n> -o TARGET_ORG --jsonPublishing does not activate the agent. For automation, prefer --version <n> --json so activation is deterministic and machine-readable.
Deterministic Building Blocks
These execute as code, not suggestions:
- conditionals
available whenguards- variable checks
- direct
set/transition to run @actions.Xonly when `X` is a topic-level action definition with `target:`- variable injection into LLM-facing text
Important distinction:
More from jaganpro
Use this skill in a project
Open any RiverX project, search the Skills panel for jaganpro/sf-skills/sf-ai-agentscript, and install it in one click.
