SkillTool:执行 Skills
2026/8/2 15:02:50 · 更新于 2026/8/2 15:03:16 · 来源
SkillTool 是 Claude Code 的核心技能执行器,负责定位命令、解析参数、调度本地或 MCP skill,并通过 fork 子 Agent 将技能从文本 prompt 提升为可系统调度的正式能力单元。
它不是命令别名,而是技能运行时
很多人第一次看到 /commit、/verify、/update-config 这类 skill,会以为它们只是更长 prompt 的快捷方式。
但从源码看,SkillTool 明显比“文本别名”复杂得多。
它负责的是:
- 找到 skill 对应的 command
- 解析参数
- 处理本地 skill 和 MCP skill
- 必要时 fork 一个子 Agent 去跑
所以更准确的说法是:
SkillTool是 Claude Code 的技能执行器。
关键源码
tools/SkillTool/SkillTool.ts:
import {
builtInCommandNames,
findCommand,
getCommands,
} from 'src/commands.js'
import { runAgent } from '../AgentTool/runAgent.js'
文件里还有一段很关键:
async function executeForkedSkill(
command: Command & { type: 'prompt' },
...
): Promise<ToolResult<Output>> {
...
}
这说明 skill 执行并不总在当前线程内完成,复杂 skill 可以 fork。
调用链
用户或模型触发 skill > SkillTool > 查找对应 command / prompt > 解析参数与元数据 > 当前线程执行或 fork 子 Agent > 返回结果给主线程
它还兼容 MCP skills
源码里专门有一段:
async function getAllCommands(context: ToolUseContext): Promise<Command[]> {
const mcpSkills = context
.getAppState()
.mcp.commands.filter(
cmd => cmd.type === 'prompt' && cmd.loadedFrom === 'mcp',
)
...
}
这说明 SkillTool 并不只执行本地技能,还能把 MCP 侧暴露出来的 prompt skills 统一纳入调度。
一次典型使用路径
- 用户输入
/commit SkillTool找到这个 skill 的 command- skill prompt 被展开
- 必要时 fork 子 Agent 跑完整流程
- 结果回到主线程
它和相邻工具的关系

小结
SkillTool 代表 Claude Code 走向平台化的一步:
它把“技能”从普通 prompt 文本提升成了可被系统调度、可 fork、可统计、可扩展的正式能力单元。
学习地图
Learning Map: SkillTool Architecture
Phase 1 — Conceptual Foundation
- Understand the difference between command aliases and true skill executors
- Learn how Claude Code routes user input to registered commands
- Explore the role of
builtInCommandNamesand the command registry
Phase 2 — Core Mechanism
- Study
findCommand()discovery and parameter parsing flow - Trace execution through the main thread path
- Understand when and how
executeForkedSkill()triggers a child agent
Phase 3 — MCP Integration
- Map how MCP prompt skills are loaded and discovered
- Learn the
loadedFrom: 'mcp'tagging convention - Explore unified scheduling of local vs. remote skills
Phase 4 — Advanced Patterns
- Design your own skill and register it in Claude Code
- Handle complex skill workflows across forked agents
- Monitor and debug skill execution chains
动手实践——分步指南
- Install Claude Code and verify the
SkillToolmodule is loaded by triggering a built-in skill like/commit - Open the source file
tools/SkillTool/SkillTool.tsin your IDE — locate thefindCommand()dispatcher and trace how/commitmaps to its underlyingCommandobject - Follow the parameter-parsing logic: identify where arg strings split on spaces or named flags, and confirm metadata (type, loadedFrom) gets attached
- Find the
executeForkedSkill()function: note its signature(command: Command & { type: 'prompt' })and observe when the condition triggers a fork vs. inline execution - Add a local skill by defining a new Command entry in the commands registry, then trigger it to see the full dispatch cycle — from user input → discovery → parsing → execution → result return
三大推荐资源
- 1Claude Code Documentation
Official Anthropic documentation covering Claude Code's skills, commands, and agent architecture.
https://docs.anthropic.com/en/docs/claude-code/introduction
- 2Model Context Protocol (MCP) Specification
The MCP standard that defines how prompt skills are exposed and discovered for integration with Claude Code.
https://modelcontextprotocol.io/specification
- 3Claude Code GitHub Repository
Claude Code's source code repository, including the SkillTool implementation and command system.
https://github.com/anthropics/claude-code
链接由 AI 推荐——使用前建议快速核实。