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.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.