|
1 | 1 | # Rule: Salesforce Metadata Generation |
2 | 2 |
|
3 | | -## Objective |
4 | | -Enforce: **skill load → API context → file generation** for all Salesforce metadata. |
5 | | - |
6 | 3 | ## Constraints |
7 | 4 |
|
8 | | -1. **Never write** without both: metadata type skill loaded AND `get_metadata_api_context` called for that type |
9 | | -2. **One type at a time** - complete full cycle before next type |
10 | | -3. **One type per API call** - no batching |
11 | | -4. **Child types need own context** - if adding any child metadata inside a parent metadata's file, load skill and call `get_metadata_api_context` for each child type (e.g. CustomField inside CustomObject) separately; don't rely on the parent's schema for creating child metadata |
| 5 | +1. **Never write** without both: metadata type skill loaded AND context tools from `salesforce-api-context` MCP server called for that type. |
| 6 | +2. **One type at a time** - finish one type before starting the next |
| 7 | +3. **One type per API call** - do not batch types when calling MCP tools |
| 8 | +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 |
12 | 9 | 5. **Max one clarifying question** before starting |
13 | 10 |
|
14 | 11 | ## Workflow |
15 | 12 |
|
16 | | -### 1. Detect Intent |
17 | | -- **Solution skill** (end-to-end capability like lex/react app) → Solution Path |
18 | | -- **Direct metadata** (specific fields/objects/pages) → Direct Path |
19 | | - |
20 | | -### 2. Solution Path |
21 | | -1. Load solution skill, extract metadata type sequence |
22 | | -2. For each type, execute loop (a-e below) |
23 | | -3. Proceed to Step 3 |
24 | | - |
25 | | -### 2. Direct Path |
26 | | -1. Identify all needed types |
27 | | -2. For each type in dependency order, execute loop (a-e below) |
28 | | -3. Proceed to Step 3 |
29 | | - |
30 | | -### Loop (a-e) - Execute for Each Type |
| 13 | +### Step 1: Metadata Loop - Execute for Each Type |
| 14 | +For each type, execute loop below |
31 | 15 |
|
32 | 16 | **a. Load Skill** |
33 | | -- Load metadata type skill once (not per record) |
34 | | -- If no skill exists, continue with API context only |
| 17 | +- Load the metadata type skill once (not per record) |
35 | 18 |
|
36 | | -**b. Call API Context** |
37 | | -- `get_metadata_api_context("TypeName")` - single type only |
38 | | -- Wait for response |
| 19 | +**b. Get entity context** |
| 20 | +- Use these tools from `salesforce-api-context` MCP server for entity context. |
| 21 | + - `get_metadata_type_sections` |
| 22 | + - `get_metadata_type_context` |
| 23 | + - `get_metadata_type_fields` |
| 24 | + - `get_metadata_type_fields_properties` |
| 25 | + - `search_metadata_types` |
39 | 26 |
|
40 | | -**c. Pre-Write Gate** |
41 | | -- Before EVERY write: confirm API context called for this type |
42 | | -- If no → stop and call now |
43 | 27 |
|
44 | | -**d. Generate Files** |
45 | | -- Use skill constraints + API context |
46 | | -- Generate all records for this type now |
47 | | - |
48 | | -**e. Checkpoint** |
49 | | -- Skill loaded? API context called? All files written? |
50 | | -- Only proceed to next type when all true |
51 | | - |
52 | | -### 3. Deploy Verification |
| 28 | +### Step 2. Verify deployment |
53 | 29 | ```bash |
54 | 30 | sf project deploy start --dry-run -d "force-app/main/default" --target-org <alias> --test-level NoTestRun --wait 10 --json |
55 | 31 | ``` |
56 | 32 | On failure: attempt to fix the errors and re-run, retrying up to a maximum of 3 times until it succeeds. |
57 | 33 |
|
| 34 | + |
58 | 35 | ## Anti-Patterns |
59 | 36 |
|
60 | 37 | | Don't | Why | Do | |
61 | 38 | |-------|-----|-----| |
62 | | -| Write without API context | Missing schema validation | Call API context before first write | |
63 | 39 | | Reload skill per record | Wastes tokens | Load once per type | |
64 | | -| Skip API context for later types | No schema for those types | Call for EVERY type | |
65 | 40 | | Skip metadata skills | Missing platform constraints | Load skill for every type | |
66 | 41 | | Ask 3+ questions | Token waste | Max 1 question | |
67 | | -| Skip solution skill gates | Wrong artifacts | Follow all mandatory gates | |
68 | | -| Write despite missing checkpoint | Aware violation | Stop and complete missing step | |
69 | | -| Batch types in API call | Violates constraint #3 | One type per call | |
| 42 | +| Batch types in calls to MCP tools | Violates constraint | One type per call | |
0 commit comments