form-requests
Skill4 starsChanged 5 months agoMITView on GitHub
Use Laravel Form Requests for non-trivial validation and authorization while keeping controllers thin and testable.
In this repository75 other files it gives its agents.
- AGENTS.mdAGENTS.md
- templates/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- actions-and-servicesSkill
- ai-sdkSkill
- api-resources-and-paginationSkill
- api-surface-evolutionSkill
- architectureSkill
- blade-components-and-layoutsSkill
- brainstormingSkill
- code-review-requestsSkill
- complexity-guardrailsSkill
- config-env-storageSkill
- constants-and-configurationSkill
- controller-cleanupSkill
- controller-testsSkill
- custom-helpersSkill
- daily-workflowSkill
- database-transactionsSkill
- data-chunking-large-datasetsSkill
- debugging-promptsSkill
- dependencies-trim-packagesSkill
- documentation-best-practicesSkill
- e2e-playwrightSkill
- effective-contextSkill
- eloquent-patternsSkill
- eloquent-relationshipsSkill
- exception-handling-and-loggingSkill
- executing-plansSkill
- extract-laravel-standardsSkill
- filesystem-uploadsSkill
- horizon-metrics-and-dashboardsSkill
- http-client-resilienceSkill
- integrate-whatsapp-baileys-laravelSkill
- interfaces-and-diSkill
- internationalization-and-translationSkill
- iterating-on-codeSkill
- laravel-11-12-app-guidelinesSkill
- laravel-database-optimizationSkill
- laravel-prompting-patternsSkill
- laravel-specialistSkill
- least-codeSkill
- livewire-developmentSkill
- memory-managementSkill
- migrations-and-factoriesSkill
- module-per-menuSkill
- nova-resource-patternsSkill
- performance-cachingSkill
- performance-eager-loadingSkill
- performance-select-columnsSkill
- php-attributesSkill
- policies-and-authorizationSkill
- ports-and-adaptersSkill
- prompt-structureSkill
- quality-checksSkill
- queues-and-jobsSkill
- rate-limitingSkill
- request-forgery-protectionSkill
- responsive-ui-testingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 11
Use Form Requests for HTTP validation and request-bound authorization when rules are complex, reused, sensitive, or likely to grow.
- Distinctive: line 22
use custom messages and attribute labels.
- Very specific: line 60
Use authorize() when the decision depends on request context or validated input.
- Distinctive: line 71
Use the simplest Laravel-native validation rule set that fully matches the actual input shape and behavior.
- Distinctive: line 86
Prefer named custom rule objects when validation has reusable domain meaning.
- Distinctive: line 90
Test validation failures and authorization failures.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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
Form Requests
Use Form Requests for HTTP validation and request-bound authorization when rules are complex, reused, sensitive, or likely to grow.
Inline controller validation is acceptable for tiny prototypes or legacy maintenance, but it is not the global standard for new or heavily edited workflows.
Responsibilities
A Form Request may:
- authorize the HTTP operation;
- normalize input in
prepareForValidation(); - return validation rules;
- use custom messages and attribute labels;
- expose small helper methods for typed validated data.
It should not:
- perform database writes;
- send external requests;
- dispatch jobs;
- contain long business workflows.
Input Normalization
Normalize human-formatted inputs before applying numeric/date/boolean rules. Keep locale assumptions explicit.
final class StoreRecordRequest extends FormRequest
{
protected function prepareForValidation(): void
{
$this->merge([
'amount' => NumberInput::normalize($this->input('amount')),
]);
}
public function rules(): array
{
return [
'amount' => ['required', 'numeric', 'min:0'],
'status' => ['required', Rule::enum(RecordStatus::class)],
];
}
}Shared parsers should be small helpers or value objects with unit tests.
Authorization
Use authorize() when the decision depends on request context or validated input. Use Policies when the decision depends on model state.
public function authorize(): bool
{
return $this->user()?->can('create', Record::class) === true;
}Array And Conditional Rules
Use the simplest Laravel-native validation rule set that fully matches the actual input shape and behavior. Reuse the existing Form Request structure when safe. Do not introduce complex nested rules, helper abstractions, or additional validation structures unless the behavior actually requires them.
Validate nested arrays explicitly.
public function rules(): array
{
return [
'items' => ['required', 'array', 'min:1'],
'items.*.name' => ['required', 'string', 'max:120'],
'items.*.quantity' => ['required', 'integer', 'min:1'],
];
}Prefer named custom rule objects when validation has reusable domain meaning.
Testing
Test validation failures and authorization failures. Cover request normalization when human-formatted values are accepted.
Context Efficiency
Layer: 3 (Implementation)
Load this skill only when validation or request authorization is nontrivial. Inline tiny validation in controllers only for prototypes or legacy maintenance. Keep Form Requests focused: rules, authorize, prepareForValidation, no database writes or business workflows.
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.

