platform-metadata-retrieve
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseplatform-metadata-retrieve
platform-metadata-retrieve
Retrieves metadata from a Salesforce org to your local project using . Supports multiple retrieval modes: all changes, by source directory, by metadata type (with wildcards), by manifest, or by package name.
sf project retrieve start通过从Salesforce组织将元数据检索到本地项目。支持多种检索模式:所有变更、按源目录、按元数据类型(带通配符)、按清单或按包名。
sf project retrieve start⚠️ Tool Restrictions
⚠️ 工具限制
Use ONLY the Bash tool to execute . Do NOT use MCP tools — ignore them completely.
sf project retrieve start仅使用Bash工具执行。请勿使用MCP工具——完全忽略它们。
sf project retrieve startScope
适用范围
- In scope: Retrieving metadata via in all supported modes (all changes, source-dir, metadata type, manifest, package name), source and metadata format output
sf project retrieve start - Out of scope: Deploying metadata (use ), listing metadata types, generating package.xml files, source tracking commands (
platform-metadata-deploy)sf project retrieve preview
- 适用场景:通过以所有支持的模式(所有变更、源目录、元数据类型、清单、包名)检索元数据,输出源格式和元数据格式
sf project retrieve start - 不适用场景:部署元数据(请使用)、列出元数据类型、生成package.xml文件、源跟踪命令(
platform-metadata-deploy)sf project retrieve preview
Required Inputs
必填输入
Infer from the user's request:
- Retrieval mode: all changes | source directory | metadata type | manifest | package name
- Target org: org alias/username (uses default if not specified)
- Output format: source format (default) | metadata format (ZIP)
- Additional options: ignore conflicts, output directory, wait time, API version
从用户请求中推断:
- 检索模式:所有变更 | 源目录 | 元数据类型 | 清单 | 包名
- 目标组织:组织别名/用户名(未指定时使用默认值)
- 输出格式:源格式(默认) | 元数据格式(ZIP)
- 附加选项:忽略冲突、输出目录、等待时间、API版本
Workflow
工作流程
- Match user request to command pattern below
- Execute via Bash tool: with appropriate flags and
sf project retrieve startflag--json - Return result with retrieved components count and file paths
- 将用户请求匹配到下方的命令模式
- 通过Bash工具执行:带适当标志和标志的
--jsonsf project retrieve start - 返回包含检索到的组件数量和文件路径的结果
Command Patterns
命令模式
| User intent | Execute via Bash tool |
|---|---|
| Retrieve all remote changes | |
| Retrieve by source directory | |
| Retrieve by metadata type | |
| Retrieve by metadata type with wildcard | |
| Retrieve multiple metadata types | |
| Retrieve by manifest | |
| Retrieve by package name | |
| Retrieve to metadata format (ZIP) | |
| Ignore conflicts | |
| 用户意图 | 通过Bash工具执行的命令 |
|---|---|
| 检索所有远程变更 | |
| 按源目录检索 | |
| 按元数据类型检索 | |
| 按带通配符的元数据类型检索 | |
| 检索多种元数据类型 | |
| 按清单检索 | |
| 按包名检索 | |
| 检索为元数据格式(ZIP) | |
| 忽略冲突 | |
Rules / Constraints
规则/约束
| Constraint | Rationale |
|---|---|
Always use | Provides structured output for reliable parsing and error handling |
| Must run from within Salesforce project | Command requires |
| Wildcard patterns must be quoted | Shell expansion breaks unquoted wildcards like |
| Cannot mix --manifest with --metadata or --source-dir | Mutually exclusive flags — command will error |
| Retrieve all changes requires source tracking | Production orgs don't support source tracking — must use other retrieval modes |
| --ignore-conflicts only works on trackable orgs | No effect on production orgs; applies to scratch/sandbox only |
| --output-dir must be inside project directory | Command validates output path is within project boundary |
| --output-dir cannot match package directory | Command fails if target matches |
| Default wait time is 33 minutes | Use --wait flag to override for large retrievals |
| Package retrieval is for reference only | Retrieved package metadata should not be added to source control for development |
| CustomField retrieval auto-includes CustomObject | When retrieving CustomField, CLI automatically adds CustomObject to get full context |
| 约束 | 理由 |
|---|---|
始终使用 | 提供结构化输出,以便可靠解析和错误处理 |
| 必须在Salesforce项目内运行 | 命令需要在仓库根目录存在 |
| 通配符模式必须加引号 | 未加引号的通配符(如 |
| 不能同时使用--manifest与--metadata或--source-dir | 这些标志互斥——命令会报错 |
| 检索所有变更需要源跟踪 | 生产组织不支持源跟踪——必须使用其他检索模式 |
| --ignore-conflicts仅在可跟踪组织上生效 | 在生产组织上无效果;仅适用于临时环境/沙箱 |
| --output-dir必须在项目目录内 | 命令会验证输出路径是否在项目边界内 |
| --output-dir不能与包目录匹配 | 如果目标与 |
| 默认等待时间为33分钟 | 对于大型检索,使用--wait标志覆盖默认值 |
| 包检索仅用于参考 | 检索到的包元数据不应添加到源代码控制用于开发 |
| 检索CustomField会自动包含CustomObject | 检索CustomField时,CLI会自动添加CustomObject以获取完整上下文 |
Troubleshooting
故障排除
| Issue | Resolution |
|---|---|
| "This command is required to run from within an SFDX project" | Not in Salesforce project directory — cd to project root with |
| "No org found for <alias>" error | Org alias doesn't exist or isn't authenticated — verify with |
| "This org does not support source tracking" | Production org doesn't allow "retrieve all changes" mode — use --source-dir, --metadata, or --manifest instead |
| "ERROR running project retrieve start: Cannot mix --manifest with --metadata or --source-dir" | Remove conflicting flags — use one retrieval mode only |
| Wildcard pattern retrieves nothing | Pattern not quoted — wrap in single quotes: |
| "The package directory path in sfdx-project.json does not exist" | Output directory conflicts with package directory — use different path |
| "Output directory must be inside the project" | --output-dir path is outside project boundary — use relative path inside project |
| Retrieve times out | Increase wait time with |
| Retrieved files overwrite local changes | Use |
| SourceConflictError with conflict table | Conflicts detected between local and remote on trackable org (scratch/sandbox) — resolve conflicts manually or use --ignore-conflicts to force overwrite |
| 问题 | 解决方案 |
|---|---|
| "This command is required to run from within an SFDX project" | 不在Salesforce项目目录中——切换到包含 |
| "No org found for <alias>" 错误 | 组织别名不存在或未通过身份验证——使用 |
| "This org does not support source tracking" | 生产组织不允许“检索所有变更”模式——改用--source-dir、--metadata或--manifest |
| "ERROR running project retrieve start: Cannot mix --manifest with --metadata or --source-dir" | 删除冲突的标志——仅使用一种检索模式 |
| 通配符模式未检索到任何内容 | 模式未加引号——用单引号包裹: |
| "The package directory path in sfdx-project.json does not exist" | 输出目录与包目录冲突——使用不同路径 |
| "Output directory must be inside the project" | --output-dir路径在项目边界外——使用项目内的相对路径 |
| 检索超时 | 对于大型元数据量,使用 |
| 检索到的文件覆盖本地变更 | 使用 |
| 出现包含冲突表的SourceConflictError | 在可跟踪组织(临时环境/沙箱)中检测到本地与远程的冲突——手动解决冲突或使用--ignore-conflicts强制覆盖 |
Output Expectations
输出预期
The command returns JSON output with retrieved components details.
See and for response structures.
examples/success_output.jsonexamples/error_output.json命令返回包含检索到的组件详情的JSON输出。
请查看和了解响应结构。
examples/success_output.jsonexamples/error_output.jsonCross-Skill Integration
跨Skill集成
| Need | Delegate to |
|---|---|
| Deploy metadata to org | |
| Preview retrieve without executing | Execute |
| List available metadata types | Execute |
| 需求 | 委托给 |
|---|---|
| 将元数据部署到组织 | |
| 预览检索而不执行 | 执行 |
| 列出可用的元数据类型 | 执行 |
Reference File Index
参考文件索引
| File | When to read |
|---|---|
| To understand successful retrieve response structure |
| To handle common error scenarios |
| For detailed explanation of all retrieval modes and when to use each |
| For complete flag reference with usage patterns |
| 文件 | 阅读时机 |
|---|---|
| 了解成功检索的响应结构时 |
| 处理常见错误场景时 |
| 需要详细解释所有检索模式及适用场景时 |
| 需要完整的标志参考及使用模式时 |