Agent skill
laravel-state-machines
State machines using Spatie Model States for complex state transitions. Use when working with complex state management, state transitions, or when user mentions state machines, Spatie Model States, state transitions, transition validation.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/product/laravel-state-machines-leeovery-claude-laravel
SKILL.md
Laravel State Machines
State machines with Spatie Model States for complex state transitions and validation.
Core Concept
state-management.md - State machine patterns:
- Spatie Model States setup
- State classes with behavior
- Transition classes with validation
- State-specific methods
- When to use state machines vs simple enums
- Testing state transitions
Pattern
// State classes
final class DraftOrderState extends OrderState
{
public function canBeSubmitted(): bool
{
return true;
}
}
final class PendingOrderState extends OrderState
{
public function canBeSubmitted(): bool
{
return false;
}
}
// Transition class
final class SubmitOrderTransition extends Transition
{
public function handle(): OrderState
{
// Validation and side effects
return new PendingOrderState($this->order);
}
}
// Usage
$order->status->transitionTo(PendingOrderState::class);
Use state machines for complex state with validation, side effects, or state-specific behavior. Use simple enums for basic status fields.
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?