360 Secure SkillHub
360 安全技能中心

dx-org-switch

该 Skill 通过 Salesforce CLI 将默认 target-org 切换到用户指定的用户名或别名;未指定时列出已授权 org 供选择。默认只修改当前项目配置,用户明确要求时才改为全局配置,并读取配置值进行验证,失败时提示错误及后续检查建议。

forcedotcom
热度 0.00
最近更新 2026-10-19 02:23:58
分类:开发依赖:代码执行应用场景:DevOps / 工作流

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add forcedotcom/sf-skills/dx-org-switch
Metadata
name
dx-org-switch
description
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.
metadata
{"version":"1.0","domains":["Developer Experience"],"cliTools":[{"tool":["sf"],"semver":">=2.0.0"}]}

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