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
decompose-model
alizharb/agent-skills
claude-code
eloquent
model-refactoring
concerns
query-builders
casts
code-extraction

Use when a model is getting too large and needs concerns, casts, builders, or other extractions.

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

Save this content to: .claude/skills/decompose-model/SKILL.md

# Decompose Model

## When To Use

Use this skill when an Eloquent model is becoming too large or starts mixing persistence with workflow code.

## Inputs Needed

- Model name, current responsibilities, reusable behaviors, query needs, and extraction target.

## Workflow

1. Inspect the model and its related classes.
2. Identify what belongs in relations, casts, accessors, mutators, builders, policies, or support classes.
3. Extract reusable query logic into a builder or query object.
4. Extract reusable behavior into a concern when it fits.
5. Keep only small model-level invariants in the model.
6. Add or update tests for the extracted behavior.

## Files That May Be Created

- Builders, concerns, casts, support classes, policies, DTOs, and tests.

## Files That May Be Modified

- The model, related builders, and related tests.

## Architecture Rules

- The model should stay readable and persistence-focused.
- Reusable query logic should not become model scopes in new code.
- The model should not orchestrate workflows.

## Testing Requirements

- Test the extracted behavior where it now lives.

## Review Checklist

- Did the extraction reduce model size?
- Is the logic in the right layer?
- Did behavior stay the same?

## Common Mistakes to Avoid

- Extracting too many tiny files without reducing complexity.
- Leaving reusable query behavior in model scopes.

Decompose Model

When To Use

Use this skill when an Eloquent model is becoming too large or starts mixing persistence with workflow code.

Inputs Needed

  • Model name, current responsibilities, reusable behaviors, query needs, and extraction target.

Workflow

  1. Inspect the model and its related classes.
  2. Identify what belongs in relations, casts, accessors, mutators, builders, policies, or support classes.
  3. Extract reusable query logic into a builder or query object.
  4. Extract reusable behavior into a concern when it fits.
  5. Keep only small model-level invariants in the model.
  6. Add or update tests for the extracted behavior.

Files That May Be Created

  • Builders, concerns, casts, support classes, policies, DTOs, and tests.

Files That May Be Modified

  • The model, related builders, and related tests.

Architecture Rules

  • The model should stay readable and persistence-focused.
  • Reusable query logic should not become model scopes in new code.
  • The model should not orchestrate workflows.

Testing Requirements

  • Test the extracted behavior where it now lives.

Review Checklist

  • Did the extraction reduce model size?
  • Is the logic in the right layer?
  • Did behavior stay the same?

Common Mistakes to Avoid

  • Extracting too many tiny files without reducing complexity.
  • Leaving reusable query behavior in model scopes.
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.
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
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource