Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

role-permission-table-builder角色权限表构建器

Agent Skill

role-permission-table-builder 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

264

周安装

11

GitHub Stars

3

下载量

88
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:role-permission-table-builder(角色权限表构建器)
来源仓库:https://github.com/hopeoverture/worldbuilding-app-skills
仓库路径:skills/role-permission-table-builder
安装命令:
npx skills add https://github.com/hopeoverture/worldbuilding-app-skills --skill role-permission-table-builder
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/hopeoverture/worldbuilding-app-skills --skill role-permission-table-builder

简介

role-permission-table-builder 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中整理相关事项。

  • 适用于围绕仓库状态、代码变更或协作任务进行信息梳理的场景。
  • 通过 npx skills add 命令从指定 GitHub 仓库安装并使用。
  • 安装前需确认权限范围和维护状态,注意可能触发的联网或文件操作。
  • 建议结合原始 README 核验具体用法和功能边界。

SKILL.md

Role Permission Table Builder

Generate and maintain comprehensive role-based access control (RBAC) permission matrices for worldbuilding applications.

Overview

To build role permission systems:

  1. Define user roles and hierarchies
  2. Identify protected resources (pages, components, data, actions)
  3. Create permission matrices mapping roles to resources
  4. Generate implementation code for middleware and components
  5. Document permission policies for team reference

Role Definitions

Standard Roles

Define common application roles:

  • Guest: Unauthenticated users (read-only public content)
  • User: Basic authenticated users (read own data, limited writes)
  • Creator: Content creators (create/edit entities, manage own content)
  • Editor: Content editors (edit any content, moderate submissions)
  • Admin: System administrators (full access, user management)
  • Super Admin: Platform owners (all permissions, system configuration)

Custom Roles

To define worldbuilding-specific roles:

  • World Owner: Creator of worldbuilding project
  • Collaborator: Invited contributor to world
  • Viewer: Read-only access to private world
  • Game Master: Special permissions for RPG campaigns
  • Publisher: Can publish worlds publicly

Consult references/role-hierarchy.md for role inheritance patterns.

Permission Matrix

Page-Level Permissions

To define page access:

Page RouteGuestUserCreatorEditorAdmin
/[OK][OK][OK][OK][OK]
/login[OK][OK][OK][OK][OK]
/dashboard[ERROR][OK][OK][OK][OK]
/worlds/create[ERROR][OK][OK][OK][OK]
/worlds/[id]🔒🔒[OK][OK][OK]
/worlds/[id]/edit[ERROR][ERROR][OK][OK][OK]
/admin/users[ERROR][ERROR][ERROR][ERROR][OK]
/admin/settings[ERROR][ERROR][ERROR][ERROR][OK]

Legend:

  • [OK] Full access
  • 🔒 Conditional access (ownership/invitation)
  • [ERROR] No access

Component-Level Permissions

To define component visibility:

ComponentGuestUserCreatorEditorAdmin
WorldList[OK] Public[OK] All[OK] All[OK] All[OK] All
WorldCreateButton[ERROR][OK][OK][OK][OK]
EntityEditor[ERROR][ERROR][OK] Own[OK] All[OK] All
DeleteButton[ERROR][ERROR][OK] Own[OK] All[OK] All
ShareWorldButton[ERROR][ERROR][OK] Own[OK] All[OK] All
AdminPanel[ERROR][ERROR][ERROR][ERROR][OK]
UserManagement[ERROR][ERROR][ERROR][ERROR][OK]

Data Access Permissions

To define data operations:

OperationGuestUserCreatorEditorAdmin
Read public worlds[OK][OK][OK][OK][OK]
Read private worlds[ERROR]🔒 Invited🔒 Own[OK][OK]
Create world[ERROR][OK][OK][OK][OK]
Update own world[ERROR][OK][OK][OK][OK]
Update any world[ERROR][ERROR][ERROR][OK][OK]
Delete own world[ERROR][OK][OK][OK][OK]
Delete any world[ERROR][ERROR][ERROR][ERROR][OK]
Create entity[ERROR][ERROR][OK][OK][OK]
Update own entity[ERROR][ERROR][OK][OK][OK]
Update any entity[ERROR][ERROR][ERROR][OK][OK]
Delete entity[ERROR][ERROR][OK] Own[OK][OK]
Manage collaborators[ERROR][ERROR][OK] Own[OK][OK]
Publish world[ERROR][ERROR][OK] Own[OK][OK]
Moderate content[ERROR][ERROR][ERROR][OK][OK]
Manage users[ERROR][ERROR][ERROR][ERROR][OK]

Action Permissions

To define Server Action permissions:

Server ActionGuestUserCreatorEditorAdmin
createWorld[ERROR][OK][OK][OK][OK]
updateWorld[ERROR]🔒🔒[OK][OK]
deleteWorld[ERROR]🔒🔒[ERROR][OK]
createEntity[ERROR][ERROR][OK][OK][OK]
updateEntity[ERROR][ERROR]🔒[OK][OK]
deleteEntity[ERROR][ERROR]🔒[OK][OK]
inviteCollaborator[ERROR][ERROR]🔒[OK][OK]
publishWorld[ERROR][ERROR]🔒[OK][OK]
deleteUser[ERROR][ERROR][ERROR][ERROR][OK]

Use scripts/generate_permission_matrix.py to create customized permission tables.

SQL Schema

To implement permissions in database:

-- Roles table
CREATE TABLE roles (
  id SERIAL PRIMARY KEY,
  name VARCHAR(50) UNIQUE NOT NULL,
  description TEXT,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

-- Permissions table
CREATE TABLE permissions (
  id SERIAL PRIMARY KEY,
  resource VARCHAR(100) NOT NULL,
  action VARCHAR(50) NOT NULL,
  description TEXT,
  UNIQUE(resource, action)
);

-- Role permissions mapping
CREATE TABLE role_permissions (
  id SERIAL PRIMARY KEY,
  role_id INTEGER REFERENCES roles(id) ON DELETE CASCADE,
  permission_id INTEGER REFERENCES permissions(id) ON DELETE CASCADE,
  UNIQUE(role_id, permission_id)
);

-- User roles
CREATE TABLE user_roles (
  id SERIAL PRIMARY KEY,
  user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
  role_id INTEGER REFERENCES roles(id) ON DELETE CASCADE,
  assigned_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  UNIQUE(user_id, role_id)
);

-- Resource ownership
CREATE TABLE resource_ownership (
  id SERIAL PRIMARY KEY,
  user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
  resource_type VARCHAR(50) NOT NULL,
  resource_id INTEGER NOT NULL,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  UNIQUE(resource_type, resource_id)
);

-- Collaborators (for conditional access)
CREATE TABLE collaborators (
  id SERIAL PRIMARY KEY,
  world_id INTEGER REFERENCES worlds(id) ON DELETE CASCADE,
  user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
  role VARCHAR(50) NOT NULL,
  invited_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
  UNIQUE(world_id, user_id)
);

Use scripts/generate_rbac_schema.py to generate database schema with seed data.

Reference assets/rbac-schema.sql for complete schema with indexes and constraints.

Implementation

Middleware Protection

To protect routes with middleware:

// middleware.ts
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
import { getSession } from '@/lib/auth';
import { checkPermission } from '@/lib/permissions';

const protectedRoutes = {
  '/dashboard': ['user', 'creator', 'editor', 'admin'],
  '/worlds/create': ['user', 'creator', 'editor', 'admin'],
  '/admin': ['admin'],
};

export async function middleware(request: NextRequest) {
  const session = await getSession(request);
  const path = request.nextUrl.pathname;

  // Check if route requires authentication
  for (const [route, allowedRoles] of Object.entries(protectedRoutes)) {
    if (path.startsWith(route)) {
      if (!session) {
        return NextResponse.redirect(new URL('/login', request.url));
      }

      if (!allowedRoles.includes(session.user.role)) {
        return NextResponse.redirect(new URL('/unauthorized', request.url));
      }
    }
  }

  return NextResponse.next();
}

export const config = {
  matcher: ['/((?!api|_next/static|_next/image|favicon.ico).*)'],
};

Component-Level Checks

To conditionally render components:

// components/ProtectedComponent.tsx
import { useSession } from '@/lib/auth';
import { hasPermission } from '@/lib/permissions';

interface Props {
  requiredRole?: string[];
  requiredPermission?: string;
  fallback?: React.ReactNode;
  children: React.ReactNode;
}

export function ProtectedComponent({
  requiredRole,
  requiredPermission,
  fallback = null,
  children,
}: Props) {
  const { session } = useSession();

  if (!session) {
    return <>{fallback}</>;
  }

  if (requiredRole && !requiredRole.includes(session.user.role)) {
    return <>{fallback}</>;
  }

  if (requiredPermission && !hasPermission(session.user, requiredPermission)) {
    return <>{fallback}</>;
  }

  return <>{children}</>;
}

Usage:

<ProtectedComponent requiredRole={['creator', 'editor', 'admin']}>
  <EntityEditor entity={entity} />
</ProtectedComponent>

Reference assets/protected-component.tsx for complete implementation.

Server Action Protection

To protect Server Actions:

// lib/permissions.ts
'use server';

import { getSession } from '@/lib/auth';
import { checkPermission } from '@/lib/rbac';

export async function requirePermission(permission: string) {
  const session = await getSession();

  if (!session) {
    throw new Error('Unauthorized');
  }

  const hasAccess = await checkPermission(session.user, permission);

  if (!hasAccess) {
    throw new Error('Forbidden');
  }

  return session;
}

export async function requireOwnership(resourceType: string, resourceId: number) {
  const session = await getSession();

  if (!session) {
    throw new Error('Unauthorized');
  }

  const isOwner = await checkOwnership(session.user.id, resourceType, resourceId);

  if (!isOwner && session.user.role !== 'admin') {
    throw new Error('Forbidden');
  }

  return session;
}

Usage in Server Actions:

'use server';

import { requirePermission, requireOwnership } from '@/lib/permissions';

export async function updateEntity(entityId: number, data: EntityData) {
  await requireOwnership('entity', entityId);

  // Proceed with update
  return updateEntityInDB(entityId, data);
}

export async function deleteWorld(worldId: number) {
  const session = await requirePermission('world:delete');

  if (session.user.role !== 'admin') {
    await requireOwnership('world', worldId);
  }

  return deleteWorldFromDB(worldId);
}

Dynamic Permission Checks

To implement complex permission logic:

// lib/rbac.ts
export async function checkPermission(
  user: User,
  resource: string,
  action: string,
  context?: { resourceId?: number; ownerId?: number }
): Promise<boolean> {
  // Admin has all permissions
  if (user.role === 'admin') {
    return true;
  }

  // Check role-based permission
  const hasRolePermission = await hasRolePermission(user.role, resource, action);

  if (!hasRolePermission) {
    return false;
  }

  // Check ownership if required
  if (context?.resourceId) {
    const isOwner = await checkOwnership(user.id, resource, context.resourceId);
    return isOwner;
  }

  return true;
}

Consult references/permission-check-patterns.md for advanced patterns.

Permission Utilities

Use scripts/permission_utils.py for common operations:

# Check user permissions
python scripts/permission_utils.py check --user-id 123 --permission "world:update"

# List role permissions
python scripts/permission_utils.py list-role --role creator

# Grant permission to role
python scripts/permission_utils.py grant --role editor --permission "entity:delete"

# Revoke permission from role
python scripts/permission_utils.py revoke --role user --permission "world:delete"

Testing Permissions

To test authorization:

// tests/permissions.test.ts
import { checkPermission } from '@/lib/rbac';

describe('RBAC', () => {
  it('admin can delete any world', async () => {
    const admin = { id: 1, role: 'admin' };
    const canDelete = await checkPermission(admin, 'world', 'delete');
    expect(canDelete).toBe(true);
  });

  it('creator can only delete own world', async () => {
    const creator = { id: 2, role: 'creator' };
    const ownWorld = { id: 10, ownerId: 2 };

    const canDeleteOwn = await checkPermission(creator, 'world', 'delete', {
      resourceId: ownWorld.id,
      ownerId: ownWorld.ownerId,
    });
    expect(canDeleteOwn).toBe(true);

    const othersWorld = { id: 11, ownerId: 3 };
    const canDeleteOthers = await checkPermission(creator, 'world', 'delete', {
      resourceId: othersWorld.id,
      ownerId: othersWorld.ownerId,
    });
    expect(canDeleteOthers).toBe(false);
  });
});

Documentation Generation

Use scripts/generate_permission_docs.py to create permission documentation:

# Generate markdown documentation
python scripts/generate_permission_docs.py --format markdown --output docs/permissions.md

# Generate SQL seed data
python scripts/generate_permission_docs.py --format sql --output db/seeds/permissions.sql

# Generate TypeScript types
python scripts/generate_permission_docs.py --format typescript --output lib/types/permissions.ts

Output includes:

  • Complete permission matrix tables
  • Role hierarchy diagrams
  • Implementation examples
  • API documentation

Reference assets/permission-docs-template.md for documentation structure.

Best Practices

  1. Principle of Least Privilege: Grant minimum required permissions
  2. Role Hierarchy: Implement role inheritance for simpler management
  3. Audit Logging: Track permission checks and access attempts
  4. Regular Reviews: Periodically audit and update permissions
  5. Clear Naming: Use consistent, descriptive permission names
  6. Documentation: Maintain up-to-date permission documentation
  7. Testing: Test authorization for all roles and edge cases
  8. Graceful Degradation: Show appropriate UI for unauthorized users

Troubleshooting

Common issues:

  • Permission Denied Unexpectedly: Check role assignments and ownership
  • Middleware Not Applied: Verify middleware matcher configuration
  • Cached Permissions: Clear session cache after permission changes
  • Inconsistent Checks: Ensure same logic in middleware, components, and actions
  • Performance Issues: Cache permission checks, use database indexes

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.42%
按下载量换算32

Claude

32.67%
按下载量换算29

Cursor

16.81%
按下载量换算15

Gemini CLI

9.27%
按下载量换算8

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills