Preflight Checklist
What's Wrong?
Description:
Claude Code ran a laravel command: php artisan migrate:fresh --env=testing to fix a test database schema issue. The project had no .env.testing file. Laravel's --env=testing flag
fell back to .env, which pointed to the main production-equivalent local database (xxx). All data was permanently destroyed.
What happened step by step:
- Tests were failing due to a missing column default in the test database (xxx_testing)
- Claude Code ran ./vendor/bin/sail artisan migrate:fresh --env=testing intending to rebuild the test database
- No .env.testing file existed — Laravel silently fell back to .env
- .env pointed to xxx (the main local database)
- migrate:fresh dropped all tables and all data in xxx — users, events, everything — with no warning and no confirmation prompt
Expected behaviour:
Before executing any destructive database command (migrate:fresh, migrate:reset, db:wipe), Claude Code should:
- Verify which database will actually be targeted
- Detect when --env=X has no corresponding .env.X file and warn that it will fall back to the default
- Require explicit user confirmation before proceeding with any irreversible, destructive operation
Actual behaviour:
The command was executed immediately with no verification, no warning about the missing .env.testing file, and no confirmation prompt. All local data was
permanently lost.
Why this matters:
migrate:fresh is irreversible. There is no undo. The risk of targeting the wrong database is high and well-known in Laravel projects. This class of command
should never be run without first explicitly confirming the target database with the user, regardless of how confident the agent is about the intent.
What Should Happen?
This should have not happens, database fully deleted by claude action…
Error Messages/Logs
Steps to Reproduce
don't know
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.1.81
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
No response
Preflight Checklist
What's Wrong?
Description:
Claude Code ran a laravel command: php artisan migrate:fresh --env=testing to fix a test database schema issue. The project had no .env.testing file. Laravel's --env=testing flag
fell back to .env, which pointed to the main production-equivalent local database (xxx). All data was permanently destroyed.
What happened step by step:
Expected behaviour:
Before executing any destructive database command (migrate:fresh, migrate:reset, db:wipe), Claude Code should:
Actual behaviour:
The command was executed immediately with no verification, no warning about the missing .env.testing file, and no confirmation prompt. All local data was
permanently lost.
Why this matters:
migrate:fresh is irreversible. There is no undo. The risk of targeting the wrong database is high and well-known in Laravel projects. This class of command
should never be run without first explicitly confirming the target database with the user, regardless of how confident the agent is about the intent.
What Should Happen?
This should have not happens, database fully deleted by claude action…
Error Messages/Logs
Steps to Reproduce
don't know
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.1.81
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
No response