truthanb/laravel-ai-skills
Composer 安装命令:
composer require truthanb/laravel-ai-skills
包简介
Agent Skills (agentskills.io) support for Laravel AI
关键字:
README 文档
README
Agent Skills (agentskills.io) support for Laravel AI. Load, register, and wire skill-based instructions and tools into your AI agents.
Installation
composer require truthanb/laravel-ai-skills
Compatibility
This package supports stable laravel/ai releases from 0.2 through 0.6.
Quick Start
1. Create a Skill Directory
Create a skill directory with a SKILL.md file following the Agent Skills specification:
resources/skills/
└── customer-support/
├── SKILL.md
├── scripts/
│ └── triage.sh
└── references/
└── TEMPLATES.md
The SKILL.md file uses YAML frontmatter:
--- name: customer-support description: Handle customer support inquiries and ticket routing. license: MIT --- # Customer Support Skill Use this skill when handling customer inquiries...
2. Use the HasSkills Trait
Add the HasSkills trait to your agent and call skillPrompt() in your instructions and skillTools() in your tools:
<?php namespace App\Agents; use Laravel\Ai\Contracts\Agent; use Laravel\Ai\Contracts\HasTools; use Laravel\Ai\Promptable; use Truthanb\LaravelAiSkills\HasSkills; class SupportAgent implements Agent, HasTools { use HasSkills, Promptable; public function instructions(): string { return 'You are a helpful support assistant.'.$this->skillPrompt(); } public function tools(): iterable { return [...$this->skillTools()]; } }
By default, skills are loaded from resources/skills/ — following Laravel conventions. You can publish the config to customize the path. The agent automatically gets:
- Skill descriptions injected into its system prompt (via
skillPrompt()) - A skill activation tool to load full skill instructions on demand
- A skill resource reader tool to read scripts, references, and assets from a skill
Configuration
Publish the config file to customize skill paths:
php artisan vendor:publish --tag=skills-config
This creates config/skills.php where you can set your paths:
return [ 'paths' => [ resource_path('skills'), ], ];
Custom Skill Paths Per Agent
Override skillPaths() on a specific agent to load skills from different directories:
class SupportAgent implements Agent, HasTools { use HasSkills, Promptable; public function instructions(): string { return 'You are a helpful assistant.'.$this->skillPrompt(); } public function tools(): iterable { return [...$this->skillTools()]; } protected function skillPaths(): array { return [ resource_path('skills/support'), resource_path('skills/shared'), ]; } }
Direct Override (DB, S3, etc.)
For skills loaded from a database, S3, or any non-filesystem source, override skills() directly:
class DynamicAgent implements Agent, HasTools { use HasSkills, Promptable; public function __construct(protected array $loadedSkills = []) {} public function instructions(): string { return 'You are a helpful assistant.'.$this->skillPrompt(); } public function tools(): iterable { return [...$this->skillTools()]; } public function skills(): array { return $this->loadedSkills; } }
Manual Approach
If you prefer full control, manage the SkillRegistry and tools yourself:
use Truthanb\LaravelAiSkills\ActivateSkillTool; use Truthanb\LaravelAiSkills\ReadSkillResourceTool; use Truthanb\LaravelAiSkills\SkillRegistry; class ManualAgent implements Agent, HasTools { use Promptable; public function __construct(protected SkillRegistry $skills) {} public function instructions(): string { $instructions = 'You are a helpful assistant.'; if ($this->skills->count() > 0) { $instructions .= "\n\n".$this->skills->toPrompt(); } return $instructions; } public function tools(): iterable { return [ new ActivateSkillTool($this->skills), new ReadSkillResourceTool($this->skills), ]; } }
Caching
Skills are automatically cached using Laravel's cache system (default TTL: 1 hour). If caching is unavailable, skills are loaded directly from the filesystem with a graceful fallback.
Override skillCacheTtl() to customize:
protected function skillCacheTtl(): int { return 1800; // 30 minutes }
Call clearSkillCache() to reset both in-memory and persistent caches:
$agent->clearSkillCache();
Specification
This package follows the Agent Skills specification. Each skill is a directory containing a SKILL.md file with YAML frontmatter and optional resource subdirectories (scripts/, references/, assets/).
License
MIT
truthanb/laravel-ai-skills 适用场景与选型建议
truthanb/laravel-ai-skills 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 27 次下载、GitHub Stars 达 2, 最近一次更新时间为 2026 年 02 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「Agent」 「ai」 「skills」 「agentskills」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 truthanb/laravel-ai-skills 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 truthanb/laravel-ai-skills 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 truthanb/laravel-ai-skills 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Spatie's coding guidelines as AI skills for Laravel Boost and skills.sh
A skill system for Laravel AI SDK agents. Define reusable AI capabilities with SKILL.md files.
A symfony/console command for listing and introspecting AI skills files of a project.
Custom laravel monolog logger for datadog logs management, both api and agent ways
The Message Submission Agent Diagnostics tool (msadiag) facilitates testing the compatibility of third party message submission agents.
Standalone replacement for php's native get_browser() function
统计信息
- 总下载量: 27
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-07