Audit rbac

From trycompai/comp · View interactive version

Audit rbac is an AI agent skill from the GitHub repository trycompai/comp. Audit & fix RBAC and audit log compliance in API endpoints and frontend components

How to use this skill

Skill file

Audit the specified files or directories for RBAC and audit log compliance. Fix every issue found immediately.

Rules

API Endpoints (NestJS — `apps/api/src/`)

  1. Every mutation endpoint (POST, PATCH, PUT, DELETE) MUST have @RequirePermission('resource', 'action'). If missing, add it.
  2. Read endpoints (GET) should have @RequirePermission('resource', 'read'). If missing, add it.
  3. Self-endpoints (e.g., /me/preferences) may skip @RequirePermission — authentication via HybridAuthGuard is sufficient.
  4. Controller format: Must use @Controller({ path: 'name', version: '1' }), NOT @Controller('v1/name'). If wrong, fix it.
  5. Guards: Use @UseGuards(HybridAuthGuard, PermissionGuard) at controller or endpoint level. Never skip PermissionGuard.
  6. Webhooks: External webhook endpoints use @Public() — no auth required.

Frontend Components (`apps/app/src/`)

  1. Every mutation element (button, form submit, toggle, switch, file upload) MUST be gated with usePermissions from @/hooks/use-permissions. If not:
  1. Actions columns in tables: hide entire column when user lacks write permission.
  2. No manual role string parsing (role.includes('admin')) — use hasPermission().
  3. Nav items: gate with canAccessRoute(permissions, 'routeSegment').
  4. Page-level: call requireRoutePermission('segment', orgId) server-side.

Permission Resources

organization, member, control, evidence, policy, risk, vendor, task, framework, audit, finding, questionnaire, integration, apiKey, trust, pentest, app, compliance

Multi-Product RBAC

Process

  1. Read files specified in $ARGUMENTS (or scan the directory)
  2. Check each rule above
  3. Fix every violation immediately — don't just report
  4. Run typecheck to verify: bunx turbo run typecheck --filter=@trycompai/api --filter=@trycompai/app
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.