About switching-org
A skill for setting and verifying the Salesforce CLI default org. It guides project-local configuration by default and reserves global changes for explicit requests.
Key features
- 01Choose an org by username or alias
- 02List authenticated orgs when unspecified
- 03Set project-local target org
- 04Set global target org on request
- 05Verify the configured org
Use cases
- 01Set the org for work in the current project
- 02Select an authenticated org when no alias is known
- 03Configure an org globally when explicitly requested
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ forcedotcom/ sf-skills --skill switching-orgAfter installing, type/switching-orgin Claude Code to confirm it loaded.
Details
From the project READMESteps
- Identify the org: the user provides a username or alias (
orgIdentifier). If not provided, runsf org listto show authenticated orgs and ask the user which one to use. - Set the default org:
- Local (default):
sf config set target-org <orgIdentifier>- Applies only within the current project directory. Use this for normal project work.
- Global (only if user explicitly requests):
sf config set target-org <orgIdentifier> --global- Applies system-wide across all directories. Use when working outside a project or when the user asks for global scope.
- If this fails, report the error and suggest running
sf org login webif the org may not be authorized.
- Local (default):
- Verify:
sf config get target-org --json- Note: the JSON output does not include a scope/location field — it cannot confirm whether the value is local or global. Confirm the value only, e.g.:
target-org is now set to: <value> - If it fails, report the error and advise running
sf config get target-org.
Notes
- Unified CLI uses keys like
target-organdtarget-dev-hub. Legacy sfdx keys (defaultusername,defaultdevhubusername) are deprecated in this context. - The sf CLI does not have
--localor--scopeflags for config set. Local scope is the default behavior. - If the org does not change after setting the config, check whether
SF_TARGET_ORGis set — environment variables override config values. - Salesforce CLI config (unified) reference: https://developer.salesforce.com/docs/atlas.en-us.sfdx_cli_reference.meta/sfdx_cli_reference/cli_reference_config_commands_unified.htm#cli_reference_config_set_unified
Comments
Markdown supported