Implementation & Feature Engineering
Compatible with Cursor, Claude Code, Cline, Roo Code, Antigravity

Role-Based Access Control (RBAC) & Audit Trail Implementation

Implement multi-tenant permissions, role hierarchies, and tamper-resistant audit logs.

AuthSecurityRBACAudit LogsBackend
Skill Objective

Implement granular multi-tenant Role-Based Access Control (RBAC) with permission guards, middleware, and append-only audit trail logs.

Execution Workflow Procedure

Ordered steps the coding agent executes when performing this skill.

1

Design Permission Matrix & Role Hierarchy

Define granular permissions (e.g. documents:read, documents:delete) and role mappings (Admin, Editor, Viewer).

2

Implement Authorization Middleware & Decorators

Create type-safe permission guards and decorators to enforce checks at the API controller layer.

3

Build Append-Only Audit Trail Logging

Capture who, what, when, IP address, and changed diffs in an append-only audit_logs database table.

Agent Safety Guardrails & Anti-Hallucination Rules

  • DO NOT hardcode role names inside business logic; check specific granular permissions instead.
  • DO NOT allow audit log records to be updated or deleted by standard application users.

Expected Output Format

Permission schema, authorization middleware, and audit logger.

🛡️ Permission Guard & Middleware: Route-level authorization code.
📜 Audit Logger Implementation: Append-only audit trail service.

Domain Verification Checks

Granular Permission Checks: Enforces permissions over broad role names.
Append-Only Audit Table: Protects audit logs from modification.
Tenant Boundary Guard: Ensures permissions are checked within the active workspace.

Example Agent Invocations

"Implement a granular RBAC permission guard and audit logger for our document management API."
"Add tenant role management (Admin, Member, Viewer) with permission checks in Next.js Server Actions."

Install / Configure This Skill

# Place in .cursorrules or create .cursor/rules/rbac-audit-trail-implementation.mdc
# Trigger: Whenever you perform role-based access control (rbac) & audit trail implementation

---
name: rbac-audit-trail-implementation
description: Implement multi-tenant Role-Based Access Control (RBAC) and append-only audit trail logging.
version: 1.0.0
compatibility: [Cursor, Claude Code, Cline, Roo Code, Antigravity]
---

# Role-Based Access Control (RBAC) & Audit Trail Implementation

## Objective
Implement type-safe RBAC authorization and tamper-resistant audit trail logging for enterprise multi-tenant applications.

## Workflow
1. **Permission Matrix**: Define granular permission keys and role hierarchies.
2. **Authorization Guards**: Enforce permission checks at controller and service boundaries.
3. **Audit Trail**: Record user actions, tenant IDs, timestamps, and payload diffs in append-only tables.
Complementary Agent Prompt

Need a quick one-time prompt for chat?

Try the Security Vulnerability & OWASP Code Audit — a lightweight version designed for 1-click copying directly into Claude, ChatGPT, or Cursor chat.

View Prompt

SprintKit Workflow Integrations

Complementary tools and checklists to pair with this agent workflow.

Related Agent Skills

Explore related procedural workflows in this discipline.

All Skills

Application Security & OWASP Top 10 Audit

Audit backend and frontend code for injection, authentication flaws, IDOR, SSRF, and sensitive data leakage.

SecurityOWASPAuth+2
4 workflow stepsView skill

Jira User Story to Vertical-Slice Implementation Loop

Transform Jira user stories and acceptance criteria into vertically sliced, test-backed code implementations.

ImplementationJiraFull-Stack+2
4 workflow stepsView skill

Strict TypeScript Type Safety & Soundness Audit

Audit TypeScript code for type safety, type narrowing, generics, mutation traps, and runtime boundary validation.

TypeScriptNode.jsClean Code+1
4 workflow stepsView skill