Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I simply forbid or force Claude Code to ask for permission to run a dangerous command. Here are my command validation rules:

    (
        r"\bbfs.*-exec",
        decision("deny", reason="NEVER run commands with bfs"),
    ),
    (
        r"\bbfs.*-delete",
        decision("deny", reason="NEVER delete files with bfs."),
    ),
    (
        r"\bsudo\b",
        decision("ask"),
    ),
    (
        r"\brm.*--no-preserve-root",
        decision("deny"),
    ),
    (
        r"\brm.*(-[rRf]+|--recursive|--force)",
        decision("ask"),
    ),

find and bfs -exec is forbidden, because when the model notices it can't delete, it works around with very creative solutions :)




This feels a lot like trying to sanitize database inputs instead of using prepared statements.

What's the equivalent of prepared statements when using AI agents?

Don't have the AI run the commands. You read them, consider them, and then run them yourself.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: