Hard-deleting production records is a one-way door. Soft deletes give you a safety net by flagging records as deleted with a timestamp instead of removing them — and Claude can retrofit the pattern across your entire codebase.
Add soft delete support to the User, Order, and Product models. Add a deleted_at
timestamp column via migrations. Ensure all existing queries exclude soft-deleted
records by default, and add a way to include them when needed (e.g. for admin views
or audit logs).
For Laravel apps, Claude adds the SoftDeletes trait and generates the migration automatically. For other frameworks it builds the pattern from scratch — adding a query scope, an is_deleted flag or deleted_at column, and an exclude deleted default scope.
Once the base is in place, extend it:
Add a scheduled job that permanently purges records soft-deleted more than 90 days ago,
and log each purge batch to the audit_log table.
You can also ask Claude to update your admin panel to show soft-deleted records with a restore button, or to add a restore endpoint to your API.
Soft deletes also compose nicely with event sourcing — ask Claude to emit a RecordRestored event when a record is undeleted.
Soft deletes cost almost nothing to add and save enormous pain when a user inevitably asks "can you get my data back?"
Log in to leave a comment.
The /security-review command scans your uncommitted changes for injection vectors, auth gaps, hardcoded secrets, and other common vulnerabilities.
The SessionStart hook fires when any session begins or resumes, making it ideal for loading environment variables and running one-time setup scripts.
Ask Claude to write property-based tests for your functions using fast-check — it identifies the mathematical invariants in your code and generates tests that cover inputs you'd never enumerate by hand.