forcedotcom/sf-skills / plugins/builder/dx-org-lifecycle/skills/automation-sandbox-post-copy-configure
automation-sandbox-post-copy-configure
VerifiedApply a Salesforce sandbox post-copy automation JSON config against a target org. Use when the user asks to apply, run, execute, dry-run, or preview a post-copy or post-refresh config file (e.g. `post-copy-config.json`) against a sandbox — including activating/deactivating a Flow (PATCH `FlowDefinition.Metadata.activeVersionNumber` to the version, or `null`), re-pointing an OBM endpoint, updating a RemoteSiteSetting URL, or re-scheduling a ScheduledApex job after refresh. Also trigger for phrasings like "apply post-copy config", "run post-copy automation", "activate Flow <name> post-refresh", "deactivate Flow <name>", "re-point outbound messages after refresh", or "configure sandbox after refresh". Per entry, derive the Tooling API sobject, verify via describe, resolve the Id via SOQL, then PATCH the compound `Metadata` field (`ScheduledApex` uses anonymous Apex). DO NOT TRIGGER for generating config JSON from an SOP (use `automation-sandbox-post-copy-config-generate`) or for deploying metadata XML.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 21.3 KB |
| assets/api_request_templates.json | config | 4.2 KB |
| examples/sample_config_input.json | config | 1.1 KB |
| examples/sample_execution_summary.md | markdown | 4.0 KB |
| references/api_endpoints.md | markdown | 10.7 KB |
| references/authentication.md | markdown | 2.9 KB |
| references/execution_phasing.md | markdown | 3.6 KB |
| references/flow_activation_path.md | markdown | 7.1 KB |
| references/rules_gotchas.md | markdown | 3.5 KB |
| references/scheduled_apex_path.md | markdown | 8.1 KB |
| scripts/build-scheduled-apex.mjsexecutable | script | 2.2 KB |
| scripts/classify-patch-result.mjsexecutable | script | 3.1 KB |
| scripts/map-metadata-key.mjsexecutable | script | 3.4 KB |
| scripts/plan-phases.mjsexecutable | script | 2.8 KB |
| scripts/resolve-target-org.mjsexecutable | script | 1.9 KB |
| scripts/soql-escape-job-name.mjsexecutable | script | 1.0 KB |
references/authentication.md
View on GitHub# Authentication & Session Handling
This skill mutates a live org. Getting authentication wrong writes to
the wrong place. Follow this recipe exactly.
## Discovering the target org
Before making any API call:
1. If the user supplied a `--target-org <alias>` value, use it verbatim.
2. If they did not, run `sf org list --json` and present the list of
aliases. Ask the user which to use. Do **not** default to the
`defaultusername` — the default is frequently a production alias for
internal users.
## Verifying the session
Once an alias is chosen:
```bash
sf org display --target-org <alias> --json
```
Check the result:
- `result.connectedStatus` should be `Connected`.
- `result.instanceUrl` should be present.
- `result.apiVersion` gives the exact `vXX.0` to substitute into REST
paths — do not hardcode a version.
If the command exits non-zero, or `connectedStatus` is not
`Connected`, the session has expired. Ask the user to run:
```bash
sf org login web --alias <alias>
```
Do **not** attempt to run `sf org login` on the user's behalf — it
opens a browser and requires user consent. Wait for the user to confirm
they have re-logged in, then re-verify.
## Making the request
Two supported paths:
### Path A — `sf api request rest` (preferred)
```bash
sf api request rest \
--target-org <alias> \
--method PATCH \
"/services/data/vXX.0/tooling/sobjects/RemoteProxy/<Id>" \
--body '{"EndpointUrl":"https://...","IsActive":true}'
```
The CLI handles the access token — you never touch it directly, so
there is no token-leak surface on this path.
### Path B — `curl` fallback
Only when the CLI is unavailable. Read the access token and instance
URL from the `sf org display` JSON, then:
```bash
curl -X PATCH \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"EndpointUrl":"https://...","IsActive":true}' \
"$INSTANCE_URL/services/data/vXX.0/tooling/sobjects/RemoteProxy/<Id>"
```
**Token handling rules on the fallback path**:
- Never echo `$TOKEN` to the console or a log file.
- Never include the full `sf org display` output in the summary — the
`accessToken` field is present.
- Prefer stdin or a temp file with `chmod 600` if the token must be
materialized.
- Redact `Bearer …` from any error output surfaced to the user.
## Handling 401 mid-run
An access token can expire between phases (common on longer runs). On
HTTP 401 from any entry:
1. Immediately stop dispatching further requests in the current phase.
2. Wait for in-flight requests to complete or timeout.
3. Surface a single 401 message to the user with instructions to
re-authenticate via `sf org login web --alias <alias>`.
4. Offer to resume from the failing phase (do not re-run completed
phases — the earlier PATCHes were already applied).
Never silently re-issue the request with a stale token, and never
attempt to refresh the token by hand.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deployment | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| xlsxanthropics/skillsUse this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing .xlsx, .xlsm, .xltx, .csv, or .tsv file (e.g., adding columns, computing formulas, formatting, charting, cleaning messy data); create a new spreadsheet from scratch or from other data sources; or convert between tabular file formats. Trigger especially when the user references a spreadsheet file by name or path — even casually (like "the xlsx in my downloads") — and wants something done to it or produced from it. Also trigger for cleaning or restructuring messy tabular data files (malformed rows, misplaced headers, junk data) into proper spreadsheets. The deliverable must be a spreadsheet file. Do NOT trigger when the primary deliverable is a Word document, HTML report, standalone Python script, database pipeline, or Google Sheets API integration, even if tabular data is involved. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| shipping-and-launchaddyosmani/agent-skillsPrepares production launches. Use when preparing to deploy to production, or when asking what needs to be in place before shipping. Use when you need a pre-launch checklist, when setting up monitoring, when planning a staged rollout, or when you need a rollback strategy. | Stars: 119k | Updated | Claude CodeCodex | Verified | Install |
| childhoodthedotmack/claude-memBabysit a shipped release after merge, publication, or deployment. Verify published packages, production behavior, installed plugins, and late CI or user reports until the observation window is clean; use babysit for PR readiness before release. | Stars: 118k | Updated | Claude CodeCodex | Verified | Install |