
Generating Custom Object
Generate and validate Salesforce CustomObject `.object-meta.xml` metadata so Metadata API deploys succeed on sharing, name fields, and relationships.
Overview
Generating Custom Object is an agent skill for the Build phase that creates, generates, and validates Salesforce CustomObject metadata XML with deployment-safe constraints.
Install
npx skills add https://github.com/forcedotcom/afv-library --skill generating-custom-objectWhat is this skill?
- Mandatory constraint checklist before any CustomObject XML output
- Covers sharing models, name fields, and Master-Detail deployment pitfalls
- Targets `.object-meta.xml` with filename-as-fullName convention
- Tier-1 syntactic essentials to prevent Metadata API deployment errors
- Triggered for create, generate, validate, and troubleshoot object metadata
- Tier 1 syntactic essentials constraint set for CustomObject XML
- File extension `.object-meta.xml` with API name as filename not XML tag
Adoption & trust: 1.4k installs on skills.sh; 512 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You need a new Salesforce custom object but Metadata API deploys fail on sharing, name fields, or Master-Detail rules you did not encode correctly.
Who is it for?
Solo builders or tiny teams authoring or fixing Salesforce custom objects in source-driven workflows before push or CI deploy.
Skip if: Teams only editing records in the UI with no metadata files, or flows that need Apex, LWC, or unrelated metadata types without object XML.
When should I use this skill?
Users need to create, generate, or validate Salesforce Custom Object metadata; mention custom objects, .object files, sharing models, name fields, validation rules on objects, or object deployment errors.
What do I get? / Deliverables
You get constraint-checked `.object-meta.xml` aligned to mandatory CustomObject rules so object metadata deploys without the usual sharing and relationship errors.
- Deployment-ready CustomObject `.object-meta.xml`
- Constraint verification notes for sharing and required elements
- Guidance for resolving object-related deploy errors
Recommended Skills
Journey fit
Custom objects are core Salesforce data-model work during product build and platform integration. Object XML, sharing models, and Master-Detail rules are integration-layer metadata, not generic frontend or docs tasks.
How it compares
Use for governed object metadata generation instead of pasting unstructured CustomObject XML from generic Salesforce chat answers.
Common Questions / FAQ
Who is generating-custom-object for?
Salesforce-focused solo builders and indies generating or validating CustomObject `.object-meta.xml` for Metadata API or source deploys.
When should I use generating-custom-object?
Use it when creating custom objects, generating object metadata, setting sharing or name fields, or troubleshooting object deployment errors especially around sharing models and Master-Detail relationships.
Is generating-custom-object safe to install?
Review the Security Audits panel on this Prism page and your org change process; the skill guides metadata XML output and does not replace your deploy approvals or org access controls.
SKILL.md
READMESKILL.md - Generating Custom Object
## When to Use This Skill Use this skill when you need to: - Create new custom objects - Generate custom object metadata XML - Configure object sharing and security settings - Set up object features and capabilities - Troubleshoot deployment errors related to custom objects ## Specification ## 1. Overview and Purpose This document defines the mandatory constraints for generating CustomObject metadata XML (`.object-meta.xml` file). The agent must verify these constraints before outputting XML to prevent Metadata API deployment errors. **File extension:** `.object-meta.xml` --- ## 2. Syntactic Essentials (Tier 1) The following constraints must be true for the XML body to deploy successfully. **Note:** The API Name (fullName) is NOT a tag; it is the filename (e.g., `Vehicle__c.object-meta.xml`). ### Required Elements | Element | Requirement | Notes | |---------|-------------|-------| | `<label>` | Required | Singular UI name | | `<pluralLabel>` | Required | Plural UI name | | `<sharingModel>` | Required | See Sharing Model Rules below | | `<deploymentStatus>` | Required | Always set to `Deployed` | | `<nameField>` | Required | Primary record identifier (requires `<label>` and `<type>`) | | `<visibility>` | Required | Always set to `Public` | ### Sharing Model Rules **Default:** Set `<sharingModel>` to `ReadWrite`. **Exception:** If this object contains a Master-Detail relationship field, `<sharingModel>` MUST be `ControlledByParent`. **Decision Logic:** - IF object has NO Master-Detail field → use `ReadWrite` - IF object has Master-Detail field → use `ControlledByParent` - IF a Master-Detail field is being added to an existing child object → that existing object's `<sharingModel>` must also be updated to `ControlledByParent` **❌ INCORRECT** — Will cause error: `Cannot set sharingModel to ReadWrite on a CustomObject with a MasterDetail relationship field` ```xml <CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> <label>Order Line Item</label> <pluralLabel>Order Line Items</pluralLabel> <sharingModel>ReadWrite</sharingModel> <!-- WRONG: Object has a M-D field --> <deploymentStatus>Deployed</deploymentStatus> </CustomObject> ``` **✅ CORRECT:** ```xml <CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> <label>Order Line Item</label> <pluralLabel>Order Line Items</pluralLabel> <sharingModel>ControlledByParent</sharingModel> <!-- CORRECT --> <deploymentStatus>Deployed</deploymentStatus> </CustomObject> ``` --- ## 3. Smart Defaults & Decision Logic (Tier 2) The agent must choose which features to enable based on the object's intended use case. ### A. The Name Field Decision | Type | When to Use | Additional Requirements | |------|-------------|------------------------| | **Text** | Default for human-named entities (Projects, Locations, Teams) | None | | **AutoNumber** | Use for transactions, logs, or IDs (Invoices, Requests, Tickets) | Must include `<displayFormat>` (e.g., `INV-{0000}`) and `<startingNumber>1</startingNumber>` | **Text Name Field Example:** ```xml <nameField> <label>Project Name</label> <type>Text</type> </nameField> ``` **AutoNumber Name Field Example:** ```xml <nameField> <label>Invoice Number</label> <type>AutoNumber</type> <displayFormat>INV-{0000}</displayFormat> <startingNumber>1</startingNumber> </nameField> `