PluginBench
Skill
Pass
Audit score 90

platform-deploy-validate

forcedotcom/sf-skills

Validate Salesforce metadata before deploying to catch errors without modifying the org.

What is platform-deploy-validate?

Validates Salesforce metadata deployments before they execute, routing production orgs through `sf project deploy validate` (which produces a reusable 10-day job ID) and sandbox/scratch orgs through dry-run mode. Use this when a user asks to validate, do a dry-run, check before deploying, or targets production for any deploy operation.

  • Routes production targets to `sf project deploy validate` and returns a 10-day quick-deploy job ID
  • Routes sandbox and scratch orgs to `sf project deploy start --dry-run` for server-side validation without modification
  • Classifies target org type (production, sandbox, scratch, trial, devhub) to determine validation path
  • Parses and surfaces top component errors and test failures with suggested fixes
  • Persists validation job ID to `.sfdx/last-validation.json` for handoff to quick-deploy
  • Enforces `RunLocalTests` test level for production validations by default

How to install platform-deploy-validate

npx skills add https://github.com/forcedotcom/sf-skills --skill platform-deploy-validate
Prerequisites
  • Salesforce CLI (sf) version 2.0.0 or later
  • Authorized target org (production, sandbox, or scratch)
  • Valid metadata source (directory, manifest, or component list)
Claude Code
Cursor
Windsurf
Cline

How to use platform-deploy-validate

  1. 1.Invoke the skill when the user asks to validate, dry-run, or check a deployment
  2. 2.The skill classifies the target org to determine the validation path (production vs. sandbox/scratch)
  3. 3.For production: runs `sf project deploy validate` with `RunLocalTests` test level and captures the job ID
  4. 4.For sandbox/scratch: runs `sf project deploy start --dry-run` to validate without modification
  5. 5.Parse and report validation results, component errors, test failures, and suggested fixes
  6. 6.Persist the job ID (for production) to `.sfdx/last-validation.json` for use with platform-quick-deploy

Use cases

Good for
  • Validate a large metadata deployment to production before committing the actual deploy
  • Run a dry-run validation against a sandbox to catch component errors and FLS issues early
  • Check a specific metadata component or manifest against production without executing the deploy
  • Validate a deployment and immediately hand off the job ID to quick-deploy for a fast, test-free production deploy
  • Triage validation failures to identify missing dependencies, syntax errors, or test failures before rework
Who it's for
  • Salesforce developers validating metadata changes
  • Release managers checking deployments before production promotion
  • CI/CD pipelines that need pre-deploy validation gates
  • Teams using quick-deploy workflows that require prior validation

platform-deploy-validate FAQ

What's the difference between validating production and sandbox?

Production validations use `sf project deploy validate` and return a 10-day job ID for quick-deploy; sandbox/scratch use `--dry-run` which validates but does not return a reusable job ID.

Do I need to run validation before every deploy?

Validation is required before production deploys; for sandbox/scratch it is optional but recommended to catch errors early.

What test level is used by default?

Production validations use `RunLocalTests` by default; sandbox/scratch defer to the org's default unless the user specifies `RunSpecifiedTests`.

Can I use the job ID from validation to deploy later?

Yes. Production validation job IDs are valid for 10 days and can be used with `platform-quick-deploy` to deploy without re-running tests.

What happens if validation fails?

The skill parses component failures and test failures, surfaces the top errors with suggested fixes, and recommends rework before retrying.

Full instructions (SKILL.md)

Source of truth, from forcedotcom/sf-skills.


name: platform-deploy-validate description: "Validate Salesforce metadata before deploying. TRIGGER when the user asks to validate a deploy, do a dry-run, check before deploying, or targets a Production org for any deploy operation. Routes prod targets to sf project deploy validate (returns a 10-day quick-deploy job ID) and sandbox/scratch targets to sf project deploy start --dry-run. DO NOT TRIGGER for actual deploys (use platform-metadata-deploy) or destructive changes (use platform-destructive-deploy)." allowed-tools:

  • Bash
  • Read
  • Write metadata: cliTools:
    • tool: ["sf"] semver: ">=2.0.0" relatedSkills:
    • "platform-metadata-deploy"
    • "platform-destructive-deploy"
    • "platform-quick-deploy"

Validating Deployment

Run a server-side validation before deploying metadata. Validation surfaces errors without modifying the org and — for production targets — produces a job ID usable with platform-quick-deploy for a fast, test-free deploy.

Capability Resolution

Always prefer sf project deploy validate (prod) or sf project deploy start --dry-run (sandbox/scratch) over the Tooling API directly.

Workflow

Step 1 — Confirm the target org

Classify the org with the gate's classifier — it is the authoritative source of truth (it handles sandbox/scratch markers, trial and Developer Edition hosts, and dev hubs, and returns one of production|sandbox|scratch|trial|devhub|unknown):

sf org display --target-org <alias> --json | "${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" classify

Only production takes the production path (Step 2b); every other result takes the sandbox/scratch path (Step 2a).

Step 2a — Sandbox/Scratch path (dry-run)

sf project deploy start --dry-run --target-org <alias> --json [scope flags]

Scope flags (use exactly one, not all):

  • --source-dir <path> — deploy a directory
  • --metadata <Type:Name> — deploy specific components
  • --manifest manifest/package.xml — deploy from manifest

Default test level: omit --test-level for sandboxes (defers to org default). Add --test-level RunLocalTests only if the user asks.

Report back: success/failure, components attempted, any errors. No job ID is returned for dry-runs (this is expected).

Step 2b — Production path (validate)

sf project deploy validate --target-org <alias> --json [scope flags] --test-level RunLocalTests

Production validations REQUIRE a test level. Use RunLocalTests by default; switch to RunSpecifiedTests --tests <ClassName>... if the user has explicitly listed tests.

The response returns a job ID (result.id) valid for 10 days. Persist it for platform-quick-deploy:

mkdir -p .sfdx
echo '{"jobId":"<id>","createdAt":"<iso8601>","targetOrg":"<alias>","testLevel":"RunLocalTests"}' > .sfdx/last-validation.json

Report:

  • Validation result (passed / failed)
  • Job ID and 10-day expiry date
  • Test results summary (run / passed / failed)
  • Recommended next step: platform-quick-deploy with this job ID

Step 3 — Failure triage

If validation fails, parse result.details.componentFailures and result.details.runTestResult.failures and surface:

  • Top 5 component errors with full message
  • Top 5 test failures with stack
  • Suggested fix (component name → likely cause: missing dependency, FLS, syntax, etc.)

Do NOT propose fixes that change unrelated metadata. Stay scoped to what the validation reported.

Rules

  • ALWAYS use --json on every CLI call
  • NEVER skip validation when targeting Production (do not run sf project deploy start against prod from this skill)
  • NEVER use --ignore-errors or --ignore-warnings during validation; those flags belong to actual deploys, not validation
  • If the user asks to "deploy to prod" without prior validation, FIRST run validation, THEN hand off to platform-quick-deploy (do not start a regular deploy against prod)
  • Persist the validation job ID to .sfdx/last-validation.json so the quick-deploy skill can find it

Output

Always end with:

  • ✅ Validation passed → next-step pointer to platform-quick-deploy (with job ID + expiry) OR to platform-metadata-deploy for non-prod
  • ❌ Validation failed → categorized error list and suggested next iteration