$npx -y skills add forcedotcom/sf-skills --skill dx-org-permission-set-assignALWAYS USE THIS SKILL to assign permission sets to org users. Assign one or more permission sets to org users using the sf org assign permset command. TRIGGER when the user asks to assign, grant, give, add, or apply permission sets to users, admins, specific orgs, or specific use
| 1 | # dx-org-permission-set-assign |
| 2 | |
| 3 | Assigns one or more permission sets to org users using `sf org assign permset`. Handles all variants: default admin user, specific org targets, multiple permission sets, and assignment to specific users. |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | ## Tool Restrictions |
| 8 | |
| 9 | **Use ONLY the Bash tool** to execute `sf org assign permset`. Do NOT use MCP tools like `assign_permission_set` — ignore them completely. |
| 10 | |
| 11 | --- |
| 12 | |
| 13 | ## Scope |
| 14 | |
| 15 | - **In scope**: Assigning permission sets to users via `sf org assign permset` |
| 16 | - **Out of scope**: Creating permission sets (use `platform-permission-set-generate`), listing permission sets, checking user permissions |
| 17 | |
| 18 | --- |
| 19 | |
| 20 | ## Required Inputs |
| 21 | |
| 22 | Infer from the user's request: |
| 23 | |
| 24 | - **Permission set name(s)**: Extract from user message (can be multiple) |
| 25 | - **Target org**: Use default unless specific alias/username mentioned |
| 26 | - **Target user(s)**: Default is org's default admin user; use `--on-behalf-of` if specific users mentioned |
| 27 | |
| 28 | --- |
| 29 | |
| 30 | ## Workflow |
| 31 | |
| 32 | 1. Match user request to command in table below |
| 33 | 2. Execute via Bash tool: `sf org assign permset` with appropriate flags and `--json` flag |
| 34 | 3. Return result |
| 35 | |
| 36 | If error occurs, check the `failures` array in JSON output for details. |
| 37 | |
| 38 | ### Command Decision Table |
| 39 | |
| 40 | | User intent | Execute via Bash tool | |
| 41 | |-------------|---------| |
| 42 | | Assign one permission set to default admin | `sf org assign permset --name <PermSetName> --json` | |
| 43 | | Assign multiple permission sets to default admin | `sf org assign permset --name <PermSet1> --name <PermSet2> --json` | |
| 44 | | Assign to specific org | `sf org assign permset --name <PermSetName> --target-org <alias> --json` | |
| 45 | | Assign to specific user(s) | `sf org assign permset --name <PermSetName> --on-behalf-of <username1> --on-behalf-of <username2> --json` | |
| 46 | | Assign multiple sets to specific users | `sf org assign permset --name <PermSet1> --name <PermSet2> --on-behalf-of <username1> --on-behalf-of <username2> --json` | |
| 47 | |
| 48 | --- |
| 49 | |
| 50 | ## Rules / Constraints |
| 51 | |
| 52 | | Constraint | Rationale | |
| 53 | |-----------|-----------| |
| 54 | | Always use `--json` flag | Provides structured output for reliable parsing and error handling | |
| 55 | | Permission set names are case-sensitive | Use exact API names as they appear in the org | |
| 56 | | Multiple `--name` flags can be combined in one command | More efficient than separate commands per permission set | |
| 57 | | Multiple `--on-behalf-of` flags assign to multiple users | Batch assignment in single command; processed sequentially to avoid auth file collisions | |
| 58 | | Use CLI username aliases, not Salesforce User.Alias field | The `--target-org` and `--on-behalf-of` flags expect CLI aliases set via `sf alias set`, not the User object's Alias field | |
| 59 | | Duplicate assignments are idempotent | Re-assigning an already-assigned permission set succeeds silently | |
| 60 | | Partial success is possible | Command can return both successes and failures in one run; non-zero exit code if any failures | |
| 61 | |
| 62 | --- |
| 63 | |
| 64 | ## Gotchas |
| 65 | |
| 66 | | Issue | Resolution | |
| 67 | |-------|------------| |
| 68 | | Permission set name with spaces | Enclose in double quotes: `--name "Permission Set Name"` | |
| 69 | | "PermissionSet not found" error | Verify permission set exists in target org; check for typos in name | |
| 70 | | Assignment succeeds but user doesn't see permissions | Check `<hasActivationRequired>` in permission set metadata — may need manual activation in Setup | |
| 71 | | "User not found" error | Username/alias doesn't exist in target org — verify with `sf org display user --target-org <alias>` | |
| 72 | | Partial success (some users succeed, others fail) | Check JSON output — command returns both `successes` and `failures` arrays; exit code will be non-zero if any failures occurred | |
| 73 | |
| 74 | --- |
| 75 | |
| 76 | ## Output Expectations |
| 77 | |
| 78 | The command returns JSON output with status code and result details. |
| 79 | |
| 80 | See `examples/success_output.json` and `examples/error_output.json` for response structures. |
| 81 | |
| 82 | --- |
| 83 | |
| 84 | ## Reference File Index |
| 85 | |
| 86 | | File | When to read | |
| 87 | |------|-------------| |
| 88 | | `examples/success_output.json` | To understand successful assignment response structure | |
| 89 | | `examples/error_output.json` | To handle common error scenarios | |
| 90 | | `references/cli_flags.md` | For detailed explanation of all available flags | |