Installation:
composer require joshcirre/instrukt-laravel --dev
php artisan instruckt:install
This handles config publishing, Vite integration, and MCP auto-configuration.
First Use Case:
resources/views/your-view.blade.php).adapters: ['blade'] in Vite config).storage/instrukt/annotations.json.Viewing Annotations:
$annotations = \Instrukt\Instrukt::getAnnotations();
Browser Annotations:
/dashboard").selector: CSS selector of the element (e.g., #submit-button).comment: Free-form text.metadata: Custom key-value pairs (e.g., {"priority": "high"}).AI Integration:
config/instrukt.php:
'mcp' => [
'tools' => [
'annotate' => [
'description' => 'Add or update UI annotations.',
'parameters' => [
'selector' => 'string',
'comment' => 'string',
],
],
],
],
{
"tool": "annotate",
"args": {
"selector": "#login-form",
"comment": "Add validation for email field."
}
}
Blade Integration:
@instrukt directive to mark elements for annotation:
<button @instrukt("submit-button")>Submit</button>
@instrukt('form-field')
<input type="text" name="email">
@endInstrukt
Livewire/Alpine:
livewire adapter:
instruckt({
adapters: ['livewire', 'blade'],
});
Export/Import:
php artisan instrukt:export --path=annotations.json
php artisan instrukt:import --path=annotations.json
Vite Plugin Conflicts:
server: true in the Vite plugin, ensure your Laravel dev server isn’t running on the same port (default: 8000). Use:
instruckt({ server: false }), // Recommended for Laravel.
npm run dev -- --debug
Selector Leakage:
\Instrukt\Instrukt::validateSelector('#dynamic-id');
MCP Tool Misconfiguration:
php artisan mcp:tools
Tool "annotate" not found → Check config/instrukt.php and restart MCP.Storage Permissions:
storage/instrukt/ is writable:
chmod -R 755 storage/instrukt
Log Annotations:
config/instrukt.php:
'debug' => env('INSTRUKT_DEBUG', false),
storage/logs/instrukt.log.Toolbar Not Showing:
adapters include 'blade'.npm run dev
AI Agent Not Reading Annotations:
'mcp' => true in Vite config).php artisan mcp:test
Custom Metadata: Add structured metadata to annotations for AI context:
// In browser console (after toolbar loads)
instrukt.addAnnotation({
selector: '#sidebar',
comment: 'Collapse on mobile',
metadata: { device: 'mobile', priority: 'high' }
});
Conditional Annotations: Use Blade directives to toggle annotations in dev/staging:
@if(config('app.env') === 'local')
@instrukt('dev-only-element')
<div>Debug info</div>
@endInstrukt
@endif
CI/CD Integration:
php artisan instrukt:export --path=annotations-prod.json
php artisan instrukt:import --path=annotations-prod.json
Performance:
adapters: ['blade'] only).instruckt({ lazyLoad: true });
Extending Storage: Override the default JSON storage by binding a custom driver:
// InstruktServiceProvider.php
$this->app->bind(\Instrukt\Contracts\AnnotationStorage::class, function () {
return new \App\Services\DatabaseAnnotationStorage();
});
Implement \Instrukt\Contracts\AnnotationStorage to use a database or cache.
How can I help you explore Laravel packages today?