DEV Community

疏影
疏影

Posted on AI-assisted

Stop Worrying About AI Deleting Your Files. Map a Drive Letter Instead.

Every AI coding assistant user has had this nightmare:

You step away for 10 minutes. Come back. The agent has "optimized" your project structure. Half your files are gone. Your .env is in the recycle bin.

You didn't tell it to delete anything. It just... decided to.

The problem with "be careful"

You can add all the rules you want to your system prompt:

  • "Never delete files"
  • "Ask before making changes"
  • "Don't touch .env"

But the model doesn't care. It's predicting the next token. Sometimes it predicts "delete" instead of "keep". Sometimes context gets truncated and it forgets your rules. Sometimes it just makes a mistake.

Prompts are not security. They're suggestions.

The solution that actually works

Give the AI agent its own drive letter.

Create a folder for the task, map it to a drive on Windows, point the agent at that drive. Now the agent's entire world is that drive. It can delete everything in there — it's fine, that's what the folder is for. But it literally cannot see anything outside of it.

This is enforced by the operating system, not by the AI. The kernel doesn't care what the model wants.

How I do it

I use ScsSubst (https://subst.scsoi.com/) to manage my mapped drives. It's a GUI tool that wraps the Windows subst command, with persistent mappings that survive reboots. $9.99 lifetime, one-time purchase.

The built-in subst command works too, but mappings disappear after reboot. ScsSubst makes them stick.

The mental model

Think of it like a playpen for a toddler. You don't yell "don't touch the stove" — you put the toddler in a playpen where there is no stove.

Same thing for AI agents. Don't yell "don't delete files" — put the agent in a drive where there are no important files to delete.

It's the cheapest, most reliable safety measure you can take. And it costs less than a coffee.

Top comments (0)