次のような場合に使用: ユーザーが Salesforce のカスタムオブジェクト(独自に作成できるデータ構造)のメタデータ(設定情報)を作成、生成、または検証する場合 **発動する状況:** - カスタムオブジェクト、.object ファイル、共有モデル(データにアクセスできる人の範囲)、名前フィールド、または検証ルール(データの入力ルール)に関する処理 - ユーザーが「カスタムオブジェクトを作成して」と指示した場合 - 共有モデルとマスター・ディテール関係(データ間の親子関係)の展開エラーが発生した場合 **その他の役割:** - オブジェクトに含まれるフィールドや検証ルールが変わったときは、そのオブジェクトの説明文を最新の状態に保つ **使用しない場合:** - カスタムオブジェクト以外のメタデータ(Apex、フロー、LWC、権限セット、カスタムメタデータ型など) - 標準オブジェクト(Salesforce があらかじめ用意しているデータ構造)
Use when users create, generate, or validate Salesforce Custom Object metadata. Trigger on custom objects, .object files, sharing models, name fields, or validation rules — e.g. "create a custom object" — and deployment errors around sharing models and Master-Detail relationships. Also keep the object's <description> current when its fields or validation rules change. Do NOT use for non-Custom-Object metadata (Apex, Flows, LWC, Permission Sets, Custom Metadata Types) or standard objects.
Use this skill when you need to:
<description> stale, so you must refresh it (propose + confirm). This applies equally to validation-rule changes, not just fields. See Section 3.B.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
Description freshness — applies to EVERY object change, fields AND validation rules: Whenever you add, update, or delete a field or a validation rule on an object, the
<description>may now be stale. Before finishing, refresh it per Section 3.B (propose, confirm with the user, write). A validation-rule change counts exactly like a field change — the change is not done until the description has been reconciled. This is easy to forget on validation-rule edits/deletes — don't.
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).
| 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 |
Default: Set <sharingModel> to ReadWrite.
Exception: If this object contains a Master-Detail relationship field, <sharingModel> MUST be ControlledByParent.
Decision Logic:
ReadWriteControlledByParent<sharingModel> must also be updated to ControlledByParentINCORRECT — Will cause error: Cannot set sharingModel to ReadWrite on a CustomObject with a MasterDetail relationship field
<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:
<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>
The agent must choose which features to enable based on the object's intended use case.
| 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:
<nameField>
<label>Project Name</label>
<type>Text</type>
</nameField>
AutoNumber Name Field Example:
<nameField>
<label>Invoice Number</label>
<type>AutoNumber</type>
<displayFormat>INV-{0000}</displayFormat>
<startingNumber>1</startingNumber>
</nameField>
<description>: Mandatory — every Custom Object MUST have one. It must read like human-written documentation, never a generic template ("Object used to track and manage...") or a metadata dump ("Contains 8 fields including Project_Name__c...").
Always compose an enriched description — when creating the object, and again on any change to it: adding, updating, or deleting a field or a validation rule (so it never goes stale). The change — field or validation rule — is never "done" until you've refreshed the object's description. This is not optional; do not ask whether to add a description.
Confirm per change — every time. Propose and confirm on each field/rule change separately. A previous "keep current" applies only to that one change; it is never standing permission to skip the proposal on a later change. Do not infer a preference from an earlier answer — re-propose and re-ask for every new change.
Compose the description (steps below). If the object already has one, use it as a strong signal — preserve the business context it carries (domain, team, intent the schema can't reveal) and fold the new field/rule in rather than discarding it.
Then branch on whether a description already exists:
No existing description (brand-new object): there is nothing to overwrite — just write the composed description. Do not prompt.
An existing description (update, delete, or any re-enrichment): never overwrite it silently — you can't tell from the file whether it was hand-written by an admin or generated earlier. Show the proposal, ask, and STOP — wait for the user's reply before writing:
Proposed description for
{Object}:<the enriched description>Current:<the existing description>Use this? (yes / keep current / edit)
You MUST NOT write the <description> until the user replies — showing the diff is not approval, even when the change looks obvious or minor. Then act: yes → write the proposed text · keep current → leave the existing one untouched (this applies to this change only — re-propose on the next one) · edit → use the user's wording.
Always end with a <description> written.
Composing the description:
VIN (required, external ID), Color (Red/Green only)Purpose → key fields → computed fields → validation rules (as business rules) → "Commonly used for {use cases}."
Example (Car, 46 words):
<description>The Car object tracks vehicle inventory and maintenance. It captures Year, VIN (required, external ID), Color (Red/Green only), and Location; the Age Years field auto-calculates vehicle age. VIN is required and Black cars cannot be sold. Commonly used for fleet management, inventory tracking, and service scheduling.</description>
→ For the full workflow and examples, read references/description-enrichment.md.
If the object is a many-to-many link between two parents, name the object by combining the two parent entities to ensure the schema remains intuitive.
Examples:
Position_Candidate__c (links Position and Candidate)Job_Application__c (links Job and Application)To maintain "Clean XML," only include optional tags when deviating from the Salesforce platform default of false.
Scenario A: User-Facing Objects (Apps, Trackers, Business Entities)
<enableSearch>, <enableReports>, <enableActivities>, and <enableHistory> to trueScenario B: System-Facing Objects (Junctions, Background Logs)
Never use reserved words as API names for Custom Objects or Custom Fields:
| Category | Reserved Words (Do Not Use as API Names) |
|---|---|
| SOQL/SQL | Select, From, Where, Limit, Order, Group |
| System | User, External, View, Type |
| Temporal | Date, Number |
Do not create more than 2 Master-Detail relationships for a single object. If a third relationship is required, use a Lookup instead.
Do NOT include the <fullName> tag at the root of the .object-meta.xml file. The API name is derived from the filename.
INCORRECT:
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<fullName>Vehicle__c</fullName> <!-- WRONG: Remove this -->
<label>Vehicle</label>
</CustomObject>
CORRECT:
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
<label>Vehicle</label>
<!-- fullName comes from filename: Vehicle__c.object-meta.xml -->
</CustomObject>
Validation rule names follow different conventions than custom fields.
Rules:
__c (unlike custom fields)INCORRECT:
<validationRules>
<fullName>Require_Start_Date__c</fullName> <!-- WRONG: Has __c suffix -->
<active>true</active>
<errorMessage>Start Date is required.</errorMessage>
<formula>ISBLANK(Start_Date__c)</formula>
</validationRules>
Error: The validation name can only contain alphanumeric characters, must begin with a letter, cannot end with an underscore...
CORRECT:
<validationRules>
<fullName>Require_Start_Date</fullName> <!-- CORRECT: No __c suffix -->
<active>true</active>
<errorMessage>Start Date is required.</errorMessage>
<formula>ISBLANK(Start_Date__c)</formula>
</validationRules>
Naming Pattern Reference:
| Metadata Type | Naming Pattern | Example |
|---|---|---|
| Custom Fields | Ends with __c |
Start_Date__c |
| Validation Rules | No suffix | Require_Start_Date |
| Custom Objects | Ends with __c |
Vehicle__c |
Before generating the Custom Object XML, verify:
<label> and <pluralLabel> present?<deploymentStatus> set to Deployed?<visibility> set to Public?<nameField> include both <label> and <type>?<type> is AutoNumber, are <displayFormat> and <startingNumber> included?<sharingModel> MUST be ControlledByParent<sharingModel> should be ReadWrite<fullName> absent from the XML root?__c?<description> present? (Enriched per Section B — proposed and confirmed with the user before writing.)<enableSearch> and <enableReports> set to true if user-facing?| File | When to read |
|---|---|
references/description-enrichment.md |
Composing or refreshing an object's <description> (on create, or when a field/rule changes) — full enrichment workflow, field-prioritization tiers, junction/child handling, edge cases, and more examples |
原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。