2026-03-11 20:27:52 +08:00
# Rule: Salesforce Metadata Generation
## Constraints
2026-03-18 22:51:46 +08:00
1. **Never write** without both: metadata type skill loaded AND context tools from `salesforce-api-context` MCP server called for that type.
2. **One type at a time** - finish one type before starting the next
3. **One type per API call** - do not batch types when calling MCP tools
4. **Child types need their own context** - if adding any child metadata inside a parent metadata's file, treat the child metadata seperately; don't rely on the parent's schema for creating child metadata
2026-03-11 20:27:52 +08:00
5. **Max one clarifying question** before starting
## Workflow
2026-03-18 22:51:46 +08:00
### Step 1: Metadata Loop - Execute for Each Type
For each type, execute loop below
2026-03-11 20:27:52 +08:00
**a. Load Skill**
2026-03-18 22:51:46 +08:00
- Load the metadata type skill once (not per record)
2026-03-11 20:27:52 +08:00
2026-03-18 22:51:46 +08:00
**b. Get entity context**
- Use these tools from `salesforce-api-context` MCP server for entity context.
- `get_metadata_type_sections`
- `get_metadata_type_context`
- `get_metadata_type_fields`
- `get_metadata_type_fields_properties`
- `search_metadata_types`
2026-03-11 20:27:52 +08:00
2026-03-18 22:51:46 +08:00
### Step 2. Verify deployment
2026-03-11 20:27:52 +08:00
```bash
2026-03-13 17:16:03 +08:00
sf project deploy start --dry-run -d "force-app/main/default" --target-org < alias > --test-level NoTestRun --wait 10 --json
2026-03-11 20:27:52 +08:00
```
2026-03-13 17:16:03 +08:00
On failure: attempt to fix the errors and re-run, retrying up to a maximum of 3 times until it succeeds.
2026-03-11 20:27:52 +08:00
2026-03-18 22:51:46 +08:00
2026-03-11 20:27:52 +08:00
## Anti-Patterns
| Don't | Why | Do |
|-------|-----|-----|
| Reload skill per record | Wastes tokens | Load once per type |
| Skip metadata skills | Missing platform constraints | Load skill for every type |
| Ask 3+ questions | Token waste | Max 1 question |
2026-03-18 22:51:46 +08:00
| Batch types in calls to MCP tools | Violates constraint | One type per call |