All skills
asyrafhussin avatar

/laravel-ai-sdk

@7221662

Laravel AI SDK for building AI-powered features. Use when creating agents, generating images or audio, working with embeddings, vector search, or testing AI features. Triggers on tasks involving laravel/ai, AI agents, tool-calling, structured output, streaming, embeddings, reranking, or AI faking in tests.

Use this Skill: https://skilld.dev/gh/asyrafhussin/agent-skills/laravel-ai-sdk

This session only. Nothing lands on disk.

rulestool-create.md

≈805 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Create Custom Tools

Impact: HIGH (Give agents abilities beyond text generation)

Tools let agents call your application code — generate random numbers, query databases, send emails. Each tool has a description, input schema, and handle method.

Bad Example

// Putting tool logic inside the agent — unstructured and untestable
class SalesCoach implements Agent
{
    use Promptable;

    public function instructions(): string
    {
        // Trying to describe tools in prose — model can't actually call them
        return 'You are a sales coach. When asked for random numbers, generate one between 1-100.';
    }
}

Good Example

// php artisan make:tool RandomNumberGenerator

namespace App\Ai\Tools;

use Illuminate\Contracts\JsonSchema\JsonSchema;
use Laravel\Ai\Contracts\Tool;
use Laravel\Ai\Tools\Request;

class RandomNumberGenerator implements Tool
{
    public function description(): string
    {
        return 'Generate a cryptographically secure random number within a range.';
    }

    public function handle(Request $request): string
    {
        return (string) random_int($request['min'], $request['max']);
    }

    public function schema(JsonSchema $schema): array
    {
        return [
            'min' => $schema->integer()->min(0)->required(),
            'max' => $schema->integer()->required(),
        ];
    }
}
// Register tools on an agent
use App\Ai\Tools\RandomNumberGenerator;
use Laravel\Ai\Contracts\Agent;
use Laravel\Ai\Contracts\HasTools;
use Laravel\Ai\Promptable;

class SalesCoach implements Agent, HasTools
{
    use Promptable;

    public function instructions(): string
    {
        return 'You are a sales coach.';
    }

    public function tools(): iterable
    {
        return [
            new RandomNumberGenerator,
        ];
    }
}
// Tool with dependency injection — constructor and handle method
namespace App\Ai\Tools;

use App\Repositories\WeatherRepository;
use Laravel\Ai\Contracts\Tool;
use Laravel\Ai\Tools\Request;

class GetWeather implements Tool
{
    public function __construct(
        private readonly WeatherRepository $weather,
    ) {}

    public function description(): string
    {
        return 'Get current weather for a location.';
    }

    public function handle(Request $request, WeatherRepository $weather): string
    {
        return $weather->getForecastFor($request['location']);
    }

    public function schema(JsonSchema $schema): array
    {
        return [
            'location' => $schema->string()
                ->description('City name or coordinates')
                ->required(),
        ];
    }
}

Why

  • Structured: JSON schema defines exact inputs the model can send
  • Testable: Tools are independent classes with clear inputs and outputs
  • DI support: Laravel container resolves constructor and handle dependencies
  • Composable: Mix and match tools across different agents

Reference: Laravel AI SDK — Tools

Source: SKILL.md on GitHub

1 warning16d4 checks · Risk MEDIUM
  • Gen Agent Trust Hub16d

    The skill provides a comprehensive guide for the Laravel AI SDK but contains deceptive metadata claiming authorship by the 'Laravel Community' despite being associated with the user 'asyrafhussin'. It also presents an indirect prompt injection surface by documenting patterns for ingesting untrusted data (such as transcripts and external URLs) while granting agents capabilities like file system storage and network access.

  • Socket16d

    No alerts

  • Snyk16d

    Risk: LOW · No issues

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 7221662. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Steadyupdated 7 months ago
Other metadata
metadata
{
  "author": "Laravel Community",
  "version": "1.0.0",
  "laravelVersion": "13.x",
  "phpVersion": "8.3+"
}

README badge

README badge for asyrafhussin/agent-skills/laravel-ai-sdk