<?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: Ibrahim Musayev</title>
    <description>The latest articles on DEV Community by Ibrahim Musayev (@codehunter-py).</description>
    <link>https://dev.to/codehunter-py</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4281320%2Faafff674-1549-4e8e-9121-697672c7ef31.jpg</url>
      <title>DEV Community: Ibrahim Musayev</title>
      <link>https://dev.to/codehunter-py</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codehunter-py"/>
    <language>en</language>
    <item>
      <title>How I harden my AI coding agent</title>
      <dc:creator>Ibrahim Musayev</dc:creator>
      <pubDate>Thu, 03 Dec 2026 20:01:10 +0000</pubDate>
      <link>https://dev.to/codehunter-py/how-i-harden-my-ai-coding-agent-3pl9</link>
      <guid>https://dev.to/codehunter-py/how-i-harden-my-ai-coding-agent-3pl9</guid>
      <description>&lt;p&gt;I once asked an AI agent to delete a project's cache folder. It ran &lt;code&gt;rm -rf&lt;/code&gt; on the whole project folder.&lt;/p&gt;

&lt;p&gt;This was on my laptop, and the agent had almost full access to my file system. Luckily I had daily backups, so I restored the project in a couple of minutes. Another time, agents opened ports that should have stayed closed and ran commands they shouldn't have run.&lt;/p&gt;

&lt;p&gt;That's when I stopped treating the agent as a helper and started treating it like any process I don't fully trust. It runs with my permissions, so its mistakes are my mistakes.&lt;/p&gt;

&lt;p&gt;These are the rules I use now.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. I approve every change
&lt;/h2&gt;

&lt;p&gt;The agent can read freely. Every write, install or command with side effects waits for my yes.&lt;/p&gt;

&lt;p&gt;Sometimes that slows me down. When it does, I give the agent a short allowlist of safe commands it can run without asking. Everything else still waits for me. This has already stopped it from deleting files I didn't want deleted.&lt;/p&gt;

&lt;p&gt;Auto-accept and skip-permission modes stay off.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Nothing installs on my Mac
&lt;/h2&gt;

&lt;p&gt;I don't want a skill running a malicious Python script directly on my Mac. So the agent's tools, runtimes and packages live in a Lima VM with rootless Docker, and everything runs in containers. If something bad runs, it runs there, isolated from me.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The VM sees one shared folder and nothing else in my home directory.&lt;/li&gt;
&lt;li&gt;Containers are thrown away after each run. Mounts are read-only unless a test needs to write, and the network is off when nothing needs downloading.&lt;/li&gt;
&lt;li&gt;No &lt;code&gt;--privileged&lt;/code&gt;, no Docker socket, no &lt;code&gt;~/.ssh&lt;/code&gt;, no env files in a container.&lt;/li&gt;
&lt;li&gt;Tests run on a copy of the repo, not the real one.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. The agent never sees a secret
&lt;/h2&gt;

&lt;p&gt;The agent may check that a secret file exists. It never reads, prints or commits the value. To check that a credential works, it looks at the result, not the value.&lt;/p&gt;

&lt;p&gt;If a secret was ever committed, I rotate it, even in a private repo. Deleting it from the file doesn't delete it from git history.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Branches, pull requests, and I merge
&lt;/h2&gt;

&lt;p&gt;The agent works on a branch and never pushes without asking. Every change goes through a pull request with automated checks, and I read the diff before merging.&lt;/p&gt;

&lt;p&gt;When two agents share a repo, one develops and one reviews. Only I merge.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Every agent gets a written scope
&lt;/h2&gt;

&lt;p&gt;A written scope ties the agent to one job. Think of it as a harness.&lt;/p&gt;

&lt;p&gt;Review agents only get read-only tools. My security agent scans code, dependencies and public endpoints from an isolated container, and it's read-only by default. Active tests need my OK for each target and each technique. It can suggest changes to its own scope, but they only count once I merge them.&lt;/p&gt;

&lt;p&gt;I wouldn't recommend anyone run an agent with full access. An agent with full access is a ticking bomb. It can destroy your server at any time.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. On production, the agent writes the command and I run it
&lt;/h2&gt;

&lt;p&gt;On production servers, the agent hands me the commands instead of running them. Before anything irreversible, I take a snapshot. That's the backup lesson from the start of this post, turned into a rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Skills are third-party code
&lt;/h2&gt;

&lt;p&gt;A skill is a set of instructions the agent will follow, so I vet it like any dependency. I pin it to a commit and read it for prompt injection and data exfiltration before importing it. That's also why skills run inside the VM and not on my Mac.&lt;/p&gt;

&lt;h2&gt;
  
  
  The one rule
&lt;/h2&gt;

&lt;p&gt;If you keep one thing from this post: never give an agent more access than the job needs.&lt;/p&gt;

&lt;p&gt;My agent deleted a project folder because it could. Today it can't. That's not because the agent got smarter. It's because the environment won't let it.&lt;/p&gt;

&lt;p&gt;Which rule would you never run an agent without?&lt;/p&gt;

</description>
      <category>security</category>
      <category>ai</category>
      <category>devops</category>
      <category>linux</category>
    </item>
  </channel>
</rss>
