跳到主要内容

创建技能

技能是为 Hermes Agent 添加新能力的首选方式。它们比工具更容易创建,不需要对 agent 代码进行更改,可以与社区共享。

应该用技能还是工具?

技能当:

  • 能力可以表达为指令 + shell 命令 + 现有工具
  • 它包装了 Agent 可以通过 terminalweb_extract 调用的外部 CLI 或 API
  • 它不需要烘焙到 agent 中的自定义 Python 集成或 API 密钥管理
  • 示例:arXiv 搜索、git 工作流、Docker 管理、PDF 处理、通过 CLI 工具发送邮件

工具当:

  • 需要与 API 密钥、auth 流程或多组件配置进行端到端集成
  • 需要每次精确执行的自定义处理逻辑
  • 处理二进制数据、流式传输或实时事件
  • 示例:浏览器自动化、TTS、视觉分析

技能目录结构

捆绑技能组织在 skills/ 按类别。官方可选技能在 optional-skills/ 中使用相同的结构:

skills/
├── research/
│ └── arxiv/
│ ├── SKILL.md # 必需:主要指令
│ └── scripts/ # 可选:辅助脚本
│ └── search_arxiv.py
├── productivity/
│ └── ocr-and-documents/
│ ├── SKILL.md
│ ├── scripts/
│ └── references/
└── ...

SKILL.md 格式

---
name: my-skill
description: Brief description (shown in skill search results)
version: 1.0.0
author: Your Name
license: MIT
platforms: [macos, linux] # 可选 — 限制到特定 OS 平台
metadata:
hermes:
tags: [Category, Subcategory, Keywords]
related_skills: [other-skill-name]
requires_toolsets: [web] # 可选 — 仅当这些工具集活跃时显示
requires_tools: [web_search] # 可选 — 仅当这些工具可用时显示
fallback_for_toolsets: [browser] # 可选 — 当这些工具集活跃时隐藏
config: # 可选 — 技能需要的 config.yaml 设置
- key: my.setting
description: "What this setting controls"
default: "sensible-default"
prompt: "Display prompt for setup"
required_environment_variables: # 可选 — 技能需要的环境变量
- name: MY_API_KEY
prompt: "Enter your API key"
help: "Get one at https://example.com"
required_for: "API access"
---

# Skill Title

Brief intro.

## When to Use
Trigger conditions — when should the agent load this skill?

## Quick Reference
Table of common commands or API calls.

## Procedure
Step-by-step instructions the agent follows.

## Pitfalls
Known failure modes and how to handle them.

## Verification
How the agent confirms it worked.

平台特定技能

技能可以使用 platforms 字段限制自己到特定操作系统:

platforms: [macos]            # 仅 macOS(例如 iMessage、Apple Reminders)
platforms: [macos, linux] # macOS 和 Linux
platforms: [windows] # 仅 Windows

条件技能激活

技能可以声明对特定工具或工具集的依赖:

metadata:
hermes:
requires_toolsets: [web] # 当 web 工具集不可用时隐藏
requires_tools: [web_search] # 当 web_search 不可用时隐藏
fallback_for_toolsets: [browser] # 当浏览器工具集可用时隐藏
fallback_for_tools: [browser_navigate] # 当 browser_navigate 可用时隐藏

环境变量要求

技能可以声明它们需要的环境变量。当技能通过 skill_view 加载时,其必需的变量会自动注册以传递到沙箱执行环境:

required_environment_variables:
- name: TENOR_API_KEY
prompt: "Tenor API key"
help: "Get your key at https://tenors.com"
required_for: "GIF search functionality"

安全设置加载

当技能需要 API 密钥或令牌时使用 required_environment_variables。缺失值不会从发现中隐藏技能。相反,Hermes 在本地 CLI 中加载技能时安全地提示输入。

沙箱传递

当你的技能加载时,任何已设置的声明 required_environment_variables 会自动传递到 execute_codeterminal 沙箱 — 包括 Docker 和 Modal 等远程后端。你的技能脚本可以访问 $TENOR_API_KEY,无需用户配置任何额外内容。

配置文件设置(config.yaml)

技能可以声明存储在 config.yaml skills.config 命名空间下的非秘密设置:

metadata:
hermes:
config:
- key: wiki.path
description: Path to the LLM Wiki knowledge base directory
default: "~/wiki"
prompt: Wiki directory path
何时使用哪种

对 API 密钥、令牌和秘密(存储在 ~/.hermes/.env,永不向模型显示)使用 required_environment_variables。对路径、偏好设置和非敏感设置(存储在 config.yaml,可在配置显示中查看)使用 config

技能指南

无外部依赖

优先使用标准库 Python、curl 和现有 Hermes 工具(web_extractterminalread_file)。

渐进式披露

把最常见的工作流放在前面。边缘情况和高级用法放在底部。

包含辅助脚本

对于 XML/JSON 解析或复杂逻辑,在 scripts/ 中包含辅助脚本 — 不要期望 LLM 每次都内联编写解析器。

测试它

运行技能并验证 Agent 正确遵循指令:

hermes chat --toolsets skills -q "Use the X skill to do Y"

技能应该放在哪里?

捆绑技能(在 skills/ 中)随每个 Hermes 安装附带。它们应该对大多数用户广泛有用

  • 文档处理、网络研究、常见开发工作流、系统管理
  • 被广泛范围的人定期使用

如果你的技能是官方的且有用但不是普遍需要的(例如付费服务集成、重度依赖),放在 optional-skills/ — 它随 repo 附带,可通过 hermes skills browse 发现(标记为「official」),并以 builtin trust 安装。

如果你的技能是专业的、社区贡献的或小众的,更适合 Skills Hub — 上传到注册表并通过 hermes skills install 与他人分享。

发布技能

到 Skills Hub

hermes skills publish skills/my-skill --to github --repo owner/repo

到自定义仓库

添加你的 repo 作为 tap:

hermes skills tap add owner/repo

安全扫描

所有 hub 安装的技能都经过安全扫描,检查:

  • 数据泄露模式
  • 提示注入尝试
  • 破坏性命令
  • Shell 注入

信任级别:

  • builtin — 随 Hermes 附带(始终信任)
  • official — 来自 repo 中的 optional-skills/(builtin trust,无第三方警告)
  • trusted — 来自 openai/skills、anthropics/skills
  • community — 非危险发现可用 --force 覆盖;危险判定保持阻止