### Start Agent Preview with Authoring Bundle and Live Actions Source: https://github.com/salesforcecli/cli/blob/main/README.md Initiate a preview session for an agent using an authoring bundle and executing real actions in the org. This example uses the default org. ```bash $ sf agent preview start --authoring-bundle My_Agent_Bundle --use-live-actions ``` -------------------------------- ### Install Package with Installation Key Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs a key-protected package using the provided installation key. ```bash $ sf package install --package 04t... --target-org me@example.com --installation-key YOUR_KEY ``` -------------------------------- ### Start Agent Preview with Authoring Bundle and Simulated Actions Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to start a preview session for an agent defined by an authoring bundle, simulating action execution. Specify the target org using its alias. ```bash $ sf agent preview start --authoring-bundle My_Agent_Bundle --target-org my-dev-org --simulate-actions ``` -------------------------------- ### Install Package with Apex Compilation Options Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs a package and specifies Apex compilation behavior. Use 'package' to compile only Apex in the package, or 'all' to compile all Apex in the org and package. ```bash $ sf package install --package 04t... --target-org me@example.com --apex-compile package ``` ```bash $ sf package install --package 04t... --target-org me@example.com --apex-compile all ``` -------------------------------- ### Create Package Version with Post-Install Script and URL Source: https://github.com/salesforcecli/cli/blob/main/README.md This example shows how to create a package version that includes a post-install script and a URL for post-install instructions. This is applicable to managed packages. ```bash sf package version create -p -v --post-install-script "MyScript" --post-install-url "http://example.com/instructions" ``` -------------------------------- ### Display Autocomplete Installation Instructions Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to display instructions for installing shell autocompletion. You can specify the shell type (zsh, bash, powershell) or refresh the cache. ```bash sf autocomplete ``` ```bash sf autocomplete bash ``` ```bash sf autocomplete zsh ``` ```bash sf autocomplete powershell ``` ```bash sf autocomplete --refresh-cache ``` -------------------------------- ### List Installed Plugins Source: https://github.com/salesforcecli/cli/blob/main/README.md Lists all installed Salesforce CLI plugins. Use the --core flag to include core plugins. ```bash sf plugins ``` -------------------------------- ### Install Package with Wait Time Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs a package and specifies the number of minutes to wait for the installation status. ```bash $ sf package install --package 04t... --target-org me@example.com --wait 20 ``` -------------------------------- ### Create Package Version with Async Validation Source: https://github.com/salesforcecli/cli/blob/main/README.md Create a package version from a directory, providing an installation key and performing package validations asynchronously. ```bash $ sf package version create --path common --installation-key password123 --async-validation ``` -------------------------------- ### Install Salesforce CLI Plugin from npm Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs a plugin into sf using npm. Supports installation from the npm registry, a GitHub URL, or a GitHub slug. Note that user-installed plugins can override core plugins. ```bash sf plugins install @salesforce/plugin-packaging ``` ```bash sf plugins install https://github.com/someuser/someplugin ``` ```bash sf plugins install someuser/someplugin ``` -------------------------------- ### Install Salesforce CLI Source: https://github.com/salesforcecli/cli/blob/main/README.md Install the Salesforce CLI globally using npm. This command is required before you can use the `sf` command. ```sh $ npm install -g @salesforce/cli ``` -------------------------------- ### Install Package with JSON Output Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs a package and formats the output as JSON. This is useful for programmatic consumption of command results. ```bash $ sf package install --package 04t... --target-org me@example.com --json ``` -------------------------------- ### List All Endpoints and Stream to File Source: https://github.com/salesforcecli/cli/blob/main/README.md This example demonstrates how to list all available endpoints in your default org and save the output to a file. It also includes the HTTP response status and headers in the output. ```bash $ sf api request rest '/services/data/v56.0/' --stream-to-file output.txt --include ``` -------------------------------- ### Install Package Version by Alias Source: https://github.com/salesforcecli/cli/blob/main/README.md Install or upgrade a package version using its alias into your default org. ```bash $ sf package install --package awesome_package_alias ``` -------------------------------- ### Salesforce CLI Version Output Example Source: https://github.com/salesforcecli/cli/blob/main/README.md Example output when checking the Salesforce CLI version. This shows the CLI version, operating system, and Node.js version. ```sh @salesforce/cli/2.141.0 linux-x64 node-v22.22.3 ``` -------------------------------- ### Create Package Version from Directory Source: https://github.com/salesforcecli/cli/blob/main/README.md Create a package version from the contents of a directory. Requires an installation key and uses the default Dev Hub org. ```bash $ sf package version create --path common --installation-key password123 ``` -------------------------------- ### Install Package with Publish Wait Time Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs a package and sets a maximum wait time in minutes for the Subscriber Package Version ID to become available. ```bash $ sf package install --package 04t... --target-org me@example.com --publish-wait 10 ``` -------------------------------- ### Start Agent Preview with Published Agent API Name Source: https://github.com/salesforcecli/cli/blob/main/README.md Start a preview session for an already activated and published agent using its API name. This method always uses live actions. ```bash $ sf agent preview start --api-name My_Published_Agent ``` -------------------------------- ### Install Package with Flags Directory Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs a package, importing flag values from a specified directory. This helps manage complex configurations. ```bash $ sf package install --package 04t... --target-org me@example.com --flags-dir ./flags ``` -------------------------------- ### Create Package Version with Options Source: https://github.com/salesforcecli/cli/blob/main/README.md This example demonstrates creating a package version with additional options such as a specific version number, description, and enabling code coverage calculation. The `--code-coverage` flag is required to promote a package version to released. ```bash sf package version create -p 0Ho... -v devhubusername -n 1.0.0 -e "My package version description" -c --tag "beta" ``` -------------------------------- ### Install Package with Security Type Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs a package and sets the security access type. 'AllUsers' grants access to all users, while 'AdminsOnly' restricts it to administrators. ```bash $ sf package install --package 04t... --target-org me@example.com --security-type AllUsers ``` ```bash $ sf package install --package 04t... --target-org me@example.com --security-type AdminsOnly ``` -------------------------------- ### Convert Package with Installation Key Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to convert a first-generation managed package to second-generation, providing an installation key for protection. It utilizes your default Dev Hub org. ```bash sf package convert --package 033... --installation-key password123 ``` -------------------------------- ### Preview Agent with Default Org Source: https://github.com/salesforcecli/cli/blob/main/README.md Preview an agent by selecting from available local or published agents. This example uses the default org and simulated mode for local agents. ```bash sf agent preview --target-org my-dev-org ``` -------------------------------- ### Create Account Record from File Body Source: https://github.com/salesforcecli/cli/blob/main/README.md This example demonstrates creating an account record by providing the request body from a JSON file. Prefix the filename with '@' when using the `--body` flag. ```bash $ sf api request rest '/services/data/v56.0/sobjects/account' --body @info.json --method POST ``` -------------------------------- ### Create Account Record with Inline Body Source: https://github.com/salesforcecli/cli/blob/main/README.md This example shows how to create an account record using the POST method. The request details, including the JSON body, are specified directly on the command line using the `--body` flag. ```bash $ sf api request rest /services/data/v56.0/sobjects/account --body "{\"Name\" : \"Account from REST \n API\",\"ShippingCity\" : \"Boise\"}" --method POST ``` -------------------------------- ### Install Package Version by ID Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to install or upgrade a package version using its 04t ID in a specified target org. ```bash $ sf package install --package 04t... --target-org me@example.com ``` -------------------------------- ### Create Package Version from Package ID Source: https://github.com/salesforcecli/cli/blob/main/README.md Create a package version using a specific package ID and an installation key. ```bash $ sf package version create --package 0Ho... --installation-key password123 ``` -------------------------------- ### Create Package Version Skipping Validation Source: https://github.com/salesforcecli/cli/blob/main/README.md Create a package version from a directory, providing an installation key and skipping the validation step. ```bash $ sf package version create --path common --installation-key password123 --skip-validation ``` -------------------------------- ### Generate Agent Template Example Source: https://github.com/salesforcecli/cli/blob/main/README.md Generates an agent template from a specified Bot metadata file and agent version. The generated BotTemplate and GenAiPlannerBundle files are saved to the output directory. This command requires the source org alias, agent file path, agent version, and an output directory. ```bash 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-org ``` -------------------------------- ### Discover Salesforce CLI Plugins Source: https://github.com/salesforcecli/cli/blob/main/README.md Lists available third-party sf plugins that can be installed. Use this command to find plugins that extend the CLI's functionality. ```bash sf plugins discover ``` -------------------------------- ### Create Agent with Flags Source: https://github.com/salesforcecli/cli/blob/main/README.md Create an agent by specifying all required details such as name, API name, and spec file path using flags. This example also specifies a target org alias. The command will fail if the provided API name already exists in the org. ```bash sf agent create --name "Resort Manager" --api-name Resort_Manager --spec specs/resortManagerAgent.yaml \ --target-org my-org ``` -------------------------------- ### Example of Repeating Suite Names Flag Source: https://github.com/salesforcecli/cli/blob/main/README.md Illustrates how to specify multiple Apex test suite names by repeating the `--suite-names` flag. ```bash --suite-names Suite1 --suite-names Suite2 ``` -------------------------------- ### Example: Bulk Update Account Records Source: https://github.com/salesforcecli/cli/blob/main/README.md Demonstrates how to update Account records from a CSV file (`accounts.csv`) to an org aliased as `my-scratch`. The command will wait up to 10 minutes for completion and display a job ID if it times out. ```bash sf data update bulk --file accounts.csv --sobject Account --wait 10 --target-org my-scratch ``` -------------------------------- ### Use JSON File for Request Configuration Source: https://github.com/salesforcecli/cli/blob/main/README.md This example shows how to configure an entire REST API request, including headers, body, and method, by storing the details in a JSON file and referencing it with the `--file` flag. ```bash $ sf api request rest --file myFile.json ``` -------------------------------- ### Display Help for sf Command Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to get detailed help information for any Salesforce CLI command. It shows usage, arguments, flags, and descriptions. ```bash sf help [COMMAND...] ``` -------------------------------- ### View Available sf CLI Versions Source: https://github.com/salesforcecli/cli/blob/main/README.md Use the `--available` flag to list all versions of the Salesforce CLI that can be installed. This helps in deciding which version to update to. ```bash sf update --available ``` -------------------------------- ### Create a Scratch Org from an Org Shape Source: https://github.com/salesforcecli/cli/blob/main/README.md Use the `--source-org` flag with the 15-character ID of an org shape to create a new scratch org. This mimics the baseline setup of a source org. The `--edition` flag is mutually exclusive with `--source-org`. ```bash sf org create scratch --target-dev-hub MyDevHub --source-org 001xxxxxxxxxxxx ``` -------------------------------- ### Example of Repeating Class Names Flag Source: https://github.com/salesforcecli/cli/blob/main/README.md Demonstrates how to specify multiple Apex test class names by repeating the `--class-names` flag. ```bash --class-names Class1 --class-names Class2 ``` -------------------------------- ### Create Package Version with Installation Key Bypass Source: https://github.com/salesforcecli/cli/blob/main/README.md This command creates a package version and bypasses the installation key requirement. Use this when the installation key is not necessary or has been handled separately. ```bash sf package version create -p -v -x ``` -------------------------------- ### sf package installed list Source: https://github.com/salesforcecli/cli/blob/main/README.md Lists all installed packages within a Salesforce organization. ```APIDOC ## `sf package installed list` ### Description List the org’s installed packages. ### Method Not specified (CLI command) ### Endpoint Not specified (CLI command) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Flags - **-o, --target-org** (string) - Required - Username or alias of the target org. Not required if the `target-org` configuration variable is already set. - **--api-version** (string) - Optional - Override the api version used for api requests made by this command ### Global Flags - **--flags-dir** (string) - Optional - Import flag values from a directory. - **--json** - Optional - Format output as json. ### Request Example ```bash sf package installed list --target-org me@example.com ``` ### Response #### Success Response List of installed packages (specific fields not detailed in source). #### Response Example (Example not provided in source) ``` -------------------------------- ### Preview Deployment using a Manifest File Source: https://github.com/salesforcecli/cli/blob/main/README.md Preview the deployment of all components listed in a manifest (package.xml) file. This method is useful for deploying predefined sets of components. ```bash $ sf project deploy preview --manifest path/to/package.xml ``` -------------------------------- ### Publish Authoring Bundle (Interactive) Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command when you want to be prompted for the authoring bundle's API name and use your default org. No prior setup is required. ```bash $ sf agent publish authoring-bundle ``` -------------------------------- ### sf package install report Source: https://github.com/salesforcecli/cli/blob/main/README.md Retrieves the status of a package installation request using its ID. ```APIDOC ## `sf package install report` ### Description Retrieve the status of a package installation request. ### Method Not specified (CLI command) ### Endpoint Not specified (CLI command) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Flags - **-i, --request-id** (string) - Required - ID of the package install request you want to check; starts with 0Hf. - **-o, --target-org** (string) - Required - Username or alias of the target org. Not required if the `target-org` configuration variable is already set. - **--api-version** (string) - Optional - Override the api version used for api requests made by this command ### Global Flags - **--flags-dir** (string) - Optional - Import flag values from a directory. - **--json** - Optional - Format output as json. ### Request Example ```bash sf package install report --request-id 0Hf... --target-org me@example.com ``` ### Response #### Success Response Details about the package installation status (specific fields not detailed in source). #### Response Example (Example not provided in source) ``` -------------------------------- ### Deploy Components from Manifest Source: https://github.com/salesforcecli/cli/blob/main/README.md Deploys all components listed in a specified manifest file (package.xml). ```bash sf project deploy start --manifest path/to/package.xml ``` -------------------------------- ### Install Package with API Version Override Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs a package, overriding the default API version used for the request. ```bash $ sf package install --package 04t... --target-org me@example.com --api-version 58.0 ``` -------------------------------- ### Deploy Source Directory with Concise Output Source: https://github.com/salesforcecli/cli/blob/main/README.md Deploys all source files in the 'force-app' directory to an org with alias 'my-scratch', showing only concise output. ```bash sf project deploy start --source-dir force-app --target-org my-scratch --concise ``` -------------------------------- ### Create a Scratch Org with Edition Source: https://github.com/salesforcecli/cli/blob/main/README.md Use the `--edition` flag to specify the Salesforce edition for the scratch org. This method does not require a definition file. ```bash sf org create scratch --target-dev-hub MyDevHub --edition developer ``` -------------------------------- ### Install Package Without Prompt Source: https://github.com/salesforcecli/cli/blob/main/README.md Installs or upgrades a package version without prompting for confirmation. This is useful for automation scripts. ```bash $ sf package install --package 04t... --target-org me@example.com --no-prompt ``` -------------------------------- ### Create a Scratch Org Asynchronously Source: https://github.com/salesforcecli/cli/blob/main/README.md Use the `--async` flag to initiate the scratch org creation process without waiting for it to complete. The command will return immediately after the request is made. ```bash sf org create scratch --target-dev-hub MyDevHub --edition developer --async ``` -------------------------------- ### Create Scratch Org with Definition File Source: https://github.com/salesforcecli/cli/blob/main/README.md Creates a scratch org using a definition file, specifying the Dev Hub by alias, setting the new org as default, and setting an expiration of 3 days. Use definition files for more complex org configurations. ```bash $ sf org create scratch --target-dev-hub MyHub --definition-file config/project-scratch-def.json --set-default \ --duration-days 3 ``` -------------------------------- ### Preview Deployment of Source Files Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to preview the deployment of source files from a specific directory to your default org. Ensure you are running this command from within a project. ```bash $ sf project deploy preview --source-dir force-app ``` -------------------------------- ### Display Salesforce CLI Version Source: https://github.com/salesforcecli/cli/blob/main/README.md Check the installed version of the Salesforce CLI. This command is useful for verifying the installation and current version. ```sh $ sf (--version|-v) ``` -------------------------------- ### Create a Scratch Org with a Definition File Source: https://github.com/salesforcecli/cli/blob/main/README.md Specify a definition file using the `--definition-file` flag to configure scratch org options. Flags like `--description`, `--name`, and `--username` can override options within the definition file. ```bash sf org create scratch --target-dev-hub MyDevHub --definition-file config/scratch-config.json ``` -------------------------------- ### Create a Scratch Org using Alias Source: https://github.com/salesforcecli/cli/blob/main/README.md Use the alias `sf env create scratch` as a shortcut for `sf org create scratch`. ```bash sf env create scratch --target-dev-hub MyDevHub --edition developer ``` -------------------------------- ### Install Package Version with Alias Containing Spaces Source: https://github.com/salesforcecli/cli/blob/main/README.md Install or upgrade a package version using an alias that includes spaces. Ensure the alias is enclosed in quotes. ```bash $ sf package install --package "Awesome Package Alias" ``` -------------------------------- ### Generate project using the 'empty' template Source: https://github.com/salesforcecli/cli/blob/main/README.md Generates a project with the minimum required files and directories using the 'empty' template. ```bash $ sf template generate project --name mywork --template empty ``` -------------------------------- ### Create Package Version with Path Source: https://github.com/salesforcecli/cli/blob/main/README.md Create a package version using the contents of a specified directory. This flag points to the directory containing the package's metadata. ```bash sf package version create -p -v -d path/to/package/contents ``` -------------------------------- ### Update Package Version with Alias and Installation Key Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this snippet to update a package version using its alias and provide a new installation key. It defaults to using your configured Dev Hub. ```bash $ sf package version update --package "Your Package Alias" --installation-key password123 ``` -------------------------------- ### Get Agent Test Results by Job ID Source: https://github.com/salesforcecli/cli/blob/main/README.md Retrieve results for a completed agent test run using its specific job ID. This is the most direct way to get results when the job ID is known. ```bash $ sf agent test results --job-id 4KBfake0000003F4AQ ``` -------------------------------- ### Deploy Metadata Files from Directory Source: https://github.com/salesforcecli/cli/blob/main/README.md Deploys all metadata-formatted files located within the 'MDAPI' directory. ```bash sf project deploy start --metadata-dir MDAPI ``` -------------------------------- ### Generate project with manifest file Source: https://github.com/salesforcecli/cli/blob/main/README.md Creates a project that includes a default package.xml manifest file, essential for change-set based development. ```bash $ sf template generate project --name mywork --default-package-dir myapp --manifest ``` -------------------------------- ### Create Sandbox with Definition File Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this snippet to create a sandbox org using a JSON definition file. It allows for detailed configuration of the sandbox. The production org containing the license must be specified. ```bash sf org create sandbox --definition-file config/dev-sandbox-def.json --alias MyDevSandbox --target-org prodOrg ``` -------------------------------- ### Convert Package with Specific Dev Hub and Installation Key Source: https://github.com/salesforcecli/cli/blob/main/README.md Convert a first-generation managed package to second-generation, specifying both the target Dev Hub org and an installation key. This is useful when you have multiple Dev Hubs or need to explicitly set the target. ```bash sf package convert --package 033... --installation-key password123 --target-dev-hub devhuborg@example.com ``` -------------------------------- ### Create a Package Version Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to create a package version in your Dev Hub org. Specify the package ID or alias and the target Dev Hub. Consider using `--installation-key` to protect your package. ```bash sf package version create -p -v ``` -------------------------------- ### Schedule Package Push Upgrade with Specific Start Time Source: https://github.com/salesforcecli/cli/blob/main/README.md Schedule a package push upgrade to initiate at a specified UTC time. Requires the package ID, start time, a file containing subscriber org IDs, and the target Dev Hub org. ```bash $ sf package push-upgrade schedule --package 04txyz --start-time "2024-12-06T21:00:00" --org-file \ upgrade-orgs.csv --target-dev-hub myHub ``` -------------------------------- ### sf apex get log Source: https://github.com/salesforcecli/cli/blob/main/README.md Fetch the specified log or given number of most recent logs from the org. To get the IDs for your debug logs, run "sf apex log list". Executing this command without flags returns the most recent log. ```APIDOC ## `sf apex get log` ### Description Fetch the specified log or given number of most recent logs from the org. ### Method SF CLI Command ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters - **-o, --target-org** (string) - Required - Username or alias of the target org. Not required if the `target-org` configuration variable is already set. - **-i, --log-id** (string) - Optional - ID of the specific log to display. - **-n, --number** (string) - Optional - Number of the most recent logs to display. - **-d, --output-dir** (string) - Optional - Directory for saving the log files. The location can be an absolute path or relative to the current working directory. The default is the current directory. - **--api-version** (string) - Optional - Override the api version used for api requests made by this command #### Request Body None ### Request Example ```bash sf apex get log --log-id sf apex get log --log-id --target-org me@my.org sf apex get log --number 2 sf apex get log --output-dir /Users/sfdxUser/logs --number 2 ``` ### Response #### Success Response (200) Log file content or information about the fetched logs. #### Response Example None provided in source. ``` -------------------------------- ### Create a Scratch Org with JSON Output Source: https://github.com/salesforcecli/cli/blob/main/README.md Format the command output as JSON by including the `--json` flag. ```bash sf org create scratch --target-dev-hub MyDevHub --edition developer --json ``` -------------------------------- ### Preview retrieval from default org Source: https://github.com/salesforcecli/cli/blob/main/README.md Run this command from within a project to preview the retrieval of all changes from your default org. ```bash sf project retrieve preview ``` -------------------------------- ### Get a single configuration variable Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to retrieve the value of a specific configuration variable, such as 'target-org'. ```bash $ sf config get target-org ``` -------------------------------- ### Create a Scratch Org with a Specific Release Source: https://github.com/salesforcecli/cli/blob/main/README.md Specify the release version for the scratch org using the `--release` flag. Options include `preview` or `previous` relative to the Dev Hub release. ```bash sf org create scratch --target-dev-hub MyDevHub --edition developer --release preview ``` -------------------------------- ### Example of Repeating Tests Flag Source: https://github.com/salesforcecli/cli/blob/main/README.md Shows how to specify multiple Apex tests (classes or methods) by repeating the `--tests` flag. ```bash --tests Test1 --tests Test2 ``` -------------------------------- ### Create Managed Package with Description and Specific Dev Hub Source: https://github.com/salesforcecli/cli/blob/main/README.md This command creates a managed package from the files in the 'force-app' directory, includes a description, and specifies a particular Dev Hub org for the operation. ```bash sf package create --name MyManagedPackage --description "Your Package Descripton" --package-type Managed \ --path force-app --target-dev-hub devhub@example.com ``` -------------------------------- ### Uninstall Salesforce CLI Plugin Source: https://github.com/salesforcecli/cli/blob/main/README.md Removes a specified plugin from your Salesforce CLI installation. You can also use aliases like 'unlink' or 'remove'. ```bash sf plugins uninstall @salesforce/plugin-packaging ``` -------------------------------- ### Inspect Salesforce CLI Plugin Properties Source: https://github.com/salesforcecli/cli/blob/main/README.md Displays installation properties of a specified plugin. This is useful for understanding a plugin's configuration and status. ```bash sf plugins inspect @salesforce/plugin-packaging ``` -------------------------------- ### Create Package Version with Release Notes URL Source: https://github.com/salesforcecli/cli/blob/main/README.md Create a package version and provide a URL for release notes. This helps users access important information about the new version. ```bash sf package version create -p -v --releasenotes-url "http://example.com/releasenotes" ``` -------------------------------- ### Preview Deployment of Apex Classes Source: https://github.com/salesforcecli/cli/blob/main/README.md Preview the deployment of all Apex classes to a specified org alias. This command helps in verifying the deployment of metadata types. ```bash $ sf project deploy preview --metadata ApexClass --target-org my-scratch ``` -------------------------------- ### Run an Agent Test with JSON Output to Directory Source: https://github.com/salesforcecli/cli/blob/main/README.md Start an agent test, wait for completion, and save the JSON-formatted results to a specified directory. ```bash $ sf agent test run --api-name Resort_Manager_Test --wait 10 --output-dir ./test-results --result-format json ``` -------------------------------- ### Create a Scratch Org and Set as Default Source: https://github.com/salesforcecli/cli/blob/main/README.md Use the `--set-default` flag to designate the newly created scratch org as the default org for subsequent CLI commands. ```bash sf org create scratch --target-dev-hub MyDevHub --edition developer --set-default ``` -------------------------------- ### Run an Agent Test (No Wait) Source: https://github.com/salesforcecli/cli/blob/main/README.md Start an agent test and do not wait for completion. Use the `agent test resume` command later to check results. ```bash $ sf agent test run --api-name Resort_Manager_Test ``` -------------------------------- ### Query SourceMember for Revision Number Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to query the SourceMember Tooling API object to get the revision number for resetting source tracking. ```bash sf data query --query "SELECT MemberName, MemberType, RevisionCounter FROM SourceMember" --use-tooling-api --target-org my-scratch ``` -------------------------------- ### Read Session Trace Summary Source: https://github.com/salesforcecli/cli/blob/main/README.md Displays a summary of the trace for all turns in a specified agent preview session. Use this to get a high-level overview of the conversation. ```bash sf agent trace read --session-id ``` -------------------------------- ### Log in with Specific Browser and Set as Default Source: https://github.com/salesforcecli/cli/blob/main/README.md Log in to a sandbox org, set it as the default, and specify Google Chrome as the browser for the authentication flow. Adjust the `--instance-url` as needed. ```bash sf org login web --instance-url https://MyDomainName--SandboxName.sandbox.my.salesforce.com --set-default \ --browser chrome ``` -------------------------------- ### Update Salesforce CLI Plugins Source: https://github.com/salesforcecli/cli/blob/main/README.md Updates all installed Salesforce CLI plugins to their latest available versions. Use the --verbose flag for more detailed output. ```bash sf plugins update ``` -------------------------------- ### Create a Scratch Org with a Custom Client ID Source: https://github.com/salesforcecli/cli/blob/main/README.md Specify the consumer key of the Dev Hub connected app using the `--client-id` flag. ```bash sf org create scratch --target-dev-hub MyDevHub --edition developer --client-id MyConnectedAppClientId ``` -------------------------------- ### Run an Agent Test with Wait and Target Org Source: https://github.com/salesforcecli/cli/blob/main/README.md Start an agent test, specify the target org alias, and wait for a specified duration for the test to finish. ```bash $ sf agent test run --api-name Resort_Manager_Test --wait 10 --target-org my-org ``` -------------------------------- ### Get Package Version Creation Status Source: https://github.com/salesforcecli/cli/blob/main/README.md Retrieve the status of a package version creation request. Use this command to check the progress of a package version being built. ```bash sf package1 version create get --request-id 0HD... ``` ```bash sf package1 version create get --request-id 0HD... --target-org myorg@example.com ``` -------------------------------- ### Deploy Apex Classes from Package Directories Source: https://github.com/salesforcecli/cli/blob/main/README.md Deploys all Apex classes found in all package directories defined in the 'sfdx-project.json' file. ```bash sf project deploy start --metadata ApexClass ``` -------------------------------- ### Install Package with Mixed Upgrade Type Source: https://github.com/salesforcecli/cli/blob/main/README.md Upgrades an unlocked package, deleting safely removable components and deprecating others. This is the default behavior if --upgrade-type is not specified. ```bash $ sf package install --package 04t... --upgrade-type Mixed ``` -------------------------------- ### Create Package Version with Definition File Source: https://github.com/salesforcecli/cli/blob/main/README.md Create a package version using a definition file that specifies features and org preferences. This is useful for complex package configurations. ```bash sf package version create -p -v -f path/to/definitionfile.json ``` -------------------------------- ### Generate Static Resource with JSON Type Source: https://github.com/salesforcecli/cli/blob/main/README.md Generates a static resource metadata file with a specified MIME type. Use the `--type` flag for this, for example, `application/json`. ```bash sf template generate static-resource --name MyResource --type application/json ``` -------------------------------- ### Deploy All Custom Objects in Namespace with Wildcard Source: https://github.com/salesforcecli/cli/blob/main/README.md Deploys all custom objects within the 'SBQQ' namespace using a wildcard. Quotes are used to ensure the wildcard is interpreted correctly. ```bash sf project deploy start --metadata 'CustomObject:SBQQ__*' ``` -------------------------------- ### Interactive Anonymous Apex Execution Source: https://github.com/salesforcecli/cli/blob/main/README.md Starts an interactive mode for executing anonymous Apex code directly on the command line. Press CTRL+D when finished typing your code. ```bash $ sf apex run ``` -------------------------------- ### Get Test Run Results (JUnit Format) Source: https://github.com/salesforcecli/cli/blob/main/README.md Retrieves test run results, formats them as JUnit, and saves them to a specified directory using a specific org alias. ```bash $ sf logic get test --test-run-id --result-format junit --target-org my-scratch ``` -------------------------------- ### Publish Authoring Bundle with Concise Output Source: https://github.com/salesforcecli/cli/blob/main/README.md Use the --concise flag to display minimal output, showing only essential information about the publish operation. This is useful for scripting or when only a summary is needed. ```bash $ sf agent publish authoring-bundle --api-name MyAuthoringbundle --concise ``` -------------------------------- ### Get Test Run Results (Human-Readable) Source: https://github.com/salesforcecli/cli/blob/main/README.md Retrieves test run results in the default human-readable format for a specified test run ID, using the default org. ```bash $ sf logic get test --test-run-id ``` -------------------------------- ### Get multiple configuration variables with verbose output Source: https://github.com/salesforcecli/cli/blob/main/README.md Retrieve multiple configuration variables and display whether they are set locally or globally by using the --verbose flag. ```bash $ sf config get target-org api-version --verbose ``` -------------------------------- ### Preview Deployment of a Specific Apex Class Source: https://github.com/salesforcecli/cli/blob/main/README.md Preview the deployment of a single, specific Apex class. This is useful for targeted verification of individual components. ```bash $ sf project deploy preview --metadata ApexClass:MyApexClass ``` -------------------------------- ### Get Most Recent Results in JSON to a Directory Source: https://github.com/salesforcecli/cli/blob/main/README.md Retrieve the most recent agent test results, format them as JSON, and save them to a specified directory. This is ideal for automated processing or archiving. ```bash $ sf agent test results --use-most-recent --output-dir ./test-results --result-format json ``` -------------------------------- ### Get Most Recent Agent Test Results Source: https://github.com/salesforcecli/cli/blob/main/README.md Fetch results for the most recently executed agent test. This is useful when you don't have the specific job ID but want the latest results. ```bash $ sf agent test results --use-most-recent --target-org my-org ``` -------------------------------- ### List All Package Version Creation Requests Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to list all package version creation requests in your default Dev Hub org. No additional flags are required if a Dev Hub is already configured. ```bash sf package version create list ``` -------------------------------- ### Get Agentforce Data Library Details Source: https://github.com/salesforcecli/cli/blob/main/README.md Retrieve detailed information about a specific Agentforce Data Library. Requires the library ID and target org username or alias. ```bash $ sf agent adl get --library-id 1JDSG000007IbWX4A0 --target-org myOrg ``` -------------------------------- ### Display Salesforce CLI Help Source: https://github.com/salesforcecli/cli/blob/main/README.md Get help for a specific Salesforce CLI command. Use `sf --help [COMMAND]` to view usage details for any command. ```sh $ sf --help [COMMAND] ``` -------------------------------- ### List Configuration Variables Source: https://github.com/salesforcecli/cli/blob/main/README.md Use this command to view all configuration variables that have been set. It shows local, global, and environment variable overrides based on your current project context. ```bash sf config list ``` -------------------------------- ### Update sf CLI to Specific Version Source: https://github.com/salesforcecli/cli/blob/main/README.md Install a precise version of the Salesforce CLI using the `--version` flag. This is useful for maintaining compatibility with specific project requirements. ```bash sf update --version 1.0.0 ```