By mjtrapani
Generates a least-privilege Kubernetes RBAC manifest — a Role/ClusterRole plus a matching binding — scoped to exactly the API groups, resources, and verbs your workload actually uses. For platform and app engineers locking down a workload's ServiceAccount: reads the code, infers the API access patterns, emits annotated YAML.
Use when working with Kubernetes client code (client-go, controller-runtime, the kubernetes Python client, or kubectl), generating or reviewing Kubernetes RBAC (Role/ClusterRole plus RoleBinding/ClusterRoleBinding), or discussing RBAC rule syntax (apiGroups/resources/verbs/resourceNames). Provides the RBAC rule-grammar primer, the Role-vs-ClusterRole scope map, built-in and aggregated ClusterRoles, and pointers to detailed reference docs (API-resource map, version deltas, client-library patterns, resource extraction).
Generate a least-privilege Kubernetes RBAC manifest (Role/ClusterRole + matching binding) for the codebase at the given path. Use when invoked via `/k8s-rbac-companion:rule <path>` or when the user explicitly asks to scope or generate RBAC / a Role / a ServiceAccount's permissions for a workload with a path argument. Orchestrates the `k8s-rbac-companion:rbac-generator` agent across two phases (discovery, synthesis) and gathers user input between them via `AskUserQuestion`.
Executes bash commands
Hook triggers when Bash tool is used
Modifies files
Hook triggers on file write and edit operations
Own this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimOwn this plugin?
Verify ownership to unlock analytics, metadata editing, and a verified badge. GitHub access is read-only (username + org membership).
Sign in to claimBased on adoption, maintenance, documentation, and repository signals. Not a security audit or endorsement.
A Claude Code plugin for scoping a workload's Kubernetes access to the minimum permissions it actually needs. Reads the workload's code, infers the API access patterns (groups, resources, verbs, subresources), and generates a least-privilege Role/ClusterRole + matching binding as annotated YAML — bound to the workload's ServiceAccount. Apply it with one kubectl command.
You point it at a workload's directory. It detects the Kubernetes client (client-go, controller-runtime, the kubernetes Python client, or kubectl), infers the API access — which (apiGroup, resource, verb) tuples the code uses, including subresources like pods/log and <resource>/status — asks you three targeted questions (scope, ServiceAccount, and custom-vs-built-in), and emits an RBAC manifest that grants only what the workload actually needs.
The output is a directly-appliable rbac-<sa>.yaml on rbac.authorization.k8s.io/v1, with each rule annotated by an inline # comment citing the source line that justifies it.
Platform and application engineers scoping a workload's Kubernetes access to the minimum necessary permissions — a controller, operator, job, or service that talks to the API server. The pain is well-known:
apiGroups + resources + verbs. A wrong apiGroup (e.g. putting ingresses in the core group instead of networking.k8s.io) produces a rule that silently grants nothing — the authorizer matches on group, so the workload gets Forbidden at runtime with no syntax error to catch it.List() needs both list and watch; kubectl exec needs create on pods/exec (not get); writing .status needs the <resource>/status subresource; leader election needs leases.cluster-admin or a broad built-in (edit) because hand-authoring a tight Role is tedious and easy to get subtly wrong.This plugin reads the code and derives the intent — then explains every grant back to you in terms of the line that needed it.
You need Claude Code installed and authenticated.
In any Claude Code session:
/pluginsmjtrapani/k8s-rbac-companiongit clone https://github.com/mjtrapani/k8s-rbac-companion.git
cd k8s-rbac-companion
claude --plugin-dir .
To verify either install, run /agents — you should see rbac-generator in the list. You can also confirm the knowledge-base skill is active by asking something RBAC-adjacent, like "what verbs does kubectl exec need?" — the rbac-reference skill should auto-load (it's hidden from the slash menu by design — it's a model-invocable knowledge base, not an action command) and inform the answer.
In Claude Code, from your repo:
/k8s-rbac-companion:rule ./path/to/your/workload
The plugin will:
controller-runtime from go.mod + r.Get(/r.List( call sites)(apiGroup, resource, verb) — including subresources, leader-election leases, and event-recorder eventsRole vs cluster-wide ClusterRole + namespace), the target ServiceAccount (name + namespace), and role style (a custom least-privilege Role, or bind to a built-in view/edit/admin) — plus a conditional question if it finds a // TODO near K8s calls hinting at planned access./rbac-<sa>.yaml to your cwd — the appliable manifest with per-rule rationale as inline commentskubectl commands to validate, apply, and verifyYou can also invoke conversationally:
scope an RBAC role for ./my-controller
The strongest validation: apply the manifest and prove the workload's ServiceAccount can do exactly what it needs — and nothing else.
# 1. Validate the manifest without touching the cluster
kubectl apply -f ./rbac-my-sa.yaml --dry-run=client
# 2. Apply it
kubectl apply -f ./rbac-my-sa.yaml
# 3. Verify what the ServiceAccount can now do
kubectl auth can-i --list --as=system:serviceaccount:my-ns:my-sa
# 4. Negative test — an out-of-scope action should print "no"
kubectl auth can-i delete secrets --as=system:serviceaccount:my-ns:my-sa -n my-ns
# → no
A clean auth can-i --list showing only the intended verbs, and a no on step 4, means the generated rule grants exactly what the workload uses and denies the rest.
npx claudepluginhub mjtrapani/k8s-rbac-companion --plugin k8s-rbac-companionGenerates a version-aware, annotated Redis ACL rule scoped to the minimum permissions your service actually needs. For backend engineers locking down new or existing services — reads the code, infers the access patterns, emits the rule.
Ultra-compressed communication mode. Cuts ~75% of tokens while keeping full technical accuracy by speaking like a caveman.
Memory compression system for Claude Code - persist context across sessions
Multi-model consensus engine integrating OpenAI Codex CLI, Gemini CLI, and Claude CLI for collaborative code review and problem-solving.
Curate auto-memory, promote learnings to CLAUDE.md and rules, extract proven patterns into reusable skills.
Comprehensive UI/UX design plugin for mobile (iOS, Android, React Native) and web applications with design systems, accessibility, and modern patterns
Standalone image generation plugin using Nano Banana MCP server. Generates and edits images, icons, diagrams, patterns, and visual assets via Gemini image models. No Gemini CLI dependency required.