dx-org-switch

Switches the default Salesforce target org using the Salesforce CLI.

Updated Jul 2, 2026
One-click install
npx skills add https://github.com/padjei/SF_Build --skill dx-org-switch-padjei
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dx-org-switch
Source: https://github.com/padjei/SF_Build/tree/main/.claude/skills/dx-org-switch
Command: npx skills add https://github.com/padjei/SF_Build --skill dx-org-switch-padjei

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Developers working across multiple Salesforce orgs (scratch orgs, sandboxes, production) often run CLI commands against the wrong org. This Skill changes the default target-org so subsequent sf CLI commands run against the intended environment. ## Core Features & Use Cases - Set Default Org: Runs sf config set target-org <orgIdentifier> to point CLI commands at a specific username or alias, locally by default or globally on request. - Org Discovery: Lists authenticated orgs with sf org list when the user does not specify which org to use. - Verification: Confirms the change with sf config get target-org --json and reports the new value. - Use Case: A developer finishing work in a scratch org says "switch my default org to the UAT sandbox" — the Skill sets the config, verifies the value, and warns about SF_TARGET_ORG environment variable overrides if the change does not take effect. ## Quick Start Switch my default Salesforce org to the alias 'uat-sandbox' and verify the change.

Frequently Asked Questions about dx-org-switch

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I change the default org in Salesforce CLI?▼

Run `sf config set target-org <username-or-alias>` to set the default org for the current project directory. Add the `--global` flag only if you want the setting to apply system-wide across all directories.

How to list all authenticated Salesforce orgs with sf CLI?▼

Run `sf org list` to display all orgs authenticated on your machine, including their aliases and usernames. You can then pick one and set it as the default with `sf config set target-org`.

Why does my Salesforce org not change after setting target-org?▼

The `SF_TARGET_ORG` environment variable overrides config values, so the org appears unchanged if it is set. Unset the environment variable or update it to the desired org, then verify with `sf config get target-org`.

What is the difference between local and global target-org config?▼

Local scope is the default and applies only within the current project directory, which suits normal project work. Global scope, set with the `--global` flag, applies system-wide across all directories.

Does sf CLI still support defaultusername from sfdx?▼

Legacy sfdx keys like `defaultusername` and `defaultdevhubusername` are deprecated in the unified CLI. Use `target-org` and `target-dev-hub` with the sf CLI v2+ instead.