refactor:laravel

Refactor Laravel controllers into Actions and services with SOLID principles.

9|1|Updated Jan 12, 2026
One-click install
npx skills add https://github.com/SnakeO/claude-debug-and-refactor-skills-plugin --skill refactor-laravel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: refactor:laravel
Source: https://github.com/SnakeO/claude-debug-and-refactor-skills-plugin/tree/main/plugins/debug-and-refactor/skills/refactor-laravel
Command: npx skills add https://github.com/SnakeO/claude-debug-and-refactor-skills-plugin --skill refactor-laravel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps Laravel projects shed fat controllers, duplicated logic, and inconsistent patterns by applying modern PHP 8.3+/8.4+ features and Laravel 11+ best practices. It enables teams to produce clean, maintainable code with clear responsibilities, strong typing, and modular architecture.

Core Features & Use Cases

  • Extract business logic from controllers into single-purpose actions or services to follow the Single Responsibility Principle.
  • Introduce modern PHP features (typed constants, property hooks) and Laravel 11+ patterns (Actions, simplified structure) to reduce boilerplate.
  • Identify and address common anti-patterns (fat controllers, N+1 queries, missing type declarations) and retrofit with clean architecture.
  • Use cases: refactor a legacy controller into a thin controller + actions/services, or gradually migrate to domain-driven structure with tests.

Quick Start

Start by locating a fatty controller (e.g., app/Http/Controllers/AuthController), create a dedicated Action or Service, inject it into the controller, and progressively move logic with type declarations. Then run your Pest/PHPUnit tests to ensure behavior remains unchanged.

Frequently Asked Questions about refactor:laravel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I refactor fat controllers in a Laravel application?▼

To refactor fat controllers in Laravel, extract business logic into single-purpose Actions or services, inject them into the controller, and apply SOLID principles to separate responsibilities. This makes controllers thin and maintainable.

What is the best way to fix N+1 query issues during a Laravel refactor?▼

Fixing N+1 query issues during a Laravel refactor involves identifying the anti-pattern in your current logic and retrofitting it with clean architecture and modern PHP features to optimize query execution and improve testability.

How do I migrate legacy Laravel code to use Actions and services?▼

Migrate legacy Laravel code by locating a fatty controller, creating a dedicated Action or Service, injecting it, and progressively moving logic with strong type declarations to gradually adopt a domain-driven structure.

Can I use modern PHP 8.3+ features when refactoring Laravel 11+ projects?▼

Yes, you can apply modern PHP 8.3+ features like typed constants and property hooks alongside Laravel 11+ patterns to reduce boilerplate and improve code maintainability when refactoring your application architecture.

When should I not move controller logic into separate Actions?▼

You should avoid splitting logic into separate Actions when your controllers are already thin, lack duplicated code, or when doing so would unnecessarily overcomplicate simple CRUD operations without improving testability.