Laravel Policies And Authorization
This skill automates Laravel policy creation & authorization setup, streamlining security and simplifying access control management for your applications.
Install on your platform
We auto-selected Claude Code based on this skill’s supported platforms.
Run in terminal (recommended)
claude mcp add laravel-policies-and-authorization npx -- -y @trustedskills/laravel-policies-and-authorization
Or manually add to ~/.claude/settings.json
{
"mcpServers": {
"laravel-policies-and-authorization": {
"command": "npx",
"args": [
"-y",
"@trustedskills/laravel-policies-and-authorization"
]
}
}
}Requires Claude Code (claude CLI). Run claude --version to verify your install.
About This Skill
What it does
This skill enables AI agents to implement and utilize Laravel policies for fine-grained authorization within a Laravel application. It allows developers to define specific access rules for models, controlling which users or roles can perform actions like viewing, creating, updating, or deleting data. This promotes secure and maintainable code by centralizing authorization logic.
When to use it
- Implementing Role-Based Access Control (RBAC): Define different user roles (e.g., admin, editor, viewer) and restrict access based on these roles.
- Protecting Sensitive Data: Ensure only authorized users can access specific resources or perform sensitive operations within the application.
- Enforcing Business Logic for Access: Implement complex authorization rules beyond simple role assignments, such as restricting access to a record based on its ownership.
- Centralizing Authorization Logic: Move authorization checks out of controller methods and into policies for cleaner code and easier maintenance.
Key capabilities
- Defining Policies: Create policy classes that encapsulate authorization logic for specific models.
- Model-Specific Rules: Apply different rules to different models based on user roles or other criteria.
- Centralized Authorization: Move authorization checks out of controllers into policies.
- Gate Creation: Define gates using the
@candirective in Blade templates and controller methods.
Example prompts
- "Create a policy for the 'Post' model that allows only administrators to delete posts."
- "Generate a gate to check if a user can edit this article based on their role."
- "Show me an example of how to use a policy to authorize access to a specific resource."
Tips & gotchas
- Requires a working Laravel application. Familiarity with Laravel's Eloquent ORM and basic authorization concepts is helpful for effective utilization.
- Policies are best used when you need more complex authorization logic than simple role-based checks can provide.
Tags
TrustedSkills Verification
Unlike other registries that point to live repositories, TrustedSkills pins every skill to a verified commit hash. This protects you from malicious updates — what you install today is exactly what was reviewed and verified.
Security Audits
| Gen Agent Trust Hub | Pass |
| Socket | Pass |
| Snyk | Pass |
🌐 Community
Passed automated security scans.