xiaohongshu
xiaohongshu
laravel-12
Expert guidance for building Laravel 12 applications following best practices, modern conventions, and the streamlined Laravel 12 architecture. Use this skill when creating Laravel projects, working with Eloquent models, building APIs, implementing authentication, writing tests, or any Laravel de...
Full skill instructions
This skill provides comprehensive guidance for developing high-quality Laravel 12 applications using modern best practices, proper architecture patterns, and Laravel's streamlined structure.
Provide expert-level Laravel 12 development guidance covering:
Use this skill when:
Always create files using php artisan make: commands with appropriate options:
# Models with migrations, factories, seeders
php artisan make:model Post -mfs
# Form Requests for validation
php artisan make:request StorePostRequest
# Controllers
php artisan make:controller PostController --resource
# Jobs
php artisan make:job ProcessPodcast
# Generic PHP classes
php artisan make:class Services/PaymentService
Important: Pass --no-interaction when running commands programmatically.
Laravel 12 uses a simplified structure:
app/Http/Middleware/ directory - register middleware in bootstrap/app.phpapp/Console/Kernel.php - use bootstrap/app.php or routes/console.phpapp/Console/Commands/bootstrap/app.php for middleware, routing, exceptionsRead references/structure.md for complete details on Laravel 12 architecture.
CRITICAL: Always retrieve authenticated user via $request->user(), never use auth()->user() or Auth::user():
// ✅ CORRECT
public function index(Request $request): Response
{
$user = $request->user();
// ...
}
// ❌ WRONG
public function index(): Response
{
$user = auth()->user(); // Don't do this
}
Read references/authentication.md for complete authentication and authorization guidance.
Prefer Eloquent models and relationships over raw queries:
// ✅ PREFER
$users = User::query()->where('active', true)->get();
// ❌ AVOID
$users = DB::table('users')->where('active', true)->get();
Prevent N+1 queries by eager loading relationships:
// ✅ GOOD - Prevents N+1
$posts = Post::with('user', 'comments')->get();
// ❌ BAD - Causes N+1
$posts = Post::all();
foreach ($posts as $post) {
echo $post->user->name; // New query each iteration
}
Read references/database.md for Eloquent patterns, relationships, migrations, and query optimization.
Never use inline validation. Always create Form Request classes:
php artisan make:request StorePostRequest
Form Requests should include:
public function rules(): array
{
return [
'title' => ['required', 'string', 'max:255'],
'body' => ['required', 'string'],
];
}
Read references/validation.md for complete validation patterns and examples.
// ❌ WRONG
$apiKey = env('API_KEY');
// ✅ CORRECT
$apiKey = config('services.api.key');
Environment variables should only be accessed in config/*.php files, then accessed via config() helper throughout the application.
Use queued jobs with ShouldQueue interface for time-consuming operations:
php artisan make:job ProcessPodcast
class ProcessPodcast implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public int $tries = 3;
public int $timeout = 120;
public function __construct(public Podcast $podcast) {}
public function handle(): void
{
$this->podcast->process();
}
}
Read references/queues.md for queue patterns, job chains, batches, and worker management.
When creating models, use appropriate flags:
# Model with migration, factory, seeder
php artisan make:model Post -mfs
# Model with migration, factory, seeder, policy, controller
php artisan make:model Post -mfsc --policy
public function posts(): HasMany
{
return $this->hasMany(Post::class);
}
casts() method for type casting:protected function casts(): array
{
return [
'published_at' => 'datetime',
'is_featured' => 'boolean',
'metadata' => 'array',
];
}
public function __construct(
public string $name,
public int $age,
) {}
public function store(StorePostRequest $request): RedirectResponse
{
$post = Post::create($request->validated());
return redirect()->route('posts.show', $post);
}
Use Eloquent API Resources for consistent API responses:
php artisan make:resource PostResource
class PostResource extends JsonResource
{
public function toArray($request): array
{
return [
'id' => $this->id,
'title' => $this->title,
'author' => new UserResource($this->whenLoaded('user')),
];
}
}
CRITICAL: When modifying columns, include ALL previous attributes or they will be lost:
// ❌ WRONG - Loses 'nullable' attribute
$table->string('email')->unique()->change();
// ✅ CORRECT - Preserves all attributes
$table->string('email')->nullable()->unique()->change();
This skill includes detailed reference files for specific topics:
references/structure.md - Laravel 12 file structure, Artisan commands, configurationreferences/authentication.md - Authentication, authorization, policies, gatesreferences/database.md - Eloquent, relationships, migrations, queries, API resourcesreferences/validation.md - Form Requests, validation rules, custom messagesreferences/queues.md - Jobs, queues, workers, chains, batchesRead the appropriate reference file(s) when working on related tasks to ensure following best practices.
protected function isAccessible(User $user, ?string $path = null): bool
{
// Implementation
}
php artisan make: commands to create files$request->user() for authenticationenv() outside config filesroute() helperphp artisan make:model Post -mfphp artisan make:request StorePostRequestphp artisan make:controller PostController --resourcephp artisan make:resource PostResourcebootstrap/app.php$request->user()This skill ensures Laravel applications follow modern best practices, maintain clean architecture, and leverage Laravel 12's streamlined structure effectively.
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience