From powerplatformcopilot
Design a Dataverse security role from a concrete purpose and access requirement. Always start from the Basic User security role, unless told otherwise, inspect existing reference roles named by the user, discover underlying dependent privileges needed to complete the intended business action, propose an exact least-privilege matrix, allow review and adjustment, and only then create a validating role if approved.
How this skill is triggered — by the user, by Claude, or both
Slash command
/powerplatformcopilot:security-modelThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
**Triggers**: dataverse-security, security model, security roles, privileges, access levels, role hardening, least privilege
Triggers: dataverse-security, security model, security roles, privileges, access levels, role hardening, least privilege Aliases: /security-model, /dataverse-security, /security-roles
Follow these steps in order for every /security-model invocation.
Basic User o el que el usuario indique; no se diseña desde cero ignorando ese baseline.pac auth list
pac auth who
pac env who
If there is no authentication, tell the user to run:
pac auth create --environment https://your-env.crm.dynamics.com
Capture and report:
Ask these questions. The purpose and requirement questions are mandatory on every invocation:
Do not proceed to design until purpose, requirement, business case, reference-role, and scope constraint input state are explicit.
If the user does not name any reference roles, explicitly record that no reference roles were supplied and continue with environment discovery anyway.
mcp_microsoftdocs_microsoft_docs_search to find current official guidance for:
mcp_microsoftdocs_microsoft_docs_fetch on high-value result pages before finalizing the proposal.Basic User or the one indicated by the user exists in the connected environment and treat it as the mandatory baseline role for every new proposal, unless the user explicitly states otherwise.Basic User or the user-specified baseline roleBasic User, reference roles, and candidate matchesPrefer Dataverse MCP for metadata/data retrieval and PAC CLI for environment/session validation and supplemental checks.
If direct role query automation is not available in the current toolset, inspect existing roles through the Power Platform admin center:
Basic User, the user-supplied reference roles, and candidate matching roles before deciding whether a new validating role is needed.Present a structured proposal in plan mode including:
validating.[purpose]-validating.Basic User or the user-specified baseline role.Basic User or the baseline role.Basic User, Reference role, Newly required, Explicitly excluded)Primary requirement or Underlying dependency)Before creating anything, provide a compliance check:
Basic User or the user-specified baseline role plus the requested deltas, not only against standalone custom roles.Before any approval request, present the draft plan and invite the user to review it.
The user must be able to:
If the user requests adjustments, update the plan and present the revised matrix again. Repeat this review loop until the user explicitly states that the plan is approved for creation or approved as final proposal only.
Ask for user approval after presenting:
Basic User or user-specified baseline role)validating/references/ security-role-proposal to structure the proposal and ensure all points are coveredDo not create or modify roles before explicit approval.
Create the role in the connected environment using available MCP/PAC capabilities ONLY IF USER ASKS TO CREATE THE ROLE AFTER APPROVAL. If the user approved the plan but did not request creation, explicitly say that no role was created and the output is the approved design only.
Basic User security role as the base or the user-specified baseline role if different. Do not start from scratch or from an intermediate role that is not the baseline.validating in the name.Basic User or the baseline role.Use MSAL interactive popup authentication to obtain a bearer token before calling the Dataverse Web API. Do not attempt device code flow, Azure CLI, or any other method first.
Steps:
# 1. Locate the MSAL DLL bundled with the PAC CLI VS Code extension
$pacFolder = (Get-Command pac).Source | Split-Path
$msalDll = Get-ChildItem $pacFolder -Filter "Microsoft.Identity.Client.dll" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
if (-not $msalDll) {
# Fallback: search VS Code global storage
$msalDll = Get-ChildItem "$env:APPDATA\Code\User\globalStorage" -Filter "Microsoft.Identity.Client.dll" -Recurse -ErrorAction SilentlyContinue | Select-Object -First 1
}
Add-Type -Path $msalDll.FullName
# 2. Build the public client and acquire token interactively (browser popup)
$tenantId = "<tenant-id-from-pac-auth-who>"
$clientId = "1950a258-227b-4e31-a9cf-717495945fc2" # Azure PowerShell public client
$orgUrl = "<environment-url-from-pac-env-who>" # e.g. https://org.crm4.dynamics.com/
$scope = "$orgUrl.default"
$builder = [Microsoft.Identity.Client.PublicClientApplicationBuilder]::Create($clientId)
$builder = $builder.WithAuthority("https://login.microsoftonline.com/$tenantId")
$builder = $builder.WithDefaultRedirectUri()
$app = $builder.Build()
Write-Host "A browser window will open. Please sign in to authorize Dataverse access." -ForegroundColor Cyan
$result = $app.AcquireTokenInteractive([string[]]@($scope)).ExecuteAsync().GetAwaiter().GetResult()
$token = $result.AccessToken
Write-Host "Authenticated as $($result.Account.Username)" -ForegroundColor Green
# 3. Apply privileges using AddPrivilegesRole Web API action
$roleId = "<role-guid>"
$headers = @{
"Authorization" = "Bearer $token"
"Content-Type" = "application/json"
"OData-MaxVersion" = "4.0"
"OData-Version" = "4.0"
}
# Depth values: "Basic" = User, "Local" = BU, "Deep" = Parent:Child BU, "Global" = Org
$privileges = @(
@{ PrivilegeId = "<guid>"; Depth = "Local" },
@{ PrivilegeId = "<guid>"; Depth = "Global" }
# ... one entry per approved privilege
)
$body = @{ Privileges = $privileges } | ConvertTo-Json -Depth 5
$url = "$orgUrl`api/data/v9.2/roles($roleId)/Microsoft.Dynamics.CRM.AddPrivilegesRole"
Invoke-RestMethod -Method Post -Uri $url -Headers $headers -Body $body | Out-Null
Write-Host "Privileges applied successfully." -ForegroundColor Green
If technical limitations block creation, still write the final output file and document blockers with exact next actions.
DO NOT MOVE TO STEP 9 UNTIL CREATION IS CONFIRMED OR EXPLICITLY SKIPPED.
Return a concise summary including:
Basic User or user-specified baseline role)If the user approved the plan but did not request creation, explicitly say that no role was created and the output is the approved design only.
Always write the Step 9 final output to a file in an output folder.
Rules:
security-model/output/ if it doesn't exist.security-model/output/[role-name].md.npx claudepluginhub cesardlcs/powerplatformcopilot --plugin powerplatformcopilotCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.