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 frontmatter
3 scripts/ # Optional: Executable scripts
4 helper.py
5 references/ # Optional: Reference documentation
6 guide.md

The 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-skill
3description: Short description of what this skill does
4---
  • 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-review
3description: Code review assistance with style checking and best practices
4license: Apache-2.0
5metadata:
6 version: "1.0.0"
7 author: your-name
8 tags: ["python", "code-quality"]
9---

Full Example

1---
2name: code-review
3description: Code review assistance with style checking and best practices
4license: Apache-2.0
5metadata:
6 version: "1.0.0"
7 author: your-name
8 tags: ["python", "code-quality"]
9---
10
11# Code Review Skill
12
13Use this skill when reviewing code for quality, style, and best practices.
14
15## When to Use
16
17- User asks for code review or feedback
18- User wants to improve code quality
19- User needs help with refactoring
20
21## Process
22
231. **Analyze Structure**: Review overall code organization
242. **Check Style**: Look for style guide violations
253. **Identify Issues**: Find bugs, security issues, performance problems
264. **Suggest Improvements**: Provide actionable recommendations
27
28## Best Practices
29
30- Focus on the most impactful issues first
31- Explain the "why" behind suggestions
32- Provide code examples for fixes

Adding 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 python3
2"""Check code style and return results."""
3
4import sys
5
6def check_style(code: str) -> dict:
7 issues = []
8 lines = code.split('\n')
9
10 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")
15
16 return {"issues": issues, "count": len(issues)}
17
18if __name__ == "__main__":
19 # Read code from stdin or argument
20 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/bash
2# Run linting on provided file
3
4if [ -z "$1" ]; then
5 echo "Usage: lint.sh <file>"
6 exit 1
7fi
8
9ruff check "$1" 2>&1
Note

Scripts 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 Guide
2
3## Naming Conventions
4
5- **Variables**: `snake_case`
6- **Classes**: `PascalCase`
7- **Constants**: `UPPER_SNAKE_CASE`
8
9## Line Length
10
11- Maximum 100 characters per line
12- Break long lines at logical points
13
14## Imports
15
16- Standard library imports first
17- Third-party imports second
18- Local imports third
19- Alphabetize within each group

Validation 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

FieldMax Length
name64 characters
description1024 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.md
4 scripts/
5 references/
6 git-workflow/
7 SKILL.md
8 scripts/
9 references/
10 testing/
11 SKILL.md
12 references/

Load all skills at once:

1from kern.skills import Skills, LocalSkills
2
3skills = Skills(loaders=[LocalSkills("/path/to/skills")])