Skip to content

forcedotcom/sf-skills / skills/platform-policy-rule-generate

platform-policy-rule-generate

Verified

THE skill for creating a Data Cloud / Data Governance access policy — authors and deploys a PolicyRuleDefinitionSet + PolicyRuleDefinition pair (CRUD) covering OLS, FLS, RLS, masking/transform, and tag/classification-based access for the DATACLOUD or ALL consumer. TRIGGER when the user wants to create/write/author a Data Cloud or Data Governance policy, access policy, or policy rule, or to grant access to a Data Cloud object THROUGH A POLICY — a Data Cloud policy-create request routes here, not to the tag/classification surface. Resolves every reference via Data 360 MCP. SCOPE: Data Cloud policies only (not Security Center, DSAR, or User Access Policies). DO NOT TRIGGER to create tags/classifications, or to grant object/dataspace access via a PERMISSION SET / RBAC grant (use platform-dataspace-access-configure). For a vague object-access ask, surface both skills and ASK the permission-set way vs the policy way; if unsure the object is Data Cloud, ask which first.

FileKindSize
SKILL.mdskill md22.8 KB
references/condition-model.mdmarkdown2.5 KB
references/condition-templates.mdmarkdown3.3 KB
references/conjunction-compiler.mdmarkdown1.6 KB
references/conjunction-expression.mdmarkdown2.3 KB
references/consumer-all.mdmarkdown883 B
references/consumer-datacloud-ui.mdmarkdown6.4 KB
references/deploy-errors.mdmarkdown5.5 KB
references/examples/ExistsJoinRLS/package.xmlconfig371 B
references/examples/ExistsJoinRLS/policyRuleDefinitionSets/ExistsJoinRLS.policyRuleDefinitionSetother221 B
references/examples/ExistsJoinRLS/policyRuleDefinitions/ExistsJoinRLS_Rule_1.policyRuleDefinitionother3.8 KB
references/examples/FieldReadDeny/package.xmlconfig371 B
references/examples/FieldReadDeny/policyRuleDefinitionSets/FieldReadDeny.policyRuleDefinitionSetother221 B
references/examples/FieldReadDeny/policyRuleDefinitions/FieldReadDeny_Rule_1.policyRuleDefinitionother3.0 KB
references/examples/LastCharactersFieldMasking/package.xmlconfig397 B
references/examples/LastCharactersFieldMasking/policyRuleDefinitionSets/LastCharactersFieldMasking.policyRuleDefinitionSetother234 B
references/examples/LastCharactersFieldMasking/policyRuleDefinitions/LastCharactersFieldMasking_Rule_1.policyRuleDefinitionother3.2 KB
references/examples/PrincipalFieldMatchRLS/package.xmlconfig389 B
references/examples/PrincipalFieldMatchRLS/policyRuleDefinitionSets/PrincipalFieldMatchRLS.policyRuleDefinitionSetother230 B
references/examples/PrincipalFieldMatchRLS/policyRuleDefinitions/PrincipalFieldMatchRLS_Rule_1.policyRuleDefinitionother3.1 KB
references/examples/TaggedObjectAccess/package.xmlconfig381 B
references/examples/TaggedObjectAccess/policyRuleDefinitionSets/TaggedObjectAccess.policyRuleDefinitionSetother226 B
references/examples/TaggedObjectAccess/policyRuleDefinitions/TaggedObjectAccess_Rule_1.policyRuleDefinitionother2.7 KB
references/headless-transport.mdmarkdown7.6 KB
references/policy-schema-full.mdmarkdown10.3 KB
references/policy-shapes.mdmarkdown8.3 KB
references/principal-expression.mdmarkdown1.7 KB
references/reference-resolution.mdmarkdown9.8 KB
references/resource-expression.mdmarkdown2.3 KB
references/runtime-context.mdmarkdown864 B
references/templates-access.mdmarkdown5.2 KB
references/templates-advanced.mdmarkdown2.2 KB
references/templates-record.mdmarkdown3.6 KB
references/templates-transform.mdmarkdown2.7 KB
references/templates.mdmarkdown865 B
references/ui-compatibility.mdmarkdown12.8 KB

references/templates-access.md

View on GitHub
# ACCESS / GOVERNANCE Templates

The GOVERNANCE TupleRead shape is MDAPI persistence-validated. Policy Builder open/save compatibility is not yet validated. The ACCESS examples are older fixture-only shapes retained for explicitly requested API-only metadata.

Prefer the complete semantic OLS evidence under `examples/TaggedObjectAccess/` and resolve every target-org value again.

---

## API-only ACCESS — Simple Permit (no conditions)

Source: `baseSteelthread`

```xml
<?xml version="1.0" encoding="UTF-8"?>
<PolicyRuleDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
    <action>Read</action>
    <category>ACCESS_POLICY_RULE_DEFINITION</category>
    <effect>Permit</effect>
    <label>Rule0</label>
    <policyRuleDefinitionSetName>Set1</policyRuleDefinitionSetName>
    <principalAuthenticationLevel>INTERNAL</principalAuthenticationLevel>
    <principalScopeType>ANY</principalScopeType>
    <resourceScopeType>ANY</resourceScopeType>
    <ruleConsumer>DATACLOUD</ruleConsumer>
    <transformPrecedence>0</transformPrecedence>
</PolicyRuleDefinition>
```

---

## GOVERNANCE — "Objects AND all their fields" via TupleRead

Source: `references/examples/TaggedObjectAccess/`

Three required pieces:
1. `<action>TupleRead</action>` — cascades object-level condition to fields
2. **OR-of-ENTITYTYPE clause** — required for UI editability (without it the builder crashes)
3. The actual semantic gate (tag / classification / permission)

```xml
<?xml version="1.0" encoding="UTF-8"?>
<PolicyRuleDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
    <action>TupleRead</action>
    <category>GOVERNANCE_POLICY_RULE_DEFINITION</category>
    <effect>Permit</effect>
    <label>GrantPublicAccess</label>
    <policyRuleDefinitionSetName>PublicAccessSet</policyRuleDefinitionSetName>
    <principalAuthenticationLevel>INTERNAL</principalAuthenticationLevel>
    <principalScopeType>ANY</principalScopeType>
    <resourceScopeType>ANY</resourceScopeType>
    <ruleConsumer>DATACLOUD</ruleConsumer>
    <transformPrecedence>0</transformPrecedence>
    <whenPolicyRuleDefinitionClauseConjunction>
        <!-- (1) and (2): OR-of-ENTITYTYPE clause — required for UI rendering -->
        <conditions>
            <clause>WHEN</clause>
            <operator>IS</operator>
            <policyRuleValueSet>
                <valueText>OBJECT</valueText>
            </policyRuleValueSet>
            <resourcePath>ENTITYTYPE</resourcePath>
        </conditions>
        <conditions>
            <clause>WHEN</clause>
            <operator>IS</operator>
            <policyRuleValueSet>
                <valueText>FIELD</valueText>
            </policyRuleValueSet>
            <resourcePath>ENTITYTYPE</resourcePath>
        </conditions>
        <!-- (3): actual semantic gate -->
        <conditions>
            <clause>WHEN</clause>
            <operator>CONTAINS_ANY</operator>
            <resourcePath>TAG</resourcePath>
            <policyRuleValueSet>
                <valueReference>DataGovernanceTags.ExternalData.Visibility.Public</valueReference>
                <valueReferenceType>STANDARD_TAG</valueReferenceType>
            </policyRuleValueSet>
        </conditions>
        <!-- MUST use (AND N) not bare N for every top-level param — bare index crashes UI -->
        <conjunctionExpression>(AND (OR 1 2) (AND 3))</conjunctionExpression>
    </whenPolicyRuleDefinitionClauseConjunction>
</PolicyRuleDefinition>
```

Do not infer deny semantics from this Permit example. Use a separately retrieved and target-org-validated shape.

---

## API-only ACCESS — Gated by Tag / Classification / Permission

Source: `conditionTagValidSteelthread`, `conditionClassificationValidClauseSteelthread`, `conditionAssignedPermPathValidSteelthread`

```xml
<?xml version="1.0" encoding="UTF-8"?>
<PolicyRuleDefinition xmlns="http://soap.sforce.com/2006/04/metadata">
    <action>Read</action>
    <category>ACCESS_POLICY_RULE_DEFINITION</category>
    <effect>Permit</effect>
    <label>Rule0</label>
    <policyRuleDefinitionSetName>TagSet1</policyRuleDefinitionSetName>
    <principalAuthenticationLevel>INTERNAL</principalAuthenticationLevel>
    <principalScopeType>ANY</principalScopeType>
    <resourceScopeType>ANY</resourceScopeType>
    <ruleConsumer>DATACLOUD</ruleConsumer>
    <transformPrecedence>0</transformPrecedence>
    <whenPolicyRuleDefinitionClauseConjunction>
        <conditions>
            <clause>WHEN</clause>
            <operator>CONTAINS_ANY</operator>
            <resourcePath>TAG</resourcePath>
            <policyRuleValueSet>
                <valueReference>CustomTagRef</valueReference>
                <valueReferenceType>CUSTOM_TAG</valueReferenceType>
            </policyRuleValueSet>
        </conditions>
        <conjunctionExpression>(AND 1)</conjunctionExpression>
    </whenPolicyRuleDefinitionClauseConjunction>
</PolicyRuleDefinition>
```

Swap the inner condition for permission gating:
```xml
<conditions>
    <clause>WHEN</clause>
    <operator>CONTAINS_ANY</operator>
    <principalPath>ASSIGNED_PERMISSIONS_PATH</principalPath>
    <policyRuleValueSet>
        <valueReference>testCustomPermission1</valueReference>
        <valueReferenceType>CUSTOM_PERMISSION</valueReferenceType>
    </policyRuleValueSet>
</conditions>
```
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall