/laraclaude:lc:generate-test [ModelName | ControllerName | path/to/file]from laraclaude
Generates PHPUnit or Pest tests for Laravel models, controllers, actions, and components by analyzing code and identifying testable behaviors.
Ships in laraclaude. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Generate PHPUnit or Pest test files for a given model, controller, action, or component by analyzing its code and identifying testable behaviors.
| Subcommand | Description |
|---|---|
| (no argument) | Prompt for the class or file to generate tests for. |
[ModelName] | Generate tests for the specified model (searches in app/Models/). |
[ControllerName] | Generate tests for the specified controller (searches in app/Http/Controllers/). |
[path/to/file] | Generate tests for the file at the given path. |
This is a generator skill -- it always creates files.
Read to load the file directly.app/Models/ for model matchesapp/Http/Controllers/ for controller matchesapp/Actions/ for action matchesresources/views/livewire/ for Volt component matchescomposer.json for test dependencies:
pestphp/pest -> use Pest syntaxphpunit/phpunit -> use PHPUnit syntaxtests/ to match the project's style.Read to examine 1-2 existing test files for patterns:
actingAs(), factory patterns)RefreshDatabase, DatabaseTransactions)Use Read to load the target file and extract:
database/factories/{Model}Factory.php)$dispatch() callsCreate the test file at the appropriate location:
tests/Feature/{path matching source}/{ClassName}Test.php
tests/Unit/{path matching source}/{ClassName}Test.php
<?php
namespace Tests\Feature;
use App\Models\Property;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
class PropertyControllerTest extends TestCase
{
use RefreshDatabase;
public function test_index_returns_properties_for_authenticated_user(): void
{
$user = User::factory()->create();
$property = Property::factory()->create(['organization_id' => $user->organization_id]);
$response = $this->actingAs($user)->get(route('properties.index'));
$response->assertOk();
$response->assertSee($property->name);
}
public function test_store_validates_required_fields(): void
{
$user = User::factory()->create();
$response = $this->actingAs($user)->post(route('properties.store'), []);
$response->assertSessionHasErrors(['name', 'address']);
}
public function test_unauthenticated_user_is_redirected(): void
{
$response = $this->get(route('properties.index'));
$response->assertRedirect(route('login'));
}
}
For each testable method, generate tests for:
Write to create the test file.php -l via Bash (Docker-aware).After generating:
TEST FILE GENERATED
====================
File: tests/Feature/Models/PropertyTest.php
Test cases: 12
Tests generated:
- test_belongs_to_organization
- test_belongs_to_office
- test_has_many_operations
- test_scope_active_filters_correctly
- test_fillable_fields_are_protected
- test_soft_delete_works
- test_accessor_full_address
- test_toggle_showcase_action
...
Run with: docker exec {container} php artisan test --filter=PropertyTest
Model::create() with explicit attributes instead.RefreshDatabase trait for tests that modify the database.Livewire::test() syntax.actingAs() with the appropriate guard.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
test-generation, laravel-testing, phpunit, pest, model-testing, controller-testing
npx claudepluginhub edulazaro/laraclaude --plugin laraclaude32 skills in this plugin
/lc:analyze-errorPaste a Laravel stacktrace and get root cause analysis with suggested fix./lc:analyze-modelDeep analysis of a Laravel Eloquent model - relationships, scopes, casts, fillable, observers, keepers, actions./lc:api-docsGenerate API documentation from routes, controllers, and form requests./lc:blade-auditDetect hardcoded text without @text(), duplicate CSS classes, unused Blade components, and accessibility issues./lc:boost-inspectRuntime-verified Laravel inspection using the Laravel Boost MCP server (Tinker, Database Query/Schema, Last Error) instead of static grep. Falls back to Docker/Tinker if Boost is not installed./lc:cache-opportunitiesDetect repeated queries and computations that should be cached.Other plugins' skills for the same job