Skip to main content
skill CX Codex

dx-org-permission-set-assign — Claude Code skill: install & use

Assigns Salesforce permission sets to org users via sf org assign permset. Handles default admins, target org aliases, and batch assignments.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add forcedotcom/sf-skills --skill dx-org-permission-set-assign -a claude-code
Open on GitHub

What dx-org-permission-set-assign does

The skill executes sf org assign permset using the Bash tool and parses the structured JSON response. It handles assignments for the default org admin or routes them to specific accounts using the --on-behalf-of flag. You can pass several --name flags in a single command. Re-assigning an existing permission set runs without throwing errors.

MCP tools like assign_permission_set are explicitly bypassed in favor of direct CLI execution. The skill stays strictly focused on assignments. It will not generate permission sets, inspect existing user permissions, or list available permissions.

Execution fails if the system lacks the sf CLI binary at version 2.0.0 or higher. Target orgs and users must use CLI aliases configured through sf alias set rather than the Salesforce User.Alias field.

What it helps with

  • assign a permission set to the default scratch org admin
  • grant multiple permission sets to specific users in one run
  • apply permissions to a target org alias with JSON error tracking
  • handle batch permission assignments sequentially to avoid auth file conflicts

Example prompts for the agent

  • Assign the SalesOps permission set to the default admin
  • Grant BillingManager and SupportAgent to user qa-user in org uat
  • Apply permission set "Custom Analytics" to users dev1 and dev2

How to install dx-org-permission-set-assign

1Skills CLI (Vercel)

npx skills add forcedotcom/sf-skills --skill dx-org-permission-set-assign -a claude-code

2Manually: put the files in place

~/.claude/skills/dx-org-permission-set-assign/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/dx-org-permission-set-assign/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about dx-org-permission-set-assign

How do I install dx-org-permission-set-assign in Claude Code?

Run npx skills add forcedotcom/sf-skills --skill dx-org-permission-set-assign -a claude-code in your terminal.

What does dx-org-permission-set-assign do?

It automates assigning Salesforce permission sets to org users by running sf org assign permset via Bash with --json formatting.

Which prerequisites are required for dx-org-permission-set-assign?

You need the Salesforce CLI (sf) version 2.0.0 or newer installed in your environment. User and org arguments must be CLI aliases established with sf alias set.

Source text

SKILL.md · Apache-2.0
---
name: dx-org-permission-set-assign
description: "ALWAYS 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 users. Supports granting permissions, giving access, and adding permission sets to default admin or specific users via --on-behalf-of. DO NOT TRIGGER for listing permission sets or checking user permissions."
metadata:
  version: "1.0"
  domains: ["Developer Experience"]
  relatedSkills:
    - "platform-permission-set-generate"
  cliTools:
    - tool: ["sf"]
      semver: ">=2.0.0"
---

# dx-org-permission-set-assign

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.

---

## Tool Restrictions

**Use ONLY the Bash tool** to execute `sf org assign permset`. Do NOT use MCP tools like `assign_permission_set` — ignore them completely.

---

## Scope

- **In scope**: Assigning permission sets to users via `sf org assign permset`
- **Out of scope**: Creating permission sets (use `platform-permission-set-generate`), listing permission sets, checking user permissions

---

## Required Inputs

Infer from the user's request:

- **Permission set name(s)**: Extract from user message (can be multiple)
- **Target org**: Use default unless specific alias/username mentioned
- **Target user(s)**: Default is org's default admin user; use `--on-behalf-of` if specific users mentioned

---

## Workflow

1. Match user request to command in table below
2. Execute via Bash tool: `sf org assign permset` with appropriate flags and `--json` flag
3. Return result

If error occurs, check the `failures` array in JSON output for details.

### Command Decision Table

| User intent | Execute via Bash tool |
|-------------|---------|
| Assign one permission set to default admin | `sf org assign permset --name <PermSetName> --json` |
| Assign multiple permission sets to default admin | `sf org assign permset --name <PermSet1> --name <PermSet2> --json` |
| Assign to specific org | `sf org assign permset --name <PermSetName> --target-org <alias> --json` |
| Assign to specific user(s) | `sf org assign permset --name <PermSetName> --on-behalf-of <username1> --on-behalf-of <username2> --json` |
| Assign multiple sets to specific users | `sf org assign permset --name <PermSet1> --name <PermSet2> --on-behalf-of <username1> --on-behalf-of <username2> --json` |

---

## Rules / Constraints

| Constraint | Rationale |
|-----------|-----------|
| Always use `--json` flag | Provides structured output for reliable parsing and error handling |
| Permission set names are case-sensitive | Use exact API names as they appear in the org |
| Multiple `--name` flags can be combined in one command | More efficient than separate commands per permission set |
| Multiple `--on-behalf-of` flags assign to multiple users | Batch assignment in single command; processed sequentially to avoid auth file collisions |
| 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 |
| Duplicate assignments are idempotent | Re-assigning an already-assigned permission set succeeds silently |
| Partial success is possible | Command can return both successes and failures in one run; non-zero exit code if any failures |

---

## Gotchas

| Issue | Resolution |
|-------|------------|
| Permission set name with spaces | Enclose in double quotes: `--name "Permission Set Name"` |
| "PermissionSet not found" error | Verify permission set exists in target org; check for typos in name |
| Assignment succeeds but user doesn't see permissions | Check `<hasActivationRequired>` in permission set metadata — may need manual activation in Setup |
| "User not found" error | Username/alias doesn't exist in target org — verify with `sf org display user --target-org <alias>` |
| 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 |

---

## Output Expectations

The command returns JSON output with status code and result details.

See `examples/success_output.json` and `examples/error_output.json` for response structures.

---

## Reference File Index

| File | When to read |
|------|-------------|
| `examples/success_output.json` | To understand successful assignment response structure |
| `examples/error_output.json` | To handle common error scenarios |
| `references/cli_flags.md` | For detailed explanation of all available flags |

© forcedotcom · Apache-2.0 · forcedotcom/sf-skills

Similar skills

Everything for DevOps and infrastructure →

From the same set167

platform-custom-lightning-type-generate Builds Custom Lightning Types as JSON Schema — the input and output shapes for Einstein Agent actions. Useful when the validator keeps rejecting your schema. CX Codex +1 5,700installs agentforce-observe Analyzes production Agentforce agent behavior via Data Cloud session traces and manages Agent Health Monitoring alerts. CX Codex +1 5,700installs agentforce-test Writes and runs test suites for Agentforce agents: smoke checks, batch runs and adversarial probes. Useful once an agent is built and needs checking before it ships. CX Codex +1 5,700installs platform-list-view-generate Generates and validates Salesforce List View metadata: filters, columns, visibility. Useful when you need a filtered record list for a specific task. CX Codex +1 5,700installs dx-org-switch Switches the active Salesforce org via sf config set target-org. Useful when CLI commands keep hitting the wrong org. CX Codex +1 5,700installs platform-lightning-app-coordinate Builds deployable Salesforce Lightning Experience apps from natural-language requests. Use it when an app needs connected metadata components. CX Codex +1 5,600installs design-systems-slds2-migrate Runs the SLDS linter over your components and walks you through fixing violations while moving Lightning Web Components from SLDS 1 to SLDS 2. CX Codex +1 5,600installs external-diagram-mermaid-generate Turns Salesforce architecture into Mermaid diagrams: OAuth flows, ERDs, integration sequences, Agentforce structure. Ships an ASCII fallback for plain-text use. CX Codex +1 5,500installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor