laravel-backend
Implements Laravel 12 backend features using routes, controllers, Form Requests, Eloquent, policies, services/actions, jobs, events, notifications, caching, files, sessions, and HTTP responses. Use fo
SKILL.md.agents/skills/laravel-backend/SKILL.md
GitHubLaravel Backend Development
Role
Act as a senior Laravel 12 backend developer.
Implementation sequence
- Read the requirement and acceptance criteria.
- Inspect existing code and conventions.
- Identify authentication/authorization.
- Design validation.
- Design persistence and relationships.
- Implement business logic in the right layer.
- Implement response/redirect behavior.
- Add tests.
- Run tests and inspect logs/errors.
Validation
- Validate every user-controlled input server-side.
- Prefer Form Requests for substantial forms/endpoints.
- Normalize input deliberately.
- Never rely on client-side validation.
Eloquent
- Define relationships explicitly.
- Use casts intentionally.
- Prevent mass-assignment vulnerabilities.
- Use scopes for recurring query constraints.
- Eager-load relationships used in loops.
- Paginate large datasets.
- Use
withCount,withExists, aggregates, or selective columns where they materially improve queries.
HTTP behavior
- Use correct status codes.
- Use named route redirects for web flows.
- Preserve validation errors and old input for Blade forms.
- Follow the project’s existing flash-message conventions.
External services
- Isolate integrations.
- Set timeouts.
- Handle non-success responses.
- Never log secrets or tokens.
- Use safe retry strategies.
- Queue slow operations when appropriate.
File uploads
- Validate type and size.
- Use Laravel Storage APIs.
- Generate safe paths/names.
- Store outside public web root unless public access is intentional.
- Never trust original filenames.
Caching
- Cache only when there is a real performance reason.
- Use stable, scoped keys.
- Define invalidation rules.
- Never share user-specific data under a global cache key.
Jobs
- Prefer idempotent jobs.
- Avoid serializing unnecessary objects.
- Design retries/failures intentionally.
- Be careful with jobs dispatched before database commit.
Error handling
Do not swallow exceptions. Return safe user-facing errors while preserving useful server-side diagnostics without exposing secrets.