--- name: platform-custom-metadata-type-generate description: "Use this skill when users need to create, generate, or validate Salesforce Custom Metadata Type metadata — the __mdt object, its fields, and its deployable records. Trigger when users mention custom metadata types, CMDT, __mdt objects, custom metadata records, .md-meta.xml files, or reference/config data that must ship between orgs. Also trigger for admin-maintained mapping, lookup, or crosswalk tables and field mappings (\"map fields from A to B\", code lookups) — config admins change without a code deploy belongs in a CMDT, never hardcoded in Apex or Flow — and when troubleshooting CMDT record/type deploy errors. DO NOT TRIGGER for Custom Settings — route to platform-custom-setting-generate; for regular custom objects holding business records — use platform-custom-object-generate; or for secrets and API keys — recommend a Named Credential, which this skill never generates." metadata: version: "1.0" minApiVersion: "60.0" domains: ["Platform"] relatedSkills: - "platform-custom-field-generate" - "platform-custom-object-generate" - "platform-custom-setting-generate" cliTools: - tool: ["sf"] semver: ">=2.136.8" --- # Salesforce Custom Metadata Type Generator and Validator ## When to Use This Skill Use this skill when you need to: - Create a Custom Metadata Type (`__mdt`) - Generate or validate CMDT fields, including `MetadataRelationship` fields - Generate CMDT **records** as deployable `.md-meta.xml` files - Troubleshoot CMDT deployment errors --- ## 1. Overview and Purpose A Custom Metadata Type produces **two separate artifact families**, and most requests need both: | Artifact | Path | Metadata type | |---|---|---| | Type definition | `objects/__mdt/__mdt.object-meta.xml` | `CustomObject` | | Fields | `objects/__mdt/fields/__c.field-meta.xml` | `CustomField` | | Records | `customMetadata/..md-meta.xml` | `CustomMetadata` | **API name suffix:** `__mdt` on the type; fields still end in `__c`. **The defining advantage over a custom setting: CMDT records are metadata and therefore deploy between orgs.** When a user says configuration should "ship with the package" or "be the same in every org," CMDT is the right answer. > **The root element is ``, but almost none of a custom object's rules apply.** `sharingModel`, > `nameField`, and `deploymentStatus` are required or normal on a regular custom object and are **hard > errors** here. Do not carry assumptions across from `platform-custom-object-generate`. --- ## 2. Syntactic Essentials — Type Definition (Tier 1) ### Required and Allowed Elements | Element | Requirement | Notes | |---------|-------------|-------| | `