SShortSingh.
Back to feed

Guard Claude Code against destructive shell commands with a 40-line PreToolUse hook

0
·6 views

The author runs Claude Code unattended for overnight jobs and scheduled runs, where a single destructive command could be costly. Claude Code supports hooks, and a script that exits with code 2 blocks a tool call while feeding its stderr message back to the model. The post provides a Node.js hook that uses regex patterns to block commands such as recursive deletes of root or home, force-pushes to protected branches, git reset --hard, and unfiltered SQL deletes or drops. The hook is registered in settings.json, with notes on Windows path handling and a shell snippet for testing it with simulated tool calls. The author stresses that this is a regex-based seatbelt rather than a true sandbox, and recommends complementing it with behavioral rules in CLAUDE.md.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Free Browser-Based Concrete Calculators Built With Plain HTML and JavaScript

A developer from Pakistan created Concrete Calculator Now, a free set of US-unit concrete calculators built only from HTML, CSS, and JavaScript without frameworks or a build step. The site works either hosted online or offline by opening index.html directly from a saved folder. Its ten tools estimate poured volume, bag counts, blocks, weight, and cement-sand-gravel ratios, with no backend or third-party scripts. The article explains the approach, including converting slab thickness from inches to feet and applying a one-time waste allowance before calculating bag counts. The author also shares core functions to show how the math is structured and separated from the page interface.

0
ProgrammingDEV Community ·

FileHarbor: Open-Source Tool Turns Existing Hosting Into a File Storage API

A developer has released FileHarbor, an open-source, self-hosted file management server available in PHP and Node.js versions. It is designed to let users turn a VPS or shared hosting plan they already own into a file storage API. Applications can upload supported files such as images, videos, and documents, which remain ordinary files on the server while the application keeps its own metadata. The tool requires no mandatory external database server or Docker setup, offering an alternative to services like S3 and R2. The creator is developing the project openly and invites feedback, issues, and contributions.

0
ProgrammingDEV Community ·

Enterprise AI Needs Context and Decision Traceability, Not Just Vector Search

A DEV Community article argues that many AI agents can retrieve information but cannot explain how facts connect, where they originated, or why a decision was reached. It contends that enterprise AI requires knowledge graphs that link entities, evidence, and causal relationships. The author describes Semantica, a system whose ContextGraph API records decisions, links them causally, traces decision chains, and checks them against policy rules. The piece stresses that such provenance and explainability matter most in regulated sectors like finance and healthcare. It concludes by suggesting organizations audit individual AI decisions to determine whether they have full decision-intelligence infrastructure.

0
ProgrammingDEV Community ·

Practical Cybersecurity Tips Small Businesses Can Use to Protect Their Data

Cybersecurity is increasingly vital for businesses, yet small companies are especially exposed to threats like phishing, ransomware, and data breaches due to limited resources and dedicated IT staff. The article outlines 16 practical measures, such as using strong unique passwords and enabling two-factor authentication. It also recommends keeping software updated, training employees to spot social engineering, and securing Wi-Fi networks. Regular data backups following the 3-2-1 strategy are highlighted as a way to limit disruption from data loss.