
Generating Custom Field
Generate and validate Salesforce CustomField metadata XML for lookups, roll-ups, formulas, and picklists without Metadata API deployment surprises.
Overview
Generating Custom Field is an agent skill for the Build phase that creates and validates Salesforce CustomField metadata with enforced rules for roll-ups and master-detail fields.
Install
npx skills add https://github.com/forcedotcom/afv-library --skill generating-custom-fieldWhat is this skill?
- Mandatory constraint checks before emitting CustomField metadata XML
- Deep coverage of high-failure types: Roll-up Summary and Master-Detail relationship rules
- Supports Lookup, formula, picklist, and standard custom field generation flows
- Troubleshooting path for Roll-up format, Master-Detail constraints, and formula deployment errors
- Explicit trigger coverage for any custom field metadata generation or validation task
- Skill metadata version 1.0
- Explicit focus on highest-failure field types: Roll-up Summary and Master-Detail
Adoption & trust: 1.4k installs on skills.sh; 512 GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
Your agent keeps proposing Salesforce field XML that fails deploy with roll-up or master-detail errors you do not have time to debug.
Who is it for?
Indie consultants and builders shipping Salesforce custom objects, lookups, and roll-ups via source-driven workflows.
Skip if: Non-Salesforce databases, one-off SOQL questions, or orgs where admins forbid agent-generated metadata without human sign-off.
When should I use this skill?
User mentions Salesforce custom fields, field types, roll-up summary, master-detail, lookup, formula fields, or field metadata deployment errors.
What do I get? / Deliverables
You get constraint-verified CustomField metadata ready for Metadata API deployment and clearer fixes when errors are relationship or formula related.
- Validated CustomField metadata XML
- Constraint notes for relationship and roll-up configurations
Recommended Skills
Journey fit
Build integrations is the canonical shelf because the skill operates on Salesforce org metadata—custom fields and relationships—not frontend UI or launch distribution work. Integrations subphase covers CRM and platform extension work where correct CustomField XML is the handoff artifact to deployment pipelines.
How it compares
Specialized Salesforce metadata generator—not a generic REST schema tool or Apex development skill.
Common Questions / FAQ
Who is generating-custom-field for?
Builders and admins automating Salesforce field creation who need XML that respects Metadata API constraints.
When should I use generating-custom-field?
Use it during Build integrations whenever you add custom fields, relationship fields, formulas, roll-ups, or troubleshoot field deployment errors.
Is generating-custom-field safe to install?
Review the Security Audits panel on this Prism page; deploying metadata still requires sandbox testing and your org’s governance rules.
SKILL.md
READMESKILL.md - Generating Custom Field
## When to Use This Skill Use this skill when you need to: - Create custom fields on any object - Generate field metadata for any field type - Set up relationship fields (Lookup or Master-Detail) - Create formula or roll-up summary fields - Troubleshoot deployment errors related to custom fields # Salesforce Custom Field Generator and Validator ## Overview Generate and validate Salesforce Custom Field metadata with mandatory constraints to prevent deployment errors. This skill has special focus on the **highest-failure-rate field types**: Roll-up Summary and Master-Detail relationships. ## Specification ## 1. Purpose This document defines the mandatory constraints for generating CustomField metadata XML. The agent must verify these constraints before outputting XML to prevent Metadata API deployment errors. **Critical Focus Areas:** - Roll-up Summary field format errors - Master-Detail field attribute restrictions - Lookup Filter restrictions --- ## 2. Universal Mandatory Attributes Every generated field must include these tags: | Attribute | Requirement | Notes | |-----------|-------------|-------| | `<fullName>` | Required | Derive from `<label>`: capitalize each word, replace spaces with `_`, append `__c`. Must start with a letter. E.g., label `Total Contract Value` → `Total_Contract_Value__c` | | `<label>` | Required | The UI name (Title Case) | | `<description>` | Mandatory | State the business "why" behind the field | | `<inlineHelpText>` | Mandatory | Provide actionable guidance for the end-user. Must add value beyond the label (e.g., "Enter the value in USD including tax" instead of just "The amount") | ### External ID Configuration **Trigger:** If the user mentions "integration," "importing data," "external system ID," or "unique key from [System Name]," set `<externalId>true</externalId>`. **Applicable Types:** Text, Number, Email --- ## 3. Technical Interplay: Precision, Scale, and Length To ensure deployment success, follow these mathematical constraints: ### Precision vs. Scale Rules - `precision` is the total digits; `scale` is the decimal digits - **Rule:** `precision ≤ 18` AND `scale ≤ precision` - **Calculation:** Digits to the left of decimal = `precision - scale` ### The "Fixed 255" Rule For standard TextArea types, the Metadata API requires `<length>255</length>`, even though it isn't configurable in the UI. ### Visible Lines Mandatory for Long/Rich text and Multi-select picklists to control UI height. --- ## 4. Field Data Types ### 4.1 Simple Attribute Types | Type | `<type>` Value | Required Attributes | |------|----------------|---------------------| | Auto Number | `AutoNumber` | `displayFormat` (must include `{0}`), `startingNumber` | | Checkbox | `Checkbox` | Default `defaultValue` to `false` | | Date | `Date` | No precision/length required | | Date/Time | `DateTime` | No precision/length required | | Email | `Email` | Built-in format validation | | Lookup Relationship | `Lookup` | `referenceTo`, `relationshipName`, `deleteConstraint` | | Master-Detail Relationship | `MasterDetail` | `referenceTo`, `relationshipName`, `relationshipOrder` | | Number | `Number` | `precision`, `scale` | | Currency | `Currency` | Default precision: 18, scale: 2 | | Percent | `Percent` | Default precision: 5, scale: 2 | | Phone | `Phone` | Standardizes phone number formatting | | Picklist | `Picklist` | `va