# 技能扩展

> ## 文档 索引
> 获取 the 完成 文档 索引 at: https://代码.claude.com/docs/llms.txt
> 使用 this 文件 to disc结束 所有 可用 页s 之前探索 further.

# 使用技能扩展 Claude

> 创建, manage, and 分享技能 to ext结束 Claude's 能力 in Claude 代码. Includes 习俗 命令 and 捆绑d 技能.

技能 ext结束 what Claude can do. 创建 a `技能.md` 文件 with 说明, and Claude 添加s it to its 工具包. Claude 使用s 技能 when 相关, or you can invoke one 直接ly with `/技能-名称`.

  For built-in 命令 像 `/帮助` and `/紧凑`,看见 the [built-in 命令 参考](/en/命令).

  **习俗 命令 have been 合并 into 技能.** A 文件 at `.claude/命令/部署.md` and a 技能 at `.claude/技能/部署/技能.md` 机器人h 创建 `/部署` and 工作 the 相同 方式. Your 现有 `.claude/命令/` 文件 keep工作. 技能 添加 可选 features: a 目录 for 支持ing 文件, front事情 to [控制 whether you or Claude invokes them](#控制-who-invokes-a-技能), and the ability for Claude to 加载 them 自动所有y when 相关.

Claude 代码 技能 fol低 the [代理 技能](https://代理技能.io) 打开 标准, which 工作s across mul提示le AI 工具. Claude 代码 ext结束s the 标准 with 添加itional features 像 [invocation 控制](#控制-who-invokes-a-技能), [sub代理 执行](#运行-技能-in-a-sub代理), and [动态 上下文 injection](#inject-动态-上下文).

## 捆绑d 技能

捆绑d 技能 ship with Claude 代码 and are 可用 in 每个 会话. 不像 [built-in 命令](/en/命令), which 执行 固定 日志ic 直接ly, 捆绑d 技能 are 及时-基础d: they give Claude a 详情ed playbook and let it orchest速率 the 工作 using its 工具. This 手段 捆绑d 技能 can spawn 平行 代理s, 读取 文件, and adapt to your 代码基础.

You invoke 捆绑d 技能 the 相同 方式 as 任何 other 技能: 类型 `/` foll欠 by the 技能 名称. In the 表 be低, `` indicates a 必需 论点 and `[arg]` indicates an 可选 one.

| 技能                       | 目的                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| :-------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `/batch `      | Orchest速率 large-scale 更改s across a 代码基础 in 平行.研究es the 代码基础,分解s the 工作 into 5 to 30 独立 单位s, and 现在s a 计划. Once 批准, spawns one 背景 代理 per 单位 in an iso晚d [Git 工作树](/en/常见-工作流s#运行-平行-claude-代码-会话s-with-Git-工作树). 每个 代理 实现s its 单位, 运行s 测试s, and 打开s a 拉取请求. Requ怒s a Git 仓库. 示例: `/batch mig速率 src/ from 固体 to React` |
| `/claude-api`               | 加载 Claude API 参考 物质 for your 项目's language (Python, 类型脚本, Java, 前往, Ruby, C#, pH值P, or cURL) and 代理 SDK 参考 for Python and 类型脚本. C结束s 工具 使用, 流ing, batches, 结构化 输出s, and 常见 pit下降s. Also 激活s 自动所有y when your 代码 进口s `anthropic`, `@anthropic-ai/sdk`, or `claude_代理_sdk`                                                                                                                 |
| `/调试 [描述]`      | 启用 调试日志 for the 当前 会话 and 麻烦shoot 问题s by 读取ing the 会话 调试 日志. 调试日志 is off by 默认 un较少 you 开始 with `claude --调试`, so 运行中 `/调试` mid-会话 启动s capturing 日志s from that point 前进. 可选ly describe the 问题 to 焦点 the 分析                                                                                                                                                                |
| `/loop [间隔] ` | 运行 a 及时 repeatedly on an 间隔 while the 会话 stays 打开. 有用 for polling a 部署ment, baby坐 a PR, or 期间ic所有y re-运行中 another 技能. 示例: `/loop 5m 检查 if the 部署 完成`.看见 [运行 及时s on a 时间表](/en/计划-任务s)                                                                                                                                                                                                           |
| `/simplify [焦点]`         | Re视图 your 最近ly 更改d 文件 for 代码 re使用, quality, and efficiency 问题s, then 修复 them. Spawns three re视图 代理s in 平行, aggregates their发现s, and 应用lies 修复es. Pass 文本 to 焦点 on 特定 关心s: `/simplify 焦点 on 记忆 efficiency`                                                                                                                                                                                                            |

## 入门

### 创建 your 第一个 技能

This 示例 创建s a 技能 that t每个es Claude to ex简单 代码 using visual 图表s and ana日志ies. Since it 使用s 默认 front事情, Claude can 加载 it 自动所有y when you ask how 一些薄g 工作s, or you can invoke it 直接ly with `/ex简单-代码`.

  
    创建 a 目录 for the 技能 in your 个人 技能 文件夹. 个人 技能 are 可用 across 所有 your 项目s.

    ```bash  主题={空}
    mkdir -p ~/.claude/技能/ex简单-代码
    ```
  

  
    每个 技能 需要s a `技能.md` 文件 with two 部分s: YAML front事情 (between `---` 标记s) that tells Claude when to 使用 the 技能, and mark下 满意 with 说明 Claude fol低s when the 技能 is invoked. The `名称` 字段 becomes the `/slash-命令`, and the `描述` 帮助s Claude decide when to 加载 it 自动所有y.

    创建 `~/.claude/技能/ex简单-代码/技能.md`:

    ```yaml  主题={空}
    ---
    名称: ex简单-代码
    描述: Ex简单s 代码 with visual 图表s and ana日志ies. 使用 when ex简单ing how 代码 工作s,教学 about a 代码基础, or when the 用户 asks "how does this 工作?"
    ---

    When ex简单ing 代码, al方式s include:

    1. **启动 with an ana日志y**: 比较 the 代码 to 一些薄g from 日常 life
    2. **Draw a 图表**: 使用 ASCII 艺术 to 显示 the f低, 结构, or relationships
    3. **走 th粗糙 the 代码**: Ex简单步骤-by-步骤 what h应用ens
    4. **高轻 a 前往tcha**: What's a 常见 薄雾ake or mis概念ion?

    Keep 解释s 对话al. For 复杂 概念s, 使用 mul提示le ana日志ies.
    ```
  

  
    You can 测试 it two 方式s:

    **Let Claude invoke it 自动所有y** by询问 一些薄g that 匹配es the 描述:

    ```文本  主题={空}
    How does this 代码 工作?
    ```

    **Or invoke it 直接ly** with the 技能 名称:

    ```文本  主题={空}
    /ex简单-代码 src/auth/日志in.ts
    ```

    Either 方式, Claude should include an ana日志y and ASCII 图表 in its 解释.
  

### Where 技能 live

Where you store a 技能 determines who can 使用 it:

| Location   | 路径                                                | 应用lies to                     |
| :--------- | :-------------------------------------------------- | :----------------------------- |
| 企业 |看见 [管理 设置](/en/设置#设置-文件) | 所有 用户s in your 组织 |
| 个人   | `~/.claude/技能//技能.md`            | 所有 your 项目s              |
| 项目    | `.claude/技能//技能.md`              | This 项目 only              |
| 插件     | `/技能//技能.md`             | Where 插件 is 启用        |

When 技能 share the 相同 名称 across 级别s, 高er-优先级 locations win: 企业 > 个人 > 项目. 插件 技能 使用 a `插件-名称:技能-名称` 名称s步伐, so they cannot conflict with other 级别s. If you have 文件 in `.claude/命令/`, those 工作 the 相同 方式, but if a 技能 and a 命令 share the 相同 名称, the 技能 takes precedence.

#### 自动 发现 from nested 总监ies

When you 工作 with 文件 in sub总监ies, Claude 代码 自动所有y disc结束s 技能 from nested `.claude/技能/` 总监ies. For 示例, if you're 编辑ing a 文件 in `包s/front结束/`, Claude 代码 also看s for 技能 in `包s/front结束/.claude/技能/`. This 支持s monorepo 设置s where 包s have their own 技能.

每个 技能 is a 目录 with `技能.md` as the 条目point:

```文本  主题={空}
my-技能/
├── 技能.md           # 主 说明 (必需)
├── 模板.md        # 模板 for Claude to fill in
├── 示例/
│   └── 样本.md      # 示例 输出显示 预期 格式
└── 脚本s/
    └── 验证.sh    # 脚本 Claude can 执行
```

The `技能.md` contains the 主 说明 and is 必需. Other 文件 are 可选 and let you 构建 更多 强大 技能: 模板s for Claude to fill in, 示例 输出s显示 the 预期 格式, 脚本s Claude can 执行, or 详情ed 参考 文档. 参考 these 文件 from your `技能.md` so Claude knows what they contain and when to 加载 them.看见 [添加 支持ing 文件](#添加-支持ing-文件) for 更多 详情s.

  文件 in `.claude/命令/` 静止 工作 and 支持 the 相同 [front事情](#front事情-参考). 技能 are 推荐 since they 支持 添加itional features 像 支持ing 文件.

#### 技能 from 添加itional 总监ies

The `--添加-dir` flag [授予s 文件 access](/en/权限#添加itional-总监ies-授予-文件-access-not-配置) rather than 配置 发现, but 技能 are an 异常: `.claude/技能/` 在...内 an 加 目录 is 加载 自动所有y and picked 上 by live 更改 检测, so you can 编辑 those 技能 期间 a 会话 without 重启ing.

Other `.claude/` 配置 such as 子代理, 命令, and 输出 styles is not 加载 from 添加itional 总监ies.看见 the [异常 表](/en/权限#添加itional-总监ies-授予-文件-access-not-配置) for the 完成 列表 of what is and isn't 加载, and the 推荐 方式s to share 配置 across 项目s.

  CLAUDE.md 文件 from `--添加-dir` 总监ies are not 加载 by 默认. To 加载 them, 设置 `CLAUDE_代码_添加ITIONAL_总监IES_CLAUDE_MD=1`.看见 [加载 from 添加itional 总监ies](/en/记忆#加载-from-添加itional-总监ies).

## Con图 技能

技能 are con图d th粗糙 YAML front事情 at the 顶部 of `技能.md` and the mark下 满意 that fol低s.

### 类型s of 技能 满意

技能 文件 can contain 任何 说明, but思考 about how you 想要 to invoke them 帮助s 指南 what to include:

**参考 满意** 添加s 知识 Claude 应用lies to your 当前 工作. 惯例, 模式s, style 指南s, do主 知识. This 满意 运行s in行 so Claude can 使用 it a长side your 对话 上下文.

```yaml  主题={空}
---
名称: api-惯例
描述: API 设计模式s for this 代码基础
---

When写作 API 结束points:
- 使用 安静 naming 惯例
- 回报 一致 错误 格式s
- Include 请求 验证
```

**任务 满意** gives Claude步骤-by-步骤 说明 for a 特定 行动, 像 部署ments, 提交s, or 代码 生成. These are often 行动s you 想要 to invoke 直接ly with `/技能-名称` rather than让 Claude decide when to 运行 them. 添加 `禁用-模型-invocation: 真实` to pr事件 Claude from triggering it 自动所有y.

```yaml  主题={空}
---
名称: 部署
描述: 部署 the 应用程序 to 生产
上下文: 分叉
禁用-模型-invocation: 真实
---

部署 the 应用程序:
1. 运行 the 测试 suite
2. 构建 the 应用程序
3. 推送 to the 部署ment 目标
```

Your `技能.md` can contain 任何薄g, but思考 th粗糙 how you 想要 the 技能 invoked (by you, by Claude, or 机器人h) and where you 想要 it to 运行 (in行 or in a sub代理) 帮助s 指南 what to include. For 复杂 技能, you can also [添加 支持ing 文件](#添加-支持ing-文件) to keep the 主 技能 焦点ed.

### Front事情 参考

超出 the mark下 满意, you can con图 技能 behavior using YAML front事情 字段s between `---` 标记s at the 顶部 of your `技能.md` 文件:

```yaml  主题={空}
---
名称: my-技能
描述: What this 技能 does
禁用-模型-invocation: 真实
允许-工具: 读取 Grep
---

Your 技能 说明 here...
```

所有 字段s are 可选. Only `描述` is 推荐 so Claude knows when to 使用 the 技能.

| 字段                      | 必需    | 描述                                                                                                                                                                                                                                                                               |
| :------------------------- | :---------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `名称`                     | No          | 显示 名称 for the 技能. If omitted, 使用s the 目录 名称. 低er案例 letters, 数字s, and hypH值ens only (max 64 字符s).                                                                                                                                                        |
| `描述`              | 推荐 | What the 技能 does and when to 使用 it. Claude 使用s this to decide when to 应用ly the 技能. If omitted, 使用s the 第一个 段落 of mark下 满意. Front-加载 the 键 使用 案例: 描述s 长er than 250 字符s are t运行cated in the 技能列表 to reduce 上下文 使用方法.    |
| `论点-暗示`            | No          | 暗示 显示n 期间 auto完成 to indicate 预期 参数. 示例: `[问题-数字]` or `[文件名称] [格式]`.                                                                                                                                                                        |
| `禁用-模型-invocation` | No          | 设置 to `真实` to pr事件 Claude from 自动所有y 加载ing this 技能. 使用 for 工作流s you 想要 to trigger 手册ly with `/名称`. 默认: `虚假`.                                                                                                                                     |
| `用户-invoc能够`           | No          | 设置 to `虚假` to 隐藏 from the `/` menu. 使用 for 背景 知识 用户s shouldn't invoke 直接ly. 默认: `真实`.                                                                                                                                                                  |
| `允许-工具`            | No          | 工具 Claude can 使用 without询问 许可 when this 技能 is 活跃. 接受s a s步伐-分离 字符串 or a YAML 列表.                                                                                                                                                                |
| `模型`                    | No          | 模型 to 使用 when this 技能 is 活跃.                                                                                                                                                                                                                                                   |
| `effort`                   | No          | [Effort 级别](/en/模型-config#ad公正-effort-级别) when this 技能 is 活跃. 结束rides the 会话 effort 级别. 默认: inherits from 会话. 选项: `低`, `中`, `高`, `max` (Opus 4.6 only).                                                                              |
| `上下文`                  | No          | 设置 to `分叉` to 运行 in a 分叉ed sub代理 上下文.                                                                                                                                                                                                                                        |
| `代理`                    | No          | Which sub代理 类型 to 使用 when `上下文: 分叉` is 设置.                                                                                                                                                                                                                                   |
| `钩子`                    | No          | 钩子 范围d to this 技能's lifecycle.看见 [钩子 in 技能 and 代理s](/en/钩子#钩子-in-技能-and-代理s) for 配置 格式.                                                                                                                                                  |
| `路径s`                    | No          | Glob 模式s that 限制 when this 技能 is 激活d. 接受s a comma-分离 字符串 or a YAML 列表. When 设置, Claude 加载s the 技能 自动所有y only when工作 with 文件 匹配 the 模式s. 使用s the 相同 格式 as [路径-特定 规则](/en/记忆#路径-特定-规则). |
| `命令行`                    | No          | 命令行 to 使用 for `` !`命令` `` 块s in this 技能. 接受s `bash` (默认) or `权力命令行`.设置 `权力命令行` 运行s in行 命令行 命令 via 权力命令行 on 风ows. Requ怒s `CLAUDE_代码_使用_权力命令行_工具=1`.                                                                |

#### 可用 字符串 substitutions

技能 支持 字符串 substitution for 动态 值s in the 技能 满意:

| 可变               | 描述                                                                                                                                                                                                                                                                              |
| :--------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$参数`           | 所有 参数 passed when invoking the 技能. If `$参数` is not 现在 in the 满意, 参数 are 应用结束 as `参数: `.                                                                                                                                             |
| `$参数[N]`        | Access a 特定 论点 by 0-基础d 索引, such as `$参数[0]` for the 第一个 论点.                                                                                                                                                                                             |
| `$N`                   | 短hand for `$参数[N]`, such as `$0` for the 第一个 论点 or `$1` for the second.                                                                                                                                                                                               |
| `${CLAUDE_会话_ID}` | The 当前 会话 ID. 有用 for日志,创建 会话-特定 文件, or关联 技能 输出 with 会话s.                                                                                                                                                                  |
| `${CLAUDE_技能_DIR}`  | The 目录包含 the 技能's `技能.md` 文件. For 插件 技能, this is the 技能's sub目录 在...内 the 插件, not the 插件 根. 使用 this in bash injection 命令 to 参考 脚本s or 文件 捆绑d with the 技能, 注意较少 of the 当前工作 目录. |

**示例 using substitutions:**

```yaml  主题={空}
---
名称: 会话-日志ger
描述: 日志 活动 for this 会话
---

日志 the跟随 to 日志s/${CLAUDE_会话_ID}.日志:

$参数
```

### 添加 支持ing 文件

技能 can include mul提示le 文件 in their 目录. This keeps `技能.md` 焦点ed on the 必要s while让 Claude access 详情ed 参考 物质 only when 需要ed. Large 参考 docs, API 规范s, or 示例 collections don't 需要 to 加载 into 上下文 每个 时间 the 技能 运行s.

```文本  主题={空}
my-技能/
├── 技能.md (必需 - 概述 and navigation)
├── 参考.md (详情ed API docs - 加载 when 需要ed)
├── 示例.md (使用方法 示例 - 加载 when 需要ed)
└── 脚本s/
    └── 帮助er.py (实用 脚本 - 执行d, not 加载)
```

参考 支持ing 文件 from `技能.md` so Claude knows what 每个 文件 contains and when to 加载 it:

```mark下  主题={空}
## 添加itional 资源

- For 完成 API 详情s,看见 [参考.md](参考.md)
- For 使用方法 示例,看见 [示例.md](示例.md)
```

Keep `技能.md` under 500 行s. 移动 详情ed 参考 物质 to 单独 文件.

### 控制 who invokes a 技能

By 默认, 机器人h you and Claude can invoke 任何 技能. You can 类型 `/技能-名称` to invoke it 直接ly, and Claude can 加载 it 自动所有y when 相关 to your 对话. Two front事情 字段s let you re严格 this:

* **`禁用-模型-invocation: 真实`**: Only you can invoke the 技能. 使用 this for 工作流s with side 效果s or that you 想要 to 控制 timing, 像 `/提交`, `/部署`, or `/发送-松弛-消息`. You don't 想要 Claude决定 to 部署 be原因 your 代码看s 就绪.

* **`用户-invoc能够: 虚假`**: Only Claude can invoke the 技能. 使用 this for 背景 知识 that isn't 行动能够 as a 命令. A `legacy-系统-上下文` 技能 ex简单s how an 旧 系统 工作s. Claude should know this when 相关, but `/legacy-系统-上下文` isn't a 有意义 行动 for 用户s to take.

This 示例 创建s a 部署 技能 that only you can trigger. The `禁用-模型-invocation: 真实` 字段 pr事件s Claude from 运行中 it 自动所有y:

```yaml  主题={空}
---
名称: 部署
描述: 部署 the 应用程序 to 生产
禁用-模型-invocation: 真实
---

部署 $参数 to 生产:

1. 运行 the 测试 suite
2. 构建 the 应用程序
3. 推送 to the 部署ment 目标
4. 验证 the 部署ment 成功
```

Here's how the two 字段s affect invocation and 上下文 加载ing:

| Front事情                      | You can invoke | Claude can invoke | When 加载 into 上下文                                     |
| :------------------------------- | :------------- | :---------------- | :----------------------------------------------------------- |
| (默认)                        | Yes            | Yes               | 描述 al方式s in 上下文, 满 技能 加载s when invoked |
| `禁用-模型-invocation: 真实` | Yes            | No                | 描述 not in 上下文, 满 技能 加载s when you invoke |
| `用户-invoc能够: 虚假`          | No             | Yes               | 描述 al方式s in 上下文, 满 技能 加载s when invoked |

  In a 常规 会话, 技能 描述s are 加载 into 上下文 so Claude knows what's 可用, but 满 技能 满意 only 加载s when invoked. [子代理 with p重新加载ed 技能](/en/sub-代理s#p重新加载-技能-into-子代理) 工作 不同ly: the 满 技能 满意 is injected at 启动上.

### Re严格 工具 access

使用 the `允许-工具` 字段 to 限制 which 工具 Claude can 使用 when a 技能 is 活跃. This 技能 创建s a 读取-only 模式 where Claude can探索 文件 but not 修改 them:

```yaml  主题={空}
---
名称: 安全-读取器
描述: 读取 文件 without制造 更改s
允许-工具: 读取 Grep Glob
---
```

### Pass 参数 to 技能

机器人h you and Claude can pass 参数 when invoking a 技能. 参数 are 可用 via the `$参数` placeh更旧.

This 技能 修复es a GitHub 问题 by 数字. The `$参数` placeh更旧 gets 替换d with whatever fol低s the 技能 名称:

```yaml  主题={空}
---
名称: 修复-问题
描述: 修复 a GitHub 问题
禁用-模型-invocation: 真实
---

修复 GitHub 问题 $参数跟随 our coding 标准.

1. 读取 the 问题 描述
2. Understand the 要求
3. 实现 the 修复
4. 写入 测试s
5. 创建 a 提交
```

When you 运行 `/修复-问题 123`, Claude 接收s "修复 GitHub 问题 123跟随 our coding 标准..."

If you invoke a 技能 with 参数 but the 技能 doesn't include `$参数`, Claude 代码 应用结束s `参数: ` to the 结束 of the 技能 满意 so Claude 静止看见s what you 类型化.

To access 个人 参数 by 位置, 使用 `$参数[N]` or the 短er `$N`:

```yaml  主题={空}
---
名称: mig速率-组件
描述: Mig速率 a 组件 from one 框架 to another
---

Mig速率 the $参数[0] 组件 from $参数[1] to $参数[2].
Preserve 所有 现有 behavior and 测试s.
```

运行中 `/mig速率-组件 搜索Bar React Vue` 替换s `$参数[0]` with `搜索Bar`, `$参数[1]` with `React`, and `$参数[2]` with `Vue`. The 相同 技能 using the `$N` 短hand:

```yaml  主题={空}
---
名称: mig速率-组件
描述: Mig速率 a 组件 from one 框架 to another
---

Mig速率 the $0 组件 from $1 to $2.
Preserve 所有 现有 behavior and 测试s.
```

## 先进 模式s

### Inject 动态 上下文

The `` !`` `` syn税 运行s 命令行 命令 之前 the 技能 满意 is 发送 to Claude. The 命令 输出 替换s the placeh更旧, so Claude 接收s 实际 数据, not the 命令 itself.

This 技能 总和marizes a 拉取请求 by 获取ing live PR 数据 with the GitHub CLI. The `` !`gh pr diff` `` and other 命令 运行 第一个, and their 输出 gets 插入 into the 及时:

```yaml  主题={空}
---
名称: pr-摘要
描述: 总和marize 更改s in a 拉取请求
上下文: 分叉
代理:探索
允许-工具: Bash(gh *)
---

## 拉取请求 上下文
- PR diff: !`gh pr diff`
- PR comments: !`gh pr视图 --comments`
- 更改d 文件: !`gh pr diff --名称-only`

## Your 任务
总和marize this 拉取请求...
```

When this 技能 运行s:

1. 每个 `` !`` `` 执行s 立即ly (之前 Claude看见s 任何薄g)
2. The 输出 替换s the placeh更旧 in the 技能 满意
3. Claude 接收s the 满y-r结束ered 及时 with 实际 PR 数据

This is pre处理中, not 一些薄g Claude 执行s. Claude only看见s the 最终 结果.

  To 启用 [延长思考](/en/常见-工作流s#使用-延长-薄king-薄king-模式) in a 技能, include the 词 "ultra薄k" 任何where in your 技能 满意.

### 运行 技能 in a sub代理

添加 `上下文: 分叉` to your front事情 when you 想要 a 技能 to 运行 in isolation. The 技能 满意 becomes the 及时 that drives the sub代理. It 获胜't have access to your 对话 history.

  `上下文: 分叉` only makes 感觉 for 技能 with 明确 说明. If your 技能 contains 准则 像 "使用 these API 惯例" without a 任务, the sub代理 接收s the 准则 but no 行动能够 及时, and 回报s without 有意义 输出.

技能 and [子代理](/en/sub-代理s) 工作 together in two 说明:

| 方法                     | 系统 及时                             | 任务                        | Also 加载s                   |
| :--------------------------- | :---------------------------------------- | :-------------------------- | :--------------------------- |
| 技能 with `上下文: 分叉`   | From 代理 类型 (`探索`, `计划`, etc.) | 技能.md 满意            | CLAUDE.md                    |
| Sub代理 with `技能` 字段 | Sub代理's mark下 正文                  | Claude's delegation 消息 | P重新加载ed 技能 + CLAUDE.md |

With `上下文: 分叉`, you 写入 the 任务 in your 技能 and pick an 代理 类型 to 执行 it. For the inverse (defining a 习俗 sub代理 that 使用s 技能 as 参考 物质),看见 [子代理](/en/sub-代理s#p重新加载-技能-into-子代理).

#### 示例:研究 技能 using探索 代理

This 技能 运行s研究 in a 分叉ed探索 代理. The 技能 满意 becomes the 任务, and the 代理 provides 读取-only 工具 优化 for 代码基础 探索:

```yaml  主题={空}
---
名称: 深-研究
描述:研究 a 话题 tho粗糙ly
上下文: 分叉
代理:探索
---

研究 $参数 tho粗糙ly:

1. 查找 相关 文件 using Glob and Grep
2. 读取 and分析 the 代码
3. 总和marize发现s with 特定 文件 参考文献
```

When this 技能 运行s:

1. A 新 iso晚d 上下文 is 创建d
2. The sub代理 接收s the 技能 满意 as its 及时 ("研究 \$参数 tho粗糙ly...")
3. The `代理` 字段 determines the 执行 环境 (模型, 工具, and 权限)
4. 结果s are 总和marized and 返回 to your 主 对话

The `代理` 字段 规格ifies which sub代理 配置 to 使用. 选项 include built-in 代理s (`探索`, `计划`, `一般-目的`) or 任何 习俗 sub代理 from `.claude/代理s/`. If omitted, 使用s `一般-目的`.

### Re严格 Claude's 技能 access

By 默认, Claude can invoke 任何 技能 that doesn't have `禁用-模型-invocation: 真实` 设置. 技能 that de好 `允许-工具` 授予 Claude access to those 工具 without per-使用 批准 when the 技能 is 活跃. Your [许可 设置](/en/权限) 静止 g结束n 基础行 批准 behavior for 所有 other 工具. Built-in 命令 像 `/紧凑` and `/init` are not 可用 th粗糙 the 技能 工具.

Three 方式s to 控制 which 技能 Claude can invoke:

**禁用 所有 技能** by 拒绝ing the 技能 工具 in `/权限`:

```文本  主题={空}
# 添加 to 拒绝 规则:
技能
```

**允许 or 拒绝 特定 技能** using [许可 规则](/en/权限):

```文本  主题={空}
# 允许 only 特定 技能
技能(提交)
技能(re视图-pr *)

# 拒绝 特定 技能
技能(部署 *)
```

许可 syn税: `技能(名称)` for 精确 匹配, `技能(名称 *)` for pre修复 匹配 with 任何 参数.

**隐藏 个人 技能** by添加 `禁用-模型-invocation: 真实` to their front事情. This 移除s the 技能 from Claude's 上下文 整个ly.

  The `用户-invoc能够` 字段 only 控制s menu 可见, not 技能 工具 access. 使用 `禁用-模型-invocation: 真实` to 块 计划matic invocation.

## 分享技能

技能 can be 分配 at 不同 范围s de待处理 on your audience:

* **项目 技能**: 提交 `.claude/技能/` to 版本 控制
* **插件s**: 创建 a `技能/` 目录 in your [插件](/en/插件s)
* **管理**: 部署 组织-wide th粗糙 [管理 设置](/en/设置#设置-文件)

### Gene速率 visual 输出

技能 can 捆绑 and 运行 脚本s in 任何 language,给 Claude 能力 超出 what's 可能 in a single 及时. One 强大 模式 is生成 visual 输出: 交互 HTML 文件 that 打开 in your 浏览器 for探索 数据, 调试ging, or创建 报告s.

This 示例 创建s a 代码基础探索r: an 交互 树视图 where you can expand and collapse 总监ies,看见 文件 尺寸s at a一瞥, and identify 文件 类型s by color.

创建 the 技能 目录:

```bash  主题={空}
mkdir -p ~/.claude/技能/代码基础-visualizer/脚本s
```

创建 `~/.claude/技能/代码基础-visualizer/技能.md`. The 描述 tells Claude when to 激活 this 技能, and the 说明 tell Claude to 运行 the 捆绑d 脚本:

````yaml  主题={空}
---
名称: 代码基础-visualizer
描述: Gene速率 an 交互 collapsible 树 可视化 of your 代码基础. 使用 when探索 a 新 repo, 理解 项目 结构, or识别 large 文件.
允许-工具: Bash(python *)
---

# 代码基础 Visualizer

Gene速率 an 交互 HTML 树视图 that 显示s your 项目's 文件 结构 with collapsible 总监ies.

## 使用方法

运行 the 可视化 脚本 from your 项目 根:

```bash
python ~/.claude/技能/代码基础-visualizer/脚本s/visualize.py .
```

This 创建s `代码基础-映射.html` in the 当前 目录 and 打开s it in your 默认 浏览器.

## What the 可视化 显示s

- **Collapsible 总监ies**: Click 文件夹s to expand/collapse
- **文件 尺寸s**: 显示ed 下一个 to 每个 文件
- **Colors**: 不同 colors for 不同 文件 类型s
- **目录 总计s**: 显示s aggregate 尺寸 of 每个 文件夹
````

创建 `~/.claude/技能/代码基础-visualizer/脚本s/visualize.py`. This 脚本扫描s a 目录 树 and gene速率s a self-contained HTML 文件 with:

* A **摘要 侧边栏**显示 文件 count, 目录 count, 总计 尺寸, and 数字 of 文件 类型s
* A **bar 图表** breaking 下 the 代码基础 by 文件 类型 (顶部 8 by 尺寸)
* A **collapsible 树** where you can expand and collapse 总监ies, with color-代码d 文件 类型 指标s

The 脚本 requ怒s Python but 使用s only built-in libraries, so there are no 包s to 安装:

```python expand能够 主题={空}
#!/usr/bin/env python3
"""Gene速率 an 交互 collapsible 树 可视化 of a 代码基础."""

进口 json
进口 sys
进口 网页浏览器
from 路径lib 进口 路径
from collections 进口 Counter

IGNORE = {'.Git', '节点_模块s', '__py缓存__', '.venv', 'venv', 'dist', '构建'}

def扫描(路径: 路径, stats: dict) -> dict:
    结果 = {"名称": 路径.名称, "children": [], "尺寸": 0}
    尝试:
        for 项 in 排序(路径.iterdir()):
            if 项.名称 in IGNORE or 项.名称.启动swith('.'):
                继续
            if 项.is_文件():
                尺寸 = 项.stat().st_尺寸
                ext = 项.suf修复.低er() or '(no ext)'
                结果["children"].应用结束({"名称": 项.名称, "尺寸": 尺寸, "ext": ext})
                结果["尺寸"] += 尺寸
                stats["文件"] += 1
                stats["扩展s"][ext] += 1
                stats["ext_尺寸s"][ext] += 尺寸
            elif 项.is_dir():
                stats["dirs"] += 1
                child =扫描(项, stats)
                if child["children"]:
                    结果["children"].应用结束(child)
                    结果["尺寸"] += child["尺寸"]
    except 许可错误:
        pass
    回报 结果

def gene速率_html(数据: dict, stats: dict, 输出: 路径) -> 无:
    ext_尺寸s = stats["ext_尺寸s"]
    总计_尺寸 = 总和(ext_尺寸s.值s()) or 1
    排序_exts = 排序(ext_尺寸s.项s(), 键=lambda x: -x[1])[:8]
    colors = {
        '.js': '#f7df1e', '.ts': '#3178c6', '.py': '#3776ab', '.前往': '#00添加8',
        '.rs': '#dea584', '.rb': '#cc342d', '.css': '#264de4', '.html': '#e34c26',
        '.json': '#6b7280', '.md': '#083fa1', '.yaml': '#cb171e', '.yml': '#cb171e',
        '.mdx': '#083fa1', '.tsx': '#3178c6', '.jsx': '#61dafb', '.sh': '#4eaa25',
    }
    lang_bars = "".join(
        f'{ext}'
        f''
        f'{(尺寸/总计_尺寸)*100:.1f}%'
        for ext, 尺寸 in 排序_exts
    )
    def fmt(b):
        if b 

  代码基础探索r
  
    正文 {{ font: 14px/1.5 系统-ui, sans-serif; margin: 0; 背景: #1a1a2e; color: #eee; }}
    .container {{ 显示: flex; 身高: 100vh; }}
    .侧边栏 {{ 宽度: 280px; 背景: #252542; p添加ing: 20px; b顺序-正确: 1px 固体 #3d3d5c; 结束f低-y: auto; flex-shrink: 0; }}
    .主 {{ flex: 1; p添加ing: 20px; 结束f低-y: auto; }}
    h1 {{ margin: 0 0 10px 0; font-尺寸: 18px; }}
    h2 {{ margin: 20px 0 10px 0; font-尺寸: 14px; color: #888; 文本-转换: 上per案例; }}
    .stat {{ 显示: flex; 公正ify-满意: s步伐-between; p添加ing: 8px 0; b顺序-底部: 1px 固体 #3d3d5c; }}
    .stat-值 {{ font-重量: b旧; }}
    .bar-行 {{ 显示: flex; align-项s: c进入; margin: 6px 0; }}
    .bar-标签 {{ 宽度: 55px; font-尺寸: 12px; color: #aaa; }}
    .bar {{ 身高: 18px; b顺序-半径: 3px; }}
    .bar-pct {{ margin-左: 8px; font-尺寸: 12px; color: #666; }}
    .树 {{ 列表-style: 无; p添加ing-左: 20px; }}
    详情s {{ cursor: pointer; }}
    摘要 {{ p添加ing: 4px 8px; b顺序-半径: 4px; }}
    摘要:h结束 {{ 背景: #2d2d44; }}
    .文件夹 {{ color: #ffd700; }}
    .文件 {{ 显示: flex; align-项s: c进入; p添加ing: 4px 8px; b顺序-半径: 4px; }}
    .文件:h结束 {{ 背景: #2d2d44; }}
    .尺寸 {{ color: #888; margin-左: auto; font-尺寸: 12px; }}
    .dot {{ 宽度: 8px; 身高: 8px; b顺序-半径: 50%; margin-正确: 8px; }}
  

  
    
      📊 摘要
      文件{stats["文件"]:,}
      总监ies{stats["dirs"]:,}
      总计 尺寸{fmt(数据["尺寸"])}
      文件 类型s{len(stats["扩展s"])}
      By 文件 类型
      {lang_bars}
    
    
      📁 {数据["名称"]}
      
    
  
  
    常量 数据 = {json.dumps(数据)};
    常量 colors = {json.dumps(colors)};
    功能 fmt(b) {{ if (b 📁 ${{节点.名称}}${{fmt(节点.尺寸)}}`;
        常量 ul = document.创建元素('ul'); ul.阶级名称 = '树';
        节点.children.类别((a,b) => (b.children?1:0)-(a.children?1:0) || a.名称.本地e比较(b.名称));
        节点.children.fo范围(c => r结束er(c, ul));
        det.应用结束Child(ul);
        常量 li = document.创建元素('li'); li.应用结束Child(det); parent.应用结束Child(li);
      }} else {{
        常量 li = document.创建元素('li'); li.阶级名称 = '文件';
        li.内部HTML = `${{节点.名称}}${{fmt(节点.尺寸)}}`;
        parent.应用结束Child(li);
      }}
    }}
    数据.children.fo范围(c => r结束er(c, document.get元素ById('根')));
  
'''
    输出.写入_文本(html)

if __名称__ == '__主__':
    目标 = 路径(sys.argv[1] if len(sys.argv) > 1 else '.').resolve()
    stats = {"文件": 0, "dirs": 0, "扩展s": Counter(), "ext_尺寸s": Counter()}
    数据 =扫描(目标, stats)
    out = 路径('代码基础-映射.html')
    gene速率_html(数据, stats, out)
    print(f'Gene速率d {out.absolute()}')
    网页浏览器.打开(f'文件://{out.absolute()}')
```

To 测试, 打开 Claude 代码 in 任何 项目 and ask "Visualize this 代码基础." Claude 运行s the 脚本, gene速率s `代码基础-映射.html`, and 打开s it in your 浏览器.

This 模式 工作s for 任何 visual 输出: dep结束ency 图s, 测试 cove狂怒 报告s, API 文档, or 数据库 模式 可视化s. The 捆绑d 脚本 does the 重 lifting while Claude handles orchest比率n.

## 故障排除

### 技能 not triggering

If Claude doesn't 使用 your 技能 when 预期:

1. 检查 the 描述 includes 键词s 用户s would 自然ly say
2. 验证 the 技能 应用ears in `What 技能 are 可用?`
3. 尝试 repH值rasing your 请求 to 匹配 the 描述 更多 关闭ly
4. Invoke it 直接ly with `/技能-名称` if the 技能 is 用户-invoc能够

### 技能 triggers too often

If Claude 使用s your 技能 when you don't 想要 it:

1. Make the 描述 更多 特定
2. 添加 `禁用-模型-invocation: 真实` if you only 想要 手册 invocation

### 技能 描述s are 剪切 短

技能 描述s are 加载 into 上下文 so Claude knows what's 可用. 所有 技能 名称s are al方式s 包含, but if you have 许多 技能, 描述s are 缩短 to fit the 字符 预算, which can s旅行 the 键词s Claude 需要s to 匹配 your 请求. The 预算 scales 动态所有y at 1% of the 上下文 风ow, with a 下降返回 of 8,000 字符s.

To raise the 限制, 设置 the `SLASH_命令_工具_CHAR_预算` 环境 可变. Or trim 描述s at the 来源: front-加载 the 键 使用 案例, since 每个 条目 is c应用ed at 250 字符s 注意较少 of 预算.

## R兴高采烈 资源

* **[子代理](/en/sub-代理s)**: delegate 任务s to 专业 代理s
* **[插件s](/en/插件s)**: 包 and distribute 技能 with other 扩展s
* **[钩子](/en/钩子)**: automate 工作流s a圆 工具 事件s
* **[记忆](/en/记忆)**: manage CLAUDE.md 文件 for 持续 上下文
* **[Built-in 命令](/en/命令)**: 参考 for built-in `/` 命令
* **[权限](/en/权限)**: 控制 工具 and 技能 access