Create a new Laravel policy with philsquare/permissions role-based permissions
How this command is triggered — by the user, by Claude, or both
Slash command
/philsquare-permissions:make-policyThe summary Claude sees in its command listing — used to decide when to auto-load this command
Create a new Laravel policy for the model `$model` with role-based permissions using philsquare/permissions.
## Steps
1. First, check if the policy already exists at `app/Policies/{$model}Policy.php`
2. If it exists, ask the user if they want to add permissions to the existing policy
3. Create the policy file with the following structure:
4. Check if `app/Enums/Roles.php` exists and use it in rolePermissions() if available
5. Register the policy in `app/Providers/AuthServiceProvider.php` if it uses explicit registration
6. Remind the user to:
- Customize the `rolePermissions()` meth...Create a new Laravel policy for the model $model with role-based permissions using philsquare/permissions.
app/Policies/{$model}Policy.php<?php
namespace App\Policies;
use App\Models\{$model};
use App\Models\User;
use Philsquare\Permissions\BasePolicy;
class {$model}Policy extends BasePolicy
{
public function rolePermissions(): array
{
return [
'admin' => $this->permissions()->all(),
];
}
/**
* Determine whether the user can view any models.
*/
public function viewAny(User $user): bool
{
return true;
}
/**
* Determine whether the user can view the model.
*/
public function view(User $user, {$model} $model): bool
{
return true;
}
/**
* Determine whether the user can create models.
*/
public function create(User $user): bool
{
return true;
}
/**
* Determine whether the user can update the model.
*/
public function update(User $user, {$model} $model): bool
{
return true;
}
/**
* Determine whether the user can delete the model.
*/
public function delete(User $user, {$model} $model): bool
{
return true;
}
}
app/Enums/Roles.php exists and use it in rolePermissions() if availableapp/Providers/AuthServiceProvider.php if it uses explicit registrationrolePermissions() method with appropriate rolesphp artisan permissions:refresh to sync permissionsBasePolicy from philsquare/permissionstrue by default - add business logic as neededbefore() hooknpx claudepluginhub philsquare/permissions --plugin philsquare-permissions/laravel-policiesEnforces access control using Laravel Policies by invoking the laravel:policies-and-authorization skill exactly as written.
/policiesGenerates Pest 4 tests for Laravel authorization policies and gates, including role-based, gate, and middleware scenarios. Options: [policy] [--model name] [--all] [--roles] [--gates] [--middleware].
/new-endpointAdds a complete CRUD endpoint to Laravel projects (standard or DDD), via ordered steps for model, migration, filter, controller, policy, resources, and more.
/laravelBuilds, configures, and optimizes Laravel apps with Eloquent models, service layers, queues, events, broadcasting, Sanctum/Passport auth, and Pest tests. Supports API, auth, queue, model gen, optimization, upgrade, audit flags.
/resourceGenerates complete FilamentPHP v4 resource for <ModelName> with form schema, table config, relation managers, and Pest tests. Supports --generate, --simple, --soft-deletes, --view flags.