PHP code example of neuron-core / agent-skills

1. Go to this page and download the library: Download neuron-core/agent-skills library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

neuron-core / agent-skills example snippets


use NeuronAI\Agent\Agent;
use NeuronAI\Chat\Messages\UserMessage;
use NeuronAI\Providers\OpenAI\OpenAI;
use NeuronAI\AgentSkills\Storage\FileSystemSkillStorage;
use NeuronAI\AgentSkills\Tools\SkillToolkit;

$toolkit = SkillToolkit::make()
    ->fromStorage(new FileSystemSkillStorage(__DIR__.'/.agents/skills'));

$agent = Agent::make()
    ->setThreadId('quick-start')
    ->setAiProvider(new OpenAI(key: 'your-api-key', model: 'gpt-5.4-mini'))
    ->addTool($toolkit);

$response = $agent->chat(new UserMessage(
    'Use caveman skill to explain how the universe works.',
));

echo $response->getMessage()->getContent();

// Actual response (excerpt):
// Cosmic history: big bang expansion. Early hot plasma cooled; atoms formed.
// Gravity pulled gas into stars, stars forged heavier elements. Supernovae
// spread elements; mergers build galaxies.

use NeuronAI\Tools\Toolkits\FileSystem\BashTool;

$agent = Agent::make()
    ->setAiProvider(new OpenAI(key: 'your-api-key', model: 'gpt-5.4-mini'))
    ->addTool($toolkit)          // Loads skills and prepares their files.
    ->addTool(new BashTool());   // Runs the skill scripts.

use NeuronAI\AgentSkills\Storage\DatabaseSkillStorage;

$toolkit = SkillToolkit::make()->fromStorage(
    new FileSystemSkillStorage(__DIR__.'/skills'),
    new FileSystemSkillStorage(__DIR__.'/.agents/skills'),
    new DatabaseSkillStorage(new PDO('sqlite:'.__DIR__.'/skills.sqlite')),
);

$storage = new DatabaseSkillStorage($pdo);                      // table "skills"
$archive = new DatabaseSkillStorage($pdo, table: 'archived_skills');

use NeuronAI\AgentSkills\SkillRepository;

$skills = new SkillRepository(
    new FileSystemSkillStorage(__DIR__.'/.agents/skills'),
);
$agent->addTool(new SkillToolkit($skills));

foreach ($skills->catalog() as $skill) {
    echo $skill->name().': '.$skill->description().PHP_EOL;
}

$skill = $skills->getByName('caveman');      // Throws if unknown.

$skill->loadInstructions();                  // Body without YAML frontmatter.
$skill->loadFrontmatter();                   // Parsed metadata as stdClass.
$skill->resource('references/guide.md')->load();

foreach ($skill->resources() as $resource) {
    echo $resource->path().PHP_EOL;
}

interface SkillStorageInterface
{
    /** @return list<string> Skill identifiers in this storage. */
    public function list(): array;

    /** @return list<string> Relative paths of every file, including SKILL.md. */
    public function resources(string $skillIdentifier): array;

    public function read(string $skillIdentifier, string $path): string;
}