New to Claude Skills? Learn how to install them →

forcedotcom on GitHub

Salesforce Org Management

OfficialFree

Streamline Salesforce org operations with ease.

by forcedotcom808 stars on forcedotcom/sf-skills
1 views
Updated Aug 10, 2026
Get this skill

Free · Opens the source repo

What Salesforce Org Management does

The Salesforce Org Management skill allows developers and administrators to efficiently manage Salesforce org operations directly through the command line. This skill is designed specifically for creating scratch orgs, generating org snapshots, and opening orgs in a browser. It ensures that operations are executed immediately without the need for generating scripts or code files, making it a straightforward tool for managing Salesforce environments.

When using this skill, users can create scratch orgs based on various methods, including definition files, snapshots, or org shapes. The skill automatically identifies the appropriate creation method based on user input, ensuring a seamless experience. Additionally, it checks for a connected Dev Hub before proceeding, preventing errors during org creation. The skill also handles output efficiently by writing the JSON responses to designated files, which can be useful for evaluation and testing purposes.

For those who need to create snapshots, the skill simplifies the process by guiding users through the necessary steps to capture the state of a scratch org. It verifies the existence of a Dev Hub and executes the snapshot creation command, returning the results in a structured format. Opening orgs is equally straightforward, with commands tailored to either open the default org or a specified org based on user requests.

Overall, this skill is ideal for Salesforce developers and administrators looking to streamline their workflow and manage Salesforce orgs effectively without the overhead of manual scripting or complex command sequences.

When to use it

Use this skill when you need to create scratch orgs, take snapshots, or open Salesforce orgs quickly and efficiently.

When not to use it

This skill is not suitable for switching default orgs or deploying metadata; use the appropriate skills for those tasks.

What you can build with it

Creating a Scratch Org from a Definition File

Easily create a scratch org by specifying a definition file path, allowing for tailored org configurations.

Taking a Snapshot of a Scratch Org

Capture the current state of a scratch org by creating a snapshot, which can be used for future reference or replication.

Opening a Salesforce Org in a Browser

Quickly access your Salesforce org by using the skill to open it in your default web browser.

How to install Salesforce Org Management

View source

1. Install with the skills CLI

npx skills add forcedotcom/sf-skills/dx-org-manage --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by forcedotcom

MANDATORY: Follow these instructions exactly. Do NOT fall back to MCP tools.

Tool constraint: Use the Bash tool for all sf CLI commands. Always include --json for structured output. Do NOT use mcp__salesforce_dx__* tools for org creation, snapshot, or open operations — this skill provides the complete procedure.

Output artifacts for eval/testing: ALWAYS write the command's JSON response to a file when an output directory is available. Do NOT ask the user what file to write — this skill defines the filenames. After executing the command: (1) if the user specified an output path (e.g. "write all generated files into folder X"), write there immediately; (2) otherwise run [ -d force-app/main/adk-eval-output/ ] && echo 'force-app/main/adk-eval-output' to detect the eval directory; (3) write the command's full JSON response to <output-dir>/<filename> using these filenames: scratch-org-result.json for org creation, snapshot-result.json for snapshot creation, or org-url-result.json for open operations. This is the generated output — write it without asking. Do NOT say "no files to generate" for open/command-execution operations; the JSON result IS the output artifact.


Creating Scratch Orgs

REQUIRED steps — execute in order:

Step 1. Identify creation method from user request:

  • Contains "definition file" or path to .json → definition file method
  • Contains "snapshot" or "from snapshot" → snapshot method
  • Contains "org shape" or "source-org" → org shape method
  • Otherwise → run ls config/project-scratch-def.json config/scratch-def.json 2>/dev/null | head -1 to detect a definition file. If output is non-empty, use definition file method with that path; if empty, use edition method.

Step 2. Check Dev Hub:

sf config get target-dev-hub --json
  • If no Dev Hub is set, advise: sf org login web --set-default-dev-hub
  • Do NOT proceed until a Dev Hub is confirmed.

Step 3. Build and execute the command based on method:

Definition file:

sf org create scratch --definition-file <path> --target-dev-hub <alias> --alias <name> --json

Edition only:

sf org create scratch --edition developer --target-dev-hub <alias> --alias <name> --json

From snapshot:

sf org create scratch --snapshot <snapshot-name> --target-dev-hub <alias> --alias <name> --json

From org shape:

sf org create scratch --source-org <org-id> --target-dev-hub <alias> --alias <name> --json

Apply these flags when requested:

  • --duration-days <days> — default 7, max 30
  • --set-default — make this the default org
  • --no-track-source — disable source tracking (for CI/CD)

Step 4. MANDATORY - Run org list and write output: After the org is created, you MUST run this command:

sf org list --json

Then:

  1. Parse the JSON result and find the scratchOrgs array

  2. Find the entry where username matches the username from Step 3's creation result

  3. Extract that complete org object (it will include: alias, username, orgId, instanceUrl, loginUrl, isDefaultUsername, connectedStatus, lastUsed, etc.)

  4. Report to the user:

    • Created scratch org.
    • Alias: [alias from the org list entry]
    • Username: [username]
    • Org ID: [orgId]
  5. If an output directory is available (per the output artifacts rule above), write ONLY that extracted org object (NOT the full creation result) to <output-dir>/scratch-org-result.json

Example: If sf org list --json returns {"result": {"scratchOrgs": [{"alias": "feature-dev", "username": "test@example.com", "orgId": "00D...", ...}]}}, write just the inner org object {"alias": "feature-dev", "username": "test@example.com", "orgId": "00D...", ...} to the file.

Do NOT write the creation command's output. Do NOT suggest verification steps to the user.

Error handling:

  • "Snapshot not found" → suggest sf org list snapshot --target-dev-hub <alias>
  • "No default Dev Hub" → advise sf org login web --set-default-dev-hub

When you need more detail:

  • For available features, settings, and definition file structure → load references/definition_file_options.md
  • For edition selection guidance and comparison → load references/edition_types.md
  • For snapshot workflow and post-creation usage → load references/snapshot_usage.md
  • For complete scratch org creation workflow → load references/creating-scratch-org.md

Creating Snapshots

REQUIRED steps — execute in order:

Step 1. Get inputs:

  • Source org: scratch org ID or alias (from user)
  • Snapshot name: unique name (from user)
  • Description: optional (from user)

Step 2. Determine Dev Hub:

  • If user specifies a Dev Hub (alias or username) → use that value
  • Otherwise, check for default:
sf config get target-dev-hub --json
  • If no default Dev Hub is set, advise: sf org login web --set-default-dev-hub

Step 3. Execute:

sf org create snapshot --source-org <orgId-or-alias> --name <SnapshotName> --target-dev-hub <devHub> --json

With description:

sf org create snapshot --source-org <orgId-or-alias> --name <SnapshotName> --description "<desc>" --target-dev-hub <devHub> --json

Step 4. Report result: Returns JSON with SnapshotId and Status. If an output directory is available (per the output artifacts rule above), write the JSON response to <output-dir>/snapshot-result.json.

Error handling:

  • "NOT_FOUND" → Dev Hub doesn't have snapshot feature enabled
  • "Snapshot name already exists" → use a different unique name

When you need more detail:

  • For complete snapshot creation workflow and flag reference → load references/creating-snapshot.md
  • For CLI flag reference → load references/cli_flags.md

Opening Orgs

REQUIRED steps — execute in order:

Step 1. Match user request to command:

User wantsCommand
Open default orgsf org open --json
Open specific orgsf org open --target-org <alias> --json
Specific browsersf org open --browser chrome --json
Incognito modesf org open --private --json
Navigate to pathsf org open --path '<path>' --json
URL only (don't open)sf org open --url-only --json
Open metadata filesf org open --source-file <file-path> --json

Step 2. Execute the matching command using the Bash tool.

Step 3. Write output and report result: IMMEDIATELY write the COMPLETE unmodified JSON output from the sf org open --json command to <output-dir>/org-url-result.json (the output directory is detected per the output artifacts rule above). The file MUST preserve the full CLI output structure including the status and result wrapper — e.g. {"status": 0, "result": {"orgId": "...", "url": "...", "username": "..."}}. Do NOT unwrap or flatten the JSON. Do NOT ask permission, do NOT say "no files to generate." Then report the URL and org details to the user.

Error handling:

  • "no target org" → advise sf config set target-org <alias>
  • "auth error" → advise sf org login web --alias <alias>

When you need more detail:

  • For complete opening org workflow and all available flags → load references/opening-org.md

Reference File Index

Load these reference files for detailed guidance:

FileWhen to read
references/definition_file_options.mdUser needs to configure org features, settings, or advanced definition file options beyond basic org creation
references/edition_types.mdUser asks which edition to choose or needs to understand edition differences
references/snapshot_usage.mdUser wants to use snapshots in definition files or needs post-snapshot workflow guidance
references/creating-scratch-org.mdTroubleshooting scratch org creation failures or need complete workflow with all options
references/cli_flags.mdUser needs complete snapshot CLI flag reference
references/creating-snapshot.mdTroubleshooting snapshot creation failures or need detailed snapshot workflow
references/opening-org.mdUser needs to navigate to specific setup paths, open metadata files, or use advanced open flags

Example Files

Example command outputs for testing and troubleshooting:

FilePurpose
examples/scratch-orgs/success_definition_file.jsonSuccessful scratch org creation using --definition-file
examples/scratch-orgs/success_edition.jsonSuccessful scratch org creation using --edition developer
examples/scratch-orgs/success_snapshot.jsonSuccessful scratch org creation using --snapshot
examples/scratch-orgs/error_no_devhub.jsonError when Dev Hub not authenticated
examples/scratch-orgs/error_timeout.jsonTimeout error during org creation (exit code 69)
examples/snapshots/success_output.jsonSuccessful snapshot creation
examples/snapshots/error_output.jsonCommon snapshot error scenarios

Frequently asked questions about Salesforce Org Management

Similar skills