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 を直接使うのではなく、sf project deploy validate(本番用)または sf project deploy start --dry-run(サンドボックス/スクラッチ組織用)を優先してください。
ゲートの分類機能を使って組織を判定します。この分類は信頼できる唯一の基準であり、デプロイフックと同じ方法で組織を判定します(サンドボックス/スクラッチ組織のマーカーや試用版・Developer Edition 組織、SDO に対応し、特に指定がない Dev Hub は本番環境として扱います。結果は production|sandbox|scratch|trial|unknown のいずれかです):
"${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" bucket <alias>
production だけが本番経路(ステップ2b)に進みます。それ以外の結果はすべてサンドボックス/スクラッチ経路(ステップ2a)に進みます。unknown は組織の種別が確認できなかったことを意味します(通常は組織レコードが不完全な場合)。その旨を明確に伝えてください。デプロイゲートはデプロイを許可し、自動デプロイは無効のままになり、sf org login web で再認証することで通常は分類が復旧します。
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 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):
"${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.
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 による自動翻訳です。