Skip to content

PranavNagrecha/AwesomeSalesforceSkills / skills/admin/experience-cloud-member-management

experience-cloud-member-management

Verified

Use this skill when adding external users to an Experience Cloud site, configuring self-registration, managing external user licenses, or customising the login and registration pages. Trigger keywords: add members to community, external user license, self-registration, customer portal login, partner user onboarding, ConfigurableSelfRegHandler. NOT for choosing which external user license to buy — use architect/experience-cloud-licensing-model. Also covers the networkMemberGroups membership block, NetworkMemberGroup assignment status, external-user creation from contacts, offboarding, and LoginHistory diagnosis for site logins. NOT for what records external users can see — use security/experience-cloud-security.

references/llm-anti-patterns.md

View on GitHub
# LLM Anti-Patterns — Experience Cloud Member Management

Common mistakes AI coding assistants make when generating or advising on Experience Cloud Member Management.
These patterns help the consuming agent self-check its own output.

## Anti-Pattern 1: Inventing a `registerUser(Auth.SelfRegistrationContext)` Method

**What the LLM generates:**

```apex
// DOES NOT COMPILE — every identifier below is fabricated
public class MySelfRegHandler implements Auth.ConfigurableSelfRegHandler {
    public User registerUser(Auth.SelfRegistrationContext context) {
        User u = new User();
        u.Email     = context.email;
        u.FirstName = context.firstName;
        return u;
    }
}
```

**Why it happens:** This is a confabulated *name* wrapped around a correctly
understood *mechanism*. The model knows there is one hook method, that it
receives the registration form's values, and that returning nothing cancels
registration — all true. It does not know the identifiers, so it generates the
most natural-sounding ones: `registerUser` for the method (matching the
"self-registration" feature name), `Auth.SelfRegistrationContext` for the
parameter (Apex genuinely has context objects such as
`Auth.AuthProviderCallbackState`, and Flow/Trigger contexts make "context
object" a strong prior), and `User` for the return type (because the handler
obviously produces a user). Three plausible inventions on a correct skeleton
is far harder to spot than one obviously wrong claim.

There is no `Auth.SelfRegistrationContext` class anywhere in the Auth namespace,
and no `registerUser` method on any Auth interface.

**Correct pattern:** `Auth.ConfigurableSelfRegHandler` declares exactly one
method. It returns an `Id`, and it takes four parameters — the third of which
is keyed by `SObjectField`, not `String`:

```apex
global class MySelfRegHandler implements Auth.ConfigurableSelfRegHandler {
    global Id createUser(Id accountId,
                         Id profileId,
                         Map<SObjectField, String> registrationAttributes,
                         String password) {
        User u = new User();
        u.ProfileId = profileId;
        for (SObjectField field : registrationAttributes.keySet()) {
            u.put(field, registrationAttributes.get(field));
        }
        u.EmailEncodingKey  = 'UTF-8';
        u.LanguageLocaleKey = UserInfo.getLocale();
        u.LocaleSidKey      = UserInfo.getLocale();
        u.TimeZoneSidKey    = UserInfo.getTimeZone().getID();
        if (String.isBlank(password)) {
            password = generateRandomPassword();
        }
        Site.validatePassword(u, password, password);
        return Site.createExternalUser(u, accountId, password);  // returns the new User Id
    }
}
```

Return `null` or throw to fail the registration.

**Detection hint:** Two mechanical greps, both zero-tolerance:

1. `grep -n 'SelfRegistrationContext\|registerUser' *.cls` — neither identifier
   exists in the platform. Any hit is a fabrication.
2. `grep -n 'implements Auth.ConfigurableSelfRegHandler' -A3 *.cls` and check
   the return type. If the method returns `User` rather than `Id`, or takes
   fewer than four parameters, or types the map as
   `Map<String, String>`, it will not compile.

Do **not** use "has a `password` parameter" or "has an `Id` first parameter" as
a signal that the wrong interface was chosen — `Auth.ConfigurableSelfRegHandler`
has both.

---

## Anti-Pattern 2: Recommending Profile License Changes That Violate License Binding

**What the LLM generates:** Advice such as "open the profile, change the User License field from Customer Community to Partner Community, and save." Or instructions to edit the profile XML in a deployment package to swap the `<userLicense>` tag.

**Why it happens:** LLMs generalise from the concept of "profiles are just configuration" without understanding that the user license binding is a permanent platform constraint. The Metadata API technically allows deploying a profile XML with a different license value, but the platform rejects it with a validation error.

**Correct pattern:**

```
When the wrong license type was chosen:
1. Create a NEW profile cloned from the correct external base profile
   (e.g., "Partner Community User" instead of "Customer Community User").
2. Deactivate users on the old profile.
3. Create new user records assigned to the new profile.
4. Re-share records as needed under the new profile/license context.
There is no in-place migration path — a new profile and new user records are required.
```

**Detection hint:** Any instruction that says "edit the license on the existing profile" or "change the User License field" on a profile that already has active users is incorrect. Flag and reject.

---

## Anti-Pattern 3: Omitting the Default New User Account for Self-Registration

**What the LLM generates:** A self-registration setup walkthrough that enables the Self-Registration toggle and sets a Default Profile, but does not mention or configure the Default New User Account. The instructions treat the account field as optional.

**Why it happens:** LLMs trained on incomplete tutorial content often summarise the "enable self-reg" flow at a high level, omitting the account configuration step because it appears lower in the UI and is less frequently discussed as a distinct failure mode.

**Correct pattern:**

```
In Setup > Digital Experiences > [site] > Administration > Registration:
1. Enable Allow customers and partners to self-register.
2. Default New User Account: [set to a dedicated catch-all business Account, NOT a Person Account].
3. Default Profile: [set to the external profile tied to the correct license].
Both fields are required for self-registration to function.
Without the Default New User Account, self-registration silently fails.
```

**Detection hint:** Any self-registration setup guide that does not explicitly name the Default New User Account field as a required step is missing a critical piece. Check for this field's presence before trusting the instructions.

---

## Anti-Pattern 4: Recommending Internal Profiles for Experience Cloud Sites

**What the LLM generates:** Instructions to "add the Standard User profile to the site's Members list" or "use your existing Salesforce profile to grant portal access," treating internal and external profiles as equivalent.

**Why it happens:** LLMs conflate user profiles in general (a concept they have abundant training data on) with the external-user profile concept specific to Experience Cloud. The distinction between internal licenses (Salesforce, Salesforce Platform) and external licenses (Customer Community, Partner Community, etc.) is often blurred in older training material.

**Correct pattern:**

```
External Experience Cloud site membership only accepts profiles tied to
external user licenses:
- Customer Community
- Customer Community Plus
- Partner Community
- External Identity

Internal profiles (tied to the Salesforce or Salesforce Platform license)
cannot be added to the Members list and cannot be used to log in to an
Experience Cloud site. Always create or clone an external profile before
configuring site membership.
```

**Detection hint:** If the profile being recommended has "Standard User," "System Administrator," or any internal role in its description, it is an internal profile and cannot be used for Experience Cloud site membership.

---

## Anti-Pattern 5: Ignoring License Seat Limits When Adding Bulk Users

**What the LLM generates:** A data loader or Apex script that bulk-creates external User records without first checking available license capacity, then recommending to "just run it and see if it errors."

**Why it happens:** LLMs focus on the mechanics of user creation (field mappings, SOQL, DML) and do not model the org-state dependency on available license seats. License exhaustion is a runtime constraint invisible to static code analysis.

**Correct pattern:**

```apex
// Before bulk creating external users, query available license capacity:
List<UserLicense> licenses = [
    SELECT Name, TotalLicenses, UsedLicenses
    FROM UserLicense
    WHERE Name IN ('Customer Community', 'Customer Community Plus', 'Partner Community')
];
for (UserLicense lic : licenses) {
    Integer available = lic.TotalLicenses - lic.UsedLicenses;
    if (available < plannedUserCount) {
        throw new LicenseLimitException(
            'Insufficient ' + lic.Name + ' seats: ' + available + ' available, '
            + plannedUserCount + ' required.'
        );
    }
}
// Proceed with bulk user creation only after confirming capacity.
```

**Detection hint:** Any bulk user creation script that omits a capacity pre-check or does not reference the `UserLicense` sObject is incomplete. Always validate available seats before attempting bulk provisioning.

---

## Anti-Pattern 6: Treating Login Page Changes as Instantly Live

**What the LLM generates:** Instructions to edit the login page in Experience Builder and immediately tell users to test, without mentioning the Publish step.

**Why it happens:** For authenticated community pages, some property changes (like text on a component) can be previewed without publishing. LLMs generalise this to the login page, which has different publish semantics.

**Correct pattern:**

```
After making structural changes to the login or registration page in
Experience Builder (adding/removing components, changing page layout):
1. Click Publish in the top-right of Experience Builder.
2. Wait for the publish to complete.
3. Clear browser cache (or use incognito) before testing.
Changes are NOT live to external users until the site is published.
```

**Detection hint:** Any login-page editing guide that ends without an explicit Publish step is incomplete. Flag and add the publish instruction.
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: 196kUpdated Claude CodeCodexVerifiedInstall