Claude Code Now Blocks Destructive Git Commands

Claude Code recently added a new safety feature. It now blocks destructive git commands in auto mode.

A few months ago, an AI agent almost deleted my work. I asked it to look at old code. It ran git reset --hard. This command wiped out all my uncommitted changes. I lost a whole day of work.

Since then, I manually added deny rules to my settings. I wanted to stop commands like git reset or git clean from running without my direct permission.

Now, Claude Code does this automatically. It uses a safety classifier to guess your intent. If it thinks you did not ask to throw work away, it stops the command.

At first, I thought about deleting my manual rules. Why do extra work if the tool does it for you? Then I realized why I must keep them.

The new safety feature is an inference. It is a model trying to guess what you want. Models can make mistakes. If the model is unavailable, the system might fail or misjudge you.

My manual rules are different. They are deterministic. A rule does not guess. It either matches the command or it does not. It is a hard line that never changes based on intent.

I now use three layers of defense:

• The classifier for intent. It understands your goals. • My deny rules for certainty. They provide a hard backstop for specific commands. • The sandbox for containment. It keeps the agent inside your project folder.

The new default is great, but it does not cover everything. It does not stop rm -rf. It does not stop a database wipe. It does not stop a force-push to your main branch.

Do not delete your custom safety rules just because a tool adds a new default. Use the new default as a reason to audit your setup. Keep your rules as a backup and use your extra time to protect the gaps the tool missed.

Defense in depth is about stacking layers. The safest system is the one where three different checks refuse a mistake instead of one.

Source: https://code.claude.com/docs/en/changelog

Optional learning community: https://t.me/GyaanSetuAi