Agent skill
commands
Artisan console command classes that serve as the CLI entry point for operations. Commands validate input and delegate all business logic to Actions or Services.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/commands-codebar-ag-coding-guidelines
SKILL.md
Name: Commands Description: Artisan console command classes that serve as the CLI entry point for operations. Commands validate input and delegate all business logic to Actions or Services. Compatible Agents: general-purpose, backend Tags: app/Console/Commands/**/*.php, laravel, php, backend, artisan, cli, console
Rules
- Command classes live in
app/Console/Commands/ - Each command should have a single, clearly defined responsibility
- Complex logic belongs in Actions or Services, not in the command itself — commands are the entry point only
- Use descriptive verb-noun names:
SendInvoiceReminders,ImportProductCsv,PruneExpiredSessions - Command signatures follow the
namespace:actionpattern:invoices:send-reminders,products:import - Every argument and option must have a clear description
- Validate all input using the
Validatorclass — never trust raw input - Use
--optionflags for optional behaviour; avoid positional ambiguity - Implement
PromptsForMissingInputso users receive clear prompts instead of silent failures - Commands must always return either
self::SUCCESSorself::FAILURE— nevervoidornull
Examples
class SendInvoiceReminders extends Command implements PromptsForMissingInput
{
protected $signature = 'invoices:send-reminders
{email : The email address to send the reminder to}
{--dry-run : Simulate the command without persisting changes}';
protected $description = 'Send invoice payment reminders to a specific user.';
public function __construct(private readonly SendInvoiceReminderAction $action)
{
parent::__construct();
}
public function handle(): int
{
$validated = validator(
[
'email' => $this->argument('email'),
'dry_run' => $this->option('dry-run'),
],
[
'email' => ['required', 'email'],
'dry_run' => ['boolean'],
]
)->validate();
try {
$this->action->execute($validated['email']);
$this->info("Reminder sent to {$validated['email']}.");
return self::SUCCESS;
} catch (Throwable $e) {
$this->error("Failed: {$e->getMessage()}");
return self::FAILURE;
}
}
}
Anti-Patterns
- Putting business logic directly inside
handle()instead of delegating to an Action or Service - Not returning
self::SUCCESSorself::FAILURE(e.g., returningvoidornull) - Trusting raw
$this->argument()/$this->option()values without validation - Omitting descriptions from arguments and options in the signature
- Not implementing
PromptsForMissingInput, causing silent failures for missing arguments
References
- Laravel Artisan Console
- Related:
Actions/SKILL.md— for the business logic commands delegate to
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?