技能

将可复用的、基于文件系统的专业知识附加到你的 Agent,用于领域特定的工作流程。


技能是可复用的、基于文件系统的资源,为你的 Agent 提供领域特定的专业知识:工作流程、上下文和最佳实践,将通用 Agent 转变为专家。与提示词(用于一次性任务的会话级指令)不同,技能按需加载,仅在需要时才影响上下文窗口。

你可以附加两种类型的技能。两者的工作方式相同:当技能与任务相关时,你的 Agent 会自动调用它们。

  • Anthropic 预构建技能: 常见的文档任务,如 PowerPoint、Excel、Word 和 PDF 处理。
  • 自定义技能: 你创建并上传到工作区的技能。

要了解如何创建自定义技能,请参见 Agent 技能技能创建最佳实践。本页假设你已经在工作区中拥有可用的技能,或正在使用 Anthropic 预构建技能。

Note

所有 Managed Agents API 请求都需要 managed-agents-2026-04-01 beta header。SDK 会自动设置该 beta header。

将技能附加到 Agent

在创建 Agent 时附加技能。每个会话最多支持 20 个技能,按会话中所有 Agent 统计(参见多 Agent 会话)。

skills 数组中的每个条目使用以下字段:

字段描述
typeanthropic 表示预构建技能,custom 表示工作区创建的技能。
skill_id技能标识符。对于 Anthropic 技能,使用短名称(例如 xlsx)。对于自定义技能,使用创建时返回的 skill_* ID。
version仅限自定义技能。固定到特定版本或使用 latest
agent=$(curl -sS https://api.anthropic.com/v1/agents \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "anthropic-beta: managed-agents-2026-04-01" \
  --json @- <<'EOF'
{
  "name": "Financial Analyst",
  "model": "claude-opus-4-7",
  "system": "You are a financial analysis agent.",
  "skills": [
    {"type": "anthropic", "skill_id": "xlsx"},
    {"type": "custom", "skill_id": "skill_abc123", "version": "latest"}
  ]
}
EOF
)
ant beta:agents create <<'YAML'
name: Financial Analyst
model: claude-opus-4-7
system: You are a financial analysis agent.
skills:
  - type: anthropic
    skill_id: xlsx
  - type: custom
    skill_id: skill_abc123
    version: latest
YAML
agent = client.beta.agents.create(
    name="Financial Analyst",
    model="claude-opus-4-7",
    system="You are a financial analysis agent.",
    skills=[
        {
            "type": "anthropic",
            "skill_id": "xlsx",
        },
        {
            "type": "custom",
            "skill_id": "skill_abc123",
            "version": "latest",
        },
    ],
)
const agent = await client.beta.agents.create({
  name: "Financial Analyst",
  model: "claude-opus-4-7",
  system: "You are a financial analysis agent.",
  skills: [
    {
      type: "anthropic",
      skill_id: "xlsx"
    },
    {
      type: "custom",
      skill_id: "skill_abc123",
      version: "latest"
    }
  ]
});
var agent = await client.Beta.Agents.Create(new()
{
    Name = "Financial Analyst",
    Model = BetaManagedAgentsModel.ClaudeOpus4_7,
    System = "You are a financial analysis agent.",
    Skills =
    [
        new BetaManagedAgentsAnthropicSkillParams { Type = BetaManagedAgentsAnthropicSkillParamsType.Anthropic, SkillID = "xlsx" },
        new BetaManagedAgentsCustomSkillParams { Type = BetaManagedAgentsCustomSkillParamsType.Custom, SkillID = "skill_abc123", Version = "latest" },
    ],
});
agent, err := client.Beta.Agents.New(ctx, anthropic.BetaAgentNewParams{
	Name: "Financial Analyst",
	Model: anthropic.BetaManagedAgentsModelConfigParams{
		ID: "claude-opus-4-7",
	},
	System: anthropic.String("You are a financial analysis agent."),
	Skills: []anthropic.BetaManagedAgentsSkillParamsUnion{
		{OfAnthropic: &anthropic.BetaManagedAgentsAnthropicSkillParams{
			SkillID: "xlsx",
			Type:    anthropic.BetaManagedAgentsAnthropicSkillParamsTypeAnthropic,
		}},
		{OfCustom: &anthropic.BetaManagedAgentsCustomSkillParams{
			SkillID: "skill_abc123",
			Type:    anthropic.BetaManagedAgentsCustomSkillParamsTypeCustom,
			Version: anthropic.String("latest"),
		}},
	},
})
if err != nil {
	panic(err)
}
_ = agent
var agent = client.beta().agents().create(
    AgentCreateParams.builder()
        .name("Financial Analyst")
        .model(BetaManagedAgentsModel.CLAUDE_OPUS_4_7)
        .system("You are a financial analysis agent.")
        .addSkill(
            BetaManagedAgentsAnthropicSkillParams.builder()
                .type(BetaManagedAgentsAnthropicSkillParams.Type.ANTHROPIC)
                .skillId("xlsx")
                .build()
        )
        .addSkill(
            BetaManagedAgentsCustomSkillParams.builder()
                .type(BetaManagedAgentsCustomSkillParams.Type.CUSTOM)
                .skillId("skill_abc123")
                .version("latest")
                .build()
        )
        .build()
);
$agent = $client->beta->agents->create(
    name: 'Financial Analyst',
    model: 'claude-opus-4-7',
    system: 'You are a financial analysis agent.',
    skills: [
        ['type' => 'anthropic', 'skill_id' => 'xlsx'],
        ['type' => 'custom', 'skill_id' => 'skill_abc123', 'version' => 'latest'],
    ],
);
agent = client.beta.agents.create(
  name: "Financial Analyst",
  model: "claude-opus-4-7",
  system_: "You are a financial analysis agent.",
  skills: [
    {type: "anthropic", skill_id: "xlsx"},
    {type: "custom", skill_id: "skill_abc123", version: "latest"}
  ]
)