Article

10 Claude Code Tips for Laravel Developers

10 practical tips for using Claude Code with Laravel—from installing Boost to generating tests, refactoring across files, and building complex Eloquent queries.

I've been using Claude Code as part of my daily Laravel workflow for a while now, and it's genuinely changed how I approach certain tasks. If you're a Laravel developer curious about integrating AI tooling into your workflow, here are ten practical tips that have made a real difference for me.

1. Install Laravel Boost First

Before anything else, install Laravel Boost. It's Laravel's official MCP server for AI-assisted development, and it transforms how Claude Code understands your project.
composer require laravel/boost --dev
php artisan boost:install
The installer will detect Claude Code and set everything up automatically. What you get is substantial: over 15 specialized tools that give Claude Code direct access to your application's context. It can query your database schema, search Laravel documentation with semantic search (over 17,000 indexed pieces of Laravel-specific information), run Tinker commands, list your Artisan commands, and more.
Boost also generates a CLAUDE.md file with AI guidelines tailored to your specific Laravel version and installed packages. Instead of Claude Code guessing at conventions, it knows your exact stack—your PHP version, whether you're using Pest or PHPUnit, your frontend choices, everything.
Run php artisan boost:update periodically to keep the guidelines current with your installed packages.

2. Customize Your CLAUDE.md

While Boost generates a solid CLAUDE.md automatically, you'll want to extend it with project-specific conventions. Add your own guidelines to .ai/guidelines/ as .md or .blade.php files—Boost will include them automatically on the next update.
Things worth adding:
  • Architectural patterns your team follows (actions, services, repositories)
  • Naming conventions beyond Laravel defaults
  • Business domain terminology
  • Testing patterns specific to your application
  • Common gotchas or legacy code warnings
The generated guidelines handle Laravel ecosystem knowledge; your additions handle what makes your project unique.

3. Let It Handle the Artisan Boilerplate

Artisan is great, but there's a gap between php artisan make:model and having a fully-fleshed-out model with relationships, casts, and scopes. Claude Code bridges that gap.
Instead of running make:model and then manually adding everything, I describe what I need:
Create a model for tracking equipment inspections. It belongs to a User and an Equipment model. 
It should have status (enum: pending, in_progress, completed, failed), 
scheduled_at and completed_at timestamps, and a notes text field. 
Include the migration, factory, and a policy.
You get the model with proper casts, relationships, and fillables—plus the migration, factory with realistic fake data, and a policy with sensible defaults. One prompt, four files, all consistent with each other.

4. Use It for Complex Eloquent Query Building

We've all stared at a complex query trying to figure out the right combination of whereHas, withCount, and subqueries. Claude Code excels here because you can describe the data you need in plain English.
I'll often paste my schema or model relationships and say something like:
I need to get all equipment where the last inspection was more than 90 days ago, 
or has never been inspected. Include the count of total inspections 
and eager load the assigned technician.
The resulting query is usually cleaner than what I would have written, and I can iterate on it conversationally if the results aren't quite right.

5. Generate Pest Tests from Your Existing Code

This one has saved me hours. Point Claude Code at an existing controller or action class and ask it to generate comprehensive Pest tests.
Look at app/Http/Controllers/InspectionController.php and write Pest feature tests 
covering all the endpoints. Use our existing factories and include edge cases 
for authorization.
It understands the Laravel testing ecosystem—it'll use actingAs() for auth, proper factory states, database assertions, and the Pest syntax. The tests usually need some tweaking, but you're starting from 80% done instead of a blank file.

6. Refactor Across Multiple Files Simultaneously

This is where Claude Code's agentic nature really shines. Refactoring in Laravel often means touching a controller, a form request, maybe a service class, the route file, and the tests.
Extract the inspection scheduling logic from InspectionController@store into 
a new ScheduleInspectionAction class. Update the controller to use it, 
and update the existing tests.
Claude Code will create the action class, modify the controller, update the test imports and assertions—all in one operation. It understands the ripple effects of refactoring in a way that simple code generation doesn't.

7. Explain and Debug Legacy Code

Every Laravel project has that one service class nobody wants to touch. Instead of spending an hour tracing through it, ask Claude Code to explain it:
Explain what app/Services/LegacyReportGenerator.php does. 
Identify any potential bugs or performance issues.
I've found actual bugs this way—things like N+1 queries hiding in foreach loops, or edge cases where null values weren't handled properly. It's like having a patient senior dev do a code review on demand.

8. Generate Form Requests with Validation Logic

Laravel's form requests are great, but writing validation rules gets tedious, especially for complex nested data or conditional validation.
Create a form request for updating user profiles. The user can update their name, 
email (must be unique excluding their own), password (optional, but if provided 
must be confirmed), and notification_preferences (a JSON object with email and sms boolean keys). 
Include authorization logic that only lets users edit their own profile or admins edit anyone's.
The resulting form request handles the conditional logic, proper rule syntax, and custom error messages. It's particularly good with complex array validation rules that I always have to look up.

9. Convert Raw SQL to Eloquent (and Vice Versa)

Sometimes you get a raw SQL query from a DBA or find one in legacy code, and you need to convert it to Eloquent. Sometimes you have Eloquent and need raw SQL for debugging or performance analysis.
Claude Code handles both directions fluently. Paste your raw SQL and ask for the Eloquent equivalent, or paste your query builder chain and ask for the raw SQL it generates. Helpful for understanding what Eloquent is actually doing under the hood.

10. Generate API Resources and Transformations

API resources in Laravel are simple in concept but tedious when you have nested relationships and conditional fields. Claude Code can generate comprehensive resources:
Create an API resource for the Inspection model. Include the related equipment 
and technician (but only basic info for those). Add a whenLoaded check for 
the inspection_items relationship. Include a computed 'is_overdue' field.
It handles the whenLoaded conditionals, proper date formatting, nested resources, and computed attributes. You get a well-structured resource instead of just dumping toArray() everywhere.

A Note on Workflow Integration

The biggest shift for me wasn't any individual tip—it was realizing that Claude Code works best when you treat it as a collaborator rather than a code generator. With Boost installed, that collaboration becomes significantly more productive because Claude Code can actually introspect your application instead of relying on you to provide context.

I keep a terminal with Claude Code running alongside my editor. When I hit a decision point or tedious task, I describe what I'm trying to accomplish in plain English, and we iterate from there.

It doesn't replace knowing Laravel well. In fact, it's more useful the better you understand the framework, because you can give it better context and evaluate its output more effectively. But it does eliminate a lot of the mechanical work and lets you focus on the interesting problems.

What Claude Code tips have made a difference in your workflow? I'm always looking for new ways to integrate it into Laravel development.