juststeveking/laravel-api-skill
A comprehensive Claude skill for building production-grade Laravel REST APIs with clean architecture, type safety, and Laravel best practices.
npx skills add juststeveking/laravel-api-skillREADME
Laravel API Skill for Claude
A comprehensive Claude skill for building production-grade Laravel REST APIs with clean architecture, type safety, and Laravel best practices.
šÆ What This Skill Does
This skill guides Claude in building Laravel REST APIs using opinionated architecture patterns combined with Laravel's official code quality standards. It implements:
- Stateless Design - No hidden dependencies, explicit data flow
- Boundary-First Architecture - Clear separation of HTTP, business logic, and data layers
- Resource-Scoped Organization - Routes and controllers organized by resource
- Version Discipline - Namespace-based versioning with HTTP Sunset headers
- Type Safety - Strict types, return type declarations, PSR-12 compliance
- Code Quality - Laravel simplifier patterns for maintainable code
š¦ Installation
Option 1: Claude.ai / Claude App
- Download laravel-api.skill
- Open Claude.ai or Claude app ā Settings ā Skills
- Click "Add Skill" or "Import Skill"
- Upload the
laravel-api.skillfile - Start building Laravel APIs!
Option 2: Claude Code Plugin
If you're using Claude Code, you can install via the marketplace:
/plugin marketplace add juststeveking/laravel-api-skill
/plugin install laravel-api@juststeveking
š Quick Start
Once installed, simply tell Claude what you want to build:
Build a Laravel API for managing tasks with CRUD operations
Create a Laravel API endpoint for user authentication with JWT
Review and refactor this Laravel controller to follow best practices
The skill automatically triggers when you mention Laravel API development.
šļø Architecture Patterns
Core Components
Models - Simple data access with ULIDs
final class Task extends Model
{
use HasFactory;
use HasUlids;
}
Controllers - Invokable, single responsibility
final readonly class StoreController
{
public function __invoke(StoreTaskRequest $request): JsonResponse
{
$task = $this->createTask->handle($request->payload());
return new JsonDataResponse($task, 201);
}
}
Form Requests - Validation + DTO transformation
final class StoreTaskRequest extends FormRequest
{
public function payload(): StoreTaskPayload
{
return new StoreTaskPayload(/* ... */);
}
}
Actions - Single-purpose business logic
final readonly class CreateTask
{
public function handle(StoreTaskPayload $payload): Task
{
return Task::create($payload->toArray());
}
}
DTOs - Explicit data transfer
final readonly class StoreTaskPayload
{
public function __construct(
public string $title,
public ?string $description,
) {}
}
Project Structure
app/
āāā Actions/
ā āāā Tasks/
ā āāā CreateTask.php
āāā Http/
ā āāā Controllers/
ā ā āāā Tasks/
ā ā āāā V1/
ā ā āāā StoreController.php
ā āāā Requests/
ā ā āāā Tasks/
ā ā āāā V1/
ā ā āāā StoreTaskRequest.php
ā āāā Payloads/
ā ā āāā Tasks/
ā ā āāā StoreTaskPayload.php
ā āāā Responses/
ā āāā JsonDataResponse.php
ā āāā JsonErrorResponse.php
āāā Models/
āāā Task.php
routes/
āāā api/
āāā routes.php
āāā tasks.php
š What's Included
SKILL.md
Main skill file with:
- Quick start workflow
- Core architecture principles
- Code quality standards
- Step-by-step component creation
- API versioning patterns
- Authentication setup
References
- architecture.md - Comprehensive architectural patterns and principles
- code-examples.md - Complete working examples for every component
- code-quality.md - Laravel best practices, refactoring patterns, PSR-12 standards
Templates
Ready-to-use scaffolding templates:
- Controller.php
- FormRequest.php
- Payload.php
- Action.php
- Model.php
⨠Key Features
Type Safety
All code uses declare(strict_types=1) and explicit return types:
public function handle(StoreTaskPayload $payload): Task
Match Expressions
Replace nested ternaries with readable match expressions:
$status = match (true) {
$task->completed_at && $task->verified => 'verified',
$task->completed_at => 'completed',
default => 'pending',
};
Consistent Responses
Standardized JSON responses using Responsable classes:
// Success
return new JsonDataResponse(data: $task, status: 201);
// Error (Problem+JSON RFC 7807)
return new JsonErrorResponse(errors: [...], status: 422);
Versioned Endpoints
Namespace-based versioning with deprecation warnings:
Route::middleware(['auth:api', 'http.sunset:2025-12-31'])->group(function () {
Route::get('/tasks', V1\IndexController::class);
});
š Learning Resources
The skill includes comprehensive guides on:
- PSR
...