resources/boost/skills/controllers/SKILL.md
Thin HTTP entry points that validate input, delegate to Actions or Services, and return a response. Controllers contain no business logic.
npx skillsauth add codebar-ag/coding-guidelines controllersInstall 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/Controllers/**.routes/web.php, routes/api.php).FormRequest classes for all validation:
$request->validate() or Validator::make() directly in the controller.$this->authorize() calls.authorize() methods.can: or auth).__invoke):
StoreInvoiceController, ProcessWebhookController.JsonResponse or Resource / ResourceCollection).JsonResponse when status/header control matters; otherwise Laravel response casting is acceptable for simple payloads.// Invokable single-action controller
class StoreInvoiceController extends Controller
{
public function __invoke(StoreInvoiceRequest $request, CreateInvoice $action): JsonResponse
{
$invoice = $action->execute(
orderId: (int) $request->validated('order_id'),
);
return new JsonResponse(new InvoiceResource($invoice), 201);
}
}
// Resource controller — thin, delegates to actions
class InvoiceController extends Controller
{
public function index(): JsonResponse
{
// Explicit JsonResponse keeps status/header behavior clear for API controllers.
return new JsonResponse(InvoiceResource::collection(Invoice::paginate()), 200);
}
public function store(StoreInvoiceRequest $request, CreateInvoice $action): JsonResponse
{
$this->authorize('create', Invoice::class);
$invoice = $action->execute(orderId: (int) $request->validated('order_id'));
return new JsonResponse(new InvoiceResource($invoice), 201);
}
public function destroy(Invoice $invoice, DeleteInvoice $action): JsonResponse
{
$this->authorize('delete', $invoice);
$action->execute($invoice);
return new JsonResponse(null, 204);
}
}
$request->validate() directly in a controller (use a FormRequest).Actions/SKILL.md — the delegation pattern used by thin controllersFormRequests/SKILL.md — all input validationPolicies/SKILL.md — authorization enforced in controllerstesting
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.