Mastering Laravel Boost 2.0: Optimizing AI Context for Agentic Development
Overview: Why Your AI Agent Needs a Boost
AI models like
Prerequisites: Setting the Stage
To effectively implement
- Modern PHP & Laravel: Familiarity with PHPandLaravelis essential, asLaravel Boosthas moved away from supporting older versions to utilize the latest framework features.
- AI Coding Tools: You should be using an AI-capable editor or agent such as Claude Dev,Cursor,GitHub Copilot, orWindsurf.
- Command Line Basics: You will need to interact with the terminal to run Artisan commands for installation and synchronization.
Key Libraries & Tools
- Laravel Boost: The core package that manages guidelines, skills, and the MCP server for AI integration.
- Laravel MCP: A foundational package that implements the Model Context Protocol, allowing external systems (like your app) to communicate with AI models.
- Composer: Used for managing dependencies and third-party AI skills.
- MCP Inspector: A utility for debugging the connection between your editor and the MCP server.
Code Walkthrough: Installation and Configuration
Setting up
Step 1: Installation
Run the following command in your project root:
composer require laravel/boost --dev
php artisan boost:install
During installation, the CLI will prompt you to select which AI agents you are using (e.g., .cursorrules, while others might look for agents.md.
Step 2: Synchronizing Skills and Guidelines
Whenever you update your configuration or add custom rules, you must run the update command to rebuild the context files that the AI reads:
php artisan boost:update
This command scans your AI/guidelines and AI/skills directories, composing a unified markdown file (like claudedev.md) that represents the current state of your project's rules.
Step 3: Customizing Business Logic
One of the most powerful features of
php artisan vendor:publish --tag=boost-config
Inside config/boost.php, you can add a purpose key. This is where you tell the AI exactly what the app does—for example, "This project is a logistics platform for tracking international shipping containers."
return [
'purpose' => 'A financial dashboard for tracking cryptocurrency tax compliance.',
'coding_style' => 'Spatie',
// ... other config
];
Syntax Notes: The Architecture of a Skill
A Skill in
# Name: Inertia Vue Development
# Description: Use this skill when building or modifying Vue components within the Inertia.js stack.
## Implementation Guidelines
- Always use the <script setup> syntax.
- Utilize Tailwind CSS for all styling.
- Ensure all components are stored in the resources/js/Pages directory.
The AI reads the # Description to decide if the skill is relevant to your current prompt. If you ask to fix a CSS bug, it will pull in the Tailwind Skill but ignore the Database Skill, saving thousands of tokens.
Practical Examples: Real-World Agent Workflows
Automated Refactoring with Verification
Don't just ask an AI to refactor code; ask it to verify its work using the tools provided by
"Refactor the OrderController@store method to use a Form Request. Use the Laravel Skill for validation patterns. Once completed, use the Tinker Tool via MCP to create a test order and ensure the database record is created correctly."
Documentation Ingestion
If you are using a new package that the AI hasn't been trained on, you can use the search_docs tool provided by the
Tips & Gotchas: Navigating the AI Frontier
- The Context Trap: Be careful not to put too much in your
guidelines. If youragents.mdfile becomes 10,000 lines long, the AI will lose the thread of your conversation. Move specific package logic into Skills so they are only loaded on demand. - Plan Mode First: Always use "Plan Mode" in your AI editor before letting it write code. This allows the agent to outline its approach based on the Laravel Boostguidelines before it commits to a file structure.
- Sync Often: If you change a route name or a config value, run
php artisan boost:update. If you don't, the AI will be working from a "ghost" version of your app's previous state. - Override Wisely: Laravel Boostcomes with sensible defaults forTailwind CSSandPest. However, if your team has a unique way of writing tests, create a custom file in
AI/skills/pest.mdto override the defaultLaravel Boostbehavior.
