Claude's harness now employs a sophisticated script called pre-tool-use.js to block direct commits and pushes to the main branch, addressing various bypass techniques.
This script:
- Parses refspecs for commands like
git push origin HEAD:main. - Detects implicit refspec updates when
HEADis on a protected branch. - Blocks broad-mode flags such as
--alland--mirror. - Identifies commit-producing subcommands other than
git commit, includingmerge,rebase, etc. - Handles nested-shell bypasses using recursive evaluation up to four levels deep.
- Evaluates chained commands split by logical operators (
&&,||,;) or pipes.
These measures ensure that the policy "block direct commits and pushes to main" is enforced comprehensively, preventing agents from executing destructive operations under automation.
Read the full article at DEV Community
Want to create content about this topic? Use Nemati AI tools to generate articles, social posts, and more.

![[AINews] The Unreasonable Effectiveness of Closing the Loop](/_next/image?url=https%3A%2F%2Fmedia.nemati.ai%2Fmedia%2Fblog%2Fimages%2Farticles%2F600e22851bc7453b.webp&w=3840&q=75)



