create-php-attribute
Skill1 starsChanged 5 months agoMITView on GitHub
Use when creating or reviewing a custom PHP 8 attribute for metadata, framework integration, architecture checks, tests, middleware, scanners, or support tooling in this Laravel application.
In this repository64 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- audit-ai-agent-instructionsSkill
- audit-package-versionSkill
- configure-local-environmentSkill
- configure-secure-storageSkill
- create-actionSkill
- create-api-endpointSkill
- create-api-integrationSkill
- create-architecture-testSkill
- create-console-commandSkill
- create-database-migrationSkill
- create-domain-featureSkill
- create-dtoSkill
- create-eloquent-builderSkill
- create-event-listenerSkill
- create-inertia-pageSkill
- create-jobSkill
- create-laravel-boost-guidelinesSkill
- create-laravel-packageSkill
- create-livewire-componentSkill
- create-policySkill
- create-requestSkill
- create-serviceSkill
- debug-composer-conflictsSkill
- debug-failing-testsSkill
- debug-phpstanSkill
- decompose-modelSkill
- deploying-laravel-cloudSkill
- design-blade-componentSkill
- design-multi-tenant-featureSkill
- filament-developmentSkill
- filament-shieldSkill
- fix-github-actionsSkill
- format-codebase-pintSkill
- implement-api-rate-limitingSkill
- implement-import-exportSkill
- implement-notificationsSkill
- implement-observabilitySkill
- implement-permissionsSkill
- implement-subscription-billingSkill
- implement-webhooksSkill
- laravel-pennant-feature-flagsSkill
- laravel-pulse-monitoringSkill
- laravel-reverb-websocketsSkill
- manage-frontend-stylingSkill
- manage-localizationSkill
- prepare-package-releaseSkill
- refactor-business-logicSkill
- reuse-filament-resourcesSkill
- review-accessibilitySkill
- review-ai-generated-codeSkill
- review-featureSkill
- review-open-source-packageSkill
- review-package-readmeSkill
- review-performanceSkill
- review-securitySkill
- review-static-analysisSkill
- review-tailwind-fluxSkill
- The first 60 shown.
The file
Show its rules and text
We split this skill into the rules it gives an agent
14 rules. About 0 are common, 12 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈12
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 13
Use this skill when stable metadata should be declared with PHP 8 attributes and consumed by application code, tests, middleware, scanners, …
- Very specific: line 23
Create the attribute under app/Attributes unless the project already has a different convention.
- Very specific: line 24
Use native PHP #[Attribute(...)] targets and repeatability flags.
- Distinctive: line 27
Keep the attribute as metadata only.
- Distinctive: line 28
Create or update the consumer that reads the attribute via reflection, routing, middleware, tests, or support tooling.
- Distinctive: line 29
Add tests for the consumer behavior.
- Distinctive: line 30
Run Pint and focused tests.
- Distinctive: line 46
Do not use custom attributes to bypass Actions, Policies, DTOs, Events, Jobs, or Services.
- Distinctive: line 47
Prefer Laravel built-in attributes before custom attributes.
- Distinctive: line 48
Every custom attribute must have a real consumer when introduced.
- Distinctive: line 53
Test the consumer behavior.
- Distinctive: line 54
Test invalid or missing metadata where relevant.
- Distinctive: line 55
Add architecture tests when the attribute marks security, sensitivity, external integrations, or layer boundaries.
- Distinctive: line 61
Treat reflected metadata as code-level metadata, not trusted user input.
≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Create PHP Attribute
When To Use
Use this skill when stable metadata should be declared with PHP 8 attributes and consumed by application code, tests, middleware, scanners, or tooling.
Inputs Needed
- Attribute purpose, target, allowed arguments, consuming code, security impact, tests, and naming.
Workflow
- Confirm a custom attribute is better than a method, interface, config value, enum, policy, middleware, injection attribute, Eloquent attribute, queue attribute, Form Request attribute, resource attribute, or other Laravel built-in attribute.
- Inspect existing attribute and support-class conventions.
- Create the attribute under
app/Attributesunless the project already has a different convention. - Use native PHP
#[Attribute(...)]targets and repeatability flags. - Make the attribute class
final readonlywhen possible. - Type every constructor parameter.
- Keep the attribute as metadata only.
- Create or update the consumer that reads the attribute via reflection, routing, middleware, tests, or support tooling.
- Add tests for the consumer behavior.
- Run Pint and focused tests.
Files That May Be Created
app/Attributes/*.php- Consumer classes in middleware, support, testing, or scanner namespaces.
- Tests for the attribute consumer.
Files That May Be Modified
- Classes or methods that receive the attribute.
- Middleware, Actions, Services, Providers, tests, or architecture tests that consume the attribute.
Architecture Rules
- Attributes describe metadata; they do not perform business workflows.
- Do not use custom attributes to bypass Actions, Policies, DTOs, Events, Jobs, or Services.
- Prefer Laravel built-in attributes before custom attributes.
- Every custom attribute must have a real consumer when introduced.
- Custom attributes are metadata and must not be used to bypass dependency injection.
Testing Requirements
- Test the consumer behavior.
- Test invalid or missing metadata where relevant.
- Add architecture tests when the attribute marks security, sensitivity, external integrations, or layer boundaries.
Security Requirements
- Attributes must not store secrets.
- Attributes must not become the only authorization mechanism unless the consumer explicitly enforces policy or gate checks.
- Treat reflected metadata as code-level metadata, not trusted user input.
Review Checklist
- Is an attribute the simplest clear tool?
- Is there a consumer?
- Are targets and repeatability correct?
- Is the class immutable and typed?
- Are tests focused on behavior?
Examples
Good Example
// app/Attributes/RequiresPlan.php
namespace App\Attributes;
use Attribute;
#[Attribute(Attribute::TARGET_CLASS | Attribute::TARGET_METHOD)]
final readonly class RequiresPlan
{
public function __construct(public string $plan = 'basic') {}
}// app/Http/Middleware/CheckPlanSubscription.php
namespace App\Http\Middleware;
use Closure;
use ReflectionClass;
use App\Attributes\RequiresPlan;
use Illuminate\Http\Request;
final class CheckPlanSubscription
{
public function handle(Request $request, Closure $next)
{
$controller = $request->route()?->controller;
if (! $controller) {
return $next($request);
}
// Use reflection to check for attribute on controller class
$reflection = new ReflectionClass($controller);
$attribute = $reflection->getAttributes(RequiresPlan::class)[0] ?? null;
if ($attribute) {
$requiresPlan = $attribute->newInstance();
if (! $request->user()?->subscribed($requiresPlan->plan)) {
abort(403, 'Subscription Plan Required');
}
}
return $next($request);
}
}Bad Example
// ❌ Constructing custom reflection tags, dynamic execution inside constructor, no targeting filters.
#[Attribute]
class RequiresPlan {
public function __construct($plan) {
if (!auth()->user()->subscribed($plan)) {
redirect('/billing'); // DO NOT run side-effects inside attributes!
}
}
}Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

