forcedotcom/sf-skills/platform-metadata-api-context-get
Claude Code and agent skill by forcedotcom/sf-skills
- community
Checking that the SKILL.md file is still in the repository.
REQUIRED companion for Salesforce metadata generation — load this schema/API-context skill in the SAME turn as ANY metadata generator (if you load a generator, you ALSO load this). Use whenever you create, generate, edit, or author metadata or a *-meta.xml file (custom object, field, flow, and 604 Metadata API types): it gives authoritative schema, required flags, and XML structure so files deploy cleanly. Trigger on *-meta.xml, metadata schema, api context. DO NOT use for SOQL, DML, runtime sObject access, or Tooling API records.
Install
npx vskill@latest install forcedotcom/sf-skills/platform-metadata-api-context-getSKILL.md
The same SKILL.md was published earlier as forcedotcom/sf-skills/platform-metadata-api-context-get.
Salesforce Metadata API Skill
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.
Overview
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:
- Field definitions and data types
- Required vs. optional fields
- WSDL schema definitions
- Sample XML structures
- File naming conventions
- Directory locations in Salesforce DX projects
How to Use This Skill
CRITICAL: Section-Specific Consumption
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:
- For field definitions: Load only the
fieldssection - For understanding purpose: Load only the
descriptionsection - For XML examples: Load only the
declarative_metadata_sample_definitionsection - Skip by default:
wsdl_segment(verbose schema),file_information,directory_location
This reduces token consumption by 60-80% per file.
Quick Start
To get information about a specific metadata type:
- Section-specific (BEST): "Show me only the 'fields' section from CustomObject.json"
- Multiple sections: "Show me 'fields' and 'description' from Flow.json"
- Avoid loading entire files: Don't ask for "the CustomObject metadata type" - specify sections
Example Queries (Section-Specific)
Recommended:
- "Show me only the 'fields' section from CustomObject.json"
- "What fields are in the 'fields' section of Profile.json?"
- "Load the 'description' and 'fields' sections from Flow.json"
- "Give me just the 'declarative_metadata_sample_definition' from ApexClass.json"
Avoid:
- "Show me the CustomObject metadata type" (too broad - entire file)
- "Load CustomObject.json" (includes unnecessary WSDL and other sections)
JSON File Structure
Each metadata type is stored as a JSON file in assets/metadata_api/ with the following structure:
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).
Available Sections
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 code
Some 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.
Token Optimization Strategies
CRITICAL: To minimize token usage and costs:
- Load only the specific metadata type(s) you need, not the full corpus
- Load only specific sections from each file, not entire files
Section-Specific Loading (BEST PRACTICE)
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:
- Python: `examples/python_section_loading.py` - Shows
json.load()with section extraction - JavaScript/Node.js: `examples/javascript_section_loading.js` - Shows
JSON.parse()with section extraction - Bash + jq: `examples/bash_section_loading.sh` - Shows
jqcommand-line JSON processing
See `examples/README.md` for complete documentation and usage instructions.
Quick Pattern (adapt to your language):
- Read the JSON file
- Parse it into a data structure
- Extract ONLY the sections you need (e.g.,
fields,description) - Ignore verbose sections (
wsdl_segment,declarative_metadata_sample_definition)
What NOT to Do
NEVER use the `read_file` tool on these JSON files:
NEVER load all files:
Token Impact:
- Section-specific: 50-200 tokens per metadata type
- Entire file: 500-2000 tokens per metadata type
- Savings: 60-80% per file
When to Load Multiple Types
- Related types: CustomObject + CustomField + ValidationRule
- Permission sets: Profile + PermissionSet + PermissionSetGroup
- UI components: Layout + CompactLayout + QuickAction
- Automation: Flow + WorkflowRule + ApexTrigger
When to Load Specific Sections (STRONGLY RECOMMENDED)
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:
- First, check available sections by reading just the
sectionsarray from the JSON - Extract only the sections you need (e.g.,
fieldsfor field definitions,descriptionfor overview) - Skip WSDL segments unless you specifically need schema validation
- Skip declarative_metadata_sample_definition unless you need complete XML examples
This approach can reduce token consumption by 60-80% per file by excluding verbose WSDL definitions and lengthy examples.
Conceptual Approach to Using This Skill
Step 1: Identify Your Need
Ask yourself:
- What am I trying to build or modify?
- Which Salesforce metadata type(s) am I working with?
- Which specific information do I need?
- Field definitions only? → Load
fieldssection - Understanding what it does? → Load
descriptionsection - XML example? → Load
declarative_metadata_sample_definitionsection - Schema validation? → Load
wsdl_segmentsection (rarely needed)
Step 2: Find the Right Type
Use one of these methods:
- Direct reference: If you know the type name (e.g., "CustomObject")
- Index search: Check
references/metadata_index_table.mdfor related types - Common types: See the "Quick Reference: Common Metadata Types" section below
Step 3: Load Selectively (Section-Specific)
Decision Tree for Section Loading:
Request format:
- Single section (BEST): "Show me only the 'fields' section from ApexClass.json"
- Multiple sections: "Load 'fields' and 'description' from CustomObject.json"
- Skip verbose sections: Never load
wsdl_segmentunless explicitly needed
Step 4: Apply to Your Code
Use the loaded information to:
- Create new metadata XML files
- Understand existing files in your project
- Validate field names and types
- Generate correct XML structure with proper namespaces
File Location
All metadata type JSON files are located in:
Path Resolution
When using this skill, files are referenced as:
- Absolute:
assets/metadata_api/CustomObject.json - Relative to skill root:
./assets/metadata_api/CustomObject.json
The skill will automatically resolve paths based on the working directory.
Metadata File Generation Requirements
When generating Salesforce metadata XML files, follow these requirements to ensure valid, deployable files.
XML Structure Requirements
All metadata files must:
- Include XML declaration:
``xml <?xml version="1.0" encoding="UTF-8"?> ``
- Use correct namespace:
``xml <CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> ``
- Match root element to metadata type:
- CustomObject →
<CustomObject> - Flow →
<Flow> - Profile →
<Profile> - etc.
Namespace Declaration
The namespace is required and must be exactly:
Correct:
Incorrect:
Required vs. Optional Fields
Each metadata type has different field requirements:
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassedPattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/platform-metadata-api-context-get/SKILL.md
Popularity
- Repository stars
- 1,054
- Repository forks
- 353
- 7-day trend score
- 35
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/forcedotcom/sf-skills/platform-metadata-api-context-get)