Laravel Queues logo

Laravel Queues

Community
AsyrafHussin
laravel-queues

Laravel 13 queue and job patterns — driver choice, job design (idempotency, ShouldQueue, model serialisation), retry and failure handling, worker scaling, Bus batching and chaining, Horizon when warranted, queue testing. Use when designing async jobs, scheduling background work, configuring Horizon, debugging stuck jobs, or auditing queue health. Triggers on "Laravel queue", "Laravel job", "background job", "Horizon setup", "failed jobs", "Bus batch", "queue worker tuning".

Overview

PublisherAsyrafHussin
Repositoryagent-skills
Skill namelaravel-queues
Stars
78
Forks
10
Bundled files
24
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 24 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by AsyrafHussin on GitHub. Read the source before you install it.

Installation

Install the Laravel Queues AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AsyrafHussin/agent-skills.git /tmp/agent-skills
mkdir -p .claude/skills
cp -r /tmp/agent-skills/skills/laravel-queues .claude/skills/laravel-queues
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Laravel Queues in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Laravel Queues on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Laravel Queues is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Laravel Queues & Jobs

Production-grade queue patterns for Laravel 13 (MySQL + Redis). Contains 20 rules across 6 categories covering driver choice, job design, retry/failure handling, worker scaling, batching/chaining, and testing. Targets the failure modes that pass code review but break under load — silent re-dispatch on retry, models stale on serialisation, missing idempotency on payment jobs, workers leaking memory, and "we forgot ShouldQueue and the request takes 12 seconds in production."

Metadata

  • Version: 1.0.0
  • Scope: PHP / Laravel 13 + MySQL + Redis (queues), optional Horizon
  • Rule Count: 20 rules across 6 categories
  • License: MIT

How to Use

When the user asks "design this background job", "audit our queue setup", "why is this job not running", or anything queue-related — work through this skill's rules as a checklist against the relevant files (job classes, config/queue.php, config/horizon.php, supervisor config, the dispatching call sites).

For audit mode, output per-rule verdicts:

  • PASS — pattern correctly applied
  • FAIL — anti-pattern present (with file:line + fix recommendation)
  • N/A — does not apply to this codebase

End with a top-priority fix list (idempotency on payment jobs, missing ShouldQueue, supervisor stopwaitsecs too low — these are the most common production-bite issues).

When to Apply

Reference this skill when:

  • Writing a new background job (php artisan make:job)
  • Reviewing a PR that adds or modifies a job class
  • Setting up queue workers on a new server (Forge / Vapor / bare server)
  • Configuring config/queue.php or config/horizon.php
  • Debugging a stuck, looping, or repeatedly-failing job
  • Choosing between dispatch(), dispatchSync(), dispatchAfterResponse(), Bus::batch(), Bus::chain()
  • Adding queue testing (Queue::fake(), Bus::fake())
  • Deciding whether to adopt Horizon

Step 1: Detect Queue Setup

Inspect:

FileWhat to learn
config/queue.phpDefault connection (QUEUE_CONNECTION env), failed-jobs storage, after_commit setting
config/horizon.php (if present)Horizon environments, balance strategy, worker counts, timeouts
app/Jobs/*.phpJob classes, ShouldQueue usage, tries/backoff, failed() methods
app/Console/Kernel.php or routes/console.phpScheduled jobs (Schedule::job(...), withoutOverlapping)
database/migrations/*_create_failed_jobs_table.phpFailed-jobs storage migration; or DynamoDB driver in config
supervisor*.conf / /etc/supervisor/conf.d/Worker process management, numprocs, --max-time, stopwaitsecs

Typical setups:

StackQueue driverFailed driverWorker manager
Small Laravel + MySQLdatabasedatabaseSupervisor (or systemd)
Production Laravel + Redisredisdatabase (or dynamodb for serverless)Supervisor + Horizon
Laravel VaporsqsdynamodbVapor-managed

Rule Categories by Priority

PriorityCategoryImpactPrefix
1Driver & ConfigCRITICALconfig-
2Job DesignCRITICALdesign-
3Retry & FailureHIGHretry-
4Scaling & WorkersHIGHscaling-
5Batching & ChainingHIGHbus-
6Testing & OperationsMEDIUMops-

Quick Reference

1. Driver & Config (CRITICAL)

  • config-driver-choicedatabase for small apps; redis for production scale; sqs for Laravel Vapor
  • config-after-commit — set after_commit: true to prevent dispatching jobs that reference uncommitted DB rows
  • config-failed-storagefailed_jobs table is required (or DynamoDB on Vapor); set up retention/cleanup

2. Job Design (CRITICAL)

  • design-shouldqueue — every async job MUST implement ShouldQueue (the #1 production bug: forgetting it makes the job run synchronously)
  • design-pass-ids-not-models — pass IDs to the constructor; refetch in handle() — avoids stale models and bloated serialised payloads
  • design-idempotency — payment, external API, and "create resource" jobs must be safe to run twice (ShouldBeUnique, idempotency keys, unique DB constraints)
  • design-constructor-vs-handle — constructor runs at dispatch (sync); handle() runs on the worker. No DB writes or HTTP calls in the constructor.

3. Retry & Failure (HIGH)

  • retry-tries-and-backoff — set both: #[Backoff([1, 5, 30])] for exponential delays; default 3 tries is usually too few for transient failures
  • retry-failed-method — implement failed(Throwable $e) for permanent-failure handling (alert, refund, mark-as-failed)
  • retry-transient-vs-permanentrelease($delay) for transient errors (rate-limited, network); throw for permanent
  • retry-fail-on-timeout#[FailOnTimeout] to avoid burning all attempts on hung jobs

4. Scaling & Workers (HIGH)

  • scaling-supervisor-config — Supervisor (or systemd) manages workers; stopwaitsecs > timeout; --max-time=3600 to recycle
  • scaling-multi-queue-priority — high/default/low queue lanes for SLA-critical jobs; --queue=high,default,low
  • scaling-worker-recycling--max-jobs and --max-time to combat memory leaks in long-running workers

5. Batching & Chaining (HIGH)

  • bus-batch-vs-chainBus::batch for parallel + progress tracking; Bus::chain for strict sequential
  • bus-batch-failure-handlingallowFailures() for fault-tolerant batches; use then/catch/finally callbacks
  • bus-chunking-large-sets — for 1000+ items, chunk via Bus::batch(...) rather than one job per item

6. Testing & Operations (MEDIUM)

  • ops-queue-fakeQueue::fake() / Bus::fake() in tests; assertDispatched, assertPushed, assertChained, assertBatched
  • ops-schedule-queued-jobsSchedule::job(new X)->everyMinute() queues the job; pair with withoutOverlapping() for safety
  • ops-horizon-when — adopt Horizon when on Redis with multiple supervisors; not for database queue or single-worker setups

Essential Patterns

Minimum-viable job class (Laravel 13)

php
<?php

namespace App\Jobs;

use App\Models\Order;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\Attributes\Backoff;
use Illuminate\Queue\Attributes\FailOnTimeout;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Throwable;

#[Backoff([1, 5, 30])]
#[FailOnTimeout]
class ChargeOrder implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public int $tries = 5;
    public int $timeout = 30;

    public function __construct(public readonly int $orderId) {}

    public function handle(StripeGateway $stripe): void
    {
        $order = Order::findOrFail($this->orderId);   // refetch — don't trust serialised state
        if ($order->status === 'paid') return;        // idempotency guard

        $charge = $stripe->charge($order);
        $order->markPaid($charge->id);
    }

    public function failed(Throwable $e): void
    {
        Order::find($this->orderId)?->markPaymentFailed($e->getMessage());
    }
}

Dispatching

php
ChargeOrder::dispatch($order->id);                       // default queue
ChargeOrder::dispatch($order->id)->onQueue('high');      // priority lane
ChargeOrder::dispatch($order->id)->delay(now()->addMinutes(5));
ChargeOrder::dispatchAfterResponse($order->id);          // run after HTTP response sent

Supervisor config (recommended)

ini
[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/app/artisan queue:work redis --queue=high,default,low --sleep=3 --tries=3 --max-time=3600 --backoff=3
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
user=forge
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/app/storage/logs/worker.log
stopwaitsecs=3600

Critical: stopwaitsecs must be greater than your longest job's timeout, or Supervisor will kill mid-job on deploy.

References

Full Compiled Document

For the complete guide with all rules expanded: AGENTS.md

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Laravel Queues AI skill do?

Laravel 13 queue and job patterns — driver choice, job design (idempotency, ShouldQueue, model serialisation), retry and failure handling, worker scaling, Bus batching and chaining, Horizon when warranted, queue testing. Use when designing async jobs, scheduling background work, configuring Horizon, debugging stuck jobs, or auditing queue health. Triggers on "Laravel queue", "Laravel job", "background job", "Horizon setup", "failed jobs", "Bus batch", "queue worker tuning".

Why use Laravel Queues on TypingMind?

Because you install it once and use it with any model. Laravel Queues is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Laravel Queues in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/AsyrafHussin/agent-skills/tree/main/skills/laravel-queues. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Laravel Queues?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Laravel Queues?

As many as you like. As long as a model supports skills, you can use Laravel Queues with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Laravel Queues AI skill free?

Yes. It is published on GitHub by AsyrafHussin under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇