/laravel:filament-conventionsfrom laravel
Opinionated conventions for Filament v5 panel development: schema layout, clusters, navigation, stat widgets, row actions, relation managers, auth (TOTP 2FA), three-panel app shape, panel-switch/impersonate plugins, and custom component building. Grounded in real Filament 5 source.
Ships in laravel. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Targets Filament 5 — always its latest release. Every class, namespace, and method below was
read from real Filament 5 vendor source — do not substitute from memory or from v3 habits; when the
project's installed minor is newer than the cited file:lines, re-read the line in the project's
vendor/ (the symbol is what matters, the line is the pointer). The full worked recipe (copy-paste examples + the vendor file:symbol that grounds
each claim) is in references/filament-5-recipes.md.
Filament\Forms\Components\* (e.g. TextInput, Select, KeyValue).Filament\Actions\* (e.g. Action, CreateAction, EditAction, DeleteAction,
DeleteBulkAction, BulkActionGroup, AttachAction, DetachAction).Filament\Schemas\Components\* (e.g. Section, Fieldset, Grid,
Tabs). The schema container itself is Filament\Schemas\Schema.In v5 a Resource form is a Schema, not the old v3 Form:
public static function form(Schema $schema): Schema. The top-level schema takes
->components([...]); layout components (Section, Fieldset) take ->schema([...]).
php artisan make:filament-resource Contact --generate # form, table, pages, schema dirs
php artisan make:filament-relation-manager ContactResource tags name
php artisan make:filament-page Settings
php artisan make:filament-cluster Billing # group a multi-domain area (rule 10)
php artisan make:filament-widget ContactStats --stats-overview # list-page header stats (rule 12)
php artisan make:filament-theme admin # per-panel Vite theme (rule 17)
php artisan make:filament-form-field LocationPicker # custom field class + view (rule 22)
php artisan make:filament-schema-component Chart # custom schema component (rule 22)
php artisan make:filament-infolist-entry AudioPlayerEntry
php artisan make:filament-table-column AudioPlayerColumn
php artisan make:filament-user # seed an admin (no public registration)
v5 splits a resource into Schemas/<Model>Form.php, Tables/<Model>Table.php, and
Pages/. Edit those generated files — do not relocate the logic back into the resource class.
Rules 1–9 are the core resource/panel standard; 10–21 extend it to page shape, tables, fields, theming, the multi-panel app shape, roles, plugins, and the auth split; 22 governs custom components.
Organize every form schema with Section and Fieldset first — and Tabs when it grows.
Start from grouped layout, then drop fields in — never a flat bag of inputs. Scale the
layout to the page's complexity on Edit and View pages: a handful of fields → one or
two Sections; several concerns → Sections with Fieldsets inside; many concerns or
long forms → Tabs (Filament\Schemas\Components\Tabs + Tabs\Tab) with a
Section/Fieldset per tab. The same applies to the View page's infolist(Schema).
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Fieldset;
use Filament\Forms\Components\TextInput;
$schema->components([
Section::make('Identity')
->description('Who this contact is')
->columns(2)
->schema([
TextInput::make('first_name')->required(),
TextInput::make('last_name'),
]),
Fieldset::make('Contact') // two-column grid by default
->schema([
TextInput::make('email')->email()->required(),
TextInput::make('phone')->tel(),
]),
]);
Group pages/resources into navigation menu groups — the main menu AND every cluster's
sub-menu. Set the static property; its type is string | UnitEnum | null, so prefer a
backed enum for type-safe, reusable group names. The same property on a component inside
a cluster groups it in the cluster's sidebar (Filament buckets cluster sub-navigation by
each item's group), so a cluster never shows an ungrouped flat list either.
use UnitEnum;
protected static string | UnitEnum | null $navigationGroup = 'CRM';
Provide a RelationManager for every real relation — with create AND delete by default.
Register them in the resource's getRelations() so they render on the Edit (and View)
page; each manager declares protected static string $relationship = '...' and its own
form(Schema $schema) + table(Table $table). make:filament-relation-manager already
generates CreateAction in ->headerActions() and DeleteAction/DeleteBulkAction (or
Attach/Detach, Associate/Dissociate for the relation type) in the table — keep
them; stripping the create/delete path from a relation manager is a defect unless the
PRD says the relation is read-only.
public static function getRelations(): array
{
return [TagsRelationManager::class, ActivitiesRelationManager::class];
}
Delete belongs on the LIST table, inside an ActionGroup with Edit — never on the Edit
page — and the confirmation names the record. make:filament-resource puts
DeleteAction::make() in the Edit page's getHeaderActions() by default — remove it.
In the table, wrap the row actions in Filament\Actions\ActionGroup (the "⋯" menu) and
keep DeleteBulkAction::make() inside a BulkActionGroup in ->toolbarActions([...]).
The delete modal must say what is being deleted: Filament's default heading is
Delete :label where :label is the record title — set
protected static ?string $recordTitleAttribute = 'name'; on the resource (it is piped into
the table's recordTitleAttribute) so the heading reads "Delete Acme Inc.", not "Delete
Contact"; add a ->modalDescription() that repeats the title when the label alone is
ambiguous. A delete modal that doesn't name the item is a defect.
use Filament\Actions\ActionGroup;
use Filament\Actions\DeleteAction;
use Filament\Actions\EditAction;
->recordActions([
ActionGroup::make([
EditAction::make(),
DeleteAction::make()
->modalDescription(fn ($record) => "This permanently deletes \"{$record->name}\"."),
]),
])
v5 table methods are ->recordActions() / ->toolbarActions(); v3's ->actions() /
->bulkActions() still exist as @deprecated aliases that forward to them — prefer the new names.
Create and Edit both redirect to the LIST page on save. Two ways:
->resourceCreatePageRedirect('index')->resourceEditPageRedirect('index').getRedirectUrl() to return $this->getResource()::getUrl('index').
Default Filament redirects to view/edit, so this override is required.The top-bar user menu must have a Settings/profile page. Register a profile page on the
panel — ->profile() — and Filament auto-injects the profile item into the user menu. Use a
custom page (->profile(Settings::class)) when you need more than the default account form.
Native Filament auth + authenticator-app (TOTP) 2FA, configured on EVERY panel by
default (optional for the user to enable). Enable login with ->login(). Register the
AppAuthentication provider on each panel with isRequired: false — 2FA is always
available, the user opts in from the profile page:
use Filament\Auth\MultiFactor\App\AppAuthentication;
$panel->multiFactorAuthentication([
AppAuthentication::make()->recoverable(),
]); // 3rd arg isRequired defaults to false → optional
The User model must implement Filament\Auth\MultiFactor\App\Contracts\HasAppAuthentication
(and HasAppAuthenticationRecovery for recovery codes). The enable/disable + QR-code UI is
served by the profile page from rule 6 — no custom security page to build.
No public registration. Simply do not call ->registration() on the panel. Seed users
with php artisan make:filament-user or your own invite flow.
Each panel has its OWN custom dashboard page — never the stock one. Filament's default
Filament\Pages\Dashboard auto-discovers and arranges widgets for you, which costs you control.
Generate your own page extending the base Dashboard so you decide exactly which widgets show,
in what order, and the column layout. Override getWidgets() and getColumns() (it accepts a
responsive array); getHeaderWidgets()/getFooterWidgets() for the top/bottom slots.
// php artisan make:filament-page Dashboard (then extend the base, not a blank Page)
namespace App\Filament\Pages;
use Filament\Pages\Dashboard as BaseDashboard;
class Dashboard extends BaseDashboard
{
public function getWidgets(): array
{
return [StatsOverview::class, RevenueChart::class, LatestContacts::class];
}
public function getColumns(): int | array
{
return ['md' => 2, 'xl' => 3]; // explicit, responsive widget grid
}
}
Register the custom page on the panel — ->pages([\App\Filament\Pages\Dashboard::class]) — and
make sure the stock Filament\Pages\Dashboard::class is not also registered (page
discovery + an explicit entry can yield two dashboards). One dashboard class per panel
(App\Filament\Ops\Pages\Dashboard, App\Filament\Admin\Pages\Dashboard,
App\Filament\Support\Pages\Dashboard), each showing the data that panel's audience
cares about (rule 20) — never one shared dashboard reused across panels. Grounded in Filament\Pages\Dashboard
(vendor/filament/filament/src/Pages/Dashboard.php: class Dashboard extends Page; getWidgets(),
getColumns(): int | array).
Split a complex multi-domain area into a Cluster. When one page (or one resource) is
trying to cover several domains — e.g. "Settings" holding billing + integrations +
branding — do not grow one giant page. Generate a cluster (php artisan make:filament-cluster Settings) and make one page/resource per domain belong to it
via protected static ?string $cluster = Settings::class;. The cluster becomes one
top-level menu item; its members render as a grouped sub-navigation (rule 2). Register
with ->discoverClusters(in: app_path('Filament/Clusters'), for: 'App\Filament\Clusters').
Field hints when the label isn't self-explanatory or validation is non-trivial. A
field whose intent is not obvious from its label, or that carries complex rules (format,
length, uniqueness, cross-field), must guide the user inline — ->helperText() for
"what/why", ->hint() (+ ->hintIcon()) for the constraint, ->placeholder() for the
expected shape ('+55 21 99999-0000'). Plain labels like "Name" need none; "Slug",
"Webhook secret", "Cron expression" do.
Every List page shows at least THREE stat widgets above the table. Generate a
StatsOverviewWidget for the resource (make:filament-widget ContactStats --stats-overview) returning ≥ 3 Stats of general resource data (total, active this
period, needs-attention, …) and return it from the List page's getHeaderWidgets():
// Pages/ListContacts.php
protected function getHeaderWidgets(): array
{
return [ContactStats::class];
}
A List page with a bare table is a defect.
Relationship inputs allow inline creation by default. Any Select backed by
->relationship(...) also gets ->createOptionForm([...]) (the related resource's form
schema, or a trimmed one) so the user can create the related record without leaving the
form (createOptionForm is Filament's built-in mechanism for this). Add ->searchable()->preload() on it too.
Select::make('company_id')
->relationship('company', 'name')
->searchable()->preload()
->createOptionForm(fn (Schema $schema) => CompanyForm::configure($schema)),
Omit createOptionForm only when the related model is genuinely not user-creatable
(system enums, imported lookups).
Create pages have NO "Create & create another". Disable it on every CreateRecord
page: protected static bool $canCreateAnother = false; (the static
CreateRecord::disableCreateAnother() exists too, but the property is the clear form). With rule 5 the flow is always create → list.
Web access is Filament-only. Unless the PRD says otherwise, every authenticated web area is a Filament panel using Filament's own auth (rule 7). No Breeze/Jetstream/Fortify scaffolding, no hand-rolled login, no second session-auth surface beside the panels.
API auth is Laravel Sanctum; MCP auth is OAuth2 via Laravel Passport. Machine-to-
machine / mobile / SPA APIs use Sanctum scoped tokens, separate from the panel web
session. An MCP server (laravel/mcp) is protected with OAuth2, which means
Passport is always installed when MCP exists — Mcp::oauthRoutes() wires the
authorization/token endpoints to Passport's routes. laravel/mcp can also run behind a
plain Sanctum bearer token; we don't — OAuth2 is the house default so MCP clients get
discovery + consent, not a copied token. Never expose MCP behind the web session.
Every panel has a Vite theme, installed the official way. Per panel:
php artisan make:filament-theme <panelId> → resources/css/filament/<panelId>/theme.css.
The command itself adds that path to the input array in vite.config.js and
->viteTheme('resources/css/filament/<panelId>/theme.css') to the panel provider — verify
both landed (it only prints a "do this by hand" note when an auto-edit failed) and run the
build. Do not ship a panel on the stock default theme, and do not inject CSS through render
hooks as a substitute.
Three panels by default: ops, admin, support. Every web app starts with three
PanelProviders (make:filament-panel admin first — the generator marks the first
panel ->default() and gives it the bare App\Filament\… namespace, so re-point it to
App\Filament\Admin\…; then ops, support), each with its own namespace
(App\Filament\Ops, App\Filament\Admin, App\Filament\Support), own dashboard (rule 9),
own theme (rule 17), and own resources:
ops — the platform owner's control center: sees the whole app across all users/
tenants. Ships with a User resource that can create new users (and assign roles).admin — the product itself: where ordinary users live and the app is delivered.
This is the ->default() panel.support — app health (queue/failed-jobs/errors/usage widgets) plus a read-only
User resource with two row actions only: send password-reset email (Laravel's
Password::sendResetLink(...)) and impersonate (rule 19). No edit/delete of users
from support.Two Filament plugins are installed by default.
bezhansalleh/filament-panel-switch — registered in every panel. It renders only
when the logged-in user can access ≥ 2 panels (its isVisible() counts accessible
panels), so a plain user never sees it. Configure once in AppServiceProvider::boot()
with PanelSwitch::configureUsing(fn (PanelSwitch $s) => $s->labels([...])->icons([...])->simple()).stechstudio/filament-impersonate — the Impersonate::make() row action in the
support panel's User table (rule 18). The plugin honors canImpersonate() on the
actor and canBeImpersonated() on the target if the User model defines them — define
both (only superadmin impersonates; a superadmin cannot be impersonated).Each panel's dashboard shows data relevant to that panel. ops → platform-wide
totals, growth, tenants/users, revenue; admin → the user's own workspace KPIs; support
→ health (queue depth, failed jobs, recent errors, slow requests, last deploy). Same
custom-page mechanism as rule 9, different widgets.
Panel access is role-based, roles live in a separate role_user table. Do not put a
role column on users. Create roles + the pivot role_user (make:model Role -mf,
make:migration create_role_user_table), belongsToMany both ways, and gate panels in
User::canAccessPanel(Panel $panel) by role — fail closed (unknown panel → false).
Default roles: superadmin → ops + admin + support; user → admin only. Seed
both roles; make:filament-user only creates the user (name/email/password — it never
touches roles), so attach superadmin in the seeder or via tinker to bootstrap the owner.
public function canAccessPanel(Panel $panel): bool
{
return match ($panel->getId()) {
'admin' => $this->hasAnyRole(['superadmin', 'user']),
'ops', 'support' => $this->hasRole('superadmin'),
default => false,
};
}
Custom UI extends Filament's four extension points — never ad-hoc Blade/Livewire. When no
built-in fits, climb this ladder and stop at the first rung that works: (a) a built-in
component; (b) a one-off View::make('filament.schemas.components.x') in the schema;
(c) a reusable class + view from the matching generator — make:filament-schema-component
(layout/display, extends Filament\Schemas\Components\Component), make:filament-form-field
(extends Filament\Forms\Components\Field), make:filament-infolist-entry (extends
Filament\Infolists\Components\Entry), make:filament-table-column (extends
Filament\Tables\Columns\Column); (d) Livewire::make(X::class)->key('…') only for an
isolated Livewire component (it can't see sibling state or the child schema). Shared rules:
$methodName(); configuration is setter + protected property +
getter, typed X | Closure | null and read through $this->evaluate() so callers get
utility injection (fn (Model $record, Get $get) => …) exactly like built-ins.$getStatePath() (wire:model or $wire.$entangle(...)),
wrapped with $applyStateBindingModifiers() so ->live() is honored, and keep the
generated <x-dynamic-component :component="$getFieldWrapperView()" :field="$field">
wrapper (entries: $getEntryWrapperView() / :entry="$entry") — that is where label,
hint, helper text and errors render. Columns have no wrapper: the cell is the view.#[ExposedLivewireMethod] (+ #[Renderless] when it must
not re-render) and call $wire.callSchemaComponentMethod(@js($getKey()), 'm', {…}) from a
component/field/entry view, or $wire.callTableColumnMethod(@js($getName()), @js($getRecordKey()), 'm', {…})
from a column view. Unattributed methods are not callable. A schema component must keep the
generated make() — its base class has none.{{ $getExtraAttributeBag() }} on the root, translate labels, and test it like any
other code. Full recipes, generated stubs and source citations:
references/filament-5-custom-components.md.If the Resource/panel you're editing lives in a symlinked composer package (per the repo's
package rules), make the change in that package's own folder and commit/push there — never
patch the consumer's vendor/ copy.
Section/Fieldset, not loose fields (rule 1).DeleteAction (rule 4); the table has per-row + bulk delete.->login(), a profile page, optional AppAuthentication, and no ->registration().BaseDashboard with explicit getWidgets()/getColumns(), one per panel, and the stock Filament\Pages\Dashboard is not double-registered (rules 9, 20).ActionGroup; the delete modal names the record ($recordTitleAttribute set) (rule 4).getHeaderWidgets() (rule 12).Selects carry ->createOptionForm() (rule 13); unclear/complex fields carry hint/helperText/placeholder (rule 11).CreateRecord pages set $canCreateAnother = false (rule 14).->viteTheme(...) registered and built (rule 17); ops/admin/support exist with their own dashboards and User resources as specified (rules 18, 20).panel-switch on every panel, impersonate on support's User table, canImpersonate/canBeImpersonated defined (rule 19).roles + role_user tables, superadmin + user seeded, canAccessPanel() fails closed (rule 21).Mcp::oauthRoutes() (rules 15, 16).make:filament-* generator, keeps the wrapper + $getStatePath() binding, exposes config via Closure-typed setters + evaluate(), and JS-callable methods carry #[ExposedLivewireMethod] (rule 22).See references/filament-5-recipes.md for a full panel + resource example and the source
citations behind each rule, and references/filament-5-custom-components.md for the custom
component / field / entry / column recipes (rule 22).
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
2 skills in this plugin
npx claudepluginhub mwguerra/plugins --plugin laravel