Creating Skills
Create skills with instructions, scripts, and reference documentation.
A skill is a directory containing a SKILL.md file with optional scripts/ and references/ subdirectories.
Directory Structure
1my-skill/2├── SKILL.md # Required: Instructions with YAML frontmatter3├── scripts/ # Optional: Executable scripts4│ └── helper.py5└── references/ # Optional: Reference documentation6 └── guide.mdThe SKILL.md File
The SKILL.md file is the heart of a skill. It contains YAML frontmatter with metadata, followed by markdown instructions.
Required Fields
1---2name: my-skill3description: Short description of what this skill does4---- name: Must be lowercase, alphanumeric with hyphens only (max 64 characters)
- description: Brief summary shown in the agent's system prompt (max 1024 characters)
Optional Fields
1---2name: code-review3description: Code review assistance with style checking and best practices4license: Apache-2.05metadata:6 version: "1.0.0"7 author: your-name8 tags: ["python", "code-quality"]9---Full Example
1---2name: code-review3description: Code review assistance with style checking and best practices4license: Apache-2.05metadata:6 version: "1.0.0"7 author: your-name8 tags: ["python", "code-quality"]9---1011# Code Review Skill1213Use this skill when reviewing code for quality, style, and best practices.1415## When to Use1617- User asks for code review or feedback18- User wants to improve code quality19- User needs help with refactoring2021## Process22231. **Analyze Structure**: Review overall code organization242. **Check Style**: Look for style guide violations253. **Identify Issues**: Find bugs, security issues, performance problems264. **Suggest Improvements**: Provide actionable recommendations2728## Best Practices2930- Focus on the most impactful issues first31- Explain the "why" behind suggestions32- Provide code examples for fixesAdding Scripts
Scripts are executable files the agent can run. They must have a shebang line.
Python Script Example
Create scripts/check_style.py:
1#!/usr/bin/env python32"""Check code style and return results."""34import sys56def check_style(code: str) -> dict:7 issues = []8 lines = code.split('\n')910 for i, line in enumerate(lines, 1):11 if len(line) > 100:12 issues.append(f"Line {i}: exceeds 100 characters")13 if line.endswith(' '):14 issues.append(f"Line {i}: trailing whitespace")1516 return {"issues": issues, "count": len(issues)}1718if __name__ == "__main__":19 # Read code from stdin or argument20 code = sys.stdin.read() if not sys.argv[1:] else sys.argv[1]21 result = check_style(code)22 print(result)Shell Script Example
Create scripts/lint.sh:
1#!/bin/bash2# Run linting on provided file34if [ -z "$1" ]; then5 echo "Usage: lint.sh <file>"6 exit 17fi89ruff check "$1" 2>&1Scripts are executed with the skill directory as the working directory. The agent can pass arguments when executing scripts.
Adding References
References are documentation files the agent can load on demand.
Example Reference
Create references/style-guide.md:
1# Python Style Guide23## Naming Conventions45- **Variables**: `snake_case`6- **Classes**: `PascalCase`7- **Constants**: `UPPER_SNAKE_CASE`89## Line Length1011- Maximum 100 characters per line12- Break long lines at logical points1314## Imports1516- Standard library imports first17- Third-party imports second18- Local imports third19- Alphabetize within each groupValidation Rules
Skills are validated when loaded. Here are the rules:
Name Requirements
- Maximum 64 characters
- Lowercase letters, numbers, and hyphens only
- Cannot start or end with a hyphen
- No consecutive hyphens (
--) - Must match the directory name
Field Limits
| Field | Max Length |
|---|---|
| name | 64 characters |
| description | 1024 characters |
Valid Licenses
Common SPDX identifiers are accepted: MIT, Apache-2.0, GPL-3.0, BSD-3-Clause, etc.
Organizing Multiple Skills
Create a directory containing multiple skill folders:
1skills/2├── code-review/3│ ├── SKILL.md4│ ├── scripts/5│ └── references/6├── git-workflow/7│ ├── SKILL.md8│ ├── scripts/9│ └── references/10└── testing/11 ├── SKILL.md12 └── references/Load all skills at once:
1from kern.skills import Skills, LocalSkills23skills = Skills(loaders=[LocalSkills("/path/to/skills")])