platform-manifest-generate
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseplatform-manifest-generate
platform-manifest-generate
Produce a Salesforce metadata manifest — (or one of the destructive variants) — from local source, an org, or an explicit component list. This skill is purely about authoring the manifest file. Hand off to or once the file exists.
package.xmlplatform-metadata-deployplatform-destructive-deploy从本地源、组织或明确的组件列表生成Salesforce元数据清单——(或其中一种破坏性变体)。本Skill仅负责创建清单文件。文件生成完成后,可移交至或进行后续操作。
package.xmlplatform-metadata-deployplatform-destructive-deployTool Restrictions
工具限制
Use ONLY the Bash tool to run , and the tool for the hand-built fallback path. Do NOT use MCP tools.
sf project generate manifestWrite仅可使用Bash工具运行,手动构建备选路径时使用工具。请勿使用MCP工具。
sf project generate manifestWriteWhen This Skill Owns the Task
本Skill负责的任务场景
Use when the work involves any of:
platform-manifest-generate- Building a from a source directory (e.g.
package.xml)force-app/main/default/classes/ - Building a manifest from an explicit list of components (e.g. ,
AccountService,ContactSelector)Account - Building a manifest by introspecting an org via
--from-org - Producing ,
destructiveChanges.xml, ordestructiveChangesPre.xmlfor a deletiondestructiveChangesPost.xml - Producing both a and a destructive manifest in one operation
package.xml
Delegate elsewhere when the user is:
- Running the deploy itself →
platform-metadata-deploy - Validating before a prod release →
platform-deploy-validate - Executing the destructive deploy → (that skill uses the manifest this skill generates)
platform-destructive-deploy - Retrieving metadata to local →
platform-metadata-retrieve
当工作涉及以下任一内容时,使用:
platform-manifest-generate- 从源目录构建(例如
package.xml)force-app/main/default/classes/ - 从明确的组件列表构建清单(例如、
AccountService、ContactSelector)Account - 通过参数从组织内省构建清单
--from-org - 为删除操作生成、
destructiveChanges.xml或destructiveChangesPre.xmldestructiveChangesPost.xml - 一次操作同时生成和破坏性清单
package.xml
当用户需要以下操作时,请移交至其他Skill:
- 执行部署本身 →
platform-metadata-deploy - 生产环境发布前验证 →
platform-deploy-validate - 执行破坏性部署 → (该Skill会使用本Skill生成的清单)
platform-destructive-deploy - 将元数据检索到本地 →
platform-metadata-retrieve
Two Generation Paths
两种生成路径
Path A — CLI-driven (recommended)
路径A — CLI驱动(推荐)
Wrap . Always prefer this path; it knows about every metadata type and produces canonical XML — and never emits , sidestepping the wildcard hazard entirely.
sf project generate manifest*The CLI offers three input modes (mutually exclusive):
| Input | Flag | Use when |
|---|---|---|
| Source directory | | User points to a folder containing already-on-disk metadata |
| Component list | | User names specific components, e.g. |
| Org introspection | | User wants every component currently in an org (or a filtered subset) |
You can specify either or , not both. may be combined with (filter included types) or (filter out types).
--source-dir--metadata--from-org--metadata--excluded-metadataVerified flags (do not invent flags — verify with if unsure):
sf project generate manifest --help| Flag | Purpose |
|---|---|
| Local source paths to scan |
| Component names to include (e.g. |
| Username or alias of org to introspect |
| Custom output filename (mutually exclusive with |
| Predefined manifest kind: |
| Directory to write the manifest into |
| Override the API version for the request |
| Include |
| Types to exclude when using |
| Machine-readable output |
Manifest filename by :
--type | Output file |
|---|---|
| |
| |
| |
| |
You can specify either or , not both.
--type--name封装命令。请优先使用此路径;它了解所有元数据类型,可生成标准XML,且绝不会输出,完全规避了通配符风险。
sf project generate manifest*CLI提供三种互斥的输入模式:
| 输入类型 | 参数 | 使用场景 |
|---|---|---|
| 源目录 | | 用户指向包含已存储在磁盘上元数据的文件夹 |
| 组件列表 | | 用户指定具体组件,例如 |
| 组织内省 | | 用户需要获取组织中当前的所有组件(或筛选后的子集) |
你只能指定或中的一个,不能同时指定。可与(筛选包含的类型)或(筛选排除的类型)结合使用。
--source-dir--metadata--from-org--metadata--excluded-metadata已验证的参数(请勿自行发明参数——如有疑问,请通过验证):
sf project generate manifest --help| 参数 | 用途 |
|---|---|
| 要扫描的本地源路径 |
| 要包含的组件名称(例如 |
| 要内省的组织的用户名或别名 |
| 自定义输出文件名(与 |
| 预定义的清单类型: |
| 写入清单的目录 |
| 覆盖请求的API版本 |
| 使用 |
| 使用 |
| 机器可读的输出格式 |
按划分的清单文件名:
--type | 输出文件 |
|---|---|
| |
| |
| |
| |
你只能指定或中的一个,不能同时指定。
--type--nameCanonical CLI examples
标准CLI示例
bash
undefinedbash
undefinedBuild package.xml from a source dir
从源目录构建package.xml
sf project generate manifest
--source-dir force-app/main/default
--name package.xml
--output-dir manifest
--json
--source-dir force-app/main/default
--name package.xml
--output-dir manifest
--json
sf project generate manifest
--source-dir force-app/main/default
--name package.xml
--output-dir manifest
--json
--source-dir force-app/main/default
--name package.xml
--output-dir manifest
--json
Build package.xml from an explicit component list
从明确的组件列表构建package.xml
sf project generate manifest
--metadata ApexClass:AccountService
--metadata ApexClass:ContactSelector
--metadata CustomObject:Account
--name package.xml
--output-dir manifest
--json
--metadata ApexClass:AccountService
--metadata ApexClass:ContactSelector
--metadata CustomObject:Account
--name package.xml
--output-dir manifest
--json
sf project generate manifest
--metadata ApexClass:AccountService
--metadata ApexClass:ContactSelector
--metadata CustomObject:Account
--name package.xml
--output-dir manifest
--json
--metadata ApexClass:AccountService
--metadata ApexClass:ContactSelector
--metadata CustomObject:Account
--name package.xml
--output-dir manifest
--json
Build destructiveChanges.xml from a component list
从组件列表构建destructiveChanges.xml
sf project generate manifest
--metadata CustomField:Account.OldField__c
--metadata CustomField:Account.OldStatus__c
--type destroy
--output-dir manifest
--json
--metadata CustomField:Account.OldField__c
--metadata CustomField:Account.OldStatus__c
--type destroy
--output-dir manifest
--json
sf project generate manifest
--metadata CustomField:Account.OldField__c
--metadata CustomField:Account.OldStatus__c
--type destroy
--output-dir manifest
--json
--metadata CustomField:Account.OldField__c
--metadata CustomField:Account.OldStatus__c
--type destroy
--output-dir manifest
--json
Build a manifest by introspecting an org (filtered)
通过内省组织构建筛选后的清单
sf project generate manifest
--from-org <alias>
--metadata ApexClass,CustomObject,CustomLabels
--output-dir manifest
--json
--from-org <alias>
--metadata ApexClass,CustomObject,CustomLabels
--output-dir manifest
--json
If both a `package.xml` and a destructive manifest are needed, run the CLI twice — once with `--type package` (or default), once with `--type destroy` / `pre` / `post`.sf project generate manifest
--from-org <alias>
--metadata ApexClass,CustomObject,CustomLabels
--output-dir manifest
--json
--from-org <alias>
--metadata ApexClass,CustomObject,CustomLabels
--output-dir manifest
--json
如果同时需要`package.xml`和破坏性清单,请运行两次CLI——一次使用`--type package`(或默认),一次使用`--type destroy`/`pre`/`post`。Path B — Hand-built fallback
路径B — 手动构建备选方案
Use this only when the CLI cannot express the user's intent — e.g. they want "just the Apex classes I changed today" and the change set is derived from rather than a clean directory or component list. In that case:
git diff- Resolve the components yourself (e.g. parse and map paths back to metadata types).
git diff --name-only - Group by metadata type.
- Emit the XML inline using the schema below.
- Always cross-check by running (hand off to
sf project deploy start --manifest <file> --dry-run).platform-metadata-deploy
仅当CLI无法表达用户意图时使用此路径——例如,用户需要“仅包含我今天修改的Apex类”,且变更集来自而非整洁的目录或组件列表。这种情况下:
git diff- 自行解析组件(例如解析的结果,并将路径映射回元数据类型)。
git diff --name-only - 按元数据类型分组。
- 使用以下架构内联生成XML。
- 务必通过运行进行交叉检查(移交至
sf project deploy start --manifest <file> --dry-run)。platform-metadata-deploy
Manifest XML schema
清单XML架构
Root element is in the metadata namespace. Each metadata type gets one block containing one per component plus a single . The trailing declares the API version for the manifest.
<Package><types><members><name><version>xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>AccountService</members>
<members>ContactSelector</members>
<name>ApexClass</name>
</types>
<types>
<members>Account</members>
<name>CustomObject</name>
</types>
<types>
<members>Account.Status__c</members>
<name>CustomField</name>
</types>
<version>62.0</version>
</Package>Notes:
- For component-bound types like ,
CustomField,BusinessProcess,RecordType,Layout,ListView,ValidationRule, members useWebLinknotation.Object.Name - ,
destructiveChanges.xml, anddestructiveChangesPre.xmluse the same XML structure — only the filename and intent differ.destructiveChangesPost.xml - An empty manifest (no blocks) is legal and is sometimes paired with a destructive manifest:
<types>
xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<version>62.0</version>
</Package>根元素是元数据命名空间中的。每个元数据类型对应一个块,包含每个组件的元素以及一个元素。末尾的元素声明清单的API版本。
<Package><types><members><name><version>xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>AccountService</members>
<members>ContactSelector</members>
<name>ApexClass</name>
</types>
<types>
<members>Account</members>
<name>CustomObject</name>
</types>
<types>
<members>Account.Status__c</members>
<name>CustomField</name>
</types>
<version>62.0</version>
</Package>注意事项:
- 对于、
CustomField、BusinessProcess、RecordType、Layout、ListView、ValidationRule等绑定到对象的组件类型,成员需使用WebLink格式。Object.Name - 、
destructiveChanges.xml和destructiveChangesPre.xml使用相同的XML结构——仅文件名和用途不同。destructiveChangesPost.xml - 空清单(无块)是合法的,有时会与破坏性清单配合使用:
<types>
xml
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<version>62.0</version>
</Package>API Version Handling
API版本处理
The element at the bottom of every manifest must reflect the project's API version.
<version>Resolution order:
- Read from
sourceApiVersionat the project root.sfdx-project.json - If was passed by the user, use that instead.
--api-version - If neither is available, fall back to the value reported by (the CLI's bundled API version) — but warn the user and recommend they set
sf --versioninsourceApiVersionfor reproducibility.sfdx-project.json - Never silently hardcode a value (e.g. ) into output without surfacing the source.
62.0
bash
undefined每个清单底部的元素必须反映项目的API版本。
<version>解析顺序:
- 从项目根目录的中读取
sfdx-project.json。sourceApiVersion - 如果用户传入了参数,则使用该参数值。
--api-version - 如果以上两者都不可用,则回退到报告的值(CLI捆绑的API版本)——但需警告用户,并建议他们在
sf --version中设置sfdx-project.json以确保可重复性。sourceApiVersion - 切勿在未告知来源的情况下,将值(例如)静默硬编码到输出中。
62.0
bash
undefinedQuick read of sourceApiVersion
快速读取sourceApiVersion
jq -r '.sourceApiVersion' sfdx-project.json
When using the CLI path, omit `--api-version` unless the user explicitly overrides — the CLI already reads `sourceApiVersion`.
---jq -r '.sourceApiVersion' sfdx-project.json
使用CLI路径时,除非用户明确覆盖,否则省略`--api-version`参数——CLI会自动读取`sourceApiVersion`。
---Wildcard Members (<members>*</members>
)
<members>*</members>通配符成员(<members>*</members>
)
<members>*</members>A wildcard member matches every component of that metadata type. It is not legal for every type. Using for a disallowed type causes deploy/retrieve errors like .
*Wildcards are not supported for this metadata type通配符成员匹配该元数据类型的所有组件。并非所有类型都支持通配符。对不支持的类型使用会导致部署/检索错误,例如。
*Wildcards are not supported for this metadata typeWildcard NOT allowed (must enumerate)
不允许使用通配符(必须枚举)
These types require explicit member names. Common examples: , , , , , , (in some package configurations), , , , and most "container" types whose contents are object-bound (, , , , , , ).
ProfilePermissionSetPermissionSetGroupCustomLabelsCustomObjectTranslationLayoutWorkflowSharingRulesStandardValueSetManagedTopicsCustomFieldRecordTypeBusinessProcessListViewValidationRuleWebLinkCompactLayoutFor these, enumerate explicitly:
xml
<types>
<members>Admin</members>
<members>Standard User</members>
<name>Profile</name>
</types>这些类型需要明确的成员名称。常见示例:、、、、、、(在某些包配置中)、、、,以及大多数内容绑定到对象的“容器”类型(、、、、、、)。
ProfilePermissionSetPermissionSetGroupCustomLabelsCustomObjectTranslationLayoutWorkflowSharingRulesStandardValueSetManagedTopicsCustomFieldRecordTypeBusinessProcessListViewValidationRuleWebLinkCompactLayout对于这些类型,请明确枚举:
xml
<types>
<members>Admin</members>
<members>Standard User</members>
<name>Profile</name>
</types>Wildcard generally allowed
通常允许使用通配符
Most "self-contained" component types accept . Examples: , , , , , , , , , , , , , , . See references/wildcard-allowlist.md for the full enumeration and edge cases.
*ApexClassApexTriggerApexComponentApexPageAuraDefinitionBundleLightningComponentBundleCustomApplicationCustomTabStaticResourceEmailTemplateReportDashboardFlowFlexiPageCustomMetadataRule of thumb: if you are not certain, list the components explicitly. The CLI path ( / ) sidesteps this problem because it never emits .
--source-dir--metadata*大多数“独立”组件类型支持。示例:、、、、、、、、、、、、、、。完整枚举和边缘情况请参见references/wildcard-allowlist.md。
*ApexClassApexTriggerApexComponentApexPageAuraDefinitionBundleLightningComponentBundleCustomApplicationCustomTabStaticResourceEmailTemplateReportDashboardFlowFlexiPageCustomMetadata经验法则:如果不确定,请明确列出组件。CLI路径(/)不会输出,因此可规避此问题。
--source-dir--metadata*Examples
示例
Example 1 — Build package.xml
from a directory
package.xml示例1 — 从目录构建package.xml
package.xml"Generate package.xml from"force-app/main/default/classes/
bash
sf project generate manifest \
--source-dir force-app/main/default/classes \
--name package.xml \
--output-dir manifest \
--jsonResult: listing every Apex class in that folder.
manifest/package.xml“从生成package.xml”force-app/main/default/classes/
bash
sf project generate manifest \
--source-dir force-app/main/default/classes \
--name package.xml \
--output-dir manifest \
--json结果:列出该文件夹中的所有Apex类。
manifest/package.xmlExample 2 — Build a manifest covering specific components
示例2 — 构建包含特定组件的清单
"Build a manifest covering AccountService, ContactSelector, and the Account custom object"
bash
sf project generate manifest \
--metadata ApexClass:AccountService \
--metadata ApexClass:ContactSelector \
--metadata CustomObject:Account \
--name package.xml \
--output-dir manifest \
--jsonResult: containing exactly those three components.
manifest/package.xml“构建包含AccountService、ContactSelector和Account自定义对象的清单”
bash
sf project generate manifest \
--metadata ApexClass:AccountService \
--metadata ApexClass:ContactSelector \
--metadata CustomObject:Account \
--name package.xml \
--output-dir manifest \
--json结果:仅包含这三个组件。
manifest/package.xmlExample 3 — Generate both package.xml
and destructiveChanges.xml
for deletions
package.xmldestructiveChanges.xml示例3 — 为删除操作同时生成package.xml
和destructiveChanges.xml
package.xmldestructiveChanges.xml"Create both package.xml and destructiveChanges.xml for these deletions:,Account.OldField__c"Account.OldStatus__c
bash
undefined“为以下删除操作同时创建package.xml和destructiveChanges.xml:、Account.OldField__c”Account.OldStatus__c
bash
undefinedEmpty/minimal package.xml (deletion-only deploy still needs a package descriptor)
空/最小化package.xml(仅删除的部署仍需要包描述符)
sf project generate manifest
--metadata CustomLabels
--name package.xml
--output-dir manifest
--json
--metadata CustomLabels
--name package.xml
--output-dir manifest
--json
sf project generate manifest
--metadata CustomLabels
--name package.xml
--output-dir manifest
--json
--metadata CustomLabels
--name package.xml
--output-dir manifest
--json
destructiveChanges.xml
destructiveChanges.xml
sf project generate manifest
--metadata CustomField:Account.OldField__c
--metadata CustomField:Account.OldStatus__c
--type destroy
--output-dir manifest
--json
--metadata CustomField:Account.OldField__c
--metadata CustomField:Account.OldStatus__c
--type destroy
--output-dir manifest
--json
After generation, hand off to `platform-destructive-deploy` to validate and execute the deletion.
---sf project generate manifest
--metadata CustomField:Account.OldField__c
--metadata CustomField:Account.OldStatus__c
--type destroy
--output-dir manifest
--json
--metadata CustomField:Account.OldField__c
--metadata CustomField:Account.OldStatus__c
--type destroy
--output-dir manifest
--json
生成完成后,移交至`platform-destructive-deploy`进行验证和执行删除操作。
---Failure Modes
故障模式
| Symptom | Likely cause | Recovery |
|---|---|---|
| | Confirm the path; use |
| Generated manifest is empty | Source dir contained no recognizable metadata, or all files were ignored | Check |
| Hand-built manifest used | See the wildcard allowlist above; enumerate the components explicitly |
| | Add |
| CLI invocation passed both flags | Drop one; use |
| CLI invocation passed both | Pick one input mode |
Components missing from | Org introspection batched too aggressively, or the type is in a managed package | Set |
| 症状 | 可能原因 | 解决方法 |
|---|---|---|
| | 确认路径;使用 |
| 生成的清单为空 | 源目录中没有可识别的元数据,或所有文件都被忽略 | 检查 |
部署时出现 | 手动构建的清单对不支持的类型使用了 | 参见上方的通配符允许列表;明确枚举组件 |
| | 在 |
| CLI调用同时传递了两个参数 | 删除其中一个;使用 |
| CLI调用同时传递了两个参数 | 选择一种输入模式 |
| 组织内省的批处理过于激进,或类型属于托管包 | 降低 |
Cross-Skill Integration
跨Skill集成
| Need | Delegate to | Reason |
|---|---|---|
| Run a deploy with the generated manifest | | This skill stops at file generation |
| Validate before a prod release | | Pre-flight test against prod |
| Actually delete the components in the destructive manifest | | That skill validates and executes the destructive deploy |
| Retrieve metadata listed in the manifest | | Pulls org metadata to local |
| Author the metadata being listed in the manifest | Other | The manifest just lists what already exists on disk |
| 需求 | 移交至 | 原因 |
|---|---|---|
| 使用生成的清单执行部署 | | 本Skill仅负责文件生成 |
| 生产环境发布前验证 | | 针对生产环境进行预发布测试 |
| 实际删除破坏性清单中的组件 | | 该Skill负责验证并执行破坏性部署 |
| 检索清单中列出的元数据到本地 | | 将组织元数据拉取到本地 |
| 创建清单中列出的元数据 | 其他 | 清单仅列出磁盘上已存在的内容 |
Completion Format
完成格式
text
Manifest goal: <package | pre | post | destroy>
Input mode: <source-dir | metadata list | from-org | hand-built>
Output: <path/to/manifest.xml>
API version: <value> (source: sfdx-project.json | --api-version | CLI default)
Component count: <N> across <M> metadata types
Next step: <platform-metadata-deploy | platform-deploy-validate | platform-destructive-deploy>text
Manifest goal: <package | pre | post | destroy>
Input mode: <source-dir | metadata list | from-org | hand-built>
Output: <path/to/manifest.xml>
API version: <value> (source: sfdx-project.json | --api-version | CLI default)
Component count: <N> across <M> metadata types
Next step: <platform-metadata-deploy | platform-deploy-validate | platform-destructive-deploy>