resource-generator
Agent for generating Laravel API Resources for JSON transformation
$ npx -y skills add Fujigo-Software/f5-framework-claude --agent claude-codeHow it fires
How this agent gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
Context preview
The summary Claude sees to decide when to auto-load this agent.
Agent for generating Laravel API Resources for JSON transformation
Agent definition
resource-generator.mdname: laravel-resource-generator
description: Agent for generating Laravel API Resources for JSON transformation
applies_to: laravel
category: agent
Laravel Resource Generator Agent
Purpose
Generate production-ready Laravel API Resources for consistent JSON API responses with proper data transformation.
Input Requirements
required:
- entity_name: string # e.g., "Product"
optional:
- fields: array # Fields to include
- relationships: array # Related resources to include
- conditional_fields: array # Fields shown conditionally
- collection: boolean # Generate collection resource (default: false)
- with_meta: boolean # Include meta information (default: true)
Generation Process
Step 1: Analyze Model
// Get model structure
$model = app("App\\Models\\{$entityName}");
$fillable = $model->getFillable();
$casts = $model->getCasts();
$appends = $model->getAppends();
$relationships = getModelRelationships($model);Step 2: Generate Resource
<?php
// app/Http/Resources/{{Entity}}Resource.php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class {{Entity}}Resource extends JsonResource
{
/**
* The "data" wrapper that should be applied.
*
* @var string|null
*/
public static $wrap = 'data';
/**
* Transform the resource into an array.
*
* @param Request $request
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
// Primary Key
'id' => $this->id,
// Basic Fields
'name' => $this->name,
'slug' => $this->slug,
'description' => $this->description,
// Numeric Fields
'price' => $this->price,
'compare_price' => $this->compare_price,
// Computed Fields (from accessors)
'is_on_sale' => $this->is_on_sale,
'discount_percentage' => $this->discount_percentage,
// Status
'status' => $this->status?->value,
'status_label' => $this->status?->label(),
// Boolean Fields
'is_featured' => $this->is_featured,
// Relationships (whenLoaded)
'category' => CategoryResource::make($this->whenLoaded('category')),
'tags' => TagResource::collection($this->whenLoaded('tags')),
'images' => {{Entity}}ImageResource::collection($this->whenLoaded('images')),
'user' => UserResource::make($this->whenLoaded('user')),
// Conditional Fields (based on user permission)
'metadata' => $this->when(
$request->user()?->can('viewMetadata', $this->resource),
$this->metadata
),
// Admin-only fields
'internal_notes' => $this->when(
$request->user()?->isAdmin(),
$this->internal_notes
),
// Counts (when loaded)
'orders_count' => $this->when(
$this->orders_count !== null,
$this->orders_count
),
'reviews_count' => $this->when(
$this->reviews_count !== null,
$this->reviews_count
),
// Aggregates (when loaded)
'average_rating' => $this->when(
$this->average_rating !== null,
fn () => round($this->average_rating, 1)
),
// Pivot data (for many-to-many)
'pivot' => $this->whenPivotLoaded('{{entity}}_tag', function () {
return [
'sort_order' => $this->pivot->sort_order,
];
}),
// Timestamps
'published_at' => $this->published_at?->toISOString(),
'created_at' => $this->created_at->toISOString(),
'updated_at' => $this->updated_at->toISOString(),
];
}
/**
* Get additional data that should be returned with the resource array.
*
* @param Request $request
* @return array<string, mixed>
*/
public function with(Request $request): array
{
return [
'meta' => [
'api_version' => 'v1',
],
];
}
/**
* Customize the outgoing response for the resource.
*
* @param Request $request
* @param \Illuminate\Http\JsonResponse $response
* @return void
*/
public function withResponse(Request $request, $response): void
{
$response->header('X-Resource-Type', '{{Entity}}');
}
}Step 3: Generate Collection Resource
<?php
// app/Http/Resources/{{Entity}}Collection.php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
class {{Entity}}Collection extends ResourceCollection
{
/**
* The resource that this resource collects.
*
* @var string
*/
public $collects = {{Entity}}Resource::class;
/**
* Transform the resource collection into an array.
*
* @param Request $request
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'data' => $this->collection,
];
}
/**
* Get additional data that should be returned with the resource array.
*
* @param Request $request
* @return array<string, mixed>
*/
public function with(Request $request): array
{
return [
'meta' => [
'total' => $this->total(),
'per_page' => $this->perPage(),
'current_page' => $this->currentPage(),
'last_page' => $this->lastPage(),
'from' => $this->firstItem(),
'to' => $this->lastItem(),Read more
name: laravel-resource-generator description: Agent for generating Laravel API Resources for JSON transformation applies_to: laravel category: agent
Laravel Resource Generator Agent
Purpose
Generate production-ready Laravel API Resources for consistent JSON API responses with proper data transformation.
Input Requirements
required: - entity_name: string # e.g., "Product" optional: - fields: array # Fields to include - relationships: array # Related resources to include - conditional_fields: array # Fields shown conditionally - collection: boolean # Generate collection resource (default: false) - with_meta: boolean # Include meta information (default: true)
Generation Process
Step 1: Analyze Model
// Get model structure
$model = app("App\\Models\\{$entityName}");
$fillable = $model->getFillable();
$casts = $model->getCasts();
$appends = $model->getAppends();
$relationships = getModelRelationships($model);Step 2: Generate Resource
<?php
// app/Http/Resources/{{Entity}}Resource.php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
class {{Entity}}Resource extends JsonResource
{
/**
* The "data" wrapper that should be applied.
*
* @var string|null
*/
public static $wrap = 'data';
/**
* Transform the resource into an array.
*
* @param Request $request
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
// Primary Key
'id' => $this->id,
// Basic Fields
'name' => $this->name,
'slug' => $this->slug,
'description' => $this->description,
// Numeric Fields
'price' => $this->price,
'compare_price' => $this->compare_price,
// Computed Fields (from accessors)
'is_on_sale' => $this->is_on_sale,
'discount_percentage' => $this->discount_percentage,
// Status
'status' => $this->status?->value,
'status_label' => $this->status?->label(),
// Boolean Fields
'is_featured' => $this->is_featured,
// Relationships (whenLoaded)
'category' => CategoryResource::make($this->whenLoaded('category')),
'tags' => TagResource::collection($this->whenLoaded('tags')),
'images' => {{Entity}}ImageResource::collection($this->whenLoaded('images')),
'user' => UserResource::make($this->whenLoaded('user')),
// Conditional Fields (based on user permission)
'metadata' => $this->when(
$request->user()?->can('viewMetadata', $this->resource),
$this->metadata
),
// Admin-only fields
'internal_notes' => $this->when(
$request->user()?->isAdmin(),
$this->internal_notes
),
// Counts (when loaded)
'orders_count' => $this->when(
$this->orders_count !== null,
$this->orders_count
),
'reviews_count' => $this->when(
$this->reviews_count !== null,
$this->reviews_count
),
// Aggregates (when loaded)
'average_rating' => $this->when(
$this->average_rating !== null,
fn () => round($this->average_rating, 1)
),
// Pivot data (for many-to-many)
'pivot' => $this->whenPivotLoaded('{{entity}}_tag', function () {
return [
'sort_order' => $this->pivot->sort_order,
];
}),
// Timestamps
'published_at' => $this->published_at?->toISOString(),
'created_at' => $this->created_at->toISOString(),
'updated_at' => $this->updated_at->toISOString(),
];
}
/**
* Get additional data that should be returned with the resource array.
*
* @param Request $request
* @return array<string, mixed>
*/
public function with(Request $request): array
{
return [
'meta' => [
'api_version' => 'v1',
],
];
}
/**
* Customize the outgoing response for the resource.
*
* @param Request $request
* @param \Illuminate\Http\JsonResponse $response
* @return void
*/
public function withResponse(Request $request, $response): void
{
$response->header('X-Resource-Type', '{{Entity}}');
}
}Step 3: Generate Collection Resource
<?php
// app/Http/Resources/{{Entity}}Collection.php
namespace App\Http\Resources;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\ResourceCollection;
class {{Entity}}Collection extends ResourceCollection
{
/**
* The resource that this resource collects.
*
* @var string
*/
public $collects = {{Entity}}Resource::class;
/**
* Transform the resource collection into an array.
*
* @param Request $request
* @return array<string, mixed>
*/
public function toArray(Request $request): array
{
return [
'data' => $this->collection,
];
}
/**
* Get additional data that should be returned with the resource array.
*
* @param Request $request
* @return array<string, mixed>
*/
public function with(Request $request): array
{
return [
'meta' => [
'total' => $this->total(),
'per_page' => $this->perPage(),
'current_page' => $this->currentPage(),
'last_page' => $this->lastPage(),
'from' => $this->firstItem(),
'to' => $this->lastItem(),AI-Powered Development Framework for Claude Code
Repo: Fujigo-Software/f5-framework-claude
Other agents on f5-framework.
- database-expert
Expert database architect specializing in schema design, query optimization, data modeling, and migration strategies. Japanese: データベースエキスパート
Open agent - devops-architect
Expert DevOps architect specializing in CI/CD pipelines, infrastructure as code, containerization, and monitoring. Japanese: DevOpsアーキテクト
Open agent - 11-mobile-architect
Mobile app architecture specialist. iOS, Android, React Native, Flutter.
Open agent - 12-backend-architect
Backend architecture specialist. Microservices, APIs, databases.
Open agent - 13-frontend-architect
Frontend architecture specialist. React, Vue, Angular, Next.js.
Open agent - 14-data-architect
Data architecture specialist. Databases, ETL, analytics.
Open agent

