Switches the active Salesforce CLI target org using sf config set, with verification steps.
- What it does
- This skill guides an agent through changing which Salesforce org the Salesforce CLI runs commands against. It identifies an org by username or alias, sets the default target-org locally or globally via sf config set, and verifies the value with sf config get target-org --json. It also covers failure handling, such as suggesting sf org login web when an org may not be authorized, and notes that environment variables like SF_TARGET_ORG override config values.
- When to use it
- Use it when someone wants to change the org that Salesforce CLI commands target, such as switching to a scratch org, sandbox, or production org. It fits requests phrased as switching org, changing the default org, setting an alias, or pointing to a specific org.
- Requirements
- Requires the Salesforce CLI (sf) version 2.0.0 or later and an authenticated org; no scripts are included, only instructions. Network access and prior org authorization (for example via sf org login web) are needed for the CLI commands to work.