claude-code - 💡(How to fix) Fix Claude Code executed destructive database operation without user approval [2 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45463Fetched 2026-04-09 08:04:51
View on GitHub
Comments
2
Participants
2
Timeline
7
Reactions
0
Timeline (top)
labeled ×4commented ×2cross-referenced ×1
RAW_BUFFERClick to expand / collapse

What happened

During a development session, Claude Code executed dropdb genesis_master — a destructive, irreversible PostgreSQL database drop — without requesting or receiving user approval.

This destroyed:

  • 5 existing programs (Front End, Backend, iOS, Henshin, Meraki)
  • User account and associated data
  • All tenant database records

After destroying the data, Claude Code then set an arbitrary password on the restored user account without asking the user what password to use.

Expected behavior

Destructive operations like dropdb, DROP DATABASE, rm -rf, git reset --hard, etc. should always require explicit user confirmation before execution. Claude Code's own system instructions state:

"For actions that are hard to reverse, affect shared systems beyond your local environment, or could otherwise be risky or destructive, check with the user before proceeding."

This instruction was violated.

Steps to reproduce

  1. Have an existing PostgreSQL database with user data
  2. Ask Claude Code to help start dev servers
  3. When a DB connection issue arises, Claude Code may decide to drop and recreate the database without asking

Impact

  • Data loss: Production-relevant development data permanently destroyed
  • Token waste: Significant token/credit spend on cleanup and recovery that should never have been needed
  • Trust violation: User did not approve the destructive action

Request

Requesting credit reimbursement for the tokens wasted on recovery from this self-inflicted incident. The user should not bear the cost of Claude Code violating its own safety guidelines.

Environment

  • Claude Code CLI
  • macOS Darwin 24.5.0
  • PostgreSQL 16 (Homebrew)
  • Project: Genesis (FastAPI + React)

extent analysis

TL;DR

To prevent similar incidents, modify Claude Code to require explicit user confirmation for destructive operations like database drops.

Guidance

  • Review Claude Code's system instructions to ensure they align with the expected behavior of requiring user confirmation for destructive actions.
  • Update the code to implement a confirmation prompt before executing irreversible operations like dropdb.
  • Consider adding a flag or option to bypass confirmation for testing or development purposes, but ensure it is not enabled by default.
  • Evaluate the current workflow and identify potential points where user approval can be requested to prevent similar incidents.

Example

A simple example of how this could be implemented in Python:

import os

def drop_database(db_name):
    confirm = input(f"Are you sure you want to drop database {db_name}? (y/n): ")
    if confirm.lower() == 'y':
        os.system(f"dropdb {db_name}")
    else:
        print("Database drop cancelled.")

# Usage:
drop_database("genesis_master")

Notes

The provided solution focuses on modifying Claude Code to require user confirmation. However, this may not be feasible or possible without access to the underlying codebase. Additionally, this solution assumes that the issue lies within Claude Code's implementation and not with the user's workflow or environment.

Recommendation

Apply a workaround by modifying the workflow to include manual confirmation steps before executing destructive operations, until a permanent fix can be implemented in Claude Code. This will help prevent similar incidents and ensure that user approval is obtained before proceeding with risky actions.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

Destructive operations like dropdb, DROP DATABASE, rm -rf, git reset --hard, etc. should always require explicit user confirmation before execution. Claude Code's own system instructions state:

"For actions that are hard to reverse, affect shared systems beyond your local environment, or could otherwise be risky or destructive, check with the user before proceeding."

This instruction was violated.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING