commerce-b2b-open-code…
Integrate Salesforce B2B Commerce open source components from GitHub into B2B Commerce…
Use when users get, create, edit, delete, or retrieve Salesforce Sharing Rules metadata for record-level access. TRIGGER on sharing rules, record/criteria-based/role-based/guest-user sharing, sharingCriteriaRules/sharingOwnerRules/sharingGuestRules, .sharingRules-meta.xml files,
$ npx -y skills add forcedotcom/sf-skills --skill platform-sharing-rules-generate --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
/platform-sharing-rules-generateContext preview
The summary Claude sees to decide when to auto-load this skill.
Use when users get, create, edit, delete, or retrieve Salesforce Sharing Rules metadata for record-level access. TRIGGER on sharing rules, record/criteria-based/role-based/guest-user sharing, sharingCriteriaRules/sharingOwnerRules/sharingGuestRules, .sharingRules-meta.xml files,
name: platform-sharing-rules-generate
description: "Use when users get, create, edit, delete, or retrieve Salesforce Sharing Rules metadata for record-level access. TRIGGER on sharing rules, record/criteria-based/role-based/guest-user sharing, sharingCriteriaRules/sharingOwnerRules/sharingGuestRules, .sharingRules-meta.xml files, or sharing records with roles or groups, including viewing or modifying existing rules. DO NOT TRIGGER for permission sets/profiles or object-level (not record-level) security (use platform-permission-set-generate)."
metadata:
version: "1.3"
domains: ["Platform"]
minApiVersion: "60.0"
relatedSkills:
- "platform-custom-object-generate"
- "platform-permission-set-generate"
cliTools:
- tool: ["sf"]
semver: ">=2.0.0"Get, create, edit, and delete Salesforce Sharing Rules metadata to control record-level access beyond org-wide defaults. Supports criteria-based rules, role/group-based owner rules, and guest user rules for Experience Sites.
---
Before proceeding, confirm with the user if not already clear:
---
Gather or infer before proceeding:
Defaults unless specified:
---
Steps are sequential within each phase. Phase 3 branches by operation type — execute only the matching branch. Phase 4 applies to create, edit, and delete only (get operations end at Phase 3).
1. **Resolve the SFDX project path** — find the project's `sfdx-project.json` and identify the package directory for `sharingRules/`.
2. **Always retrieve the latest sharing rules from the org** using the Metadata API Retrieve pattern:
sf project retrieve start --metadata "SharingRules:<ObjectName>" --target-org <org>
This ensures the local file reflects the current org state. Never trust a local file that may be stale — edits or deletes against a stale file can recreate rules that were already removed in the org or overwrite changes made by other users.
3. **Read the retrieved file** — parse `<packageDir>/sharingRules/<ObjectName>.sharingRules-meta.xml` to understand existing rules and avoid duplicates.
4. **Identify the operation** — determine whether the user wants to **get**, **create**, **edit**, or **delete** a sharing rule.
5. **Select the rule type** based on user intent. Read `references/rule-types.md` for the complete schema of each type and its required elements.
6. **For Account sharing rules**: the `accountSettings` element is required. Default sub-access levels to `None` unless the user specifies otherwise.
7. **For Guest rules**: the `sharedTo` must use `<guestUser>` with the site guest user's community nickname. Never use `<role>` or `<group>` for guest rules.
8a. **Use the file already retrieved in Phase 1** — the retrieve in step 2 already pulled the latest `<ObjectName>.sharingRules-meta.xml` from the org. No additional retrieve is needed.
8b. **Read and present the retrieved rules** — parse the `.sharingRules-meta.xml` file and present the rules to the user in a readable format showing:
For get operations, skip Phase 4 (no write needed). The retrieve itself writes the metadata file to the local project.
8a. **Construct the XML** following the schema in `references/rule-types.md`. Key structure:
This repository provides a curated collection of Salesforce agent skills for building applications.
Repo: forcedotcom/afv-library
Integrate Salesforce B2B Commerce open source components from GitHub into B2B Commerce…
Replace OOTB (out-of-the-box) B2B Commerce components with open source equivalents in site…
Use this skill to diagnose and resolve what blocks a DevOps Center promotion of a work item's…
Use this skill to manage the full lifecycle of a DevOps Center pipeline — list all pipelines,…
Use to list, view, or manage DevOps Center projects in a Salesforce org — show all projects,…
Analyzes DevOps Center test failures and Code Analyzer violations in plain language — failure…