Permission rules pre-approve safe actions and block dangerous ones, such as reading .env files, running curl or calling a particular MCP tool. They cut prompt fatigue, but allowlisted commands can be abused through argument injection, so rules work best inside a sandbox rather than instead of one. Keep deny rules for secrets and destructive commands in a centrally managed file.
Read in this order
- OfficialClaude Code: Configure permissionsStart here: a full worked rule system with allow, ask and deny tiers.
- ArticlePrompt injection to RCE in AI agents (Trail of Bits)Shows how allowlisted commands still led to remote code execution.
- OfficialGemini CLI: Policy engineA different rule engine, useful for comparing syntax and precedence.