platform-deploy-validate — Claude Code skill: validate Salesforce
Runs a server-side validation of Salesforce metadata before deploying. Errors show up, the org stays untouched, and production returns a job ID for a quick deploy.
npx skills add forcedotcom/sf-skills --skill platform-deploy-validate -a claude-codeWhat platform-deploy-validate does
The skill validates metadata on the server without changing anything in the org. It first classifies the target org with ${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate bucket <alias>, which returns production, sandbox, scratch, trial or unknown. Only production takes the production path; everything else goes through the sandbox route.
For sandbox and scratch it runs sf project deploy start --dry-run with one scope flag: --source-dir, --metadata or --manifest. The test level is left alone unless you ask for --test-level RunLocalTests. No job ID comes back from a dry-run, and that is expected. Production requires sf project deploy validate with a test level: RunLocalTests by default, or RunSpecifiedTests --tests <ClassName> when you list the tests yourself. The response carries a job ID valid for 10 days, and the skill writes it to .sfdx/last-validation.json for platform-quick-deploy.
When validation fails, the skill parses componentFailures and runTestResult.failures and surfaces up to five component errors and five test failures with stack traces. Suggested fixes stay inside what the report covers. Actual deploys belong to platform-metadata-deploy, destructive changes to platform-destructive-deploy — this skill does neither. The --ignore-errors and --ignore-warnings flags are not used during validation; they belong to real deploys.
What it helps with
- validate metadata before a production deploy
- get a job ID for a fast deploy without rerunning tests
- run a dry-run against a sandbox or scratch org
- triage component errors and test failures after a failed validation
- check that a deploy won't break the org before starting it
Example prompts for the agent
- validate the deploy to production before we ship
- do a dry-run for this sandbox org
- validate the metadata from manifest/package.xml
How to install platform-deploy-validate
1Skills CLI (Vercel)
npx skills add forcedotcom/sf-skills --skill platform-deploy-validate -a claude-code2Manually: put the files in place
~/.claude/skills/platform-deploy-validate/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/platform-deploy-validate/
1Skills CLI (Vercel)
npx skills add forcedotcom/sf-skills --skill platform-deploy-validate -a codex2Manually: put the files in place
.agents/skills/platform-deploy-validate/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add forcedotcom/sf-skills --skill platform-deploy-validate -a cursor2Manually: put the files in place
.cursor/skills/platform-deploy-validate/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install forcedotcom/sf-skills platform-deploy-validate2Manually: put the files in place
.github/skills/platform-deploy-validate/SKILL.md1Skills CLI (Vercel)
npx skills add forcedotcom/sf-skills --skill platform-deploy-validate -a gemini-cli2Platform CLI
gemini skills install https://github.com/forcedotcom/sf-skills --path plugins/builder/salesforce-development/skills/platform-deploy-validateManually: put the files in place
.devin/skills/platform-deploy-validate/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add forcedotcom/sf-skills --skill platform-deploy-validate -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about platform-deploy-validate
How do I install platform-deploy-validate in Claude?
Run npx skills add forcedotcom/sf-skills --skill platform-deploy-validate -a claude-code. The skill lands in ~/.claude/skills/platform-deploy-validate/SKILL.md.
What does platform-deploy-validate do?
It runs a server-side validation of Salesforce metadata before deploying. Production targets get a 10-day job ID; sandbox and scratch targets get a dry-run.
How is it different from platform-metadata-deploy?
It only validates and never performs the deploy. Use platform-metadata-deploy for the real deploy and platform-destructive-deploy for destructive changes.
Source text
SKILL.md · Apache-2.0
---
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 and resolves the org the same way the deploy hook does (it handles sandbox/scratch markers, trial and Developer Edition orgs including SDOs, and treats a Dev Hub with no such signal as production; returns one of `production|sandbox|scratch|trial|unknown`):
```bash
"${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" bucket <alias>
```
Only `production` takes the production path (Step 2b); every other result takes the sandbox/scratch path (Step 2a). `unknown` means the org type could not be confirmed (usually an incomplete org record). Say so plainly: the deploy gate still allows the deploy, auto-deploy on save stays off for that org, and re-authenticating with `sf org login web` usually restores the classification.
### Step 2a — Sandbox/Scratch path (dry-run)
```bash
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)
```bash
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`:
```bash
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
© forcedotcom · Apache-2.0 · forcedotcom/sf-skills