gitmyhub

laravel-ai-skills

PHP ★ 5 updated 24d ago

Procedural knowledge skills for the Laravel AI SDK. Teach your AI agents how to behave, not just what to do.

A Laravel PHP package that lets you give AI agents reusable behavior guides, like a refund policy or tone guide, that the agent can look up on demand instead of bloating every request with instructions.

PHPLaravelsetup: moderatecomplexity 3/5

Laravel AI Skills is a PHP package that adds a "Skills" concept to the Laravel AI SDK. The Laravel AI SDK already has the idea of "tools": PHP classes that do something, like looking up a database record or calling an external API. This package argues there is a second type of thing an AI agent often needs: guidance on how to behave in a situation, not an action to take. The package calls these Skills and gives them a proper abstraction: their own base class, their own artisan scaffolding command, their own attribute for registration, and their own delivery modes.

A Skill is a PHP class with a guide() method that returns text. That text might be a tone guide for customer support replies, a refund policy, or an escalation procedure. When the AI agent needs to respond to something relevant, it can call the skill to retrieve that guidance, rather than having the guidance baked into every request whether it is needed or not.

There are three delivery modes. OnDemand (the default) exposes each skill as a zero-argument tool that the model calls when it decides the guidance is relevant. Full injects the skill content directly into the system prompt on every request, suitable for rules that always apply. Lite is for agents with many skills: it exposes two meta-tools (one that lists available skills, one that fetches a specific skill by name) to keep the tool list short, at the cost of requiring two round-trips before the model has the content it needs.

The package includes a helper for structuring the system prompt in the order that benefits AI provider prefix caching: static instructions first, then Full-mode skill content, then any per-request dynamic content like the current user plan. Skills can also be database-driven (returning an Eloquent query result), injected with runtime context, and cached. A Skill::fake() helper makes unit testing straightforward.

The package is described as experimental RFC infrastructure: the author is using it in production to gather real-world feedback before proposing the Skills concept as a first-class feature to the laravel/ai maintainers. It requires PHP 8.3+, Laravel 12+, and laravel/ai version 0.6 or later.

Where it fits