検証済みのメタデータ(Salesforce内の設定情報)を本番環境に展開し、テストの再実行をスキップします。 **次のような場合に使用:** - ユーザーが本番環境への展開を希望している - 「クイックデプロイ」「プロモート」「本番環境に送出」などの指示がある - 検証済みの状態で、その変更をすぐに反映させたい **必須条件:** 最近実行した `sf project deploy validate` コマンドのジョブID(10日以内、または `--use-most-recent` オプション使用時は3日以内)が必要です。 **使用してはいけない場合:** - サンドボックス環境やスクラッチ環境への展開(代わりに platform-metadata-deploy を使用) - 未検証の状態での展開(事前に platform-deploy-validate を使用してください)
Deploy validated metadata to a Production Salesforce org without re-running tests. TRIGGER when the user wants to deploy to production, says 'quick deploy', 'promote', 'ship to prod', or has just validated and wants to push the change live. REQUIRES a recent `sf project deploy validate` job ID (≤10 days old, ≤3 days for --use-most-recent). DO NOT TRIGGER for sandbox/scratch deploys (use platform-metadata-deploy) or unvalidated deploys (use platform-deploy-validate first).
以前実行した sf project deploy validate(デプロイの事前検証)から得たジョブIDを使って、検証済みのデプロイを本番環境に昇格させます。テストの再実行や部品の再検証は行わず、昇格処理のみを実施します。
何をする前に、以下の4つをすべて確認してください:
対象がほんとうに本番環境かを、ゲート(検証装置)の分類機能で確認します。この分類機能はデプロイフックと同じ方法で環境を判定し、production|sandbox|scratch|trial|unknown を返します:
"${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" bucket <alias>
本番環境とは、スクラッチ環境やサンドボックス(-- や test.salesforce.com のホスト名がない)および試用環境・開発者用環境ではないもの(orgfarm-*、*.develop.my.salesforce.com、*.pc-rnd.* のホスト名、または将来の試用期限が記載されているもの(SDO(Salesforce Demo Org)など)を除く)ことを意味します。これらの特徴がないDev Hub(開発用ハブ)は本番環境です。
対象が本番環境でない場合(分類機能が production 以外を返した場合)→ 処理を中止し、platform-metadata-deploy(非本番環境に対応)にリダイレクトしてください。unknown は環境タイプが確認できなかったことを意味します(通常は環境の記録が不完全)。率直にユーザーに伝え、デプロイゲートは処理を許可していること、その環境では自動デプロイが無効なこと、sf org login web で再認証すれば通常は分類が復旧することを説明してください。
以下のいずれかから検証済みジョブを取得します:
.sfdx/last-validation.json が存在すればそこから読み込む(platform-deploy-validate が作成)--use-most-recent にフォールバック(過去3日以内の検証を使用)--use-most-recent 使用時 → 3日以内であることcreatedAt がこの期間を超えている場合 → 処理を中止し、先に platform-deploy-validate を実行してください確認ブロックを表示し(エイリアス、インスタンスURL、エディション、検証済み部品数、テスト結果を含む)、「本番環境へのデプロイを実行しますか?(はい/いいえ)」と尋ねます。明確な「はい」なしには先に進まないでください。
以下の形式で表示してください:
┌─ 本番環境デプロイ ─────────────────────────────┐
│ 環境エイリアス: <alias> │
│ インスタンス: <instanceUrl> │
│ エディション: <edition> │
│ 検証ID: <jobId> │
│ 検証日時: <createdAt> (X日前) │
│ 部品数: <componentCount> 件 待機中 │
│ テスト: <run>件実行/<passed>件成功/<failed>件失敗 │
└─────────────────────────────────────────────────┘
本番環境へのデプロイを実行しますか?(はい/いいえ)
「はい」と答えた後:
sf project deploy quick --job-id <id> --target-org <alias> --wait 30 --json
または、ユーザーが同意した場合は --use-most-recent を使用します。
迅速デプロイは以下を実行します:
完了後、監査用に以下を永続化してください:
mkdir -p .sfdx/deploy-history
sf project deploy report --job-id <id> --target-org <alias> --json > ".sfdx/deploy-history/<id>.json"
ユーザーに表示する内容:
本番環境へのデプロイが成功した後、以下を提案してください:
sf project deploy start を本番環境に対して実行しない(必ず検証してから迅速デプロイを使う)--ignore-errors(エラーを無視)や --ignore-warnings(警告を無視)を使わない.sfdx/deploy-history/ に保存して監査証跡を残すplatform-deploy-validate を実行することを推奨するPromote a validated deploy to a Production org using the job ID from a prior sf project deploy validate. No tests re-run, no components re-validated — just the promotion.
Before doing ANYTHING, verify all four:
Target is Production
Confirm the target really is production with the gate's classifier, which resolves the org the same way the deploy hook does (returns production|sandbox|scratch|trial|unknown):
"${CLAUDE_PLUGIN_ROOT}/scripts/sf-deploy-gate" bucket <alias>
Production means not a scratch org or sandbox (no -- or test.salesforce.com host marker) and not a trial/Developer Edition org (orgfarm-*, *.develop.my.salesforce.com, *.pc-rnd.* hosts, or a future trial expiration date, as on SDOs). A Dev Hub with none of those signals is production.
If target is NOT production (classifier returns anything other than production) → STOP and redirect to platform-metadata-deploy (which handles non-prod natively). 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.
A validation exists
.sfdx/last-validation.json if it exists (left there by platform-deploy-validate)--use-most-recent (validates within last 3 days)Validation is fresh enough
--job-id: must be ≤10 days old per Salesforce's quick-deploy window--use-most-recent: must be ≤3 days oldcreatedAt exceeds the window → STOP and run platform-deploy-validate firstExplicit user confirmation
Format exactly:
┌─ PRODUCTION DEPLOY ─────────────────────────────┐
│ Org alias: <alias> │
│ Instance: <instanceUrl> │
│ Edition: <edition> │
│ Validation ID: <jobId> │
│ Validated: <createdAt> (X days ago) │
│ Components: <componentCount> queued │
│ Tests: <run>/<passed>/<failed> │
└─────────────────────────────────────────────────┘
Confirm deploy to PRODUCTION? (yes/no)
After "yes":
sf project deploy quick --job-id <id> --target-org <alias> --wait 30 --json
Or with --use-most-recent if the user opted in.
The quick deploy will:
After completion, persist for audit:
mkdir -p .sfdx/deploy-history
sf project deploy report --job-id <id> --target-org <alias> --json > ".sfdx/deploy-history/<id>.json"
Surface to the user:
After a successful prod deploy, suggest:
sf project deploy start against a Production target (always validate then quick-deploy)--ignore-errors or --ignore-warnings on production.sfdx/deploy-history/ for the audit trailplatform-deploy-validate first原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。