Salesforce メタデータ(データベースの構造などの設定情報)をデプロイ前に検証します。 **使用場面:** - ユーザーがデプロイの検証、ドライラン(実行前の試験)、デプロイ前のチェック、または本番環境へのデプロイを依頼した場合 **動作:** - 本番環境をターゲットとする場合:`sf project deploy validate` コマンドを実行し、10日間有効なクイックデプロイ用のジョブIDを返却 - サンドボックス環境やスクラッチ環境をターゲットとする場合:`sf project deploy start --dry-run` コマンドを実行 **注意:** 実際のデプロイ操作には使用しないでください(その場合は platform-metadata-deploy を使用してください)。また、削除を伴う変更にも対応していません(その場合は platform-destructive-deploy を使用してください)。
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).
メタデータをデプロイする前に、サーバー側で検証を実行します。検証はメタデータを変更せずにエラーを特定でき、本番環境の場合は platform-quick-deploy で使用可能なジョブIDを生成して、テストなしの高速デプロイを実現します。
Tooling API(低レベルAPI)の代わりに、常に sf project deploy validate(本番)または sf project deploy start --dry-run(サンドボックス/スクラッチ環境)を優先してください。
ゲート(チェックポイント)の分類機能を使って組織を分類します。この機能が信頼できる情報源です(サンドボックス/スクラッチの区別、試用版やDeveloper Edition、開発ハブを判別し、production|sandbox|scratch|trial|devhub|unknown のいずれかを返します):
sf org display --target-org <alias> --json | "${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" classify
production と分類された場合のみステップ2bの本番パスへ進みます。それ以外はステップ2aのサンドボックス/スクラッチパスへ進みます。
sf project deploy start --dry-run --target-org <alias> --json [scope flags]
スコープフラグ(以下から1つだけを選択):
--source-dir <path> — ディレクトリをデプロイ--metadata <Type:Name> — 指定コンポーネントをデプロイ--manifest manifest/package.xml — マニフェストファイルからデプロイデフォルトテストレベル:サンドボックスの場合は --test-level を省略(組織の初期値を使用)。ユーザーが明示的に要求した場合のみ --test-level RunLocalTests を追加します。
報告内容:成功/失敗、試行したコンポーネント、エラー内容。ドライランではジョブIDは返されません(これは正常な動作です)。
sf project deploy validate --target-org <alias> --json [scope flags] --test-level RunLocalTests
本番環境の検証にはテストレベルの指定が必須です。デフォルトは RunLocalTests を使用します。ユーザーが明確にテストを指定した場合は RunSpecifiedTests --tests <ClassName>... に切り替えてください。
レスポンスはジョブID(result.id)を返します。このIDは10日間有効です。platform-quick-deploy で使用するため保存します:
mkdir -p .sfdx
echo '{"jobId":"<id>","createdAt":"<iso8601>","targetOrg":"<alias>","testLevel":"RunLocalTests"}' > .sfdx/last-validation.json
報告内容:
platform-quick-deploy を実行すること検証が失敗した場合、result.details.componentFailures と result.details.runTestResult.failures を解析して以下を表示します:
検証結果に含まれていない無関係なメタデータを変更することは提案しないでください。検証報告の範囲内にとどめてください。
--json を使用sf project deploy start を実行しないこと)--ignore-errors や --ignore-warnings を使用しないでください。これらのフラグは実際のデプロイ用であり、検証は対象外ですplatform-quick-deploy に引き継いでください(本番環境への通常デプロイを開始しないこと).sfdx/last-validation.json に保存して、クイックデプロイスキルが参照できるようにしてください常に以下の形式で終了してください:
platform-quick-deploy へのリンク(ジョブID+有効期限付き)、または本番以外の場合は platform-metadata-deploy へのリンク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.
Always prefer sf project deploy validate (prod) or sf project deploy start --dry-run (sandbox/scratch) over the Tooling API directly.
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).
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 manifestDefault 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).
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:
platform-quick-deploy with this job IDIf validation fails, parse result.details.componentFailures and result.details.runTestResult.failures and surface:
Do NOT propose fixes that change unrelated metadata. Stay scoped to what the validation reported.
--json on every CLI callsf project deploy start against prod from this skill)--ignore-errors or --ignore-warnings during validation; those flags belong to actual deploys, not validationplatform-quick-deploy (do not start a regular deploy against prod).sfdx/last-validation.json so the quick-deploy skill can find itAlways end with:
platform-quick-deploy (with job ID + expiry) OR to platform-metadata-deploy for non-prod原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。