Pirate Voice
【免费下载链接】agentsBuild and deploy AI Agents on Cloudflare项目地址: https://gitcode.com/GitHub_Trending/agents1/agents
Answer in a playful pirate voice while keeping the response useful.
Style
- Use light nautical phrasing such as "aye", "matey", "shipshape", and "charted course".
- Keep the meaning clear. Do not bury technical details under too much slang.
- Avoid stereotypes, insults, or hard-to-read spelling.
- If the user asks a technical question, answer the technical question first and add pirate flavor second.
正文是激活后注入模型的完整操作指令。注意这份技能**没有引用文件、没有脚本**——它完全依赖提示词本身生效,是「纯提示词型」技能的最小范例。 ## 二、description:决定模型是否激活你的技能 在 Think 的技能加载机制中,技能**不是常驻的系统提示词**。Think 只在每轮把技能目录(catalog,即 name + description)放入提示,并暴露 `activate_skill` 工具;只有当**当前请求与该技能的 description 匹配**时,模型才会调用 `activate_skill` 拉取完整的 `SKILL.md` 指令。这一设计在 [design/skills.md](https://link.gitcode.com/i/bc9de836f20af5dbe6367bb8883aecc7) 的 "Skill Loading" 一节有明确描述:常驻行为应放在 `getSystemPrompt()`,而技能是可选的、按需加载的过程性指令。 因此 `description` 的质量直接决定技能能否被正确触发。分析 `pirate-voice` 的写法: ```yaml description: Rewrite or answer in a playful pirate voice. Use when the user asks for pirate tone, nautical phrasing, or says to talk like a pirate.它包含三个要素:
| 要素 | 原文 | 作用 |
|---|---|---|
| 行为声明 | Rewrite or answer in a playful pirate voice | 告诉模型激活后要做什么 |
| 触发信号 | user asks for pirate tone, nautical phrasing | 覆盖显式请求("说海盗话") |
| 兜底信号 | says to talk like a pirate | 覆盖同义表达,提高召回 |
对比同目录下其他技能,可以总结出这套描述公式的一致性:
- debug-plan/SKILL.md:
Create a systematic debugging plan... Use when the user asks how to investigate a failure, regression, or unexpected behavior. - test-plan/SKILL.md:
Produce a focused test plan for a change. Use when the user asks how to test a feature... - release-notes/SKILL.md:
Draft short release notes... Use when the user asks for changelogs, release notes...
即「激活后行为 + Use when 触发条件(含近义改写)」的固定句式。demo 前端侧栏展示技能名与描述(见 client.tsx),模型正是读取这条描述来做匹配决策,所以描述应当写清「何时用、不用则不要激活」。
三、风格约束的写法:既要个性,又要克制
pirate-voice的## Style小节体现了风格类技能的核心设计哲学:个性是增量,不是替代。
- 给出具体词汇示例,而非空泛要求:
"aye"、"matey"、"shipshape"、"charted course"是四个可直接落地的航海措辞示例,模型不必凭空发明,风格更可控。 - 以「保持含义清晰」为第一优先级:
Keep the meaning clear. Do not bury technical details under too much slang.—— 海盗腔是点缀,技术内容必须清晰,这是风格技能的可用性底线。 - 显式排除负面模式:
Avoid stereotypes, insults, or hard-to-read spelling.用否定式把模型容易滑向的刻板印象、冒犯性措辞、难读的拼写(如大量 "arrr" 变形拼写)一次性排除。 - 优先级排序:
answer the technical question first and add pirate flavor second.明确"先答问题、后加风味"的次序,避免用户提问被风格淹没。
这套「示例 + 约束 + 否定 + 优先级」的组合,本质上是一次高质量的系统提示词工程。可以把它泛化到任意人设类技能(极客腔、文言腔、教练腔……),只需替换词汇示例与排除项。
四、注册与激活:从 getSkills() 到 activate_skill 的调用链
pirate-voice之所以能生效,靠的是 examples/agent-skills/src/server.ts 中SkillsAgent的三处关键接线:
import { callable, routeAgentRequest } from "agents"; import { Think, skills } from "@cloudflare/think"; import bundledSkills from "agents:skills"; export class SkillsAgent extends Think<Env> { getModel() { return "@cf/moonshotai/kimi-k2.7-code"; } getSystemPrompt() { return [ "You are a helpful assistant demonstrating Think Agent Skills.", "If a user request matches an available skill, call activate_skill before answering.", "Mention which skill you used when it is helpful for the demo." ].join("\n"); } getSkills() { return [bundledSkills]; } getSkillScriptRunner() { return skills.runner({ loader: this.env.LOADER, workspaceInstance: this.workspace }); } @callable() async listSkills() { return bundledSkills.list(); } }import bundledSkills from "agents:skills":这是 Vite 构建期虚拟模块,指向该文件旁的./skills目录。agents/vite插件会在构建时发现所有含SKILL.md的子目录、解析 frontmatter 与正文、把references/、scripts/等资源打进包,并生成确定性的 fingerprint(详见 design/skills.md 的 "Bundled Skills" 小节)。pirate-voice因此无需任何运行时文件系统。getSkills()返回技能源数组:Think 注册后,技能目录与activate_skill、read_skill_resource、run_skill_script三个技能工具在每轮被合并进工具集(见 docs/think/tools.md 的 Tool Merge Order 第 5 项)。pirate-voice只用到activate_skill。getSystemPrompt()里明确提示模型「匹配技能时先activate_skill再作答」,这是激活链路能触发的前提。getSkillScriptRunner()是为需要执行脚本的技能(如release-notes)准备的,纯提示词技能pirate-voice不需要它,但它在示例中统一配置。
激活后,Think 默认会把解析出的SKILL.md投影进运行工作区(Computer 场景为/workspace/.agents/skills/<name>/SKILL.md),该文件本身也可被文件工具读取、编辑并影响后续回合(见 design/skills.md 的 "Workspace projection" 小节)。
五、在 agent-skills 演示中运行与观察
pirate-voice所在的应用是完整的可运行演示。运行方式(见 examples/agent-skills/README.md):
npm install npm start前提是 Wrangler 已对开通 Workers AI 的账户完成认证——示例使用ai.remote: true与 Worker Loader 绑定,本地开发会调用 Cloudflare 云服务。相关配置在 examples/agent-skills/wrangler.jsonc:
{ "ai": { "binding": "AI", "remote": true }, "compatibility_flags": ["nodejs_compat"], "worker_loaders": [{ "binding": "LOADER" }], "durable_objects": { "bindings": [{ "class_name": "SkillsAgent", "name": "SkillsAgent" }] }, "migrations": [{ "new_sqlite_classes": ["SkillsAgent"], "tag": "v1" }] }【免费下载链接】agentsBuild and deploy AI Agents on Cloudflare项目地址: https://gitcode.com/GitHub_Trending/agents1/agents
创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考