resources/boost/skills/requests/SKILL.md
Dedicated Form Request validation classes for all controller input. Every endpoint that accepts user input must use a `FormRequest` class — validation never happens directly inside a controller.
npx skillsauth add codebar-ag/coding-guidelines requestsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
app/Http/Requests/ structure exists.FormRequest class$request->validate() or Validator::make() inside a controllerapp/Http/Requests/ or a subdirectory matching the domain (e.g. Auth/)Store{Resource}Request, Update{Resource}Requestauthorize(): bool with intentional access controlrules(): array with a PHPDoc @return array shape annotationmessages(): array for user-friendly or localized error messagesreturn true in authorize() as explicit and safe only for genuinely public/non-sensitive operationsvalidated(), safe(), and typed retrieval methods where neededclass StoreInvoiceRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user()->can('create', Invoice::class);
}
/**
* @return array<string, array<int, string|object>>
*/
public function rules(): array
{
return [
'order_id' => ['required', 'integer', 'exists:orders,id'],
'due_date' => ['required', 'date', 'after:today'],
'notes' => ['nullable', 'string', 'max:1000'],
];
}
public function messages(): array
{
return [
'order_id.exists' => __('The selected order does not exist.'),
'due_date.after' => __('The due date must be a future date.'),
];
}
}
// Custom authorization logic options
public function authorize(): bool
{
// Allow all authenticated users
return $this->user() !== null;
// Scope to admin role
return $this->user()->isAdmin();
// Delegate to a policy
return $this->user()->can('update', $this->route('invoice'));
}
// Nested + conditional validation example
use Illuminate\Validation\Rule;
public function rules(): array
{
return [
'lines' => ['required', 'array', 'min:1'],
'lines.*.sku' => ['required', 'string'],
'lines.*.quantity' => ['required', 'integer', 'min:1'],
'internal_note' => Rule::when(
$this->user()?->isAdmin() === true,
['nullable', 'string', 'max:500'],
['prohibited']
),
];
}
FormRequest.authorize().FormRequest into the controller action signature.$request->validated().// Before: controller owns validation and input concerns
public function store(Request $request): JsonResponse
{
$validated = $request->validate([
'name' => ['required', 'string', 'max:255'],
]);
$project = Project::create($validated);
return response()->json($project, 201);
}
// After: controller delegates to FormRequest
public function store(StoreProjectRequest $request): JsonResponse
{
$project = Project::create($request->validated());
$meta = $request->safe()->only(['name']);
return response()->json(['data' => $project, 'meta' => $meta], 201);
}
$request->validate([...]) inside a controller'required|string|max:255' instead of ['required', 'string', 'max:255']authorize() as a passive return true without a comment explaining intentmessages() method when default Laravel messages are unclear to end users@return PHPDoc annotation on rules() (breaks PHPStan analysis)Controllers/SKILL.md — controllers that inject and use Form RequestsPolicies/SKILL.md — policies referenced in authorize()testing
Translation and localization conventions for Laravel. Use when adding user-facing strings, creating translation files, or working with lang/ directory.
tools
Reusable behaviour shared across multiple unrelated classes. Traits provide shared Eloquent scopes, accessors, lifecycle hooks, and small stateless helper methods.
development
Tailwind CSS v4 styling conventions. Use when working with CSS, Tailwind utilities, or customizing the theme in Laravel projects.
development
Orchestration classes that coordinate multiple Actions, external APIs, or domain operations into a cohesive workflow. Services own transaction boundaries and third-party API integrations.