Refactor Backend

Refactor Laravel backend code without altering API contracts or tests.

4|1|Updated Sep 25, 2025
One-click install
npx skills add https://github.com/gmedia/erp --skill refactor-backend
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Refactor Backend
Source: https://github.com/gmedia/erp/tree/main/.agent/skills/refactor-backend
Command: npx skills add https://github.com/gmedia/erp --skill refactor-backend

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve?

Panduan ini membantu tim melakukan refactor kode backend pada Laravel secara TERKONTROL tanpa merusak API contract, struktur respons, atau test yang ada.

Core Features & Use Cases

  • Instruksi arsitektur dan pola desain untuk backend Laravel (tipis Controller, FormRequest per operasi, Resources, serta opsi Layer Action/Domain).
  • Verifikasi konsistensi: tes, routes, dan pattern references untuk menjaga kompatibilitas.

Quick Start

Lakukan refactor backend secara terkendali tanpa mengubah kontrak API, struktur respons, maupun test yang ada.

Frequently Asked Questions about Refactor Backend

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

FAQPage Schema
How do I refactor a Laravel backend without breaking existing API contracts and tests?

To refactor a Laravel backend safely, use thin controllers, per-operation FormRequests, Resources, and optional Action/Domain layers. This ensures code movement and structural improvements do not alter public API contracts, response structures, or tests.

What is the best way to restructure fat Laravel controllers into domain services?

Restructuring fat Laravel controllers involves moving logic to optional Action or Domain layers while keeping controllers thin. Use per-operation FormRequests for validation and Resources for consistent responses, guided by a pattern reference.

Can I move validation and response mapping logic in Laravel without altering response structures?

Yes, you can safely move validation to per-operation FormRequests and mapping to Resources without altering response structures. The process uses a validation script to verify routes, tests, and pattern consistency.

Does guided Laravel refactoring work with existing form requests and domain services?

Guided Laravel refactoring works with existing modules containing controllers, form requests, resources, and domain services. It facilitates safe code movement and structural improvements while maintaining compatibility.

When should I not use a pattern reference for backend Laravel refactoring?

You should not skip the pattern reference when performing structural improvements or moving code across domain services. Omitting it risks breaking the controlled refactoring process and compromising API contract consistency.