# Building Role Mining For Rbac Optimization

Apply bottom-up and top-down role mining techniques to discover optimal RBAC roles from...

- Repository: https://github.com/AgentFlocks/flocks (504 stars)
- Category: Engineering
- License: Apache-2.0
- Last updated: 2026-10-30
- Runs scripts: yes, review before use

## Install

Claude Code: `npx skills add AgentFlocks/flocks --skill building-role-mining-for-rbac-optimization -g -a claude-code -y`
Codex: `npx skills add AgentFlocks/flocks --skill building-role-mining-for-rbac-optimization -g -a codex -y`
Cursor: `npx skills add AgentFlocks/flocks --skill building-role-mining-for-rbac-optimization -g -a cursor -y`
Gemini CLI: `npx skills add AgentFlocks/flocks --skill building-role-mining-for-rbac-optimization -g -a gemini-cli -y`

## Description

Apply bottom-up and top-down role mining techniques to discover optimal RBAC roles from existing user-permission assignments, reducing role explosion and enforcing least privilege.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Building Role Mining for RBAC Optimization

## Overview

Role mining is the process of analyzing existing user-permission assignments to discover optimal roles for a Role-Based Access Control (RBAC) system. Organizations accumulate excessive permissions over time through job changes, project assignments, and ad-hoc access grants, leading to "role explosion" where thousands of granular roles exist with significant overlap. Role mining uses data analysis -- including clustering algorithms, formal concept analysis, and graph-based methods -- to consolidate permissions into a minimal set of roles that accurately represent business functions while enforcing least privilege.


## When to Use

- When deploying or configuring building role mining for rbac optimization capabilities in your environment
- When establishing security controls aligned to compliance requirements
- When building or improving security architecture for this domain
- When conducting security assessments that require this implementation

## Prerequisites

- Export of current user-permission assignments (CSV/database)
- Identity governance platform or directory service access
- Python 3.9+ with pandas, scikit-learn, numpy
- Understanding of organizational structure and job functions
- Stakeholder access for role validation workshops

## Core Concepts

### Role Mining Approaches

| Approach | Description | Best For |
|----------|-------------|----------|
| Bottom-Up | Analyze existing permissions to discover common patterns | Large datasets with organic permission growth |
| Top-Down | Design roles from business requirements and job descriptions | Greenfield RBAC or organizational restructuring |
| Hybrid | Combine bottom-up analysis with top-down business validation | Most production environments |

### Role Mining Algorithms

**1. Permission Clustering**: Group users with similar permission sets using k-means or hierarchical clustering. Users in the same cluster share a common role.

The rest: https://github.com/AgentFlocks/flocks/blob/HEAD/.flocks/flockshub/plugins/skills/Anthropic-Cybersecurity-Skills/building-role-mining-for-rbac-optimization/SKILL.md
