Salesforce メタデータ生成の必須パートナースキル — このスキルは、メタデータ生成スキルと同じターン(やり取り)で読み込む必要があります。ジェネレーター(自動生成ツール)を読み込む場合は、このスキルも必ず一緒に読み込んでください。 カスタムオブジェクト、カスタムフィールド、数式フィールド、選択リスト、ルックアップ関連、主従関連、検証ルール、権限セット、プロファイル、カスタムタブ、Lightning レコードページ、フレックスページ、リストビュー、カスタムアプリケーション、フロー、レイアウト、レコードタイプ、共有ルール、レポート、および 604 のメタデータ API タイプなど、メタデータや *-meta.xml ファイルを作成・生成・追加・編集・作成する場合に使用します。 このスキルは、信頼できるスキーマ(データ構造の定義)、フィールド、フィールドプロパティ、必須フラグ、許可された値の一覧、XML 構造を提供し、生成された *-meta.xml が確実にデプロイできるようにします。このスキルを使わないと、存在しない要素名が作られたり、デプロイの失敗につながります。 次のような場合に使用:*-meta.xml、メタデータスキーマ、API コンテキスト、「Salesforce メタデータ」、「sfdx プロジェクト」 **使用しないでください:** SOQL(データベースクエリ言語)、DML(データ操作)、実行時の sObject アクセス、Tooling API レコード
REQUIRED companion for Salesforce metadata generation — load this schema/API-context skill in the SAME turn as ANY metadata generation skill; if you load a generator, you ALSO load this. Use it whenever you create, generate, add, edit, or author metadata or a *-meta.xml file: custom object, custom field, formula field, picklist, lookup, master-detail, validation rule, permission set, profile, custom tab, lightning record page, flexipage, list view, custom application, flow, layout, record type, sharing rules, report, and 604 Metadata API types. It provides the authoritative schema, fields, field properties, required flags, allowed enum values, and XML structure so generated *-meta.xml deploys cleanly — skipping it causes hallucinated element names and deploy failures. Trigger on *-meta.xml, metadata schema, api context, 'Salesforce metadata', or 'sfdx project'. DO NOT use for SOQL, DML, runtime sObject access, or Tooling API records.
This skill provides comprehensive documentation for all 604 Salesforce Metadata API types. Use this skill to create, understand, and modify Salesforce metadata XML files in your Salesforce DX projects.
The Salesforce Metadata API allows you to retrieve, deploy, create, update, or delete customizations for your org. This skill gives you access to detailed documentation for each metadata type, including:
ALWAYS consume only the specific sections you need from JSON files, NOT entire files.
CRITICAL: For assets/metadata_api/*.json files, always use jq or programmatic JSON parsing to extract only the specific sections you need. Do not load these files whole via Read, cat, read_file, or any other tool that injects the complete file — they contain verbose WSDL segments and other sections that waste 60-80% of tokens. (Loading small files like this SKILL.md or the index table with Read is fine; the rule applies specifically to the large metadata-type JSON files.)
Each JSON file contains multiple sections (fields, description, wsdl_segment, etc.). Most use cases only require 1-2 sections:
fields sectiondescription sectiondeclarative_metadata_sample_definition sectionwsdl_segment (verbose schema), file_information, directory_locationThis reduces token consumption by 60-80% per file.
To get information about a specific metadata type:
Recommended:
Avoid:
Each metadata type is stored as a JSON file in assets/metadata_api/ with the following structure:
{
"sections": ["title", "description", "fields", "wsdl_segment", ...],
"title": "MetadataTypeName - Metadata API",
"description": "Plain-text description of the metadata type.",
"fields": {
"fieldName": {
"type": "string",
"description": "Field description",
"required": true
}
},
"file_information": ".object",
"directory_location": "objects",
"wsdl_segment": "<xsd:complexType>...</xsd:complexType>",
"declarative_metadata_sample_definition": [
{
"description": "Example description",
"code": "<?xml version=\"1.0\"?>\n<MetadataType>...\n</MetadataType>"
}
]
}
Note: string values (
title,description,file_information,directory_location,wsdl_segment) are stored as plain text — no markdown headers (#/##) or code fences.file_informationholds just the file suffix (e.g..object,.ai) anddirectory_locationjust the SFDX folder name (e.g.objects,aiApplications).
The sections array indicates which top-level keys are present in each file. Common sections include:
title: The metadata type name and headerdescription: What the metadata type representsfields: The type's own fields, with types and descriptionssub_types: (composite types only) a map of referenced sub-type name → that sub-type's fields, e.g. Flow → sub_types.FlowActionCallfile_information: File naming conventions and extensionsdirectory_location: Where files are stored in SFDX projectswsdl_segment: XML schema definition from the WSDLdeclarative_metadata_sample_definition: Example XML codeSome metadata types have additional sections specific to their functionality. See the Index Table for a complete breakdown.
More detail: background on why token optimization matters, worked usage examples, common workflows, a full section glossary, and versioning/support notes live in
references/usage_guide.md. Load it with theReadtool only when needed.
CRITICAL: To minimize token usage and costs:
CRITICAL WARNING: DO NOT use the read_file tool (or any whole-file reading tool) on these JSON files!
read_file loads the entire file content into your context, defeating the purpose of section-specific consumption. You will waste 60-80% of your token budget loading unnecessary WSDL segments and verbose sections. (Using Read on small files such as this SKILL.md or the index table is fine — this rule is only about the large metadata-type JSON files.)
Approach: Programmatically parse the JSON file and extract ONLY the sections you need using code, not whole-file reading tools.
Working Examples Available:
We provide complete, working code examples in multiple languages:
examples/python_section_loading.py - Shows json.load() with section extractionexamples/javascript_section_loading.js - Shows JSON.parse() with section extractionexamples/bash_section_loading.sh - Shows jq command-line JSON processingSee examples/README.md for complete documentation and usage instructions.
Quick Pattern (adapt to your language):
fields, description)wsdl_segment, declarative_metadata_sample_definition)NEVER use the read_file tool on these JSON files:
read_file assets/metadata_api/CustomObject.json # Loads entire file into context!
read_file assets/metadata_api/Flow.json # Wastes 60-80% tokens!
NEVER load all files:
read_file assets/metadata_api/*.json # This loads ~15MB of data!
Token Impact:
Many metadata types have large WSDL segments or extensive field lists. Always load only the specific sections you need from each JSON file rather than consuming the entire file:
sections array from the JSONfields for field definitions, description for overview)This approach can reduce token consumption by 60-80% per file by excluding verbose WSDL definitions and lengthy examples.
Ask yourself:
fields sectiondescription sectiondeclarative_metadata_sample_definition sectionwsdl_segment section (rarely needed)Use one of these methods:
references/metadata_index_table.md for related typesDecision Tree for Section Loading:
Need field definitions?
→ Load ONLY 'fields' section (~50-200 tokens)
Need to understand what the type does?
→ Load ONLY 'description' section (~20-100 tokens)
Need XML structure example?
→ Load ONLY 'declarative_metadata_sample_definition' (~100-300 tokens)
Need all three?
→ Load 'fields' + 'description' + 'declarative_metadata_sample_definition'
→ Still skip 'wsdl_segment', 'file_information', 'directory_location'
→ Savings: ~60-70% vs loading entire file
Need schema validation?
→ Only then load 'wsdl_segment' (this is verbose)
Request format:
wsdl_segment unless explicitly neededUse the loaded information to:
All metadata type JSON files are located in:
assets/metadata_api/
├── CustomObject.json
├── Flow.json
├── ApexClass.json
├── Profile.json
└── ... (600 more files)
When using this skill, files are referenced as:
assets/metadata_api/CustomObject.json./assets/metadata_api/CustomObject.jsonThe skill will automatically resolve paths based on the working directory.
When generating Salesforce metadata XML files, follow these requirements to ensure valid, deployable files.
All metadata files must:
Include XML declaration:
<?xml version="1.0" encoding="UTF-8"?>
Use correct namespace:
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
Match root element to metadata type:
<CustomObject><Flow><Profile>The namespace is required and must be exactly:
http://soap.sforce.com/2006/04/metadata
Correct:
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
Incorrect:
<CustomObject> <!-- Missing namespace -->
<CustomObject xmlns="http://salesforce.com/metadata"> <!-- Wrong namespace -->
Each metadata type has different field requirements:
required: true in the JSON): the WSDL marks the field as required.externalDataSource, externalName, nameField as required: true (the first two are external-object-only quirks), but a normal __c CustomObject also needs label, pluralLabel, deploymentStatus, and sharingModel to deploy. Always cross-check with the declarative_metadata_sample_definition examples.Example from CustomObject (note: practical authoring needs more than what required: true marks):
{
"fields": {
"nameField": {
"type": "CustomField",
"description": "The name field for the custom object",
"required": true
},
"label": {
"type": "string",
"description": "The label for the custom object (effectively required for normal __c objects)",
"required": false
},
"sharingModel": {
"type": "SharingModel (enumeration)",
"description": "The sharing model for the object (effectively required for normal __c objects)",
"required": false
},
"enableHistory": {
"type": "boolean",
"description": "Enable field history tracking",
"required": false
}
}
}
Before deploying:
sf project deploy validate to catch errorsMore detail: field-type→XML mapping tables, file-naming/two-file/child-type conventions, and full well-formed-file examples are in
references/usage_guide.md.
Some Metadata API type names also exist as Enterprise/Data API or Tooling API object names. Examples include ApexClass, ApexTrigger, CustomField, CustomObject, EmailTemplate, Layout, Profile, PermissionSet, RecordType, StaticResource, WebLink, ValidationRule, and Flow.
When the prompt is ambiguous (e.g., "tell me about Profile" or "what fields are on ApexClass"), ask whether the user wants:
.profile-meta.xml, .cls-meta.xml).Heuristics that resolve most ambiguity without asking:
package.xml, force-app/, sfdx, .meta.xml, "deploy", "retrieve", "authoring", "blueprint", "template", "class definition", or "permissions" in a deployment sense → Metadata API (this skill).ApexCodeCoverage, EntityDefinition, TraceFlag, "code coverage", "compile errors", SymbolTable, debug logging → Tooling API.Default-when-no-signals rule: if the prompt has none of the signals above AND this skill (platform-metadata-api-context-get) was invoked directly by name, default to the Metadata API interpretation and explicitly disclose the assumption to the user (e.g., "Interpreting this as the Metadata API type for .cls-meta.xml authoring; let me know if you meant the Tooling API record or Enterprise/Data sObject"). The skill-invocation context itself is a signal of authoring/deployment intent.
Problem: Cannot find metadata type file
Solutions:
CustomObject.json, NOT customobject.json, Custom_Object.json, or Custom-Object.json).references/metadata_index_table.md. Use this two-pass recovery algorithm against the index:
customobject, Custom_Object, Custom-Object → CustomObject.difflib.get_close_matches(query_normalized, index_normalized, n=3, cutoff=0.7) or Levenshtein distance ≤ 2. Resolves: customfeld → CustomField, apxclass → ApexClass. Pure substring matching cannot recover character deletions.customobject matches both CustomObject and CustomObjectTranslation), prefer the entry whose normalized length equals the normalized query length; otherwise prefer the shortest match.Two related patterns to recognize:
AsyncResult, SaveResult, DeleteResult, UpsertResult, Error, DescribeMetadataResult, etc.) — fields is empty AND wsdl_segment is populated. These are SOAP response wrappers; their schema lives entirely in wsdl_segment. Consume that section if you need their structure. They are not deployable source files.AllOrNoneHeader, SessionHeader, CallOptions, DebuggingHeader, OwnerChangeOptions, etc.) — fields has 1–2 minimal entries, no wsdl_segment. These configure SOAP request behavior; they are call-time options, not metadata you author or deploy.In both cases, the thin JSON output is correct. Don't try to author a .AsyncResult-meta.xml — these types have no source-file form.
Problem: Expected section not in JSON file
Solutions:
sections array to see what's availableProblem: Field definition lacks details
Solutions:
wsdl_segment for complete schema definitionProfileObjectPermissions[])When the fields section gives a complex type name like ProfileObjectPermissions[] or LayoutItem[] or ApprovalStep[], the sub-fields of that nested type are NOT in the fields section — they live in wsdl_segment for that complex type. The skill's "skip wsdl_segment by default" rule is for token economy on the simple-field path; for nested types you need to drill in.
Worked example — find the sub-fields of objectPermissions on Profile:
# 1. Get the field type name from the fields section
jq '.fields.objectPermissions' assets/metadata_api/Profile.json
# → {"type": "ProfileObjectPermissions[]", ...}
# 2. Pull just the matching complexType from wsdl_segment using grep -A
jq -r '.wsdl_segment' assets/metadata_api/Profile.json | grep -A 30 'complexType name="ProfileObjectPermissions"'
The grep -A N window keeps token cost ~150 tokens instead of loading the whole wsdl_segment (which can be 5K+ tokens on large types). Use this pattern any time fields returns a Foo[] type and you need Foo's sub-fields.
Problem: Generated XML fails validation
Solutions:
http://soap.sforce.com/2006/04/metadataProblem: Metadata file won't deploy
Solutions:
sf project deploy validate firstHere are the most frequently used metadata types:
For a complete list of all metadata types, see Index Table.
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。