write-a-skill

作者: sanity-io

以恰当的结构、渐进式呈现和打包资源创建新的代理技能。当用户想要创建、编写或构建新技能时使用。

npx skills add https://github.com/sanity-io/sanity --skill write-a-skill

Writing Skills

Process

  1. Gather requirements - ask user about:

    • What task/domain does the skill cover?
    • What specific use cases should it handle?
    • Does it need executable scripts or just instructions?
    • Any reference materials to include?
  2. Draft the skill - create:

    • SKILL.md with concise instructions
    • Additional reference files if content exceeds 500 lines
    • Utility scripts if deterministic operations needed
  3. Review with user - present draft and ask:

    • Does this cover your use cases?
    • Anything missing or unclear?
    • Should any section be more/less detailed?

Skill Structure

skill-name/
├── SKILL.md           # Main instructions (required)
├── REFERENCE.md       # Detailed docs (if needed)
├── EXAMPLES.md        # Usage examples (if needed)
└── scripts/           # Utility scripts (if needed)
    └── helper.js

SKILL.md Template

---
name: skill-name
description: Brief description of capability. Use when [specific triggers].
---

# Skill Name

## Quick start

[Minimal working example]

## Workflows

[Step-by-step processes with checklists for complex tasks]

## Advanced features

[Link to separate files: See [REFERENCE.md](REFERENCE.md)]

Description Requirements

The description is the only thing your agent sees when deciding which skill to load. It's surfaced in the system prompt alongside all other installed skills. Your agent reads these descriptions and picks the relevant skill based on the user's request.

Goal: Give your agent just enough info to know:

  1. What capability this skill provides
  2. When/why to trigger it (specific keywords, contexts, file types)

Format:

  • Max 1024 chars
  • Write in third person
  • First sentence: what it does
  • Second sentence: "Use when [specific triggers]"

Good example:

Extract text and tables from PDF files, fill forms, merge documents. Use when working with PDF files or when user mentions PDFs, forms, or document extraction.

Bad example:

Helps with documents.

The bad example gives your agent no way to distinguish this from other document skills.

When to Add Scripts

Add utility scripts when:

  • Operation is deterministic (validation, formatting)
  • Same code would be generated repeatedly
  • Errors need explicit handling

Scripts save tokens and improve reliability vs generated code.

When to Split Files

Split into separate files when:

  • SKILL.md exceeds 100 lines
  • Content has distinct domains (finance vs sales schemas)
  • Advanced features are rarely needed

Review Checklist

After drafting, verify:

  • Description includes triggers ("Use when...")
  • SKILL.md under 100 lines
  • No time-sensitive info
  • Consistent terminology
  • Concrete examples included
  • References one level deep

来自 sanity-io 的更多技能

Agent Development
sanity-io
当用户要求“创建一个代理”、“添加一个代理”、“编写子代理”、“代理前置元数据”、“何时使用描述”、“代理…”时,应使用此技能。
code-review-and-quality
sanity-io
执行多维度代码审查。在合并任何变更前使用。在审查自己、其他智能体或人类编写的代码时使用。在需要…时使用。
code-simplification
sanity-io
简化代码以提高清晰度。适用于在不改变行为的前提下重构代码以提升可读性。适用于代码功能正常但难以阅读、维护或扩展的情况…
Command Development
sanity-io
当用户要求“创建斜杠命令”、“添加命令”、“编写自定义命令”、“定义命令参数”、“使用命令…”时,应使用此技能。
content-experimentation-best-practices
sanity-io
结构化指导,用于设计、执行和分析内容实验,以提升转化率和参与度。涵盖假设框架、指标选择、样本量计算以及A/B和多变量实验中的统计显著性检验。包含关于p值、置信区间、功效分析和贝叶斯方法的详细资源,用于解读结果。提供CMS集成模式,用于在字段级别管理变体并连接外部...
content-modeling-best-practices
sanity-io
结构化内容建模指南,涵盖模式设计、可复用性及多渠道交付。核心原则包括:将内容视为数据而非页面、维护单一事实来源、面向未来渠道设计、优化编辑工作流。提供引用与嵌入对象的选择框架、关注点分离及内容复用模式。包含扁平化、层级化及分面分类法的分类学指导。适用于...
create-agent-with-sanity-context
sanity-io
通过 Sanity Context 构建对 Sanity 内容具有结构化访问权限的 AI 代理。在设置基于 Sanity 的聊天机器人、将 AI 助手连接到 Sanity 时使用…
dial-your-context
sanity-io
交互式会话,用于为Sanity Context MCP服务器创建指令字段内容。当用户提到调整代理上下文时,使用此技能…