platform-metadata-deploy

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

platform-metadata-deploy: Comprehensive Salesforce DevOps Automation

platform-metadata-deploy:Salesforce DevOps自动化全指南

Use this skill when the user needs deployment orchestration: dry-run validation, targeted or manifest-based deploys, CI/CD workflow advice, scratch-org management, failure triage, or safe rollout sequencing for Salesforce metadata.
当用户需要部署编排时使用本技能:包括预演验证、定向或基于清单的部署、CI/CD工作流建议、临时环境(scratch-org)管理、故障排查,或Salesforce元数据的安全发布排序。

When This Skill Owns the Task

本技能适用任务场景

Use
platform-metadata-deploy
when the work involves:
  • sf project deploy start
    ,
    quick
    ,
    report
    , or retrieval workflows
  • release sequencing across objects, permission sets, Apex, and Flows
  • CI/CD gates, test-level selection, or deployment reports
  • troubleshooting deployment failures and dependency ordering
Delegate elsewhere when the user is:
  • authoring Apex code → platform-apex-generate
  • authoring LWC components → experience-lwc-generate
  • creating custom objects or fields → platform-custom-object-generate, platform-custom-field-generate
  • building Flows → automation-flow-generate
  • doing org data operations → platform-data-manage
  • authoring or testing Agentforce agents → agentforce-generate

当工作涉及以下内容时,使用
platform-metadata-deploy
  • sf project deploy start
    quick
    report
    或检索工作流
  • 跨对象、权限集、Apex和Flow的发布排序
  • CI/CD关卡、测试级别选择或部署报告
  • 排查部署失败问题和依赖顺序
当用户进行以下操作时,请转用其他技能:
  • 编写Apex代码 → platform-apex-generate
  • 编写LWC组件 → experience-lwc-generate
  • 创建自定义对象或字段 → platform-custom-object-generateplatform-custom-field-generate
  • 构建Flow → automation-flow-generate
  • 执行组织数据操作 → platform-data-manage
  • 编写或测试Agentforce代理 → agentforce-generate

Critical Operating Rules

核心操作规则

  • Use
    sf
    CLI v2 only
    .
  • On non-source-tracking orgs, deploy/retrieve commands require an explicit scope such as
    --source-dir
    ,
    --metadata
    , or
    --manifest
    .
  • Prefer
    --dry-run
    first
    before real deploys.
  • For Flows, deploy safely and activate only after validation.
  • Keep test-data creation guidance delegated to
    platform-data-manage
    after metadata is validated or deployed.
  • 仅使用**
    sf
    CLI v2**。
  • 在无源码追踪的组织中,部署/检索命令需要明确的范围,例如
    --source-dir
    --metadata
    --manifest
  • 实际部署前优先使用**
    --dry-run
    预演**。
  • 对于Flow,需安全部署,仅在验证后激活。
  • 测试数据创建指导需在元数据验证或部署后,委托给**
    platform-data-manage
    **处理。

Default deployment order

默认部署顺序

PhaseMetadata
1Custom objects / fields
2Permission sets
3Apex
4Flows as Draft
5Flow activation / post-verify
This ordering prevents many dependency and FLS failures.

阶段元数据
1自定义对象/字段
2权限集
3Apex
4草稿状态的Flow
5Flow激活/部署后验证
此顺序可避免许多依赖和FLS(字段级安全)失败问题。

Required Context to Gather First

需优先收集的必要信息

Ask for or infer:
  • target org alias and environment type
  • deployment scope: source-dir, metadata list, or manifest
  • whether this is validate-only, deploy, quick deploy, retrieve, or CI/CD guidance
  • required test level and rollback expectations
  • whether special metadata types are involved (Flow, permission sets, agents, packages)
Preflight checks:
bash
sf --version
sf org list
sf org display --target-org <alias> --json
test -f sfdx-project.json

询问或推断:
  • 目标组织别名和环境类型
  • 部署范围:source-dir、元数据列表或清单
  • 本次操作是仅验证、部署、快速部署、检索还是CI/CD指导
  • 所需测试级别和回滚预期
  • 是否涉及特殊元数据类型(Flow、权限集、代理、包)
预检命令:
bash
sf --version
sf org list
sf org display --target-org <alias> --json
test -f sfdx-project.json

Recommended Workflow

推荐工作流

1. Preflight

1. 预检

Confirm auth, repo shape, package directories, and target scope.
确认身份验证、代码库结构、包目录和目标范围。

2. Validate first

2. 优先验证

bash
sf project deploy start --dry-run --source-dir force-app --target-org <alias> --wait 30 --json
Use manifest- or metadata-scoped validation when the change set is targeted.
bash
sf project deploy start --dry-run --source-dir force-app --target-org <alias> --wait 30 --json
当变更集为定向时,使用基于清单或元数据范围的验证。

3. If validation succeeds, offer the next safe workflow

3. 验证成功后,提供下一步安全工作流

After a successful validation, guide the user to the correct next action:
  1. deploy now
  2. assign permission sets
  3. create test data via platform-data-manage
  4. run tests / smoke checks
  5. orchestrate multiple post-deploy steps in order
验证成功后,引导用户执行正确的后续操作:
  1. 立即部署
  2. 分配权限集
  3. 通过platform-data-manage创建测试数据
  4. 运行测试/冒烟测试
  5. 按顺序编排多个部署后步骤

4. Deploy the smallest correct scope

4. 部署最小且正确的范围

bash
undefined
bash
undefined

source-dir deploy

基于source-dir的部署

sf project deploy start --source-dir force-app --target-org <alias> --wait 30 --json
sf project deploy start --source-dir force-app --target-org <alias> --wait 30 --json

manifest deploy

基于清单的部署

sf project deploy start --manifest manifest/package.xml --target-org <alias> --test-level RunLocalTests --wait 30 --json
sf project deploy start --manifest manifest/package.xml --target-org <alias> --test-level RunLocalTests --wait 30 --json

manifest deploy with Spring '26 relevant-test selection

针对Spring '26版本的相关测试选择的清单部署

sf project deploy start --manifest manifest/package.xml --target-org <alias> --test-level RunRelevantTests --wait 30 --json
sf project deploy start --manifest manifest/package.xml --target-org <alias> --test-level RunRelevantTests --wait 30 --json

quick deploy after successful validation

验证成功后的快速部署

sf project deploy quick --job-id <validation-job-id> --target-org <alias> --json
undefined
sf project deploy quick --job-id <validation-job-id> --target-org <alias> --json
undefined

5. Verify

5. 验证

bash
sf project deploy report --job-id <job-id> --target-org <alias> --json
Then verify tests, Flow state, permission assignments, and smoke-test behavior.
bash
sf project deploy report --job-id <job-id> --target-org <alias> --json
然后验证测试结果、Flow状态、权限分配和冒烟测试行为。

6. Report clearly

6. 清晰报告

Summarize what deployed, what failed, what was skipped, and what the next safe action is.
Output template: references/deployment-report-template.md

总结已部署内容、失败内容、跳过内容以及下一步安全操作。
输出模板:references/deployment-report-template.md

High-Signal Failure Patterns

高信号失败模式

Error / symptomLikely causeDefault fix direction
FIELD_CUSTOM_VALIDATION_EXCEPTION
validation rule or bad test dataadjust data or rule timing
INVALID_CROSS_REFERENCE_KEY
missing dependencyinclude referenced metadata first
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
trigger / Flow / validation side effectinspect automation stack and failing logic
tests fail during deploybroken code or fragile testsrun targeted tests, fix root cause, revalidate
field/object not found in permsetwrong orderdeploy objects/fields before permission sets
Flow invalid / version conflictdependency or activation problemdeploy as Draft, verify, then activate
Full workflows: references/orchestration.md, references/trigger-deployment-safety.md

错误/症状可能原因默认修复方向
FIELD_CUSTOM_VALIDATION_EXCEPTION
验证规则或测试数据错误调整数据或规则执行时机
INVALID_CROSS_REFERENCE_KEY
缺少依赖项先包含被引用的元数据
CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY
触发器/Flow/验证的副作用检查自动化栈和失败逻辑
部署期间测试失败代码损坏或测试不稳定运行定向测试,修复根本原因,重新验证
权限集中未找到字段/对象部署顺序错误先部署对象/字段,再部署权限集
Flow无效/版本冲突依赖或激活问题以草稿状态部署,验证后再激活
完整工作流:references/orchestration.mdreferences/trigger-deployment-safety.md

CI/CD Guidance

CI/CD指导

Default pipeline shape:
  1. authenticate
  2. validate repo / org state
  3. static analysis
  4. dry-run deploy
  5. tests + coverage gates
  6. deploy
  7. verify + notify
  • When org policy and release risk allow it, consider
    --test-level RunRelevantTests
    for Apex-heavy deployments.
  • Pair this with modern Apex test annotations such as
    @IsTest(testFor=...)
    and
    @IsTest(isCritical=true)
    — see platform-apex-generate for authoring guidance.
Static analysis now uses Code Analyzer v5 (
sf code-analyzer
), not retired
sf scanner
.
Deep reference: references/deployment-workflows.md

默认流水线结构:
  1. 身份验证
  2. 验证代码库/组织状态
  3. 静态分析
  4. 预演部署
  5. 测试+覆盖率关卡
  6. 部署
  7. 验证+通知
  • 当组织策略和发布风险允许时,针对Apex密集型部署可考虑使用
    --test-level RunRelevantTests
  • 搭配现代Apex测试注解,如
    @IsTest(testFor=...)
    @IsTest(isCritical=true)
    — 编写指导请参考platform-apex-generate
静态分析现在使用Code Analyzer v5
sf code-analyzer
),而非已停用的
sf scanner
深度参考:references/deployment-workflows.md

Agentforce Deployment Note

Agentforce部署说明

Use this skill to orchestrate deployment/publish sequencing around agents, but use the agent-specific skill for authoring decisions:
  • agentforce-generate for
    .agent
    authoring, Agent Builder, Prompt Builder, and metadata config
For full agent DevOps details, including
Agent:
pseudo metadata, publish/activate, and sync-between-orgs, see:
  • references/agent-deployment-guide.md

使用本技能编排代理相关的部署/发布顺序,但代理编写决策请使用专门技能:
  • agentforce-generate用于
    .agent
    编写、Agent Builder、Prompt Builder和元数据配置
有关代理DevOps的完整细节,包括
Agent:
伪元数据、发布/激活以及跨组织同步,请查看:
  • references/agent-deployment-guide.md

Cross-Skill Integration

跨技能集成

NeedDelegate toReason
custom object creationplatform-custom-object-generatedefine objects before deploy
custom field creationplatform-custom-field-generatedefine fields before deploy
Apex authoring / fixesplatform-apex-generatecode authoring and repair
Flow creation / repairautomation-flow-generateFlow authoring and activation guidance
test data or seed recordsplatform-data-managedescribe-first data setup and cleanup
Agent authoring and publish readinessagentforce-generateagent-specific correctness

需求转用技能原因
自定义对象创建platform-custom-object-generate部署前定义对象
自定义字段创建platform-custom-field-generate部署前定义字段
Apex编写/修复platform-apex-generate代码编写与修复
Flow创建/修复automation-flow-generateFlow编写与激活指导
测试数据或种子记录platform-data-manage先描述再进行数据设置与清理
代理编写与发布就绪检查agentforce-generate代理专属正确性检查

Reference Map

参考地图

Start here

入门参考

  • references/orchestration.md
  • references/deployment-workflows.md
  • references/deployment-report-template.md
  • references/orchestration.md
  • references/deployment-workflows.md
  • references/deployment-report-template.md

Specialized deployment safety

专项部署安全

  • references/trigger-deployment-safety.md
  • references/agent-deployment-guide.md
  • references/deploy.sh
  • references/trigger-deployment-safety.md
  • references/agent-deployment-guide.md
  • references/deploy.sh

Asset templates

资产模板

  • assets/package.xml — manifest template covering common metadata types
  • assets/destructiveChanges.xml — template for removing metadata from target orgs

  • assets/package.xml — 涵盖常见元数据类型的清单模板
  • assets/destructiveChanges.xml — 用于从目标组织移除元数据的模板

Score Guide

评分指南

ScoreMeaning
90+strong deployment plan and execution guidance
75–89good deploy guidance with minor review items
60–74partial coverage of deployment risk
< 60insufficient confidence; tighten plan before rollout

分数含义
90+完善的部署计划与执行指导
75–89良好的部署指导,存在少量需审查项
60–74部分覆盖部署风险
< 60信心不足;发布前需收紧计划

Completion Format

完成格式

text
Deployment goal: <validate / deploy / retrieve / pipeline>
Target org: <alias>
Scope: <source-dir / metadata / manifest>
Result: <passed / failed / partial>
Key findings: <errors, ordering, tests, skipped items>
Next step: <safe follow-up action>
text
Deployment goal: <validate / deploy / retrieve / pipeline>
Target org: <alias>
Scope: <source-dir / metadata / manifest>
Result: <passed / failed / partial>
Key findings: <errors, ordering, tests, skipped items>
Next step: <safe follow-up action>