|
| 1 | +# Rule: Salesforce Metadata Generation |
| 2 | + |
| 3 | +## Objective |
| 4 | +Enforce: **skill load → API context → file generation** for all Salesforce metadata. |
| 5 | + |
| 6 | +## Constraints |
| 7 | + |
| 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. **No cross-type content** in files |
| 12 | +5. **Max one clarifying question** before starting |
| 13 | + |
| 14 | +## Workflow |
| 15 | + |
| 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 |
| 31 | + |
| 32 | +**a. Load Skill** |
| 33 | +- Load metadata type skill once (not per record) |
| 34 | +- If no skill exists, continue with API context only |
| 35 | + |
| 36 | +**b. Call API Context** |
| 37 | +- `get_metadata_api_context("TypeName")` - single type only |
| 38 | +- Wait for response |
| 39 | + |
| 40 | +**c. Pre-Write Gate** |
| 41 | +- Before EVERY write: confirm API context called for this type |
| 42 | +- If no → stop and call now |
| 43 | + |
| 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 |
| 53 | +```bash |
| 54 | +sf project deploy start --dry-run -d "<path>" --target-org <alias> --test-level NoTestRun --wait 10 --json |
| 55 | +``` |
| 56 | +On failure: attempt to fix the errors and re-run, retrying up to a maximum of 5 times until it succeeds. |
| 57 | + |
| 58 | +## Anti-Patterns |
| 59 | + |
| 60 | +| Don't | Why | Do | |
| 61 | +|-------|-----|-----| |
| 62 | +| Write without API context | Missing schema validation | Call API context before first write | |
| 63 | +| 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 | +| Skip metadata skills | Missing platform constraints | Load skill for every type | |
| 66 | +| 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 | |
0 commit comments