Skip to content

forcedotcom/sf-skills / plugins/builder/dx-org-lifecycle/skills/automation-sandbox-post-copy-configure

automation-sandbox-post-copy-configure

Verified

Apply 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.

scripts/map-metadata-key.mjs

View on GitHub
#!/usr/bin/env node
// Deterministic Metadata-key resolver for automation-sandbox-post-copy-configure.
//
// Encodes the field-name resolution rule that was formerly prose in SKILL.md
// (authoring standard A9). Given (ConfigurationName, ConfigFieldName, current
// Metadata block JSON), returns the exact camelCase key inside .Metadata that
// the PATCH should mutate — or FIELD_MAP_UNKNOWN so the caller aborts the
// entry rather than silently updating the wrong field.
//
// Resolution order:
//   1. Override table: known renames between the customer-facing config
//      shape and the Metadata API shape (e.g.
//      RemoteSiteSettings.RemoteSiteUrl → RemoteProxy.Metadata.url).
//   2. Default: lowercase the first character of the config field name
//      (e.g. EndpointUrl → endpointUrl).
//   3. Existence check: the resolved key MUST be present in the current
//      Metadata block. If absent (and no override matched), emit
//      FIELD_MAP_UNKNOWN — the customer's config drift, not something to
//      guess through.
//
// Usage:
//   node map-metadata-key.mjs <ConfigurationName> <ConfigFieldName> <metadataJsonPath>
//
// Emits to stdout (single JSON object):
//   OK      → { "status": "OK",                 "key": "<resolved>" }
//   Unknown → { "status": "FIELD_MAP_UNKNOWN",  "candidateKey": "<tried>",
//               "availableKeys": [...], "reason": "..." }
//
// Exit code 0 in both cases (the caller inspects status); non-zero only on
// input/parse errors.

import { readFileSync } from 'node:fs';

function fail(msg) {
  process.stderr.write(`map-metadata-key: ${msg}\n`);
  process.exit(1);
}

const [, , configurationName, configFieldName, metaPath] = process.argv;
if (!configurationName || !configFieldName || !metaPath) {
  fail('usage: map-metadata-key.mjs <ConfigurationName> <ConfigFieldName> <metadataJsonPath>');
}

const OVERRIDES = {
  RemoteSiteSettings: {
    RemoteSiteUrl: 'url',
  },
};

function defaultCamelize(name) {
  if (!name) return name;
  return name.charAt(0).toLowerCase() + name.slice(1);
}

const override = OVERRIDES[configurationName]?.[configFieldName];
const candidateKey = override ?? defaultCamelize(configFieldName);
const overrideMatched = Boolean(override);

let currentMeta;
try {
  const raw = readFileSync(metaPath, 'utf-8');
  currentMeta = JSON.parse(raw);
} catch (err) {
  fail(`cannot read/parse metadata JSON at ${metaPath}: ${err.message}`);
}

if (currentMeta === null || typeof currentMeta !== 'object' || Array.isArray(currentMeta)) {
  fail(`metadata JSON at ${metaPath} is not an object`);
}

const availableKeys = Object.keys(currentMeta);
const present = Object.prototype.hasOwnProperty.call(currentMeta, candidateKey);

if (present) {
  process.stdout.write(JSON.stringify({ status: 'OK', key: candidateKey }) + '\n');
  process.exit(0);
}

if (overrideMatched) {
  process.stdout.write(
    JSON.stringify({
      status: 'FIELD_MAP_UNKNOWN',
      candidateKey,
      availableKeys,
      reason: `override "${configurationName}.${configFieldName}" → "${candidateKey}" but that key is not present in the current Metadata block`,
    }) + '\n',
  );
  process.exit(0);
}

process.stdout.write(
  JSON.stringify({
    status: 'FIELD_MAP_UNKNOWN',
    candidateKey,
    availableKeys,
    reason: `default rename "${configFieldName}" → "${candidateKey}" is not a key in the current Metadata block; no override table entry for ${configurationName}.${configFieldName}`,
  }) + '\n',
);
writing-skillsobra/superpowersUse when creating new skills, editing existing skills, or verifying skills work before deploymentStars: 322kUpdated Claude CodeCodexVerifiedInstall
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: 198kUpdated Claude CodeCodexVerifiedInstall
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: 119kUpdated Claude CodeCodexVerifiedInstall
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: 118kUpdated Claude CodeCodexVerifiedInstall