laravel-feature

Auto-invoked skill

Build complete Laravel features with CRUD, views, API, and tests

Trigger Keywords

This skill automatically activates when Claude detects these keywords in your conversation:

build feature create crud implement

Overview

The laravel-feature skill provides specialized knowledge for building complete Laravel features. When activated, Claude gains enhanced understanding of Laravel conventions, CRUD patterns, and full-stack feature development.

How It Works

Unlike commands that you invoke explicitly, skills activate automatically based on context. When you ask Claude to build something, this skill engages to provide Laravel-specific expertise.

User: "Help me build an invoice management system"
                    ↓
         Claude detects "build" keyword
                    ↓
         laravel-feature skill activates
                    ↓
         Claude uses Laravel conventions and patterns
                    ↓
         May delegate to /build command or feature-builder agent
            

Example Conversations

# Building a complete feature
User: "I need to build a product catalog with categories and search"
Claude: [skill activates] "I'll help you build a product catalog..."
→ Generates Model, Migration, Controller, Views, Tests

# Creating CRUD functionality
User: "Create CRUD for managing blog posts"
Claude: [skill activates] "Let me create a complete CRUD system..."
→ Uses resource controller pattern, form requests, validation

# Implementing a feature
User: "Implement user notifications with email and database"
Claude: [skill activates] "I'll implement notifications using..."
→ Uses Laravel notification system, creates channels

What This Skill Provides

  • Laravel conventions - Proper naming, directory structure, PSR-4
  • CRUD patterns - Resource controllers, form requests, validation
  • Eloquent expertise - Relationships, scopes, accessors, casts
  • View patterns - Blade components, layouts, partials
  • Testing knowledge - Pest PHP, factories, database testing

When Skill Activates vs Commands

Scenario Behavior
"Build an invoice system" Skill activates, may suggest /build command
/laravel-agent:build invoices Command executes directly, skill provides context
"How do I create a model?" Skill activates for Laravel guidance
"What's the weather today?" Skill does not activate (no trigger keywords)

Complete Model Example

<?php

declare(strict_types=1);

namespace App\Features\Products\Domain\Models;

use App\Features\Products\Domain\Enums\ProductStatus;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;

final class Product extends Model
{
    use HasFactory, SoftDeletes;

    protected $fillable = [
        'name',
        'slug',
        'description',
        'price',
        'category_id',
        'status',
    ];

    protected function casts(): array
    {
        return [
            'price' => 'decimal:2',
            'status' => ProductStatus::class,
        ];
    }

    public function category(): BelongsTo
    {
        return $this->belongsTo(Category::class);
    }

    public function scopeActive($query)
    {
        return $query->where('status', ProductStatus::Active);
    }
}

Controller with Authorization

<?php

declare(strict_types=1);

namespace App\Features\Products\Http\Controllers;

use App\Features\Products\Domain\Actions\CreateProductAction;
use App\Features\Products\Domain\Models\Product;
use App\Features\Products\Http\Requests\StoreProductRequest;

final class ProductController extends Controller
{
    public function __construct()
    {
        $this->authorizeResource(Product::class, 'product');
    }

    public function index()
    {
        $products = Product::query()
            ->with(['category'])
            ->latest()
            ->paginate(15);

        return view('products.index', compact('products'));
    }

    public function store(StoreProductRequest $request, CreateProductAction $action)
    {
        $product = $action->execute($request->validated());

        return redirect()
            ->route('products.show', $product)
            ->with('success', 'Product created successfully.');
    }
}

Common Pitfalls

  • Fat Controllers - Move business logic to Actions/Services
  • Missing Authorization - Always use Policies with authorizeResource()
  • N+1 Queries - Eager load relationships with with()
  • No Validation - Use Form Requests, not inline validation
  • Hardcoded Values - Use Enums for status fields
  • Missing Tests - Every feature needs tests

Package Integration

  • spatie/laravel-sluggable - Auto-generate slugs
  • spatie/laravel-medialibrary - Handle file uploads
  • spatie/laravel-activitylog - Track changes
  • spatie/laravel-tags - Add tagging

Best Practices

  1. Be specific - "Build invoice management with line items" triggers better than "make invoices"
  2. Mention requirements - Include relationships, validations, special features
  3. Use commands for precision - When you know exactly what you want, use /build directly
  4. Use final class - For non-inheritable classes
  5. Declare strict_types=1 - For type safety
  6. Max 5 design patterns - Per project to avoid over-engineering

Related Commands

Related Agents