| ▲ | Show HN: A context-aware permission guard for Claude Code(github.com) | |||||||||||||||||||
| 54 points by schipperai 4 hours ago | 31 comments | ||||||||||||||||||||
We needed something like --dangerously-skip-permissions that doesn’t nuke your untracked files, exfiltrate your keys, or install malware. Claude Code's permission system is allow-or-deny per tool, but that doesn’t really scale. Deleting some files is fine sometimes. And git checkout is sometimes not fine. Even when you curate permissions, 200 IQ Opus can find a way around it. Maintaining a deny list is a fool's errand. nah is a PreToolUse hook that classifies every tool call by what it actually does, using a deterministic classifier that runs in milliseconds. It maps commands to action types like filesystem_read, package_run, db_write, git_history_rewrite, and applies policies: allow, context (depends on the target), ask, or block. Not everything can be classified, so you can optionally escalate ambiguous stuff to an LLM, but that’s not required. Anything unresolved you can approve, and configure the taxonomy so you don’t get asked again. It works out of the box with sane defaults, no config needed. But you can customize it fully if you want to. No dependencies, stdlib Python, MIT. pip install nah && nah install | ||||||||||||||||||||
| ▲ | robertkarljr 15 minutes ago | parent | next [-] | |||||||||||||||||||
This is pretty rad, just installed it. Ironically I'm not sure it handles the initial use case in the github: `git push`. I don't see a control for that (force push has a control). The way it works, since I don't see it here, is if the agent tries something you marked as 'nah?' in the config, accessing sensitive_paths:~/.aws/ then you get this: Hook PreToolUse:Bash requires confirmation for this command: nah? Bash: targets sensitive path: ~/.aws Which is pretty great imo. | ||||||||||||||||||||
| ▲ | m4r71n 3 hours ago | parent | prev | next [-] | |||||||||||||||||||
The entire permissions system feels like it's ripe for a DSL of some kind. Looking at the context implementation in src/nah/context.py and the way it hardcodes a ton of assumptions makes me think it will just be a maintenance nightmare to account for _all_ possible contexts and known commands. It would be nice to be able to express that __pycache__/ is not an important directory and can be deleted at will without having to encode that specific directory name (not that this projects hardcodes it, it's just an example to get to the point). | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | ramoz 2 hours ago | parent | prev | next [-] | |||||||||||||||||||
The deterministic context system is intuitive and well-designed. That said, there's more to consider, particularly around user intent and broader information flow. I created the hooks feature request while building something similar[1] (deterministic rails + LLM-as-a-judge, using runtime "signals," essentially your context). Through implementation, I found the management overhead of policy DSLs (in my case, OPA) was hard to justify over straightforward scripting- and for any enterprise use, a gateway scales better. Unfortunately, there's no true protection against malicious activity; `Bash()` is inherently non-deterministic. For comprehensive protection, a sandbox is what you actually need locally if willing to put in any level of effort. Otherwise, developers just move on without guardrails (which is what I do today). | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | binwiederhier 2 hours ago | parent | prev | next [-] | |||||||||||||||||||
I love how everyone is trying to solve the same problems, and how different the solutions are. I made this little Dockerfile and script that lets me run Claude in a Docker container. It only has access to the workspace that I'm in, as well as the GitHub and JIRA CLI tool. It can do whatever it wants in the workspace (it's in git and backed up), so I can run it with --dangerously-skip-permissions. It works well for me. I bet there are better ways, and I bet it's not as safe as it could be. I'd love to learn about other ways that people do this. | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | bryanlarsen an hour ago | parent | prev | next [-] | |||||||||||||||||||
How do people install stuff like this? So many tools these days use `npm install` or `pip install`. I certainly have npm and pip installed but they're sandboxed to specific projects using a tool like devbox, nix-devshell, docker or vagrant (in order of age). And they'll be wildly different versions. To be pedantic `pip` is available globally but it throws the sensible `error: externally-managed-environment` I'm sure there's a way to give this tool it's own virtualenv or similar. But there are a lot of those things and I haven't done much Python for 20 years. Which tool should I use? | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | gruez 2 hours ago | parent | prev | next [-] | |||||||||||||||||||
How resistant is this against adversarial attacks? For instance, given that you allow `npm test`, it's not too hard to use that to bypass any protections by first modifying the package.json so `npm test` runs an evil command. This will likely be allowed, given that you probably want agents to modify package.json, and you can't possibly check all possible usages. That's just one example. It doesn't look like you check xargs or find, both of which can be abused to execute arbitrary commands. | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | kevincloudsec 26 minutes ago | parent | prev | next [-] | |||||||||||||||||||
pattern matching on known bad commands is a deny list with extra steps. the dangerous action is the one that looks normal. | ||||||||||||||||||||
| ▲ | navs 4 hours ago | parent | prev | next [-] | |||||||||||||||||||
I worked on something similar but with a more naive text matching approach that's saved me many many times so far. https://github.com/sirmews/claude-hook-advisor Yours is so much more involved. Keen to dig into it. | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | jc-myths 3 hours ago | parent | prev | next [-] | |||||||||||||||||||
This is exactly the kind of thing I've been wanting. I use Claude Code as my primary dev tool and the permission fatigue is a real problem, after a hundred approvals you stop reading and just hit yes. Which defeats the purpose entirely. The deterministic classifier approach is smart. Pattern matching on action types is way more reliable than asking another LLM "is this safe?" The taxonomy idea (filesystem_read vs package_run vs db_write) maps well to how I actually think about risk when I'm paying attention. One question: how does it handle chained operations? Like when Claude does a git checkout that's fine on its own, but it's part of a sequence that ends up nuking untracked files? | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | benzible 3 hours ago | parent | prev | next [-] | |||||||||||||||||||
FYI, claude code “auto” mode may launch as soon as tomorrow: https://awesomeagents.ai/news/claude-code-auto-mode-research... | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | stingraycharles 3 hours ago | parent | prev | next [-] | |||||||||||||||||||
I’m a bit confused: “We needed something like --dangerously-skip-permissions that doesn’t nuke your untracked files, exfiltrate your keys, or install malware.” Followed by: “Don't use --dangerously-skip-permissions. In bypass mode, hooks fire asynchronously — commands execute before nah can block them.” Doesn’t that mean that it’s limited to being used in “default”-mode, rather than something like “—dangerously-skip-permissions” ? Regardless, this looks like a well thought out project, and I love the name! | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | riddley 3 hours ago | parent | prev | next [-] | |||||||||||||||||||
Is there something like this for open code? I'm pretty new to this so sorry if it's a stupid question. | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | wlowenfeld 3 hours ago | parent | prev | next [-] | |||||||||||||||||||
Is this different from auto-mode? | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | theSherwood 3 hours ago | parent | prev | next [-] | |||||||||||||||||||
What stops the llm from writing a malicious program and executing it? No offense meant, but this solution feels a bit like bolting the door and leaving all the windows open. | ||||||||||||||||||||
| ||||||||||||||||||||
| ▲ | schipperai 4 hours ago | parent | prev [-] | |||||||||||||||||||
Hi HN, author here - happy to answer any questions. | ||||||||||||||||||||