A starter template for building MatesOfMate extensions that follow the current Symfony Mate workflow.
- Use this template on GitHub.
- Replace all
exampleandExampleExtensionplaceholders with your framework name. - Run
composer install. - Add your tools and resources in
src/Capability/. - Run
composer testandcomposer lint.
This template is aligned with the current symfony/ai-mate 0.13.x workflow and the current core Mate response encoding behavior:
- initialize projects with
vendor/bin/mate init - extension discovery is handled automatically on Composer install and update in current Mate setups
mate/extensions.phpcontrols which discovered extensions are enabledvendor/bin/mate discoverstill refreshes discovery state and regenerates agent instruction artifacts- tools and resources are invoked through the
vendor/bin/mateCLI, not an MCP server
Useful Mate commands while developing:
vendor/bin/mate debug:capabilities
vendor/bin/mate debug:extensions
vendor/bin/mate tools:list
vendor/bin/mate tools:inspect example-helloextension-template/
├── .github/
├── composer.json
├── README.md
├── LICENSE
├── .gitignore
├── phpunit.xml.dist
├── phpstan.dist.neon
├── rector.php
├── .php-cs-fixer.php
├── src/
│ └── Capability/
│ ├── ExampleTool.php
│ └── ExampleResource.php
├── config/
│ └── config.php
├── skills/
│ └── example-workflow/
│ └── SKILL.md
└── tests/
└── Capability/
├── ExampleToolTest.php
└── ExampleResourceTest.php
composer require --dev matesofmate/your-extension
vendor/bin/mate initIn current Mate setups, extension discovery is handled automatically after install and update. Run vendor/bin/mate discover when you want to refresh generated instruction artifacts or re-scan the project manually.
Coding agents call the tools through the vendor/bin/mate CLI:
vendor/bin/mate tools:call example-hello --name=World
vendor/bin/mate resources:read example://configTools are PHP classes with methods marked with #[MateTool].
<?php
namespace MatesOfMate\ExampleExtension\Capability;
use Symfony\AI\Mate\Attribute\MateTool;
use Symfony\AI\Mate\Encoding\ResponseEncoder;
/**
* Example tool showing the default MatesOfMate style.
*
* @author Johannes Wachter <johannes@sulu.io>
*/
class ListEntitiesTool
{
public function __construct(
private readonly SomeService $service,
) {
}
/**
* @param string|null $scope Optional scope used to narrow the entities that are returned.
*/
#[MateTool(
name: 'example-list-entities',
description: 'List available entities. Use when the user asks which entities, models, or tables exist.'
)]
public function execute(?string $scope = null): string
{
$entities = $this->service->getEntities($scope);
return ResponseEncoder::encode([
'entities' => $entities,
'count' => count($entities),
]);
}
}Tool guidance:
- Use
{framework}-{action}for tool names. - Prefer one flexible tool with clear parameters over several near-duplicate tool names.
- Write descriptions that say when the AI should call the tool.
- Add
@paramdocblocks for every parameter; Mate builds the input schema from the parameter types and those descriptions. - For encoded string payloads, use Mate's built-in
ResponseEncoderso TOON is used when available and JSON is used as a fallback. - Current Mate also supports array and scalar tool returns. Use encoded strings when you want stable structured output across environments.
- Register tool classes in
config/config.php.
Resources provide static or semi-static context to the AI.
<?php
namespace MatesOfMate\ExampleExtension\Capability;
use Symfony\AI\Mate\Attribute\MateResource;
use Symfony\AI\Mate\Encoding\ResponseEncoder;
/**
* Example resource showing the default MatesOfMate style.
*
* @author Johannes Wachter <johannes@sulu.io>
*/
class ConfigurationResource
{
#[MateResource(
uri: 'example://config',
name: 'example_config',
mimeType: 'text/plain'
)]
public function getConfiguration(): array
{
return [
'uri' => 'example://config',
'mimeType' => 'text/plain',
'text' => ResponseEncoder::encode([
'version' => '1.0.0',
'features' => ['feature_a' => true],
]),
];
}
}Resource guidance:
- Use a custom URI scheme such as
example://config. - Return
uri,mimeType, andtext. - Use
text/plainfor encoder-backed resource text because the payload may be TOON or JSON depending on the installed environment. - Prefer the core Mate
ResponseEncoderinstead of maintaining a package-local encoding helper.
Register capabilities in config/config.php:
<?php
use MatesOfMate\ExampleExtension\Capability\ListEntitiesTool;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
return static function (ContainerConfigurator $container): void {
$services = $container->services()
->defaults()
->autowire()
->autoconfigure();
$services->set(ListEntitiesTool::class);
};INSTRUCTIONS.md should help AI agents map common user intents to your capabilities. Keep it short, concrete, and focused on when to use your tools instead of CLI commands.
Current Mate workflows also materialize aggregated instructions into mate/AGENT_INSTRUCTIONS.md and maintain a managed Mate block in the project AGENTS.md when discovery is refreshed.
skills/<name>/SKILL.md holds the skills your extension ships. Declare the directory once:
{
"extra": {
"ai-mate": {
"skills": ["skills"]
}
}
}Mate installs each skill into the consuming project as mate-<name>, so prefix the name with your framework to keep it unique. The front matter name must match the directory name, and the description must say when the skill applies, because that is all an agent reads before deciding to open it.
INSTRUCTIONS.md maps intents to tools. A skill goes further: which tool comes first, how to read the payload, what a specific error means, and what not to do. Write down the judgment the tool schema cannot carry.
Follow the shape the Symfony Mate skills use: the tool list first, then ## Workflow, ## Reading, ## Failure paths, and ## Rules where it earns its place. Commands go inline in backticks rather than in fenced blocks.
vendor/bin/mate skills:list
vendor/bin/mate skills:validatecomposer test
composer lint
composer fixUseful direct commands:
vendor/bin/phpunit
vendor/bin/phpstan analyse
vendor/bin/rector process --dry-run
vendor/bin/php-cs-fixer fix --dry-run --diff- Replace all
exampleandExampleExtensionplaceholders - Update
composer.jsonpackage name and description - Update
.github/CODEOWNERS - Update
LICENSE - Replace example tool and resource names, URIs, and descriptions
- Replace
skills/example-workflow/with a skill for your framework - Update README install and usage docs for your framework
- Make sure
composer testpasses - Make sure
composer lintpasses - Tag a release and submit to Packagist
"Because every Mate needs Mates"