update-allowed-tools

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Overview

概述

Analyzes a skill's full content -- SKILL.md and any sibling files in the same directory -- to find tools it references or requires, then compares against the skill's
allowed-tools
frontmatter to find missing entries.
分析技能的完整内容——SKILL.md文件及其所在目录中的所有同级文件——以查找其引用或需要的工具,然后与技能的
allowed-tools
前置元数据进行对比,找出缺失的条目。

Usage

使用方法

/update-allowed-tools <skill name>
/update-allowed-tools @path/to/SKILL.md
/update-allowed-tools <技能名称>
/update-allowed-tools @path/to/SKILL.md

Instructions

操作步骤

  1. Parse argument: The argument is either a file path to a SKILL.md file, or a skill name/description. If no file path is provided, search for the skill using Glob — first in the current working directory (e.g.,
    **/skills/**/<name>/SKILL.md
    ), then in
    ~/.claude/skills/**/<name>/SKILL.md
    .
  2. Read the skill file and separate the YAML frontmatter from the body content. Also read any other files in the same directory (sibling files referenced by or bundled with the skill).
  3. Extract declared allowed-tools: Parse all entries under
    allowed-tools:
    in the frontmatter.
  4. Scan all skill content (SKILL.md body + sibling files) for tool usage. Look for:
    • Explicit tool names: e.g.,
      Read
      ,
      Write
      ,
      Edit
      ,
      Bash
      ,
      WebFetch
      ,
      WebSearch
      ,
      Task
      ,
      AskUserQuestion
      ,
      Skill
      , etc.
    • Bash command patterns: e.g.,
      git diff
      ,
      git commit
      ,
      make
      ,
      npm
      ,
      docker
      ,
      python
      ,
      curl
      , etc.
    • For Bash commands found, the required allowed-tool format is
      Bash(<command>:*)
      (e.g.,
      git stash push
      needs
      Bash(git stash:*)
      )
    • For file tools with path patterns (Read, Write, Edit), note the paths referenced (e.g.,
      /tmp/
      needs
      Read(//tmp/**)
      )
    • Skill invocations: e.g.,
      /commit
      ,
      Use the /commit skill
      ,
      Skill(commit)
      . The required allowed-tool format is
      Skill(<name>)
      (e.g.,
      /commit
      needs
      Skill(commit)
      )
  5. Compare: For each tool detected in the body, check if it's covered by an entry in
    allowed-tools
    . Rules:
    • Glob
      ,
      Grep
      ,
      Read
      ,
      Write
      ,
      Edit
      are available by default for files within the project directory. Only add these when the skill needs to access files outside the project (e.g.,
      Read(//tmp/**)
      ,
      Write(~/.config/**)
      ).
    • Bash
      commands always need explicit
      Bash(<command>:*)
      entries.
    • A Bash pattern covers subcommands (e.g.,
      Bash(git stash:*)
      covers
      git stash push
      ).
    • Exact match counts as covered (e.g.,
      WebSearch
      matches
      WebSearch
      ).
  6. Update the skill file: For any missing tools found, add them to the
    allowed-tools
    list in the skill's YAML frontmatter using the Edit tool. Then report what was added.
  7. Validate: Re-read the updated file to confirm YAML frontmatter remains syntactically valid (proper indentation, no duplicate entries, correct list format).
  1. 解析参数:参数可以是SKILL.md文件的路径,也可以是技能名称/描述。如果未提供文件路径,则使用Glob搜索技能——首先在当前工作目录中搜索(例如:
    **/skills/**/<名称>/SKILL.md
    ),然后在
    ~/.claude/skills/**/<名称>/SKILL.md
    中搜索。
  2. 读取技能文件,将YAML前置元数据与正文内容分离。同时读取该目录中的其他所有文件(技能引用或捆绑的同级文件)。
  3. 提取已声明的allowed-tools:解析前置元数据中
    allowed-tools:
    下的所有条目。
  4. 扫描所有技能内容(SKILL.md正文 + 同级文件)以查找工具使用情况。需查找:
    • 明确的工具名称:例如
      Read
      Write
      Edit
      Bash
      WebFetch
      WebSearch
      Task
      AskUserQuestion
      Skill
      等。
    • Bash命令模式:例如
      git diff
      git commit
      make
      npm
      docker
      python
      curl
      等。
    • 对于找到的Bash命令,所需的allowed-tools格式为
      Bash(<command>:*)
      (例如:
      git stash push
      需要
      Bash(git stash:*)
    • 对于带有路径模式的文件工具(Read、Write、Edit),记录引用的路径(例如:
      /tmp/
      需要
      Read(//tmp/**)
    • 技能调用:例如
      /commit
      Use the /commit skill
      Skill(commit)
      。所需的allowed-tools格式为
      Skill(<name>)
      (例如:
      /commit
      需要
      Skill(commit)
  5. 对比:对于在正文中检测到的每个工具,检查它是否被allowed-tools中的条目覆盖。规则如下:
    • Glob
      Grep
      Read
      Write
      Edit
      默认可用于项目目录内的文件。仅当技能需要访问项目外部的文件时才添加这些工具(例如:
      Read(//tmp/**)
      Write(~/.config/**)
      )。
    • Bash命令始终需要显式的
      Bash(<command>:*)
      条目。
    • 一个Bash模式涵盖其子命令(例如:
      Bash(git stash:*)
      涵盖
      git stash push
      )。
    • 完全匹配即视为已覆盖(例如:
      WebSearch
      匹配
      WebSearch
      )。
  6. 更新技能文件:对于找到的所有缺失工具,使用Edit工具将其添加到技能YAML前置元数据的
    allowed-tools
    列表中。然后报告添加的内容。
  7. 验证:重新读取更新后的文件,确认YAML前置元数据在语法上仍然有效(正确的缩进、无重复条目、正确的列表格式)。