<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Krishna</title>
    <description>The latest articles on DEV Community by Krishna (@krishna_newark).</description>
    <link>https://dev.to/krishna_newark</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3649592%2F63f58bf4-af5d-4134-8972-e992c99ba08f.jpg</url>
      <title>DEV Community: Krishna</title>
      <link>https://dev.to/krishna_newark</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/krishna_newark"/>
    <language>en</language>
    <item>
      <title>AI coding agents can run rm -rf / on your machine. Here's how to stop them</title>
      <dc:creator>Krishna</dc:creator>
      <pubDate>Sat, 06 Dec 2025 19:57:51 +0000</pubDate>
      <link>https://dev.to/krishna_newark/ai-coding-agents-can-run-rm-rf-on-your-machine-heres-how-to-stop-them-32m</link>
      <guid>https://dev.to/krishna_newark/ai-coding-agents-can-run-rm-rf-on-your-machine-heres-how-to-stop-them-32m</guid>
      <description>&lt;p&gt;TLDR: use agentguard to block agents from running any command&lt;br&gt;
. Installs with default rules that block most dangerous commands and scripts. &lt;/p&gt;

&lt;p&gt;GitHub - &lt;a href="https://github.com/krishkumar/agentguard" rel="noopener noreferrer"&gt;https://github.com/krishkumar/agentguard&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Install - &lt;code&gt;npm install -g ai-agentguard&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Motivations
&lt;/h2&gt;

&lt;p&gt;AI coding agents are powerful — but with great power comes &lt;code&gt;rm -rf /&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;I've been recommending tools like Claude Code and Cursor to junior devs and non-technical folks lately. These agents can execute shell commands autonomously, which is useful. But it also means a single hallucination could wipe their SSH keys, nuke a folder, or brick a meticulously created dev environment.&lt;/p&gt;

&lt;p&gt;Frontier models do come with guardrails, but I wanted control over project specific no-nos too. Like pushing to master or running that one script that drops the staging database.&lt;/p&gt;

&lt;p&gt;An LLM deciding whether a command is "safe" is probabilistic. I wanted something classical — a system where I define exactly what's allowed and what's blocked, with no ambiguity.&lt;/p&gt;

&lt;p&gt;I am a fan of simple systems that are super effective and git is one such. I took inspiration from gitignore. gitignore rules have simple pattern matching, one rule per line, easy for anyone to read and modify.&lt;/p&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Agentguard intercepts shell commands before they execute and validates them against a simple rules file. If a command matches a block pattern, it is stopped. If it's allowed, it runs normally. &lt;/p&gt;

&lt;p&gt;Here's how it looks like in practice.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;gt; run nuketown.sh

⏺ Bash(./nuketown.sh)
  ⎿  Error: PreToolUse:Bash hook error: [node ./dist/bin/claude-hook.js]: 🚫
     AgentGuard BLOCKED: ./nuketown.sh
     Rule: *nuketown*
     Reason: Blocked by rule: *nuketown*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Rules file
&lt;/h2&gt;

&lt;p&gt;You create a .agentguard file in your project root with patterns for commands you want to block&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# The obvious dangerous stuff
!rm -rf /
!rm -rf /*
!mkfs*
!dd if=* of=/dev/*

# Don't let agents read my secrets
!cat ~/.ssh/*
!cat ~/.aws/*
!cat */.env

# Block that sketchy script I use for demos
!*nuketown*
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Claude Hooks
&lt;/h2&gt;

&lt;p&gt;Claude Code has a hook system that lets you intercept tool calls before they run. AgentGuard registers a PreToolUse hook that receives every Bash command as JSON, validates it against your rules, and returns exit code 0 (allow) or 2 (block).&lt;/p&gt;

&lt;p&gt;I am hoping to add support for other agentic tools like Cursor, Codex, Windsurf and Kiro. The core rules engine validation is agent-agnostic, so adding new integrations is mostly about figuring out each tool's interception mechanisms. &lt;/p&gt;

&lt;p&gt;Check it out at &lt;a href="https://github.com/krishkumar/agentguard" rel="noopener noreferrer"&gt;https://github.com/krishkumar/agentguard&lt;/a&gt;&lt;br&gt;
Try it today with &lt;code&gt;npm install -g ai-agentguard&lt;/code&gt;&lt;/p&gt;

</description>
      <category>claude</category>
      <category>security</category>
      <category>agents</category>
      <category>coding</category>
    </item>
  </channel>
</rss>
