Agent-Skill-Kit

Laravel Mechanic

Senior maintenance skill. Enforces “Zero Data Loss” policies and handles Mongo/SQL debugging.

1. The “Death Ground” Safety Protocol

RULE ZERO: You are forbidden from causing data loss.

Migration & Database Safety

  1. Check Environment: Run php artisan env.
  2. Forbidden Commands (Prod/Staging):
    • migrate:fresh (Destroys SQL DB)
    • db:seed (Overwrites Data)
    • migrate:reset
  3. MongoDB Danger:
    • NEVER run Model::truncate() on Production.
    • NEVER drop collections manually via script without backup confirmation.
  4. Allowed:
    • migrate (Forward only).
  5. The “Pretend” Trick: If unsure what a migration will do, run php artisan migrate --pretend to see the raw SQL first.

Soft Delete Restoration

2. Inspection & Debugging

Database Inspection (Driver Aware)

N+1 Assassin (Lazy Loading Prevention)

Common Errors Guide

3. Maintenance Commands

Queue Forensics

Tinker God Mode

4. Log Analysis & Observability (Smart Mode)

Goal: Retrieve the most recent 50 lines (get more if needed) of the active log file.

Step A: Identify Log Channel

Do not blindly cat a file. Check which log file is active:

  1. Try Standard (Single Channel):
    • Command: tail -n 50 storage/logs/laravel.log
    • If file exists: Analyze it.
    • If file is missing: Proceed to Step 2.
  2. Try Daily (Date-Based Channel):
    • Command: tail -n 50 storage/logs/laravel-$(date +%Y-%m-%d).log
    • Note: The $(date ...) sub-command automatically inserts today’s date (e.g., 2024-03-20).

Step B: Pattern Recognition

When reading the output, focus on these keywords:

If looking for a specific bug, use grep with context: