@cwel/sf
v2.149.9-cwel.1
Published
The Salesforce CLI
Readme
@salesforce/cli
Getting Started
- Release notes
- Read the sf Plugin Developer Guide to learn how to develop a
sfplugin. - Are you migrating an
sfdxplugin tosf? Then check out the migration section of the developer guide. - Read this section of the Setup Guide for easy instructions on how to move from your
sfdx(v7) installation tosf(v2).
Feedback
To provide feedback, use create a new issue here.
Usage
$ npm install -g @salesforce/cli
$ sf COMMAND
running command...
$ sf (--version|-v)
@salesforce/cli/2.149.9 linux-x64 node-v24.19.0
$ sf --help [COMMAND]
USAGE
$ sf COMMAND
...Architecture
See architecture page for diagrams of the Salesforce CLI.
Commands
sf agent activatesf agent adl createsf agent adl deletesf agent adl file addsf agent adl file deletesf agent adl file listsf agent adl getsf agent adl listsf agent adl statussf agent adl updatesf agent adl uploadsf agent createsf agent deactivatesf agent generate agent-specsf agent generate authoring-bundlesf agent generate templatesf agent generate test-specsf agent mcp asset listsf agent mcp asset replacesf agent mcp createsf agent mcp deletesf agent mcp fetchsf agent mcp getsf agent mcp listsf agent mcp updatesf agent previewsf agent preview endsf agent preview sendsf agent preview sessionssf agent preview startsf agent publish authoring-bundlesf agent test createsf agent test listsf agent test resultssf agent test resumesf agent test runsf agent test run-evalsf agent trace deletesf agent trace listsf agent trace readsf agent validate authoring-bundlesf alias listsf alias setsf alias unsetsf apex get logsf apex get testsf apex list logsf apex runsf apex run testsf apex tail logsf api request graphqlsf api request rest [URL]sf autocomplete [SHELL]sf commandssf config getsf config listsf config setsf config unsetsf data bulk resultssf data create filesf data create recordsf data delete bulksf data delete recordsf data delete resumesf data export bulksf data export resumesf data export treesf data get recordsf data import bulksf data import resumesf data import treesf data querysf data resumesf data searchsf data update bulksf data update recordsf data update resumesf data upsert bulksf data upsert resumesf doctorsf force data bulk deletesf force data bulk statussf force data bulk upsertsf help [COMMAND]sf info releasenotes displaysf logic get testsf logic run testsf org assign permsetsf org assign permsetlicensesf org auth show-access-tokensf org auth show-sfdx-auth-urlsf org auth show-user-passwordsf org create agent-usersf org create sandboxsf org create scratchsf org create usersf org delete sandboxsf org delete scratchsf org disable trackingsf org displaysf org display usersf org enable trackingsf org generate passwordsf org listsf org list authsf org list limitssf org list metadatasf org list metadata-typessf org list sobject record-countssf org list userssf org login access-tokensf org login jwtsf org login sfdx-urlsf org login websf org logoutsf org opensf org open agentsf org open authoring-bundlesf org refresh sandboxsf org resume sandboxsf org resume scratchsf package convertsf package createsf package deletesf package installsf package install reportsf package installed listsf package listsf package push-upgrade abortsf package push-upgrade listsf package push-upgrade reportsf package push-upgrade schedulesf package uninstallsf package uninstall reportsf package updatesf package version createsf package version create listsf package version create reportsf package version deletesf package version displayancestrysf package version displaydependenciessf package version listsf package version promotesf package version reportsf package version retrievesf package version updatesf package1 version createsf package1 version create getsf package1 version displaysf package1 version listsf pluginssf plugins discoversf plugins:inspect PLUGIN...sf plugins install PLUGINsf plugins link PATHsf plugins resetsf plugins trust allowlist addsf plugins trust allowlist listsf plugins trust allowlist removesf plugins trust verifysf plugins uninstall [PLUGIN]sf plugins updatesf project convert mdapisf project convert sourcesf project convert source-behaviorsf project delete sourcesf project delete trackingsf project deploy cancelsf project deploy previewsf project deploy quicksf project deploy reportsf project deploy resumesf project deploy startsf project deploy validatesf project generate manifestsf project list ignoredsf project reset trackingsf project retrieve previewsf project retrieve startsf schema generate fieldsf schema generate platformeventsf schema generate sobjectsf schema generate tabsf searchsf sobject describesf sobject listsf template generate analytics templatesf template generate apex classsf template generate apex triggersf template generate digital-experience sitesf template generate flexipagesf template generate lightning appsf template generate lightning componentsf template generate lightning eventsf template generate lightning interfacesf template generate lightning testsf template generate projectsf template generate static-resourcesf template generate ui-bundlesf template generate visualforce componentsf template generate visualforce pagesf update [CHANNEL]sf versionsf which
sf agent activate
Activate an agent in an org.
USAGE
$ sf agent activate -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-n <value>] [--version
<value>]
FLAGS
-n, --api-name=<value> API name of the agent to activate; if not specified, the command provides a list that you
choose from.
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
--version=<value> Version number of the agent to activate; if not specified, the command provides a list that
you choose from.
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Activate an agent in an org.
Activating an agent makes it immediately available to your users. A published agent must be active before you can
preview it with the "agent preview" CLI command or VS Code. Agents can have multiple versions; only one version can be
active at a time.
If you run the command without the --api-name or --version flags, the command provides a list of agent API names and
versions for you to choose from. Use the flags to specify the exact agent and version without being prompted. If you
use the --json flag and not --version, then the latest agent version is automatically activated.
The value of the --version flag is always a number, corresponding to the "vX" part of the "BotVersion" metadata in
your project. For example, if you have a force-app/main/default/bots/My_Agent/v4.botVersion-meta.xml file in your
project, then you activate this version with the "--version 4" flag.
EXAMPLES
Activate an agent in your default target org by being prompted for both its API name and version:
$ sf agent activate
Activate version 2 of an agent with API name Resort_Manager in the org with alias "my-org":
$ sf agent activate --api-name Resort_Manager --version 2 --target-org my-org
ENVIRONMENT VARIABLES
SF_TARGET_ORG Username or alias of your default org. Overrides the target-org configuration variable.
ERROR CODES
Succeeded (0) Agent activated successfully.
NotFound (2) Agent not found in the org.
ActivationFailed (4) Failed to activate the agent due to API or network errors.See code: @salesforce/plugin-agent
sf agent adl create
Create an Agentforce Data Library.
USAGE
$ sf agent adl create -o <value> -n <value> --developer-name <value> --source-type sfdrive|knowledge|retriever
[--json] [--flags-dir <value>] [--api-version <value>] [--description <value>] [--index-mode basic|enhanced]
[--retriever-id <value>] [--primary-index-field1 <value>] [--primary-index-field2 <value>] [--content-fields
<value>] [--data-category-ids <value>] [--data-category-names <value>] [-w <value>]
FLAGS
-n, --name=<value> (required) Display name for the data library (max 80 characters).
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
-w, --wait=<value> Wait N minutes for indexing to complete (KNOWLEDGE libraries). SFDRIVE libraries
require upload before indexing; RETRIEVER libraries are ready immediately.
--api-version=<value> Override the api version used for api requests made by this command
--content-fields=<value> Comma-separated list of content fields for KNOWLEDGE libraries (optional, mutable
after creation).
--data-category-ids=<value> Comma-separated list of data category selection IDs for KNOWLEDGE libraries.
Mutually exclusive with --data-category-names (provide one or the other, not
both).
--data-category-names=<value> Comma-separated list of data category names in qualified format (e.g.,
"Group_API_Name.Category"). Mutually exclusive with --data-category-ids (provide
one or the other, not both).
--description=<value> Description of the data library (max 255 characters).
--developer-name=<value> (required) API name for the data library (max 80 characters, alphanumeric and
underscores only, must start with a letter).
--index-mode=<option> Index mode for SFDRIVE libraries: basic or enhanced.
<options: basic|enhanced>
--primary-index-field1=<value> Primary index field 1 for KNOWLEDGE libraries (required, immutable after
creation).
--primary-index-field2=<value> Primary index field 2 for KNOWLEDGE libraries (required, immutable after
creation).
--retriever-id=<value> ID of an active Custom Retriever (required for RETRIEVER source type; retriever
must be active).
--source-type=<option> (required) Type of grounding source: sfdrive (file upload), knowledge (Salesforce
Knowledge articles), or retriever (existing active Custom Retriever).
<options: sfdrive|knowledge|retriever>
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Create an Agentforce Data Library.
Creates a new data library in the target org. The --source-type flag determines the type of library: SFDRIVE (file
upload), KNOWLEDGE (Salesforce Knowledge articles), or RETRIEVER (existing active Custom Retriever).
For SFDRIVE libraries, creation provisions the full Data Cloud pipeline (DLO → DMO → SearchIndex → Retriever). Upload
files with `sf agent adl upload` after creation.
EXAMPLES
Create an SFDRIVE library:
$ sf agent adl create --target-org myOrg --name "My Docs" --developer-name My_Docs --source-type sfdrive
Create a KNOWLEDGE library with index fields:
$ sf agent adl create --target-org myOrg --name "KB Library" --developer-name KB_Library --source-type knowledge \
--primary-index-field1 Title --primary-index-field2 Summary
Create a RETRIEVER library:
$ sf agent adl create --target-org myOrg --name "Existing Retriever" --developer-name Existing_Retriever \
--source-type retriever --retriever-id 0ppXX0000000001See code: @salesforce/plugin-agent
sf agent adl delete
Delete an Agentforce Data Library.
USAGE
$ sf agent adl delete -o <value> -i <value> [--json] [--flags-dir <value>] [--api-version <value>]
FLAGS
-i, --library-id=<value> (required) Agentforce Data Library ID (18-char Salesforce ID with prefix 1JD).
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Delete an Agentforce Data Library.
Permanently deletes a data library and all associated files and indexing data.
EXAMPLES
Delete a data library:
$ sf agent adl delete --library-id 1JDSG000007IbWX4A0 --target-org myOrgSee code: @salesforce/plugin-agent
sf agent adl file add
Add files to an existing Agentforce Data Library.
USAGE
$ sf agent adl file add -o <value> -i <value> -f <value>... [--json] [--flags-dir <value>] [--api-version <value>]
FLAGS
-f, --path=<value>... (required) Path to file(s) to add. Specify multiple times for batch upload.
-i, --library-id=<value> (required) Agentforce Data Library ID (18-char Salesforce ID with prefix 1JD).
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Add files to an existing Agentforce Data Library.
Adds one or more files to an existing SFDRIVE data library and triggers SearchIndex re-hydration. This is the day-2
operation for adding files to an already-provisioned library.
Adds files to an existing READY library. Unlike `sf agent adl upload`, this does NOT create new downstream Data Cloud
assets — it appends files to the existing SearchIndex and triggers re-indexing.
Constraints: at least 1 file required, no duplicate file names in a batch, maximum 1000 files per library.
EXAMPLES
Add a file to an existing library:
$ sf agent adl file add -i 1JDSG000007IbWX4A0 --path ./docs/new-guide.pdf --target-org myOrg
Add multiple files:
$ sf agent adl file add -i 1JDSG000007IbWX4A0 --path ./docs/guide.pdf --path ./docs/faq.txt --target-org myOrgSee code: @salesforce/plugin-agent
sf agent adl file delete
Delete a file from an Agentforce Data Library.
USAGE
$ sf agent adl file delete -o <value> -i <value> --file-id <value> [--json] [--flags-dir <value>] [--api-version
<value>]
FLAGS
-i, --library-id=<value> (required) Agentforce Data Library ID (18-char Salesforce ID with prefix 1JD).
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
--file-id=<value> (required) ID of the file to delete (AiGroundingFileRef record ID).
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Delete a file from an Agentforce Data Library.
Permanently removes a file from an SFDRIVE data library and triggers re-indexing of the search index.
EXAMPLES
Delete a file from a data library:
$ sf agent adl file delete --library-id 1JDSG000007IbWX4A0 --file-id a1B2C3D4E5F6G7H8I9 --target-org myOrgSee code: @salesforce/plugin-agent
sf agent adl file list
List files in an Agentforce Data Library.
USAGE
$ sf agent adl file list -o <value> -i <value> [--json] [--flags-dir <value>] [--api-version <value>] [--page-size
<value>] [--offset <value>] [--status uploaded|indexing|indexed|index_failed|deleting|delete_failed]
FLAGS
-i, --library-id=<value> (required) Agentforce Data Library ID (18-char Salesforce ID with prefix 1JD).
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
--offset=<value> Number of files to skip before returning results (for pagination).
--page-size=<value> [default: 50] Number of files to return per page (1-200, default 50).
--status=<option> Filter files by indexing status.
<options: uploaded|indexing|indexed|index_failed|deleting|delete_failed>
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
List files in an Agentforce Data Library.
Returns the list of files in an SFDRIVE library including file name, size, and creation date.
EXAMPLES
List files in a data library:
$ sf agent adl file list --library-id 1JDSG000007IbWX4A0 --target-org myOrg
List files and output as JSON:
$ sf agent adl file list --library-id 1JDSG000007IbWX4A0 --target-org myOrg --jsonSee code: @salesforce/plugin-agent
sf agent adl get
Get details of an Agentforce Data Library.
USAGE
$ sf agent adl get -o <value> -i <value> [--json] [--flags-dir <value>] [--api-version <value>]
FLAGS
-i, --library-id=<value> (required) Agentforce Data Library ID (18-char Salesforce ID with prefix 1JD).
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Get details of an Agentforce Data Library.
Returns the full detail of a data library including its grounding source configuration, status, and retriever ID.
EXAMPLES
Get details of a data library:
$ sf agent adl get --library-id 1JDSG000007IbWX4A0 --target-org myOrgSee code: @salesforce/plugin-agent
sf agent adl list
List Agentforce Data Libraries in an org.
USAGE
$ sf agent adl list -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [--source-type
sfdrive|knowledge|retriever]
FLAGS
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
--source-type=<option> Filter by source type: sfdrive, knowledge, or retriever.
<options: sfdrive|knowledge|retriever>
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
List Agentforce Data Libraries in an org.
Returns all data libraries in the target org, including their source type, status, and library ID.
EXAMPLES
List all data libraries in the default target org:
$ sf agent adl list --target-org myOrg
List data libraries and output as JSON:
$ sf agent adl list --target-org myOrg --jsonSee code: @salesforce/plugin-agent
sf agent adl status
Get indexing status of an Agentforce Data Library.
USAGE
$ sf agent adl status -o <value> -i <value> [--json] [--flags-dir <value>] [--api-version <value>]
[--include-artifacts]
FLAGS
-i, --library-id=<value> (required) Agentforce Data Library ID (18-char Salesforce ID with prefix 1JD).
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
--include-artifacts Resolve DC asset artifacts (DataStream, DLO, DMO, SearchIndex, Retriever) with entity IDs
and names on each stage. Slower — requires additional queries.
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Get indexing status of an Agentforce Data Library.
Returns the current indexing status including stage details (DATA_STREAM, DATA_LAKE_OBJECT, DATA_MODEL_OBJECT,
SEARCH_INDEX, RETRIEVER) and any errors.
EXAMPLES
Get status of a data library:
$ sf agent adl status --library-id 1JDSG000007IbWX4A0 --target-org myOrgSee code: @salesforce/plugin-agent
sf agent adl update
Update an Agentforce Data Library.
USAGE
$ sf agent adl update -o <value> -i <value> [--json] [--flags-dir <value>] [--api-version <value>] [-n <value>]
[--description <value>] [--content-fields <value>] [--restrict-to-public-articles] [--data-category-rule]
[--retriever-id <value>]
FLAGS
-i, --library-id=<value> (required) Agentforce Data Library ID (18-char Salesforce ID with prefix 1JD).
-n, --name=<value> New display name for the data library (max 80 characters).
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the
`target-org` configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
--content-fields=<value> Comma-separated list of content fields for KNOWLEDGE libraries (triggers
re-indexing).
--[no-]data-category-rule Enable or disable data category filtering for KNOWLEDGE libraries. Use
--no-data-category-rule to disable.
--description=<value> New description for the data library (max 255 characters).
--[no-]restrict-to-public-articles Restrict to public Knowledge articles only (KNOWLEDGE libraries, triggers
re-indexing).
--retriever-id=<value> Swap the retriever for a RETRIEVER library (must be an active Custom Retriever
ID).
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Update an Agentforce Data Library.
Updates the label, description, or other mutable properties of an existing data library.
EXAMPLES
Update the label of a data library:
$ sf agent adl update --library-id 1JDSG000007IbWX4A0 --name "New Name" --target-org myOrg
Update the description:
$ sf agent adl update --library-id 1JDSG000007IbWX4A0 --description "Updated description" --target-org myOrg
Update Knowledge library content fields (triggers re-indexing):
$ sf agent adl update --library-id 1JDSG000007IbWX4A0 --content-fields "Answer**c,Summary**c" --target-org myOrg
Restrict Knowledge library to public articles:
$ sf agent adl update --library-id 1JDSG000007IbWX4A0 --restrict-to-public-articles --target-org myOrgSee code: @salesforce/plugin-agent
sf agent adl upload
Upload a file to an SFDRIVE Agentforce Data Library.
USAGE
$ sf agent adl upload -o <value> -i <value> -f <value>... [--json] [--flags-dir <value>] [--api-version <value>] [-w
<value>]
FLAGS
-f, --file=<value>... (required) Path to the file to upload.
-i, --library-id=<value> (required) Agentforce Data Library ID (18-char Salesforce ID with prefix 1JD).
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
-w, --wait=<value> Number of minutes to wait for indexing to complete. If not specified, returns after
triggering indexing.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Upload a file to an SFDRIVE Agentforce Data Library.
Performs the multi-step upload workflow: checks upload readiness, obtains a pre-signed S3 URL, uploads the file,
triggers indexing, and optionally polls until the library is ready (retrieverId is populated).
Upload triggers the full Data Cloud provisioning pipeline, creating all downstream assets (DLO, DMO, SearchIndex,
Retriever). Use `sf agent adl status` to monitor progress. For adding files to an already-provisioned library, use `sf
agent adl file add` instead.
This command only works with SFDRIVE libraries. KNOWLEDGE libraries index automatically after creation, and RETRIEVER
libraries require no file upload.
EXAMPLES
Upload a file and wait for indexing to complete:
$ sf agent adl upload --library-id 1JDSG000007IbWX4A0 --file ./docs/guide.pdf --target-org myOrg --wait 10
Upload a file without waiting:
$ sf agent adl upload --library-id 1JDSG000007IbWX4A0 --file ./docs/guide.pdf --target-org myOrgSee code: @salesforce/plugin-agent
sf agent create
Create an agent in your org using a local agent spec file.
USAGE
$ sf agent create -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [--name <value>] [--api-name
<value>] [--spec <value>] [--preview]
FLAGS
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-name=<value> API name of the new agent; if not specified, the API name is derived from the agent name
(label); the API name must not exist in the org.
--api-version=<value> Override the api version used for api requests made by this command
--name=<value> Name (label) of the new agent.
--preview Preview the agent without saving it in your org.
--spec=<value> Path to an agent spec file.
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Create an agent in your org using a local agent spec file.
NOTE: This command creates an agent that doesn't use Agent Script as its blueprint. We generally don't recommend you
use this workflow to create an agent. Rather, use the "agent generate|validate|publish authoring-bundle" commands to
author agents that use the Agent Script language. See "Author an Agent"
(https://developer.salesforce.com/docs/einstein/genai/guide/agent-dx-nga-author-agent.html) for details.
To run this command, you must have an agent spec file, which is a YAML file that define the agent properties and
contains a list of AI-generated topics. Topics define the range of jobs the agent can handle. Use the "agent generate
agent-spec" CLI command to generate an agent spec file. Then specify the file to this command using the --spec flag,
along with the name (label) of the new agent with the --name flag. If you don't specify any of the required flags, the
command prompts you.
When this command completes, your org contains the new agent, which you can then edit and customize in the Agent
Builder UI. The new agent's topics are the same as the ones listed in the agent spec file. The agent might also have
some AI-generated actions, or you can add them. This command also retrieves all the metadata files associated with the
new agent to your local Salesforce DX project.
Use the --preview flag to review what the agent looks like without actually saving it in your org. When previewing,
the command creates a JSON file in the current directory with all the agent details. The name of the JSON file is the
agent's API name and a timestamp.
To open the new agent in your org's Agent Builder UI, run this command: "sf org open agent --api-name <api-name>".
EXAMPLES
Create an agent by being prompted for the required information, such as the agent spec file and agent name, and then
create it in your default org:
$ sf agent create
Create an agent by specifying the agent name, API name, and spec file with flags; use the org with alias "my-org";
the command fails if the API name is already being used in your org:
$ sf agent create --name "Resort Manager" --api-name Resort_Manager --spec specs/resortManagerAgent.yaml \
--target-org my-org
Preview the creation of an agent named "Resort Manager" and use your default org:
$ sf agent create --name "Resort Manager" --spec specs/resortManagerAgent.yaml --previewSee code: @salesforce/plugin-agent
sf agent deactivate
Deactivate an agent in an org.
USAGE
$ sf agent deactivate -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [-n <value>]
FLAGS
-n, --api-name=<value> API name of the agent to deactivate; if not specified, the command provides a list that you
choose from.
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Deactivate an agent in an org.
Deactivating an agent makes it unavailable to your users. To make changes to an agent, such as adding or removing
topics or actions, you must deactivate it. You can't preview an agent with the "agent preview" CLI command or VS Code
if it's deactivated.
If you run the command without the --api-name flag, the command provides a list of agent API names for you to choose
from. Use the flag to specify the exact agent without being prompted.
EXAMPLES
Deactivate an agent in your default target org by being prompted:
$ sf agent deactivate
Deactivate the agent Resort_Manager in the org with alias "my_org":
$ sf agent deactivate --api-name Resort_Manager --target-org my-org
ENVIRONMENT VARIABLES
SF_TARGET_ORG Username or alias of your default org. Overrides the target-org configuration variable.
ERROR CODES
Succeeded (0) Agent deactivated successfully.
NotFound (2) Agent not found in the org.
DeactivationFailed (4) Failed to deactivate the agent due to API or network errors.See code: @salesforce/plugin-agent
sf agent generate agent-spec
Generate an agent spec, which is a YAML file that captures what an agent can do.
USAGE
$ sf agent generate agent-spec -o <value> [--json] [--flags-dir <value>] [--api-version <value>] [--type customer|internal]
[--role <value>] [--company-name <value>] [--company-description <value>] [--company-website <value>] [--max-topics
<value>] [--agent-user <value>] [--enrich-logs true|false] [--tone formal|casual|neutral] [--spec <value>]
[--output-file <value>] [--full-interview] [--grounding-context <value> --prompt-template <value>]
[--force-overwrite]
FLAGS
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--agent-user=<value> Username of a user in your org to assign to your agent; determines what your agent
can access and do.
--api-version=<value> Override the api version used for api requests made by this command
--company-description=<value> Description of your company.
--company-name=<value> Name of your company.
--company-website=<value> Website URL of your company.
--enrich-logs=<option> Adds agent conversation data to event logs so you can view all agent session
activity in one place.
<options: true|false>
--force-overwrite Don't prompt the user to confirm that an existing spec file will be overwritten.
--full-interview Prompt for both required and optional flags.
--grounding-context=<value> Context information and personalization that's added to your prompts when using a
custom prompt template.
--max-topics=<value> Maximum number of topics to generate in the agent spec; default is 5.
--output-file=<value> [default: specs/agentSpec.yaml] Path for the generated YAML agent spec file; can be
an absolute or relative path.
--prompt-template=<value> API name of a customized prompt template to use instead of the default prompt
template.
--role=<value> Role of the agent.
--spec=<value> Agent spec file, in YAML format, to use as input to the command.
--tone=<option> Conversational style of the agent, such as how it expresses your brand personality
in its messages through word choice, punctuation, and sentence structure.
<options: formal|casual|neutral>
--type=<option> Type of agent to create. Internal types are copilots used internally by your
company and customer types are the agents you create for your customers.
<options: customer|internal>
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Generate an agent spec, which is a YAML file that captures what an agent can do.
An agent spec is a YAML-formatted file that contains basic information about the agent, such as its role, company
description, and an AI-generated list of topics based on this information. Topics define the range of jobs your agent
can handle.
Use flags, such as --role and --company-description, to provide details about your company and the role that the agent
plays in your company. If you prefer, you can also be prompted for the basic information; use --full-interview to be
prompted for all required and optional properties. Upon command execution, the large language model (LLM) associated
with your org uses the provided information to generate a list of topics for the agent. Because the LLM uses the
company and role information to generate the topics, we recommend that you provide accurate, complete, and specific
details so the LLM generates the best and most relevant topics. Once generated, you can edit the spec file; for
example, you can remove topics that don't apply or change a topic's description.
You can also iterate the spec generation process by using the --spec flag to pass an existing agent spec file to this
command, and then using the --role, --company-description, etc, flags to refine your agent properties. Iteratively
improving the description of your agent allows the LLM to generate progressively better topics.
You can also specify other agent properties, such as a custom prompt template, how to ground the prompt template to
add context to the agent's prompts, the tone of the prompts, and the username of a user in the org to assign to the
agent.
When your agent spec is ready, generate an authoring bundle from it by passing the spec file to the --spec flag of the
"agent generate authoring-bundle" CLI command. An authoring bundle is a metadata type that contains an Agent Script
file, which is the blueprint for an agent. (While not recommended, you can also use the agent spec file to immediately
create an agent with the "agent create" command. We don't recommend this workflow because these types of agents don't
use Agent Script, and are thus less flexible and more difficult to maintain.)
EXAMPLES
Generate an agent spec in the default location and use flags to specify the agent properties, such as its role and
your company details; use your default org:
$ sf agent generate agent-spec --type customer --role "Field customer complaints and manage employee schedules." \
--company-name "Coral Cloud Resorts" --company-description "Provide customers with exceptional destination \
activities, unforgettable experiences, and reservation services."
Generate an agent spec by being prompted for the required agent properties and generate a maxiumum of 5 topics;
write the generated file to the "specs/resortManagerSpec.yaml" file and use the org with alias "my-org":
$ sf agent generate agent-spec --max-topics 5 --output-file specs/resortManagerAgent.yaml --target-org my-org
Be prompted for all required and optional agent properties; use your default org:
$ sf agent generate agent-spec --full-interview
Specify an existing agent spec file called "specs/resortManagerAgent.yaml", and then overwrite it with a new version
that contains newly AI-generated topics based on the updated role information passed in with the --role flag:
$ sf agent generate agent-spec --spec specs/resortManagerAgent.yaml --output-file specs/resortManagerAgent.yaml \
--role "Field customer complaints, manage employee schedules, and ensure all resort operations are running \
smoothly"
Specify that the conversational tone of the agent is formal and to attach the "[email protected]" username to
it; be prompted for the required properties and use your default org:
$ sf agent generate agent-spec --tone formal --agent-user [email protected]See code: @salesforce/plugin-agent
sf agent generate authoring-bundle
Generate an authoring bundle from an existing agent spec YAML file.
USAGE
$ sf agent generate authoring-bundle -o <value> [--json] [--flags-dir <value>] [--api-name <value>] [--api-version <value>] [-f
<value>] [--no-spec] [-d <value>] [-n <value>] [--force-overwrite]
FLAGS
-d, --output-dir=<value> Directory where the authoring bundle files are generated.
-f, --spec=<value> Path to the agent spec YAML file. If you don't specify the flag, the command provides a
list that you can choose from. Use the --no-spec flag to skip using an agent spec entirely.
-n, --name=<value> Name (label) of the authoring bundle; if not specified, you're prompted for the name.
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-name=<value> API name of the new authoring bundle; if not specified, the API name is derived from the
authoring bundle name (label); the API name can't exist in the org.
--api-version=<value> Override the api version used for api requests made by this command
--force-overwrite Overwrite the existing authoring bundle if one with the same API name already exists
locally.
--no-spec Skip prompting for an agent spec and use the default Agent Script boilerplate in the
generated authoring bundle.
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Generate an authoring bundle from an existing agent spec YAML file.
Authoring bundles are metadata components that contain an agent's Agent Script file. The Agent Script file is the
agent's blueprint; it fully describes what the agent can do using the Agent Script language.
Use this command to generate a new authoring bundle based on an agent spec YAML file, which you create with the "agent
generate agent-spec" command. The agent spec YAML file is a high-level description of the agent; it describes its
essence rather than exactly what it can do. The resulting Agent Script file is customized to reflect what's in the
agent spec file. You can also create an authoring bundle without an agent spec file by specifying the "--no-spec"
flag; in this case, the resulting Agent Script file is just the default boilerplate.
The metadata type for authoring bundles is aiAuthoringBundle, which consist of a standard
"<bundle-api-name>.bundle-meta.xml" metadata file and the Agent Script file (with extension ".agent"). When you run
this command, the new authoring bundle is generated in the force-app/main/default/aiAuthoringBundles/<bundle-api-name>
directory. Use the --output-dir flag to generate them elsewhere.
After you generate the initial authoring bundle, code the Agent Script file so your agent behaves exactly as you want.
The Agent Script file generated by this command is just a first draft of your agent! Interactively test the agent by
conversing with it using the "agent preview" command. Then publish the agent to your org with the "agent publish
authoring-bundle" command.
This command requires an org because it uses it to access an LLM for generating the Agent Script file.
EXAMPLES
Generate an authoring bundle by being prompted for all required values, such as the agent spec YAML file, the bundle
name, and the API name; use your default org:
$ sf agent generate authoring-bundle
Generate an authoring bundle without using an agent spec file; give the bundle the label "My Authoring Bundle" and
use your default org:
$ sf agent generate authoring-bundle --no-spec --name "My Authoring Bundle"
Generate an authoring bundle from the "specs/agentSpec.yaml" agent spec YAML file and give it the label "My
Authoring Bundle"; use your default org:
$ sf agent generate authoring-bundle --spec specs/agentSpec.yaml --name "My Authoring Bundle"
Similar to previous example, but generate the authoring bundle files in the "other-package-dir/main/default" package
directory; use the org with alias "my-dev-org":
$ sf agent generate authoring-bundle --spec specs/agentSpec.yaml --name "My Authoring Bundle" --output-dir \
other-package-dir/main/default --target-org my-dev-orgSee code: @salesforce/plugin-agent
sf agent generate template
Generate an agent template from an existing agent in your DX project so you can then package the template in a second-generation managed package.
USAGE
$ sf agent generate template -s <value> --agent-version <value> -f <value> [--json] [--flags-dir <value>] [--api-version
<value>] [-r <value>]
FLAGS
-f, --agent-file=<value> (required) Path to an agent (Bot) metadata file.
-r, --output-dir=<value> Directory where the generated BotTemplate and GenAiPlannerBundle files are saved.
-s, --source-org=<value> (required) Username or alias of the namespaced scratch org that contains the agent which
this template is based on.
--agent-version=<value> (required) Version of the agent (BotVersion).
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Generate an agent template from an existing agent in your DX project so you can then package the template in a
second-generation managed package.
WARNING: This command doesn't work for agents that were created from an Agent Script file. In other words, you can't
currently package an agent template for agents that use Agent Script.
At a high-level, agents are defined by the Bot, BotVersion, and GenAiPlannerBundle metadata types. The
GenAiPlannerBundle type in turn defines the agent's topics and actions. This command uses the metadata files for these
three types, located in your local DX project, to generate a BotTemplate metadata file for a specific agent (Bot). You
then use the BotTemplate metadata file, along with the GenAiPlannerBundle metadata file that references the
BotTemplate, to package the template in a managed package that you can share between orgs or on AppExchange.
Use the --agent-file flag to specify the relative or full pathname of the Bot metadata file, such as
force-app/main/default/bots/My_Awesome_Agent/My_Awesome_Agent.bot-meta.xml. A single Bot can have multiple
BotVersions, so use the --agent-version flag to specify the version. The corresponding BotVersion metadata file must
exist locally. For example, if you specify "--agent-version 4", then the file
force-app/main/default/bots/My_Awesome_Agent/v4.botVersion-meta.xml must exist.
The new BotTemplate metadata file is generated in the "botTemplates" directory in the output directory specified with
the --output-dir flag, and has the name <Agent_API_name>\_v<Version>\_Template.botTemplate-meta.xml, such as
my-package/botTemplates/My_Awesome_Agent_v4_Template.botTemplate-meta.xml. The command displays the full pathname of
the generated files when it completes.
See "Develop and Package Agent Templates Using Scratch Orgs"
(https://developer.salesforce.com/docs/atlas.en-us.pkg2_dev.meta/pkg2_dev/dev2gp_package_agent_templates.htm) for
details about the complete process, which includes using a scratch org to create and test the agent, retrieving the
agent metadata to your DX project, running this command to create the agent template, and then packaging the template.
EXAMPLES
Generate an agent template from the My_Awesome_Agent Bot metadata file in your DX project and save the BotTemplate
and GenAiPlannerBundle to the specified directory; use version 1 of the agent. The agent that the template is based
on is in the org with alias "my-scratch-org":
$ sf agent generate template --agent-file \
force-app/main/default/bots/My_Awesome_Agent/My_Awesome_Agent.bot-meta.xml --agent-version 1 --output-dir \
my-package --source-org my-scratch-orgSee code: @salesforce/plugin-agent
sf agent generate test-spec
Generate an agent test spec, which is a YAML file that lists the test cases for testing a specific agent.
USAGE
$ sf agent generate test-spec [--flags-dir <value>] [-d <value>] [--force-overwrite] [-f <value>] [--test-runner
agentforce-studio|testing-center]
FLAGS
-d, --from-definition=<value> Filepath to an AiEvaluationDefinition or AiTestingDefinition metadata XML file in your
DX project that you want to convert to a test spec YAML file.
-f, --output-file=<value> Name of the generated test spec YAML file. Default value is
"specs/<AGENT_API_NAME>-testSpec.yaml" (legacy) or
"specs/<AGENT_API_NAME>-ngtTestSpec.yaml" (Agentforce Studio).
--force-overwrite Don't prompt for confirmation when overwriting an existing test spec YAML file.
--test-runner=<option> Explicitly specify which test runner to use (agentforce-studio or testing-center).
<options: agentforce-studio|testing-center>
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
DESCRIPTION
Generate an agent test spec, which is a YAML file that lists the test cases for testing a specific agent.
The first step when using Salesforce CLI to create an agent test in your org is to use this interactive command to
generate a local YAML-formatted test spec file. The test spec YAML file contains information about the agent being
tested, such as its API name, and then one or more test cases. This command uses the metadata components in your DX
project when prompting for information, such as the agent API name; it doesn't look in your org.
To generate a specific agent test case, this command prompts you for this information; when possible, the command
provides a list of options for you to choose from:
- Utterance: Natural language statement, question, or command used to test the agent.
- Expected topic: API name of the topic you expect the agent to use when responding to the utterance.
- Expected actions: One or more API names of the expection actions the agent takes.
- Expected outcome: Natural language description of the outcome you expect.
- (Optional) Custom evaluation: Test an agent's response for specific strings or numbers.
- (Optional) Conversation history: Boilerplate for additional context you can add to the test in the form of a
conversation history.
You can manually add contextVariables to test cases in the generated YAML file to inject contextual data (such as
CaseId or RoutableId) into agent sessions. This is useful for testing agent behavior with different contextual
information.
When your test spec is ready, you then run the "agent test create" command to actually create the test in your org and
synchronize the metadata with your DX project. The metadata type for an agent test is `AiEvaluationDefinition` (legacy
testing-center) or `AiTestingDefinition` (Agentforce Studio / NGT), selected via --test-runner.
If you have an existing AiEvaluationDefinition or AiTestingDefinition metadata XML file in your DX project, you can
generate its equivalent YAML test spec file with the --from-definition flag. The runner is inferred from the file
extension; pass --test-runner to override.
EXAMPLES
Generate an agent test spec YAML file interactively:
$ sf agent generate test-spec
Generate an Agentforce Studio (NGT) test spec YAML file interactively:
$ sf agent generate test-spec --test-runner agentforce-studio
Generate an agent test spec YAML file and specify a name for the new file; if the file exists, overwrite it without
confirmation:
$ sf agent generate test-spec --output-file specs/Resort_Manager-new-version-testSpec.yaml --force-overwrite
Generate an agent test spec YAML file from an existing AiEvaluationDefinition metadata XML file in your DX project:
$ sf agent generate test-spec --from-definition \
force-app/main/default/aiEvaluationDefinitions/Resort_Manager_Tests.aiEvaluationDefinition-meta.xml
Generate an Agentforce Studio (NGT) test spec YAML file from an existing AiTestingDefinition metadata XML file:
$ sf agent generate test-spec --from-definition \
force-app/main/default/aiTestingDefinitions/Returns_Checkout_Tests.aiTestingDefinition-meta.xml
FLAG DESCRIPTIONS
--test-runner=agentforce-studio|testing-center
Explicitly specify which test runner to use (agentforce-studio or testing-center).
By default, the command automatically detects which test runner to use based on the test definition metadata type in
your org. Use this flag to explicitly specify the runner type. 'agentforce-studio' uses AiTestingDefinition
metadata. 'testing-center' uses AiEvaluationDefinition metadata.See code: @salesforce/plugin-agent
sf agent mcp asset list
List the assets (tools, prompts, and resources) for an MCP server in the catalog.
USAGE
$ sf agent mcp asset list -o <value> -i <value> [--json] [--flags-dir <value>] [--api-version <value>]
FLAGS
-i, --mcp-server-id=<value> (required) The ID of the MCP server whose assets you want to list.
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
List the assets (tools, prompts, and resources) for an MCP server in the catalog.
Returns the assets discovered for the specified MCP server, including each asset's kind (MCP_TOOL, MCP_PROMPT, or
MCP_RESOURCE), whether it is active, and whether it is available as an agent action.
EXAMPLES
List the assets for an MCP server in the default target org:
$ sf agent mcp asset list --target-org myOrg --mcp-server-id 0XSxx0000000001
List the assets for an MCP server and output as JSON:
$ sf agent mcp asset list --target-org myOrg --mcp-server-id 0XSxx0000000001 --jsonSee code: @salesforce/plugin-agent
sf agent mcp asset replace
Replace the asset set of an MCP server in the API Catalog.
USAGE
$ sf agent mcp asset replace -o <value> -i <value> [--json] [--flags-dir <value>] [--api-version <value>] [--assets <value>
| --assets-file <value>]
FLAGS
-i, --mcp-server-id=<value> (required) ID of the MCP server whose assets you want to replace.
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
--assets=<value> The desired asset allowlist as a JSON string (or "-" to read from stdin). Mutually
exclusive with --assets-file.
--assets-file=<value> Path to a JSON file containing the desired asset allowlist. Mutually exclusive with
--assets.
GLOBAL FLAGS
--flags-dir=<value> Import flag values from a directory.
--json Format output as json.
DESCRIPTION
Replace the asset set of an MCP server in the API Catalog.
Replaces the full set of assets (tools, prompts, resources) for an MCP server with the asset items you supply. Provide
the assets either inline with `--assets` (a JSON string, or `-` to read from stdin) or from a file with
`--assets-file`. The JSON must be either an array of asset items or an object of the form `{ "assets": [...] }`. Each
asset item may include `id`, `name`, `label`, `description`, `active`, and `kind`. This is a full replacement:
existing assets not present in the supplied set are removed, so provide the complete desired asset set (read the
current set first with `agent mcp asset list` or `agent mcp fetch`).
EXAMPLES
Replace the assets inline with a JSON string:
$ sf agent mcp asset replace --mcp-server-id 0XSxx0000000001 --assets \
'{"assets":[{"name":"McpTool__add","active":true}]}' --target-org myOrg
Replace the assets from a JSON file:
$ sf agent mcp asset replace --mcp-server-id 0XSxx0000000001 --assets-file ./assets.json --target-org myOrg
Pipe the assets from stdin:
cat assets.json | sf agent mcp asset replace --mcp-server-id 0XSxx0000000001 --assets - --target-org myOrgSee code: @salesforce/plugin-agent
sf agent mcp create
Create an MCP server in the API Catalog.
USAGE
$ sf agent mcp create -o <value> -n <value> --server-url <value> [--json] [--flags-dir <value>] [--api-version
<value>] [--label <value>] [--description <value>] [--auth-type OAUTH|NO_AUTH] [--identity-provider <value>]
[--client-id <value>] [--client-secret <value>] [--scope <value>]
FLAGS
-n, --name=<value> (required) Unique name of the MCP server.
-o, --target-org=<value> (required) Username or alias of the target org. Not required if the `target-org`
configuration variable is already set.
--api-version=<value> Override the api version used for api requests made by this command
--auth-type