Claude Wiped Production .env: I Wrote a Guide to Stop It
FeralFancyBop · reddit · 2026-08-26
Following an incident where Claude Code wiped a production .env file, the author analyzes why standard permission rules (e.g., Bash(rm .env)) failed—due to path mismatches, command variants (like redirects), and content leaks. A two-layer defense strategy is proposed:
- Optimized Deny List: Covers Read/Edit of .env paths and common Bash variants, enforcing blocks even in bypass mode.
- PreToolUse Hook: Intercepts tool calls before permission evaluation, catching nested paths and keys in diffs. The author released an open-source tool, claude-code-guardrails.
This setup mitigates mistakes and casual prompt injection but is not a sandbox; direct file access via Python scripts remains a risk.
More from coding & agent
- open-daytona: rootless gVisor sandbox pool runs 1,536 concurrent agent-RL sandboxes on Slurm — victor_explore · 2026-11-30
- SteerCamp launches on iPhone: AI coworkers run cloud PCs while you approve on the go — pramodk73 · 2026-11-30
- Returning to Squad after 6 months: the agent OS feels far more mature — ayushtweetshere · 2026-11-30
- Indie dev vibe-codes a native iOS RSS app with 183 curated AI sources, awaiting TestFlight — vista8 · 2026-11-30
- AI Slides: Why Text-Layer Separation and Native PPTX Both Fall Short, and When to Pick Which — dotey · 2026-11-30
- Taku OS: open-source Android build embeds AI agents at the OS level — RevolutionStandard56 · 2026-11-30