Dx Org Switch

forcedotcom/sf-skills/plugins/builder/dx-org-lifecycle/skills/dx-org-switch

作者 forcedotcome5164d94d7511c00fa02a5b8b60754b2361e178f无许可证1K 个星标收录于 2026年10月9日更新于 2026年10月9日仓库2天前更新

Switches the active Salesforce org (default target-org) using the Salesforce CLI. Use whenever someone wants to change which org CLI commands run against — whether they say "switch org", "change default org", "set my org to", "use alias", "point to", or describe wanting to work against a specific org, scratch org, sandbox, or production.

仅含说明DevOps & Cloud
AI 生成的概览

使用 sf config set 切换 Salesforce CLI 当前的目标组织,并包含验证步骤。

功能
该技能指导代理更改 Salesforce CLI 命令所针对的 Salesforce 组织。它通过用户名或别名识别组织,使用 sf config set 在本地或全局设置默认 target-org,并用 sf config get target-org --json 验证取值。它还涵盖失败处理,例如在组织可能未授权时建议运行 sf org login web,并说明 SF_TARGET_ORG 等环境变量会覆盖配置值。
适用场景
当有人想要更改 Salesforce CLI 命令所针对的组织时使用,例如切换到 scratch org、sandbox 或生产组织。适用于“切换组织”“更改默认组织”“设置别名”或“指向”某个特定组织等表述的请求。
运行要求
需要 Salesforce CLI(sf)2.0.0 或更高版本以及一个已授权的组织;不包含脚本,只有说明。CLI 命令需要网络访问,并需事先完成组织授权(例如通过 sf org login web)。

Steps

  1. Identify the org: the user provides a username or alias (orgIdentifier). If not provided, run sf org list to show authenticated orgs and ask the user which one to use.
  2. 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 web if the org may not be authorized.
  3. 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

来源与署名

来源:forcedotcom/sf-skills位于plugins/builder/dx-org-lifecycle/skills/dx-org-switch提交e5164d9

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架