|
| 1 | +--- |
| 2 | +name: dx-pkg-post-install-configure |
| 3 | +description: "Use this skill to automate managed package post-install configuration. Package-agnostic — works with any managed package (LMA, FMA, work.com, Certinia, etc.). TRIGGER when: user installs a managed package and needs post-install configuration, mentions LMA/FMA/work.com post-install setup, asks to configure permission sets/FLS/page layouts for an installed package, says 'post-install', 'package setup', 'configure LMA', 'set up FMA', 'post-install steps'. DO NOT TRIGGER for: standalone permission set assignment (use dx-org-permission-set-assign), generating permission set metadata XML (use platform-permission-set-generate), package installation, or org switching." |
| 4 | +metadata: |
| 5 | + version: "2.2" |
| 6 | + minApiVersion: "67.0" |
| 7 | + cliTools: |
| 8 | + - tool: ["sf"] |
| 9 | + semver: ">=2.0.0" |
| 10 | +--- |
| 11 | + |
| 12 | +## When to Use This Skill |
| 13 | + |
| 14 | +Use when automating post-install configuration for any Salesforce managed package. This skill reads the package's post-install documentation, discovers available execution methods, and automates the configuration steps — including permission sets, object/field permissions, page layouts, Visualforce page access, and tab settings. |
| 15 | + |
| 16 | +## Input |
| 17 | + |
| 18 | +- **Required:** Package name (e.g., `LMA`, `FMA`, `work.com`) |
| 19 | +- **Optional:** Path to post-install doc (PDF, markdown, URL) |
| 20 | + |
| 21 | +If no doc is provided, ask the user to supply it. |
| 22 | + |
| 23 | +## Workflow |
| 24 | + |
| 25 | +Execute phases in order. Each phase must pass before proceeding. |
| 26 | + |
| 27 | +--- |
| 28 | + |
| 29 | +### Phase 1: Discover Available Execution Methods |
| 30 | + |
| 31 | +**Priority order:** |
| 32 | +1. Org-native platform MCP servers (highest — direct org access via Headless 360) |
| 33 | +2. Claude Code external MCP servers (sf-sobject-all, sf-sobject-all-sb, etc.) |
| 34 | +3. sf CLI fallback (always available if authenticated) |
| 35 | + |
| 36 | +#### Step 1A: Resolve org API version |
| 37 | + |
| 38 | +Discover the org's current API version dynamically — never hardcode a version number: |
| 39 | + |
| 40 | +```bash |
| 41 | +sf org display --target-org <alias> --json |
| 42 | +``` |
| 43 | + |
| 44 | +From the JSON response, read `result.apiVersion` (e.g., `"67.0"`). Store this value and use it as `v<apiVersion>` in all subsequent REST paths. If the command fails, fall back to the `minApiVersion` declared in this skill's metadata (`67.0`). |
| 45 | + |
| 46 | +#### Step 1B: Check for org-native platform MCP servers |
| 47 | + |
| 48 | +Query the Tooling API for MCP server availability: |
| 49 | + |
| 50 | +```bash |
| 51 | +sf api request rest "/services/data/v<apiVersion>/tooling/query?q=SELECT+Id,DeveloperName,MasterLabel+FROM+McpServerAccess" --target-org <alias> |
| 52 | +``` |
| 53 | + |
| 54 | +#### Step 1C: Determine execution method |
| 55 | + |
| 56 | +Check which Claude Code MCP tools are available and authenticated. |
| 57 | + |
| 58 | +**MCP tool prefixes by org type:** |
| 59 | + |
| 60 | +| Org Type | Tool Prefix | |
| 61 | +|---|---| |
| 62 | +| Production | `mcp__sf-sobject-all__` | |
| 63 | +| Sandbox | `mcp__sf-sobject-all-sb__` | |
| 64 | +| Falcon Test (pc-rnd) | `mcp__sf-sobject-all-falcon__` | |
| 65 | + |
| 66 | +If MCP needs auth, call the authenticate tool. If auth fails, fall back to sf CLI. |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +### Phase 2: Verify Authentication & Org Identity |
| 71 | + |
| 72 | +1. Run a lightweight test query (`SELECT Id, Name, IsSandbox FROM Organization`) |
| 73 | +2. If MCP auth fails, automatically fall back to sf CLI |
| 74 | +3. Display org info and ask user to confirm before proceeding |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +### Phase 3: Verify Package Installation |
| 79 | + |
| 80 | +1. Determine the package namespace (ask user if unknown) |
| 81 | +2. Check via Tooling API (`InstalledSubscriberPackage`) — do NOT use `PackageLicense` |
| 82 | +3. If package not found, stop and inform user |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +### Phase 4: Read and Parse Post-Install Document |
| 87 | + |
| 88 | +Read the provided document and extract discrete configuration steps. |
| 89 | + |
| 90 | +**Supported formats:** PDF, markdown, URL (via WebFetch), pasted text. |
| 91 | + |
| 92 | +**Parsing approach:** |
| 93 | +1. Extract each numbered/bulleted step from the document |
| 94 | +2. Present the extracted steps to the user for validation before proceeding |
| 95 | + |
| 96 | +--- |
| 97 | + |
| 98 | +### Phase 5: Classify Steps & Interactive Plan Review |
| 99 | + |
| 100 | +For each step extracted from the doc, classify as Automated or Manual. |
| 101 | + |
| 102 | +#### Automation capabilities reference |
| 103 | + |
| 104 | +**Via MCP (sobject-all) or sf CLI CRUD:** |
| 105 | +- Record CRUD on any standard or custom object (PermissionSet, ObjectPermissions, |
| 106 | + FieldPermissions, SetupEntityAccess, PermissionSetTabSetting, PermissionSetAssignment, etc.) |
| 107 | + |
| 108 | +**Via Metadata API retrieve/deploy (sf CLI):** |
| 109 | +- Page layout modifications (add related lists, fields, sections) |
| 110 | +- Profile settings |
| 111 | +- Custom metadata type records |
| 112 | + |
| 113 | +**Via sf CLI Tooling API:** |
| 114 | +- Tooling queries (InstalledSubscriberPackage, ApexPage, ApexClass, etc.) |
| 115 | +- Any REST-accessible Tooling operation |
| 116 | + |
| 117 | +**Manual (no API path — requires Setup UI):** |
| 118 | +- System permissions not exposed via REST |
| 119 | +- Connected app OAuth configuration |
| 120 | +- Environment Hub linkage |
| 121 | + |
| 122 | +#### Interactive approval |
| 123 | + |
| 124 | +Present the classified plan and let the user choose: |
| 125 | +- **"Approve all"** — Execute all steps as planned |
| 126 | +- **"Let me choose"** — Select which steps to approve/skip |
| 127 | +- **"I have questions"** — Discuss specific steps before deciding |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +### Phase 6: Execute Approved Steps |
| 132 | + |
| 133 | +For each approved step, use the resolved execution method. |
| 134 | + |
| 135 | +#### Execution method reference |
| 136 | + |
| 137 | +| Operation | Via MCP | Via sf CLI | |
| 138 | +|---|---|---| |
| 139 | +| SOQL query | `soqlQuery` tool | `sf data query --query "<SOQL>" --target-org <alias> --json` | |
| 140 | +| Create record | `createSobjectRecord` tool | `sf data create record --sobject <Object> --values "..." --target-org <alias> --json` | |
| 141 | +| Update record | `updateSobjectRecord` tool | `sf data update record --sobject <Object> --record-id <id> --values "..." --target-org <alias> --json` | |
| 142 | +| Describe object | `getObjectSchema` tool | `sf api request rest "/services/data/v<apiVersion>/sobjects/<Object>/describe" --target-org <alias>` | |
| 143 | +| Page layout | N/A | Metadata API retrieve/deploy | |
| 144 | + |
| 145 | +#### Page layout modifications via Metadata API |
| 146 | + |
| 147 | +Use `sf project retrieve start` → edit the layout XML → `sf project deploy start`. |
| 148 | + |
| 149 | +#### Execution rules |
| 150 | + |
| 151 | +- **Idempotency:** Before creating any record, query to check if it already exists. Skip if so. |
| 152 | +- **Report after each step:** Show success count, skipped items, and reasons. |
| 153 | +- **Automatic fallback:** If MCP fails mid-execution, retry via sf CLI. |
| 154 | +- **On failure:** Report error, ask user to retry/skip/stop. |
| 155 | + |
| 156 | +--- |
| 157 | + |
| 158 | +### Phase 7: Guide Manual Steps (if any) |
| 159 | + |
| 160 | +If any steps could not be automated, present each with Setup navigation instructions. |
| 161 | +Wait for user confirmation before proceeding to the next. |
| 162 | + |
| 163 | +--- |
| 164 | + |
| 165 | +### Phase 8: Summary |
| 166 | + |
| 167 | +Display final summary with step-by-step status, method used, and any skipped items. |
| 168 | + |
| 169 | +--- |
| 170 | + |
| 171 | +## Error Handling |
| 172 | + |
| 173 | +- **Auth failure mid-execution:** Stop, ask user to re-auth, offer to resume |
| 174 | +- **Duplicate record errors:** Treat as "already configured", skip and continue |
| 175 | +- **Permission errors:** Report which permission is missing, suggest resolution |
| 176 | +- **Unknown step type:** Ask user to clarify, offer to mark as manual |
| 177 | + |
| 178 | +## Notes |
| 179 | + |
| 180 | +- **Priority: org-native MCP > Claude Code MCP > sf CLI > manual** |
| 181 | +- sf CLI is always a valid fallback for all CRUD and Tooling API operations |
| 182 | +- Page layout modifications are automated via Metadata API retrieve/deploy |
| 183 | +- Always verify org identity before making changes |
| 184 | +- All actions respect the authenticated user's permissions |
0 commit comments