
Laravel Permission Development
This handles everything around Spatie's laravel-permission package: setting up roles and permissions, middleware guards, Blade directives, policies, and even teams for multi-tenancy. The source is thorough on best practices, like always checking permissions (not roles) with `$user->can()`, avoiding direct user permissions, and using `Gate::before` for super admin patterns. It covers the stuff you forget between projects, like flushing the permission cache when seeding or which middleware to use for OR logic in routes. If you're building any Laravel app with user authorization beyond basic gates, this consolidates the practical patterns in one place instead of rereading docs every time.
- skills.sh installs
- 310
- GitHub stars
- 13K
- last updated
- Aug 21, 2026
Install
$ npx -y skills add spatie/laravel-permission --skill laravel-permission-development --agent claude-codeInstalls into .claude/skills of the current project.
Files
Laravel Permission Development
When to use this skill
Use this skill when working with authorization, roles, permissions, access control, middleware guards, or Blade permission directives using spatie/laravel-permission.
Core Concepts
- Users have Roles, Roles have Permissions, Apps check Permissions (not Roles).
- Direct permissions on users are an anti-pattern; assign permissions to roles instead.
- Use
$user->can('permission-name')for all authorization checks (supports Super Admin via Gate). - The
HasRolestrait (which includesHasPermissions) is added to User models.
Setup
Add the HasRoles trait to your User model:
use Spatie\Permission\Traits\HasRoles;
class User extends Authenticatable
{
use HasRoles;
}
Creating Roles and Permissions
use Spatie\Permission\Models\Role;
use Spatie\Permission\Models\Permission;
$role = Role::create(['name' => 'writer']);
$permission = Permission::create(['name' => 'edit articles']);
// findOrCreate is idempotent (safe for seeders)
$role = Role::findOrCreate('writer', 'web');
$permission = Permission::findOrCreate('edit articles', 'web');
Assigning Roles and Permissions
Sponsors
Details
- Repository
- github.com/spatie/laravel-permission
- Categories
- Backend & APIs, DevOps & CI/CD, PHP & Laravel
- First seen
- Jun 3, 2026