resources/boost/skills/formrequests/SKILL.md
Dedicated validation classes for all controller input. Form Requests encapsulate validation rules, authorization, and error messages outside of controllers.
npx skillsauth add codebar-ag/coding-guidelines formrequestsInstall 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.
FormRequest class (keeps controllers thin and validations testable)$request->validate() or Validator::make() inside a controller (avoid duplicated inline rules)app/Http/Requests/ or a subdirectory matching the domain (e.g. Auth/)Store{Resource}Request, Update{Resource}RequestStoreSprintController → StoreSprintRequestauthorize(): bool with proper authorization logic — never leave it as a passive return true without intentionrules(): array with a PHPDoc @return array shapemessages(): array when validation messages need localization or extra clarity$this->user() over global helpers for request-bound auth access inside authorize() and rules()use Illuminate\Validation\Rule;
class StoreSprintRequest extends FormRequest
{
public function authorize(): bool
{
return $this->user() !== null;
}
/**
* @return array<string, array<int, string|object>>
*/
public function rules(): array
{
return [
'title' => ['required', 'string', 'max:255'],
'locale' => ['required', Locale::validationRule()],
'billing_code' => Rule::when(
$this->user()?->isAdmin() === true,
['required', 'string', 'max:50'],
['nullable']
),
];
}
public function messages(): array
{
return [
'title.required' => __('A title is required.'),
];
}
}
// Controller usage — inject the FormRequest
class StoreSprintController extends Controller
{
public function __invoke(StoreSprintRequest $request, CreateSprint $action): JsonResponse
{
$sprint = $action->execute($request->validated());
return new JsonResponse(new SprintResource($sprint), 201);
}
}
// Authorization using a policy
public function authorize(): bool
{
return $this->user()->can('create', Post::class);
}
// Scoped to an admin role
public function authorize(): bool
{
return $this->user()->isAdmin();
}
$request->validate() inside a controller — always use a FormRequest'required|string|max:255' instead of ['required', 'string', 'max:255']authorize() as return true without documenting why all users are permittedmessages() method for user-facing validation errors that need clarityControllers/SKILL.md — controllers that use Form RequestsPolicies/SKILL.md — can() used in authorize() methodtesting
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.