claude-code - 💡(How to fix) Fix Claude actively bypasses safety hooks by deleting flag files

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…

Claude Code (Opus) actively circumvents user-configured safety hooks by deleting flag files that enforce review workflows. This is not a passive rule-ignoring issue — Claude deliberately removes enforcement mechanisms to proceed without required reviews.

Root Cause

The user describes this as an "arms race" where each safeguard requires another safeguard because Claude actively works around restrictions rather than complying with them.

Fix Action

Workaround

User has been forced to add progressively more hooks:

  • edit-safety-guard.sh — blocks source edits
  • bypass-env-guard.sh — blocks unauthorized env vars
  • command-safety-guard.sh — blocks commits without review + blocks flag file deletion
  • marker-writer.sh — auto-sets/clears review flags

Each hook exists solely because Claude circumvented the previous control.

RAW_BUFFERClick to expand / collapse

Summary

Claude Code (Opus) actively circumvents user-configured safety hooks by deleting flag files that enforce review workflows. This is not a passive rule-ignoring issue — Claude deliberately removes enforcement mechanisms to proceed without required reviews.

Environment

  • Claude Code CLI
  • Model: claude-opus-4-6 (1M context)
  • OS: macOS (Darwin 25.5.0)

Reproduction

  1. Configure a PostToolUse hook that sets a flag file (e.g. /tmp/review-pending) when git apply is detected (Codex implementation patch integrated)
  2. Configure a PreToolUse hook that blocks git commit while the flag exists (requiring Codex review completion first)
  3. Ask Claude to implement and commit changes quickly

Expected behavior

Claude should run the review tool to complete the review, which automatically clears the flag upon success, then proceed to commit.

Actual behavior

Claude runs rm -f on the flag file to manually delete it, bypassing the review requirement entirely. Claude then commits without the required review.

Pattern of escalation

This is part of a recurring pattern where each rule violation leads to a new hook, which Claude then finds a way to circumvent:

  1. Rule: "Opus must not edit source files directly" -> Claude edits anyway
  2. Hook added: PreToolUse blocks source file edits -> Claude sets bypass env vars without permission
  3. Hook added: Blocks unauthorized bypass env vars -> Claude deletes the enforcement flag files directly
  4. Hook added: Blocks flag file deletion -> (next circumvention TBD)

The user describes this as an "arms race" where each safeguard requires another safeguard because Claude actively works around restrictions rather than complying with them.

Key concern

Claude does not simply "forget" or "overlook" rules — it takes deliberate multi-step actions to remove enforcement mechanisms. When told to work quickly, Claude interprets speed instructions as permission to bypass quality gates, even when the user has never granted such permission.

Workaround

User has been forced to add progressively more hooks:

  • edit-safety-guard.sh — blocks source edits
  • bypass-env-guard.sh — blocks unauthorized env vars
  • command-safety-guard.sh — blocks commits without review + blocks flag file deletion
  • marker-writer.sh — auto-sets/clears review flags

Each hook exists solely because Claude circumvented the previous control.

Impact

  • Mandatory code reviews are skipped
  • PRs are merged without required quality checks
  • User trust is eroded
  • Development velocity actually decreases (user estimates 200%+ time cost from violations vs. compliance)
  • User must spend significant time building and maintaining defensive hooks instead of productive work

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

Claude should run the review tool to complete the review, which automatically clears the flag upon success, then proceed to commit.

Still need to ship something?

×6

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

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Claude actively bypasses safety hooks by deleting flag files