Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
refactor-business-logic
refactor-business-logic
alizharb/agent-skills
claude-code
refactoring
business-logic
actions
services
dtos
policies
testing

Use when moving business logic out of controllers, Livewire components, models, routes, Blade views, or duplicated client layers.

Install
php artisan boost:add-skill alizharb/agent-skills

Save this content to: .claude/skills/refactor-business-logic/SKILL.md

# Refactor Business Logic

## When To Use

Use this skill when behavior is in the wrong layer, duplicated, hard to test, or not reusable across clients.

## Inputs Needed

- Current behavior, callers, desired boundary, preserved outputs, risks, and tests.

## Workflow

1. Identify logic inside controllers, Livewire components, models, routes, or views.
2. Add or locate regression tests before moving risky behavior.
3. Extract single operations to Actions.
4. Extract coordination or external integration to Services.
5. Extract contracts to DTOs, Data objects, Value Objects, casts, or concerns.
6. Extract access rules to Policies.
7. Extract side effects to Events, Listeners, or Jobs when useful.
8. Update callers to use the new reusable class.
9. Preserve behavior and avoid unrelated rewrites.
10. Run focused tests and formatting.

## Files That May Be Created

- Actions, Services, DTOs, Policies, Events, Jobs, Support classes, and tests.

## Files That May Be Modified

- Existing controllers, Livewire components, models, routes, Blade views, commands, jobs, and tests.

## Architecture Rules

- Refactors should reduce client-layer behavior and improve reuse.
- Preserve public contracts unless the task explicitly changes them.
- Prefer builders for query extraction, concerns for shared model behavior, and shared components for repeated UI.

## Testing Requirements

- Regression tests must prove preserved behavior.
- Add focused unit tests for newly extracted pure logic when useful.

## Security Requirements

- Do not lose authorization, validation, transactions, escaping, or throttling during extraction.

## Review Checklist

- Is behavior preserved?
- Is the new location more reusable?
- Are changes focused?
- Are existing callers updated consistently?

## Common Mistakes

- Broad rewrites during a narrow extraction.
- Moving code without tests.
- Extracting to vague helpers instead of clear operations.

Refactor Business Logic

When To Use

Use this skill when behavior is in the wrong layer, duplicated, hard to test, or not reusable across clients.

Inputs Needed

  • Current behavior, callers, desired boundary, preserved outputs, risks, and tests.

Workflow

  1. Identify logic inside controllers, Livewire components, models, routes, or views.
  2. Add or locate regression tests before moving risky behavior.
  3. Extract single operations to Actions.
  4. Extract coordination or external integration to Services.
  5. Extract contracts to DTOs, Data objects, Value Objects, casts, or concerns.
  6. Extract access rules to Policies.
  7. Extract side effects to Events, Listeners, or Jobs when useful.
  8. Update callers to use the new reusable class.
  9. Preserve behavior and avoid unrelated rewrites.
  10. Run focused tests and formatting.

Files That May Be Created

  • Actions, Services, DTOs, Policies, Events, Jobs, Support classes, and tests.

Files That May Be Modified

  • Existing controllers, Livewire components, models, routes, Blade views, commands, jobs, and tests.

Architecture Rules

  • Refactors should reduce client-layer behavior and improve reuse.
  • Preserve public contracts unless the task explicitly changes them.
  • Prefer builders for query extraction, concerns for shared model behavior, and shared components for repeated UI.

Testing Requirements

  • Regression tests must prove preserved behavior.
  • Add focused unit tests for newly extracted pure logic when useful.

Security Requirements

  • Do not lose authorization, validation, transactions, escaping, or throttling during extraction.

Review Checklist

  • Is behavior preserved?
  • Is the new location more reusable?
  • Are changes focused?
  • Are existing callers updated consistently?

Common Mistakes

  • Broad rewrites during a narrow extraction.
  • Moving code without tests.
  • Extracting to vague helpers instead of clear operations.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console