Queues and horizon

From jpcaparas/superpowers-laravel · View interactive version

Queues and horizon is an AI agent skill from the GitHub repository jpcaparas/superpowers-laravel. Operate and verify queues with or without Horizon; safe worker flags, failure handling, and test strategies

How to use this skill

Skill file

Queues and Horizon

Run workers safely, verify execution, and test job behavior.

Commands

# Start worker
sail artisan queue:work --queue=high,default --tries=3 --backoff=5   # or: php artisan queue:work --queue=high,default --tries=3 --backoff=5

# Horizon (if installed)
sail artisan horizon                                               # or: php artisan horizon

# Failed jobs
sail artisan queue:failed                                          # or: php artisan queue:failed
sail artisan queue:retry all                                       # or: php artisan queue:retry all

Patterns

Laravel 13+

# Centralized queue routing (e.g., in AppServiceProvider)
Queue::route(ProcessPodcast::class, connection: 'redis', queue: 'podcasts');

# Declarative job controls via attributes
use Illuminate\Queue\Attributes\{Tries, Backoff, Timeout, FailOnTimeout};

#[Tries(3)]
#[Backoff([10, 30, 60])]
#[Timeout(120)]
#[FailOnTimeout]
class ProcessPodcast implements ShouldQueue { /* ... */ }

# Graceful shutdown for long-running jobs
class ProcessPodcast implements ShouldQueue, Interruptible {
    public function onInterrupt(): void { /* release locks, save state */ }
}

# Auto-scaling friendly worker exit
sail artisan queue:work --stop-when-empty-for=60   # or: php artisan queue:work --stop-when-empty-for=60

Testing Jobs

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.