中文译文
任务:更新 Agent 权限
请分析我们的整个对话,并识别出所有使用过的具体命令。
为 Claude Code 和 Gemini CLI 两者更新权限。
参考文件
- Claude:~/.claude/settings.json
- Gemini 策略:~/.gemini/policies/tool-permissions.toml
- Gemini 设置:~/.gemini/settings.json
- Gemini 受信任文件夹:~/.gemini/trustedFolders.json
指令
- 审计:将识别出的命令与两个配置文件中当前允许的命令进行对比。
- 筛选:只包含提供资源只读访问权限的命令。
- 限制:明确排除任何能够修改、删除或销毁数据的命令。
- 更新:只将缺失的只读命令添加到两个配置文件中。
- 约束:不要使用通配符。每条命令必须单独列出,以实现细粒度安全控制。
将命令列表按两个类别展示给我:只读(Read-Only)和写入(Write)。
我们这里主要关注的是属于以下类别的只读命令:Read、Get、Describe、View 或类似类别。
一旦我批准了该列表,就更新两个配置文件。
Claude 格式
文件:~/.claude/settings.json
Claude 使用一个 JSON 权限对象,包含 allow、deny 和 ask 数组。
允许格式:Bash(command subcommand:*)
将新命令按字母顺序插入 allow 数组内。
Gemini 格式
文件:~/.gemini/policies/tool-permissions.toml
Gemini 使用一个 TOML 策略引擎,规则位于不同的优先级层级。
规则类型与优先级:
decision = "deny"位于priority = 200,用于破坏性操作decision = "ask_user"位于priority = 150,用于需要确认的写入操作decision = "allow"位于priority = 100,用于只读操作
对于 allow 规则,使用 commandPrefix(提供词边界匹配)。
对于 deny 和 ask 规则,使用 commandRegex(捕获标志变体)。
新的只读命令应按类别添加到相应的现有 [[rule]] 块中,如果没有合适的类别,则添加到一个新块中。
示例 allow 规则:
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["command subcommand1", "command subcommand2"]
decision = "allow"
priority = 100
Gemini 目录
如果访问了工作区之外的任何新目录,请将它们添加到:
~/.gemini/settings.json中的context.includeDirectories- ~/.gemini/trustedFolders.json,值为
"TRUST_FOLDER"
例外情况
不要建议添加以下命令:
- git branch:使用 -D 标志将删除分支
- git pull:以防触发合并操作
- git checkout:切换分支可能会中断工作
- ajira issue create:为防止过度创建新问题
- find:-delete 和 -exec 标志具有破坏性(请改用 fd)
English original
Task: Update Agent Permissions
Please analyse our entire conversation and identify all specific commands used.
Update permissions for both Claude Code and Gemini CLI.
Reference Files
- Claude: ~/.claude/settings.json
- Gemini policy: ~/.gemini/policies/tool-permissions.toml
- Gemini settings: ~/.gemini/settings.json
- Gemini trusted folders: ~/.gemini/trustedFolders.json
Instructions
- Audit: Compare the identified commands against the current allowed commands in both config files.
- Filter: Only include commands that provide read-only access to resources.
- Restrict: Explicitly exclude any commands capable of modifying, deleting, or destroying data.
- Update: Add only the missing read-only commands to both config files.
- Constraint: Do not use wildcards. Each command must be listed individually for granular security.
Show me the list of commands under two categories: Read-Only, and Write
We are mostly interested in the read-only commands here that fall under the categories: Read, Get, Describe, View, or similar.
Once I have approved the list, update both config files.
Claude Format
File: ~/.claude/settings.json
Claude uses a JSON permissions object with allow, deny, and ask arrays.
Allow format: Bash(command subcommand:*)
Insert new commands in alphabetical order within the allow array.
Gemini Format
File: ~/.gemini/policies/tool-permissions.toml
Gemini uses a TOML policy engine with rules at different priority levels.
Rule types and priorities:
decision = "deny"atpriority = 200for destructive operationsdecision = "ask_user"atpriority = 150for write operations needing confirmationdecision = "allow"atpriority = 100for read-only operations
For allow rules, use commandPrefix (provides word-boundary matching).
For deny and ask rules, use commandRegex (catches flag variants).
New read-only commands should be added to the appropriate existing [[rule]] block by category, or a new block if no category fits.
Example allow rule:
[[rule]]
toolName = "run_shell_command"
commandPrefix = ["command subcommand1", "command subcommand2"]
decision = "allow"
priority = 100
Gemini Directories
If any new directories outside the workspace were accessed, add them to:
context.includeDirectoriesin ~/.gemini/settings.json- ~/.gemini/trustedFolders.json with value
"TRUST_FOLDER"
Exceptions
Do not suggest adding the following commands:
- git branch: The -D flag will delete branches
- git pull: Incase a merge is actioned
- git checkout: Changing branches can interrupt work
- ajira issue create: To prevent excessive creation of new issues
- find: The -delete and -exec flags are destructive (use fd instead)