1. Go to this page and download the library: Download stolt/skill-validator 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/ */
stolt / skill-validator example snippets
use Stolt\Ai\Skill\Validator;
$validator = new Validator();
$result = $validator->validateFile('/path/to/an-ai-skill/SKILL.md');
use Stolt\Ai\Skill\Validator;
$validator = new Validator();
$results = $validator->validateFromDirectory('/path/to/skills');
foreach ($results as $filePath => $result) {
if ($result->isInvalid()) {
echo sprintf('Invalid: %s', $filePath) . PHP_EOL;
foreach ($result->errors() as $error) {
echo ' - ' . $error . PHP_EOL;
}
}
}
use Stolt\Ai\Skill\Validator;
$validator = new Validator();
$result = $validator->validateContent('raw-skill-content');
use Stolt\Ai\Skill\Validator;
$validator = new Validator();
$result = $validator->validateContent('raw-skill-content');
if ($result->isInvalid()) {
foreach ($result->errors() as $error) {
echo $error . PHP_EOL;
}
// Raw metadata can still be inspected when parsing succeeded but validation failed.
$rawMetadata = $result->rawMetadata();
exit(1);
}
$metadata = $result->metadata();
if ($metadata === null) {
throw new RuntimeException('Expected validated SKILL.md metadata.');
}
// Required SKILL.md metadata fields.
$name = $metadata->name();
$description = $metadata->description();
// Optional SKILL.md metadata fields.
$version = $metadata->version();
$tags = $metadata->tags();
$allowedTools = $metadata->get('allowed-tools', []);
$model = $metadata->get('model');
$effort = $metadata->get('effort');
// Markdown instructions after the YAML frontmatter.
$instructions = $result->body();
// Array representation for logging, JSON APIs, or integrations.
$arrayResult = $result->toArray();
echo sprintf('Skill "%s" is valid: %s', $name, $description) . PHP_EOL;
use Stolt\Ai\Skill\Validator;
$validator = new Validator();
$result = $validator->validateContent('raw-skill-content');
$skillMd = $result->toSkillMd();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.