Skip to content

How to use Laravel Specialist in Claude Code for beginners

Purpose

This post demonstrates how to use Laravel Specialist skill in Claude Code to improve your backend development workflow.

Environment

  • Claude Code with claude-skills plugin
  • Laravel 10.x or 11.x
  • PHP 8.1 or higher
  • Beginner to intermediate development experience

What is Laravel Specialist?

Laravel Specialist is a skill in the claude-skills ecosystem that provides specialized knowledge for Laravel framework development. When I use this skill, it gives me access to:

  • Laravel-specific patterns and best practices
  • Eloquent ORM optimization techniques
  • Artisan command usage examples
  • Service provider and facade patterns
  • Laravel testing strategies

The skill activates when I mention Laravel-specific tasks in my prompts. I don’t need to install anything extra beyond the claude-skills plugin.

When should I use this skill?

I use Laravel Specialist when:

  • Building new Laravel features or models
  • Writing database migrations and relationships
  • Creating API endpoints with Laravel
  • Setting up authentication and authorization
  • Writing Laravel tests (PHPUnit or Pest)
  • Optimizing Eloquent queries

I should NOT use this skill for:

  • Generic PHP questions (use PHP patterns instead)
  • Frontend JavaScript tasks (use frontend-patterns)
  • Database design unrelated to Laravel (use postgres-patterns)

Basic Usage Pattern

When I want to use Laravel Specialist, I simply mention Laravel in my request:

Create a Laravel model for User with relationships to Posts and Comments

Claude Code automatically invokes the Laravel Specialist skill because it detects “Laravel model” in my request.

Installation

First, I need to install claude-skills:

Terminal window
# Install the plugin
npm install -g claude-skills
# Verify installation
claude-skills --version

The Laravel Specialist skill is included by default. I can verify it’s available:

Terminal window
# List all available skills
claude-skills list
# I should see "laravel-specialist" in the output

Practical Examples

Example 1: Creating a Model with Relationships

When I ask:

Create a Laravel model for Blog with one-to-many relationship to Posts

Laravel Specialist generates:

app/Models/Blog.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
class Blog extends Model
{
protected $fillable = [
'title',
'description',
];
// One blog has many posts
public function posts(): HasMany
{
return $this->hasMany(Post::class);
}
}
app/Models/Post.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
class Post extends Model
{
protected $fillable = [
'blog_id',
'title',
'content',
];
// Many posts belong to one blog
public function blog(): BelongsTo
{
return $this->belongsTo(Blog::class);
}
}

Example 2: Writing a Controller with Validation

I asked:

Create a Laravel controller to store new posts with validation rules

The output:

app/Http/Controllers/PostController.php
<?php
namespace App\Http\Controllers;
use App\Models\Post;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
class PostController extends Controller
{
public function store(Request $request): JsonResponse
{
// Validate input
$validated = $request->validate([
'blog_id' => ['required', 'exists:blogs,id'],
'title' => ['required', 'string', 'max:255'],
'content' => ['required', 'string'],
]);
// Create post
$post = Post::create($validated);
return response()->json($post, 201);
}
}

Example 3: Setting Up API Routes

I needed API routes for my blog:

Create Laravel API routes for blog posts resource

Result:

routes/api.php
<?php
use App\Http\Controllers\PostController;
use Illuminate\Support\Facades\Route;
// API routes for posts
Route::prefix('blogs')->group(function () {
Route::get('{blog}/posts', [PostController::class, 'index']);
Route::post('{blog}/posts', [PostController::class, 'store']);
Route::get('posts/{post}', [PostController::class, 'show']);
Route::put('posts/{post}', [PostController::class, 'update']);
Route::delete('posts/{post}', [PostController::class, 'destroy']);
});

Common Trigger Phrases

These phrases invoke Laravel Specialist:

  • “Create a Laravel model for…”
  • “Write a Laravel migration that…”
  • “Set up Laravel authentication…”
  • “Create a controller with validation…”
  • “Optimize this Eloquent query…”
  • “Write a Laravel test for…”
  • “Configure Laravel service provider…”

Best Practices

DO:

  • Be specific about Laravel version (10.x or 11.x)
  • Mention relationships explicitly: “one-to-many”, “many-to-many”
  • Specify if you need API or web routes
  • Include validation requirements in your request
  • Mention if you want Pest or PHPUnit tests

Example:

Create Laravel 11 API resource for User with password validation

DON’T:

  • Use generic terms like “create a model” without “Laravel”
  • Expect the skill to know your database schema
  • Assume it knows your existing codebase structure
  • Ask for non-Laravel PHP tasks

Laravel Specialist works well with these other skills:

  • backend-patterns: For general API design and caching
  • postgres-patterns: For database optimization
  • testing-patterns: For general testing strategies
  • security-review: For validating authentication flows

How it Fits Into Development Workflow

Planning → Laravel Specialist → Implementation → Testing
↓ ↓
Generate Code Write Tests
Code Review

I typically use Laravel Specialist during the implementation phase. I plan my feature first, then use the skill to generate boilerplate code, then customize it for my needs.

Common Issues I Encountered

Issue 1: Generic PHP Instead of Laravel

When I asked:

Create a user class with login method

I got generic PHP code instead of Laravel-specific code.

Solution: I added “Laravel” to my request:

Create a Laravel User model with authentication

Issue 2: Wrong Laravel Version

The skill generated code for Laravel 8.x but I’m using 11.x.

Solution: I now always specify the version:

Create Laravel 11 API resource...

Issue 3: Missing Context

The skill couldn’t generate proper relationships because it didn’t know my database schema.

Solution: I provide more context upfront:

Create Laravel models for Order and Customer. Orders belong to customers.
Orders have: id, customer_id, total, status
Customers have: id, name, email

Tips for Maximum Effectiveness

  1. Always mention “Laravel” explicitly in your prompt
  2. Specify the version if using newer features
  3. Provide schema details when asking for models or migrations
  4. Include validation rules when requesting controllers
  5. Mention the test framework (Pest or PHPUnit)
  6. Be specific about relationships: “one-to-many”, “many-to-many”

Summary

In this post, I showed how to use Laravel Specialist skill in Claude Code for backend development. The key point is to be specific with Laravel terminology and version requirements in your prompts. The skill saves time by generating boilerplate code that follows Laravel best practices, letting me focus on business logic instead of framework setup.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments