Skip to content

PranavNagrecha/AwesomeSalesforceSkills / skills/admin/custom-label-management

custom-label-management

Verified

Custom Labels for i18n, configuration strings, and UI text: translation workbench, Apex System.Label, LWC @salesforce/label imports, 1,000-char limit. NOT for translating picklist values, field labels or layouts — use admin/multi-language-and-translation. NOT for config values in custom metadata or custom settings — use admin/custom-metadata-types.

references/llm-anti-patterns.md

View on GitHub
# LLM Anti-Patterns — Custom Label Management

Common mistakes AI coding assistants make when handling user-facing strings.

## Anti-Pattern 1: Hard-coding English strings in LWC templates

**What the LLM generates:** `<h1>Welcome, please log in</h1>` directly in the template.

**Why it happens:** The model treats LWC like a static web page without considering i18n.

**Correct pattern:**

```
Create a Custom Label `Welcome_LoginPrompt`, import in JS via
@salesforce/label/c.Welcome_LoginPrompt, and reference in template
as {labels.welcome}. Now translatable and reviewable without code.
```

**Detection hint:** LWC `.html` with prose English text not bound to a `labels` import or variable.

---

## Anti-Pattern 2: Hard-coding error messages in Apex addError

**What the LLM generates:** `acc.addError('Amount cannot be negative');`

**Why it happens:** Model generates validation logic without externalizing messages.

**Correct pattern:**

```
acc.addError(System.Label.Error_AmountNegative);

Create the label with a short-description explaining the scenario so
translators have context.
```

**Detection hint:** Apex `addError('...')` with a hard-coded English message.

---

## Anti-Pattern 3: Renaming a label Name to reflect a value change

**What the LLM generates:** Renames label `Error_Msg` → `Error_Negative_Amount`.

**Why it happens:** Model treats Name as a display string rather than an API handle.

**Correct pattern:**

```
Label Names are API references — renaming breaks Apex and LWC
references. Keep Name stable; change the Value instead. If semantics
change enough to want a new Name, add a new label and deprecate the
old one after references migrate.
```

**Detection hint:** Diff shows label Name change with matching Apex edits.

---

## Anti-Pattern 4: Splitting a label over 1,000 chars ad hoc

**What the LLM generates:** Three labels concatenated in Apex with no naming pattern.

**Why it happens:** Model brute-forces the limit without considering translator experience.

**Correct pattern:**

```
Use consistent suffix convention: My_Long_Text_Part1, My_Long_Text_Part2.
Concatenate in a helper (MessageBuilder.forEmail('My_Long_Text')) that
joins parts by base name. Translators see grouped parts, not
mysteriously-numbered labels.
```

**Detection hint:** Labels named with arbitrary suffixes concatenated in Apex string assembly.

---

## Anti-Pattern 5: Building a parallel Map<String,String> instead of using System.Label

**What the LLM generates:** `Map<String,String> labels = new Map<String,String>{ 'welcome' => 'Welcome!' };`

**Why it happens:** Model invents a parallel i18n mechanism without knowing about `System.Label`.

**Correct pattern:**

```
Use System.Label.My_Label directly. It's compiled, package-aware,
translated via Translation Workbench, and tracked by metadata
dependency tooling. A parallel Map<String,String> is unversioned,
untranslatable, and invisible to the Setup UI.
```

**Detection hint:** Apex class defining a static Map of string->string for "labels".
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 323kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 198kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 198kUpdated Claude CodeCodexVerifiedInstall