refactor-entry-point-to-action

Refactor oversized entry-point methods into dedicated Action classes.

Updated Aug 15, 2025
One-click install
npx skills add https://github.com/pekral/pekral.cz --skill refactor-entry-point-to-action
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: refactor-entry-point-to-action
Source: https://github.com/pekral/pekral.cz/tree/main/.claude/skills/refactor-entry-point-to-action
Command: npx skills add https://github.com/pekral/pekral.cz --skill refactor-entry-point-to-action

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you untangle overloaded controller, job, command, listener, or Livewire entry-point code by moving orchestration into a dedicated Action class, while keeping the exact same behavior and response contracts.

Core Features & Use Cases

  • Entry-point slimming: Convert thick controller/job/command/listener/Livewire methods into thin delegates that call a single Action.
  • Architecture-safe refactoring: Preserve signatures, responses, tenant/account scope, and existing boundaries (repositories/managers/services).
  • Validation separation: Move inline validation out of the Action into a dedicated Data Validator that follows project conventions.

Quick Start

Refactor entry-point logic into a dedicated Action by delegating from Class::method to app/Actions/<Domain>/YourAction.php while preserving behavior and response contracts.

Frequently Asked Questions about refactor-entry-point-to-action

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

FAQPage Schema
How do I refactor a fat controller method into an Action class without breaking existing behavior?

To refactor a fat controller method into an Action class, you extract orchestration logic into a dedicated readonly Action with a single __invoke method, preserving original signatures, responses, and boundary-respecting reads while delegating validation.

What is the Action pattern for extracting business orchestration from entry points?

The Action pattern extracts business orchestration from entry points like controllers and jobs into a final readonly class containing exactly one __invoke method, ensuring thin delegation and keeping database calls outside the Action.

Can I use this refactoring approach for Livewire component methods and queued jobs?

Yes, you can use this refactoring approach for Livewire component methods and queued jobs. It applies to controllers, jobs, commands, and listeners, converting thick methods into thin delegates that call a single Action class.

Where should data validation live when moving logic into a dedicated Action?

Data validation should live in a dedicated Data Validator rather than inside the Action itself. When moving logic into a dedicated Action, you must extract inline validation out of the Action to follow project conventions.

What is the best way to handle Eloquent queries when refactoring entry points into Actions?

The best way to handle Eloquent queries when refactoring entry points into Actions is to keep all database calls outside the Action entirely. The Action must contain no Eloquent or DB calls, relying instead on boundary-respecting reads and writes.