address PR review feedback on switch-org skill

- rename skill and directory to switching-org (gerund convention)
- rewrite description to follow "Use this skill when..." pattern
- add compatibility and metadata frontmatter fields
- rename ## Usage to ## When to Use This Skill
- consolidate Behavior, Steps, and Canonical Examples into single ## Steps section
- remove Purpose section (duplicated description)
- remove .sf/config.json implementation detail
- fix escaped \# in documentation URL
- rephrase --local/--scope note for clarity
This commit is contained in:
Kenneth Lewis 2026-03-20 10:29:42 -07:00
parent affdd46917
commit d082d99b22
No known key found for this signature in database
GPG Key ID: 29890E559E44ECF6
2 changed files with 46 additions and 70 deletions

View File

@ -1,70 +0,0 @@
---
name: switch-org
description: Switches the active Salesforce org (default org) using the Salesforce CLI. Supports username or alias input, defaults to local project scope, and optionally sets the global default.
---
# switch-org
A global Agentforce Skill that switches the active Salesforce org (default org) using the Salesforce CLI (sf). This Skill performs a CLI-only workflow (no project file edits) and supports either a username or an alias.
## Purpose
- Switch to a specified Salesforce org for subsequent CLI operations.
- Confirm the selection via `sf config get target-org`.
## Usage
- Invoke this Skill whenever a user asks to "switch org", "change default org", or specifies a username/alias directly.
- Input: a username or alias (e.g., `user@example.com` or `myAlias`), and an optional scope indicator.
- Default scope: **local** (updates `.sf/config.json` in the current project directory).
- Use `--global` scope only if the user explicitly asks to set the global default (e.g., "set globally", "change global org").
### Examples
- “Switch to this org: user@example.com”
- “Use alias myAlias”
- “Change default org to myDev”
## Behavior
1. Set the default org using the provided alias or username:
- Local (default): `sf config set target-org=<orgIdentifier>`
- Global (only if user explicitly requests): `sf config set target-org=<orgIdentifier> --global`
2. Verify selection:
- `sf config get target-org --json`
- Parse and display the confirmed value and scope (Local or Global).
## Steps (pseudocode)
1) Read input: `orgIdentifier`, and whether the user wants global scope (default: false)
2) Execute:
- If global: `sf config set target-org=<orgIdentifier> --global`
- Otherwise: `sf config set target-org=<orgIdentifier>`
- 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`
- Output confirmation: `Switched org (<scope>): <value>`
4) If verification fails, report the error and advise running `sf config get target-org`.
## Official Documentation
- Salesforce CLI config (unified) reference (sf):
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
## Canonical sf config set Examples
- Set project-local default (default behavior):
sf config set target-org=ALIAS_OR_USERNAME
- Set global default (only when explicitly requested):
sf config set target-org=ALIAS_OR_USERNAME --global
- Verify current effective value:
sf config get target-org
sf config get target-org --json
Notes:
- Unified CLI uses keys like target-org and target-dev-hub. Legacy sfdx keys (defaultusername, defaultdevhubusername) are deprecated in this context.
- Flags like --local or --scope are not part of current unified docs; do not use them.

View File

@ -0,0 +1,46 @@
---
name: switching-org
description: Use this skill when users need to switch the active Salesforce org (default org) using the Salesforce CLI. Trigger when users say "switch org", "change default org", "set my org to", "use alias", or specify a username/alias they want to use for subsequent CLI operations.
compatibility: Salesforce CLI (sf) v2+
metadata:
author: afv-library
version: "1.0"
---
# switching-org
Switches the active Salesforce org (default org) using the Salesforce CLI (sf). Supports either a username or an alias.
## When to Use This Skill
- User says "switch org", "change default org", or "set my org to"
- User specifies a username or alias they want to use
- User needs to change which org is targeted for subsequent CLI operations
### Examples
- "Switch to this org: user@example.com"
- "Use alias myAlias"
- "Change default org to myDev"
## Steps
1. Read input: `orgIdentifier`, and whether the user wants global scope (default: local)
2. Set the default org:
- Local (default): `sf config set target-org=<orgIdentifier>`
- Global (only if user explicitly requests): `sf config set target-org=<orgIdentifier> --global`
- 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`
- Output confirmation: `Switched org (<scope>): <value>`
4. If verification fails, report the error and advise running `sf config get target-org`.
## Official Documentation
- Salesforce CLI config (unified) reference (sf):
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
## Notes
- Unified CLI uses keys like `target-org` and `target-dev-hub`. Legacy sfdx keys (`defaultusername`, `defaultdevhubusername`) are deprecated in this context.
- The sf CLI does not have `--local` or `--scope` flags for config set. Local scope is the default behavior.