PranavNagrecha/AwesomeSalesforceSkills / skills/admin/custom-permissions
custom-permissions
VerifiedUse when creating, assigning, or checking custom permissions to control feature access beyond CRUD and FLS. Trigger keywords: 'custom permission', 'FeatureManagement.checkPermission', '$Permission global variable', 'feature gate', 'named access grant', 'beta feature flag', 'SetupEntityAccess', 'requiredPermission', 'who has this custom permission'. NOT for gating Apex service code and its tests — use apex/apex-custom-permissions-check. NOT for permission set design — use admin/permission-set-architecture.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 23.6 KB |
| references/examples.md | markdown | 8.2 KB |
| references/gotchas.md | markdown | 13.7 KB |
| references/llm-anti-patterns.md | markdown | 8.0 KB |
| references/metadata-examples.md | markdown | 14.2 KB |
| references/well-architected.md | markdown | 7.6 KB |
| scripts/check_custom_permissions.pyexecutable | script | 17.3 KB |
| scripts/fixtures/empty-tree/README.md | markdown | 473 B |
| templates/custom-permissions-template.md | markdown | 4.0 KB |
templates/custom-permissions-template.md
View on GitHub# Custom Permissions — Work Template
Use this template when working on a custom permissions task. Fill in each section before starting implementation.
---
## Scope
**Skill:** `custom-permissions`
**Request summary:** (describe what the user asked for — what feature needs to be gated, or what access check needs to be added)
---
## Context Gathered
Answer these before writing any metadata or code:
- **Custom permission API name:** (must start with a letter; alphanumeric + underscore only)
- **Custom permission label:** (human-readable; appears in permission set editor)
- **Platform contexts that will check the permission:**
- [ ] Apex (`FeatureManagement.checkPermission`)
- [ ] Validation rule (`NOT($Permission.X)` in AND condition)
- [ ] Formula field (`$Permission.X`)
- [ ] Flow (formula resource of type Boolean)
- [ ] Visualforce (`{!$Permission.X}`)
- [ ] LWC (`@salesforce/customPermission/X`)
- [ ] Lightning page component visibility / Dynamic Forms (`{!$Permission.CustomPermission.X}`)
- [ ] In-App Guidance `uiFormulaRule`
- **Description text (names every consumer above; 255-char limit):**
- **Does another custom permission have to be enabled with this one (`requiredPermission`)?**
- **Is the grant permanent, or does it expire?** (see `admin/permission-set-expiration`)
- **Permission sets that will carry this permission:** (list all)
- **Users or personas who should receive the permission:** (list or describe)
- **Is this a new permission or modifying an existing one?**
---
## Approach
Which pattern from SKILL.md applies?
- [ ] Feature Gate for Beta or Graduated Rollout
- [ ] Admin-Only Bypass in Validation Rules
- [ ] Conditional UI Visibility Gate in LWC
- [ ] Other: _______________
Why this pattern:
---
## Metadata Checklist
- [ ] Custom permission created in Setup (or `customPermissions/*.customPermission-meta.xml` authored)
- [ ] Permission set XML updated with `<customPermissions>` node
- [ ] All permission sets that need this permission have been updated
- [ ] Metadata committed to source control
## Apex / Formula Checklist
- [ ] `FeatureManagement.checkPermission('API_Name')` used in all Apex guards
- [ ] `$Permission.API_Name` used in all formula/validation rule references
- [ ] Apex unit tests have permission set assignment in `@TestSetup`
- [ ] Both positive (has permission) and negative (no permission) test cases exist
- [ ] `System.runAs(testUser)` wraps the code-under-test in permission-gated test methods
## Flow Checklist
- [ ] Formula resource of type Boolean created with value `$Permission.API_Name`
- [ ] Decision element conditions reference the formula resource variable, not the raw `$Permission` syntax
---
## Deployment Checklist
- [ ] Custom permission metadata included in deployment package
- [ ] All dependent permission sets included in deployment package
- [ ] Apex classes with updated guards included
- [ ] Validation rule updates included
- [ ] `check_custom_permissions.py` run on the post-deploy metadata to confirm assignments
---
## Notes
Record any deviations from the standard pattern and why:
---
## Reference Syntax
| Context | Syntax |
|---|---|
| Apex | `FeatureManagement.checkPermission('My_Custom_Permission')` |
| Validation rule bypass | `AND(NOT($Permission.My_Custom_Permission), /* rule conditions */)` |
| Formula field | `$Permission.My_Custom_Permission` |
| Flow formula resource | `$Permission.My_Custom_Permission` (used as resource value, type Boolean) |
| Visualforce | `{!$Permission.My_Custom_Permission}` |
| LWC | `import hasPerm from '@salesforce/customPermission/My_Custom_Permission';` (resolves to `true` or `undefined`) |
| Component visibility / In-App Guidance | `{!$Permission.CustomPermission.My_Custom_Permission}` — note the extra `CustomPermission.` segment |
| Permission set XML | `<customPermissions><enabled>true</enabled><name>My_Custom_Permission</name></customPermissions>`, inside a `<PermissionSet>` root |
Full deployable files, package.xml, deploy order, and the `SetupEntityAccess` verification queries are in `references/metadata-examples.md`.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| finishing-a-development-branchobra/superpowersUse when implementation is complete, all tests pass, and you need to decide how to integrate the work | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| systematic-debuggingobra/superpowersUse when encountering any bug, test failure, or unexpected behavior, before proposing fixes | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| test-driven-developmentobra/superpowersUse when implementing any feature or bugfix, before writing implementation code | Stars: 323k | Updated | Claude CodeCodex | Verified | Install |
| skill-creatoranthropics/skillsCreate new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |