DatabaselaravelFree
Laravel: add a safe database migration
New column/table with indexes, rollback and model updates.
Cursor / coding agents, Claude Code, ChatGPT +1
Agent Templates / Laravel
PHP, Laravel, Blade/Livewire/Inertia, Pest/PHPUnit. Files update live as you answer; download everything as a ZIP and drop it into your repo root.
What the app does and for whom.
Generated in your browser. Nothing is uploaded. Review before committing: these are starting points, not guarantees.
# AGENTS.md: my-app
## Stack
Laravel 12 on PHP 8.3, MySQL, Blade, tests with Pest, database queue.
## Setup
```bash
cp .env.example .env
php artisan key:generate
```
## Commands
- Install PHP deps: `composer install`
- Install JS deps: `npm install`
- Run migrations: `php artisan migrate`
- Dev server: `php artisan serve (and npm run dev for Vite)`
- Tests: `php artisan test`
- Format: `./vendor/bin/pint`
## Project structure
- app/Models: Eloquent models
- app/Http/Controllers: thin controllers
- app/Http/Requests: Form Request validation
- app/Actions or app/Services: business logic (create if missing)
- database/migrations, database/factories, database/seeders
- routes/web.php
- tests/Feature and tests/Unit
## Code style
- Follow PSR-12 and Laravel conventions; run Pint before finishing
- Use strict types and typed properties/returns where practical
- Validate input with Form Requests, not inline in controllers
- Keep controllers thin; move logic to Actions/Services
- Prefer Eloquent relationships and eager loading (with()) to avoid N+1 queries
- Use config() not env() outside config files
- Views live in resources/views; use Blade components for repeated UI
- Escape output with {{ }}; only use {!! !!} for trusted, sanitised HTML
- Dispatch slow work (mail, external APIs) to queued jobs; make jobs idempotent
## Testing
- Write Pest feature tests for every new endpoint or behaviour
- Use model factories and RefreshDatabase; never hit real external services (use Http::fake(), Mail::fake(), Queue::fake())
- Run `php artisan test` and make sure it passes before saying the task is done
## Security
- Use mass-assignment protection ($fillable) and authorisation (Policies/Gates)
- Never log secrets or personal data
- Use parameter binding; no raw SQL string concatenation
## Never
- Commit secrets or .env files
- Run destructive database commands without asking
- Do not edit existing migrations that may have run in production; add a new migration instead
- Do not run php artisan migrate:fresh, db:wipe or similar destructive commands without explicit approval
- Do not add packages without explaining why
## Working agreement
- Before editing, state a short plan and the files you will touch
- Make the smallest change that solves the task; do not refactor unrelated code
- If requirements are ambiguous, ask instead of guessing
- When done, summarise what changed and how you verified it
New column/table with indexes, rollback and model updates.
Cursor / coding agents, Claude Code, ChatGPT +1
Eager loading fixes with proof.
Cursor / coding agents, Claude Code, ChatGPT +1
Thin controllers with proper authorisation.
Cursor / coding agents, Claude Code, ChatGPT +1