AGENT SKILL

pulse-development

Handles Laravel Pulse setup, configuration, and custom card development. Activates when installing Pulse; configuring the dashboard or authorization gate; setting up recorders and filtering; building custom Livewire cards; optimizing with Redis ingest or sampling; or when the user mentions /pulse, pulse:check, pulse:work, Pulse::record(), or application monitoring.

License 许可
MIT
最近更新
2026-11-13
Stars
★ 54
Forks
22

01 前言 Front Matter

name
pulse-development
license
MIT
metadata
{ "author": "laravel" }
description
Handles Laravel Pulse setup, configuration, and custom card development. Activates when installing Pulse; configuring the dashboard or authorization gate; setting up recorders and filtering; building custom Livewire cards; optimizing with Redis ingest or sampling; or when the user mentions /pulse, pulse:check, pulse:work, Pulse::record(), or application monitoring.

03 SKILL.md 正文

Laravel Pulse Development

Documentation

Use search-docs for detailed Laravel Pulse patterns and documentation, including card layout customization, user resolver configuration, all recorder options, sampling, dedicated database connections, Vite/CSS integration, Tailwind scoping, blade card components, and lazy loading.

Installation

Pulse stores data in your application's database. The current package supports MySQL, MariaDB, PostgreSQL, and SQLite.

composer require laravel/pulse
php artisan vendor:publish --provider="Laravel\Pulse\PulseServiceProvider"
php artisan migrate

The dashboard is available at /pulse.

Dashboard Authorization

Define the viewPulse gate in AppServiceProvider::boot() to enable production access:

<!-- Pulse Dashboard Authorization -->

use App\Models\User;
use Illuminate\Support\Facades\Gate;

Gate::define('viewPulse', function (User $user) {
    return $user->isAdmin();
});

Without this gate, the dashboard is inaccessible in all non-local environments.

Recorders

All 10 built-in recorders are configurable in config/pulse.php:

Recorder Key Config Options
CacheInteractions sample_rate, ignore, groups (regex find/replace)
Exceptions sample_rate, ignore, location
Queues sample_rate, ignore
SlowJobs threshold (ms, per-job regex map), sample_rate, ignore
SlowOutgoingRequests threshold (ms, per-URL regex map), sample_rate, ignore, groups
SlowQueries threshold (ms, per-query regex map), sample_rate, ignore, location
SlowRequests threshold (ms, per-route regex map), sample_rate, ignore
Servers PULSE_SERVER_NAME env var, monitored disk paths
UserJobs sample_rate, ignore
UserRequests sample_rate, ignore

Per-route and per-job threshold overrides use a regex-keyed map with a default fallback:

<!-- Per-Route Threshold Override -->

Recorders\SlowRequests::class => [
    'threshold' => [
        '#^/api/reports#' => 5000,
        'default'         => env('PULSE_SLOW_REQUESTS_THRESHOLD', 1000),
    ],
],

The Servers recorder requires pulse:check running as a persistent daemon (Supervisor recommended).

Filtering Entries

Use Pulse::filter() in AppServiceProvider::boot() to exclude entries globally. Return true to record, false to skip:

<!-- Pulse Entry Filter -->

use Laravel\Pulse\Entry;
use Laravel\Pulse\Facades\Pulse;
use Laravel\Pulse\Value;
use Illuminate\Support\Facades\Auth;

Pulse::filter(function (Entry|Value $entry) {
    return Auth::user()?->isNotAdmin() ?? true;
});

Performance

Redis Ingest

Offload entry writes from the request cycle to a Redis stream (requires Redis 6.2+ and phpredis or predis):

PULSE_INGEST_DRIVER=redis
PULSE_REDIS_CONNECTION=pulse

Run a worker to drain the Redis stream into the database:

php artisan pulse:work

Signal a graceful restart during deployment (requires a working cache driver):

php artisan pulse:restart

Custom Cards

Custom cards are Livewire components extending Pulse's base Card class.

Recording Entries

Call Pulse::record() from a recorder, listener, or observer. Chain aggregation methods (avg, count, max, min, sum) in a single call:

<!-- Record Pulse Entry -->

use Laravel\Pulse\Facades\Pulse;

Pulse::record('user_sale', $user->id, $sale->amount)
    ->sum()
    ->count();

When the entry is tied to the authenticated user, use Pulse::resolveAuthenticatedUserId() instead of Auth::id() to respect custom user resolvers.

Card Component

<!-- Custom Pulse Card -->

namespace App\Livewire\Pulse;

use Laravel\Pulse\Facades\Pulse;
use Laravel\Pulse\Livewire\Card;
use Livewire\Attributes\Lazy;

#[Lazy]
class TopSellers extends Card
{
    public function render(): \Illuminate\View\View
    {
        $aggregates = $this->aggregate('user_sale', ['sum', 'count']);
        $users = Pulse::resolveUsers($aggregates->pluck('key'));

        return view('livewire.pulse.top-sellers', [
            'sellers' => $aggregates->map(fn ($row) => (object) [
                'user'  => $users->find($row->key),
                'sum'   => $row->sum,
                'count' => $row->count,
            ]),
        ]);
    }
}

$this->aggregate(type, aggregates) returns a Collection of stdClass objects with key and one property per aggregation method. $this->aggregateTotal(type, aggregate) returns a single scalar.

Custom Recorders

A recorder is a plain class with a $listen array of Laravel events:

<!-- Custom Pulse Recorder -->

class SaleRecorder
{
    public array $listen = [
        \App\Events\SaleCompleted::class,
    ];

    public function record(\App\Events\SaleCompleted $event): void
    {
        \Laravel\Pulse\Facades\Pulse::record('user_sale', $event->user->id, $event->sale->amount)
            ->sum()
            ->count();
    }
}

Register the recorder in the recorders array in config/pulse.php.

Verification

  1. Run migrations and confirm /pulse is accessible in local
  2. Define viewPulse gate and verify production access
  3. Confirm pulse:check is running for the Servers card
  4. If using Redis ingest, confirm pulse:work is running

Common Pitfalls

  • An empty dashboard or database errors usually mean the Pulse tables have not been published and migrated yet.
  • The dashboard is local-only by default. Define the viewPulse gate to enable production access.
  • The Servers card shows no data unless pulse:check runs as a persistent process. Supervisor is recommended.
  • Redis ingest silently queues data. The dashboard appears empty if pulse:work is not running.
  • pulse:restart requires a working cache driver. Without it, the signal is never received.
  • Pulse exceptions fail silently. Use Pulse::handleExceptionsUsing() to surface errors during development.
  • Multiple Authenticatable models can cause incorrect user tracking. Use Pulse::resolveAuthenticatedUserId() when recording user-keyed entries.
  • SQS queues may appear duplicated in the Queue card. Use ignore regex patterns to suppress them.
  • Sampled dashboard values are approximate and prefixed with ~. They are not suitable for financial or audit reporting.
  • Always use search-docs for the latest Pulse documentation rather than relying on this skill alone.

04 同仓库更多 Skills

karuhun-developer
karuhun-developer/ecommerce

tailwindcss-development

Always invoke when the user's message includes 'tailwind' in any form. Also invoke for: building responsive grid layouts (multi-column card grids, product grids), flex/grid page structures (dashboards with sidebars, fixed topbars, mobile-toggle navs), styling UI components (cards, tables, navbars, pricing sections, forms, inputs, badges), adding dark mode variants, fixing spacing or typography, and Tailwind v3/v4 work. The core use case: writing or fixing Tailwind utility classes in HTML templates (Blade, JSX, Vue). Skip for backend PHP logic, database queries, API routes, JavaScript with no HTML/CSS component, CSS file audits, build tool configuration, and vanilla CSS.

★ 54
karuhun-developer
karuhun-developer/ecommerce

pest-testing

Use this skill for Pest PHP testing in Laravel projects only. Trigger whenever any test is being written, edited, fixed, or refactored — including fixing tests that broke after a code change, adding assertions, converting PHPUnit to Pest, adding datasets, and TDD workflows. Always activate when the user asks how to write something in Pest, mentions test files or directories (tests/Feature, tests/Unit, tests/Browser), or needs browser testing, smoke testing multiple pages for JS errors, or architecture tests. Covers: test()/it()/expect() syntax, datasets, mocking, browser testing (visit/click/fill), smoke testing, arch(), Livewire component tests, RefreshDatabase, and all Pest 4 features. Do not use for factories, seeders, migrations, controllers, models, or non-test PHP code.

★ 54
karuhun-developer
karuhun-developer/ecommerce

medialibrary-development

Build and work with spatie/laravel-medialibrary features including associating files with Eloquent models, defining media collections and conversions, generating responsive images, and retrieving media URLs and paths.

★ 54
karuhun-developer
karuhun-developer/ecommerce

livewire-development

Use for any task or question involving Livewire. Activate if user mentions Livewire, wire: directives, or Livewire-specific concepts like wire:model, wire:click, wire:sort, or islands, invoke this skill. Covers building new components, debugging reactivity issues, real-time form validation, drag-and-drop, loading states, migrating from Livewire 3 to 4, converting component formats (SFC/MFC/class-based), and performance optimization. Do not use for non-Livewire reactive UI (React, Vue, Alpine-only, Inertia.js) or standard Laravel forms without Livewire.

★ 54
karuhun-developer
karuhun-developer/ecommerce

laravel-best-practices

Apply this skill whenever writing, reviewing, or refactoring Laravel PHP code. This includes creating or modifying controllers, models, migrations, form requests, policies, jobs, scheduled commands, service classes, and Eloquent queries. Triggers for N+1 and query performance issues, caching strategies, authorization and security patterns, validation, error handling, queue and job configuration, route definitions, and architectural decisions. Also use for Laravel code reviews and refactoring existing Laravel code to follow best practices. Covers any task involving Laravel backend PHP code patterns.

★ 54
karuhun-developer
karuhun-developer/ecommerce

fortify-development

ACTIVATE when the user works on authentication in Laravel. This includes login, registration, password reset, email verification, two-factor authentication (2FA/TOTP/QR codes/recovery codes), profile updates, password confirmation, or any auth-related routes and controllers. Activate when the user mentions Fortify, auth, authentication, login, register, signup, forgot password, verify email, 2FA, or references app/Actions/Fortify/, CreateNewUser, UpdateUserProfileInformation, FortifyServiceProvider, config/fortify.php, or auth guards. Fortify is the frontend-agnostic authentication backend for Laravel that registers all auth routes and controllers. Also activate when building SPA or headless authentication, customizing login redirects, overriding response contracts like LoginResponse, or configuring login throttling. Do NOT activate for Laravel Passport (OAuth2 API tokens), Socialite (OAuth social login), or non-auth Laravel features.

★ 54