Generate Custom Artisan Commands with Claude
Custom Artisan commands are great for maintenance tasks, data imports, scheduled jobs, and one-off scripts — but the boilerplate is always the same. Let Claude write the whole thing from a description.
Describe what you need and Claude will scaffold the command with options, arguments, output, and logic:
Create an Artisan command called reports:generate that:
- Accepts a --from and --to date option
- Accepts an optional --format option (csv or json, default csv)
- Queries orders in that date range
- Writes the output to storage/reports/
- Shows a progress bar while processing
- Logs completion to the Laravel log
Claude generates a fully working command class including the signature, handle method, progress bar, validation, and storage logic:
protected $signature = 'reports:generate
{--from= : Start date (Y-m-d)}
{--to= : End date (Y-m-d)}
{--format=csv : Output format (csv or json)}';
Once the command exists, ask Claude to register it in your scheduler too:
Schedule this command to run every Monday at 6am
and email the output to admin@example.com
You can also ask Claude to write a Pest test that calls the command via $this->artisan() and asserts against the output and exit code — no manual testing required.
Stop writing the same Artisan boilerplate by hand — describe the behaviour and let Claude ship the command.
Log in to leave a comment.
Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.
Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.
Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.