Agent skill
filament-resource-generator
Automated Filament resource generation with correct namespace imports (Schemas vs Forms), Vietnamese labels, standard structure, Observer patterns, ImagesRelationManager integration. USE WHEN user says 'tạo resource mới', 'create new resource', 'generate Filament resource', 'scaffold admin resource', or wants to add new entity to admin panel.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/hieubkav-wincellarclonebackend-claude-skills-filament-filament-r
SKILL.md
Filament Resource Generator - Quick Workflow
Generate standardized Filament resources with correct namespaces, Vietnamese labels, and Observer patterns.
When to Activate This Skill
- User says "tạo resource mới cho [Model]"
- User says "create new resource"
- User wants to "scaffold admin panel"
- Adding new entity to Filament admin
Quick Workflow
1. Gather Requirements
Ask user:
- Model name (singular): Product, Category, Article
- Has images? Gallery or single featured image?
- Relationships? BelongsTo, BelongsToMany
- Need ordering? Drag-drop reordering (requires
ordercolumn) - SEO fields? Usually yes (slug, meta_title, meta_description)
2. Generate Resource
php artisan make:filament-resource Product --generate
Creates:
app/Filament/Resources/Products/
├── ProductResource.php
├── Pages/
│ ├── ListProducts.php
│ ├── CreateProduct.php
│ └── EditProduct.php
3. Update Resource
Critical namespaces:
// Layout components → Schemas
use Filament\Schemas\Components\Tabs;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
// Form fields → Forms
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Toggle;
// Schema (NOT Form!)
use Filament\Schemas\Schema;
Vietnamese labels:
protected static ?string $navigationLabel = 'Sản phẩm';
protected static ?string $modelLabel = 'Sản phẩm';
protected static ?string $pluralModelLabel = 'Các sản phẩm';
protected static ?string $navigationIcon = 'heroicon-o-shopping-bag';
Navigation badge:
public static function getNavigationBadge(): ?string
{
return (string) static::getModel()::where('active', true)->count();
}
4. Implement Form & Table
// Form with Tabs
public static function form(Schema $schema): Schema {
return $schema->schema([
Tabs::make()->tabs([
Tabs\Tab::make('Thông tin')->schema([
TextInput::make('name')->label('Tên')->required(),
Select::make('category_id')->label('Danh mục')->relationship('category', 'name'),
Toggle::make('active')->label('Hiển thị')->default(true),
]),
])->columnSpanFull(),
]);
}
// Table with eager loading
public static function table(Table $table): Table {
return $table
->modifyQueryUsing(fn($q) => $q->with(['category']))
->reorderable('order') // If has order column
->columns([
TextColumn::make('name')->label('Tên')->searchable(),
ToggleColumn::make('active')->label('Hiển thị'),
])
->recordActions([EditAction::make()->iconButton()]);
}
5. Create Observer
class ProductObserver {
public function creating(Product $p): void {
if (empty($p->slug)) $p->slug = Str::slug($p->name);
if (empty($p->meta_title)) $p->meta_title = $p->name;
if ($p->order === null) $p->order = (Product::max('order') ?? 0) + 1;
}
}
// AppServiceProvider::boot()
Product::observe(ProductObserver::class);
6. Add Images (Optional)
// Model
public function images(): MorphMany {
return $this->morphMany(Image::class, 'model');
}
// Resource
public static function getRelations(): array {
return [ImagesRelationManager::class];
}
Checklist
Before declaring resource complete:
- Correct namespaces (Schemas vs Forms)
- Vietnamese labels (100%)
- Form with Tabs/Grid structure
- Table with eager loading
- Reorderable if order column
- ImagesRelationManager if images
- Observer for SEO + order
- Observer registered in AppServiceProvider
- Navigation badge showing count
- Tested create/edit/delete
Key Principles
- Namespace correctness:
Schemasfor layouts,Formsfor fields - Vietnamese first: All labels tiếng Việt
- Observer patterns: SEO auto-generated, hidden from form
- Eager loading: Always
modifyQueryUsing()for relations - Standard structure: Tabs → Grid → Fields
References
Detailed implementations: read .claude/skills/filament/filament-resource-generator/references/detailed-implementation.md
Complete guide: read .claude/skills/filament/filament-resource-generator/CLAUDE.md
Related: filament-rules, image-management, filament-form-debugger
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?