switching-org

Switch the Salesforce CLI target-org configuration for subsequent commands.

803|289|Updated Nov 7, 2025
One-click install
npx skills add https://github.com/forcedotcom/sf-skills --skill switching-org-forcedotcom
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: switching-org
Source: https://github.com/forcedotcom/sf-skills/tree/main/skills/switching-org
Command: npx skills add https://github.com/forcedotcom/sf-skills --skill switching-org-forcedotcom

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Switching between authenticated Salesforce orgs can be slow and error-prone when you must remember which one your CLI commands target.

Core Features & Use Cases

  • Default org switching: Sets the CLI’s active target-org using the Salesforce CLI so subsequent commands run against the correct environment.
  • Local vs global scope control: Supports project-local default org changes by default, and global changes when explicitly requested.
  • Org identification workflow: Uses a provided username or alias, or prompts you to pick from sf org list when none is provided.
  • Verification step: Confirms the configured target-org value using sf config get target-org --json.

Quick Start

Switch the CLI to use the org alias "my-sandbox" for the current project so all following commands run against it.

Frequently Asked Questions about switching-org

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

FAQPage Schema
How do I switch my Salesforce CLI default target-org to a different sandbox?

To switch your Salesforce CLI default target-org, specify the target sandbox by its username or alias. The configuration updates the active org locally for your project, ensuring subsequent sf commands execute against the intended authenticated environment.

Can I change the Salesforce CLI target-org globally instead of just for the current project?

Yes, you can change the Salesforce CLI target-org globally by explicitly requesting global scope. By default, the org switching applies locally to the current project, but global configuration overrides the active org for all CLI sessions.

What should I do if I need to switch my active Salesforce org but don't know the alias?

If you do not know the exact alias, you can select an authenticated Salesforce org from the sf org list output. The CLI retrieves all available orgs, allowing you to identify and set the correct target-org for your commands.

How can I verify that my Salesforce CLI target-org switched successfully?

You can verify your Salesforce CLI target-org switched successfully by running sf config get target-org --json. This command confirms the active default org configuration and ensures subsequent operations target the correct environment.

Why does my Salesforce CLI target-org configuration not apply when running commands?

Your Salesforce CLI target-org configuration may not apply if environment variables override the config values. Troubleshooting is recommended to identify and remove conflicting environment variables that bypass the active default org setting.

Does the Salesforce CLI support setting a default org for both scratch orgs and production?

Yes, the Salesforce CLI supports setting a default target-org for scratch orgs, sandboxes, production, or any authenticated environment. You identify the desired org by username or alias to apply the configuration.