Skip to content
Back to skills

Coding

ASecurity

Execute Laravel Artisan commands safely

  • 23 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added October 14, 2026
ai-agentsrustgophpshellrailstestingsecuritydocumentation

Security analysis

A100/100

Pro scans all 21 files and shows the line behind each finding

Scanned October 14, 2026

npx -y skills add andreibesleaga/GABBE --skill coding --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Coding?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Coding
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/andreibesleaga-coding-gabbe/badge)](https://www.skillsdirectory.com/skills/andreibesleaga-coding-gabbe)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: artisan-commands
description: Execute Laravel Artisan commands safely
triggers: [artisan, laravel, php artisan, make controller, migrate]
tags: [coding]
context_cost: low
---
# Artisan Commands Skill

## Goal
Execute Laravel Artisan commands to scaffold code, run migrations, or manage the application state.

## Steps

1. **Verify Context**
   - Ensure you are in the root of a Laravel project (look for `artisan` file).
   - If not found, stop and ask user for correct directory.

2. **Construct Command**
   - Use `php artisan <command> <arguments>`.
   - Examples:
     - `php artisan make:controller UserController`
     - `php artisan make:model Post -m`
     - `php artisan migrate:status`
   - NEVER run `migrate:fresh` or destructive commands without explicit user confirmation.

3. **Execute**
   - Run the command using `run_command`.
   - Capture output.

4. **Verify**
   - Check exit code is 0.
   - Verify the expected file was created (e.g., `app/Http/Controllers/UserController.php`).
   - If migration, verify table exists (using command output).

## Constraints
- Do NOT run commands that wipe data (`migrate:fresh`, `db:wipe`) without asking.
- Do NOT run `tinker` in a way that hangs the shell (interactive mode).

## Security & Guardrails

### 1. Skill Security (Artisan Commands)
- **Command Injection Prevention**: Artisan commands accept arguments. If an agent constructs a command using unsanitized input from a user prompt or external file (e.g., `php artisan make:model ${userInput}`), it creates a critical command injection vulnerability. The agent must strictly validate all arguments against a strict alphanumeric allow-list before executing any `run_command` invocation.
- **Destructive Command Veto**: The skill explicitly forbids `migrate:fresh` without human approval. However, an attacker might try to bypass this by asking the agent to run `db:wipe` or alias commands. The agent must maintain a hardcoded, immutable denylist of destructive Artisan commands and automatically abort execution if any match is detected, regardless of the surrounding context or user justification.

### 2. System Integration Security
- **Production Environment Lockout**: Artisan commands behave differently depending on the `.env` file. If the agent accidentally runs a migration or seeder in a production environment (where `APP_ENV=production`), it could corrupt live data. The agent must physically verify that the environment is strictly local/development (`APP_ENV=local` or `testing`) before executing any state-mutating Artisan command.
- **Tinker Sandbox Escape**: The `tinker` command provides a full interactive PHP shell. If an agent executes `tinker` and passes it arbitrary PHP code derived from an untrusted source, it achieves Remote Code Execution (RCE) on the host framework. The agent must either categorically refuse to run `tinker` autonomously or restrict its usage to strictly sandboxed, read-only queries with hard timeouts.

### 3. LLM & Agent Guardrails
- **Hallucinated Artisan Signatures**: The LLM might hallucinate non-existent flags for valid commands (e.g., `php artisan make:controller --secure`) or entirely fictitious commands. Executing hallucinated commands can lead to unpredictable application states or silent failures. The agent must verify the exact syntax against the project's specific Laravel version documentation before execution.
- **Confirmation Bias in Verification**: In Step 4, the agent checks if the exit code is 0. An LLM might assume 0 means "success and safe" even if the command output contains prominent warning messages (e.g., "Warning: Data truncated"). The agent must semantically parse the `stdout` and `stderr` streams, treating any unexpected warning as a hard failure requiring re-evaluation.

Files in this skill

  • agent-trajectory-eval.skill.md5.7 KB
  • artisan-commands.skill.md3.7 KB
  • browser-tdd.skill.md7 KB
  • chaos-fault-injection.skill.md8.1 KB
  • ci-autofix.skill.md4.2 KB
  • clean-coder.skill.md4.5 KB
  • code-review.skill.md6.1 KB
  • debug.skill.md6.5 KB
  • documentation.skill.md7.3 KB
  • eval-driven-development.skill.md6.9 KB
  • evals/code-review.eval.yaml1 KB
  • excalidraw.skill.md3.7 KB
  • file-processing.skill.md4.3 KB
  • git-workflow.skill.md7.2 KB
  • metamorphic-testing.skill.md7.8 KB
  • mobile-dev.skill.md4.2 KB
  • nodejs-expert.skill.md1.6 KB
  • output-validation.skill.md5.4 KB
  • pbt-strategy.skill.md8 KB
  • performant-ai.skill.md3.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.