Skills

Skills are markdown-based prompt templates that extend agent capabilities. Each skill is a markdown file with YAML frontmatter defining metadata and a body containing the instructions injected into the agent's prompt when invoked.

Skill File Format

A skill file has two parts:

---
name: review-pr
description: Review a pull request
user-invocable: true
argument-hint: "<PR number>"
---

Review pull request $ARGUMENTS and provide feedback on:
1. Code quality
2. Test coverage
3. Security concerns

Frontmatter Fields

The YAML frontmatter (between --- delimiters) supports these fields:

FieldTypeRequiredDefaultDescription
nameStringNoDerived from filenameSkill identifier
descriptionStringNo""Human-readable description
user-invocableboolNofalseWhether users can invoke this skill directly
allowed-toolsVec<String>No[]Tools the skill is allowed to use
modelStringNonullModel override for this skill
contextStringNonullAdditional context instructions
agentStringNonullTarget agent for the skill
hooksVec<String>No[]Hook events this skill responds to
argument-hintStringNonullHint text shown when skill expects arguments
unsafeboolNofalseWhether the skill performs potentially dangerous operations

Frontmatter uses kebab-case field names (e.g., user-invocable) which are deserialized to snake_case internally.

If frontmatter parsing fails, the skill still loads with default values — this is non-fatal.

Argument Substitution

Skill bodies support argument placeholders that are replaced at invocation time:

PlaceholderReplacement
$ARGUMENTSThe full argument string passed to the skill
$ARGUMENTS0 through $ARGUMENTS9Positional arguments (0-indexed)
$0 through $9Shorthand for positional arguments

Example:

---
name: compare
description: Compare two files
---

Compare the files $0 and $1, highlighting the differences.

Invoked as /compare src/old.rs src/new.rs, this becomes:

Compare the files src/old.rs and src/new.rs, highlighting the differences.

Resolution Order

When a skill is invoked by name, swarm searches three directories in priority order:

PriorityPathStyle
1.claude/skills/<name>/SKILL.mdProject-local, directory-style
2.skills/<name>.mdProject-local, flat files (backward-compatible)
3~/.claude/skills/<name>/SKILL.mdGlobal user skills

The first match wins. This means project-local skills override global ones.

Skill Names

Valid skill names contain only: [a-zA-Z0-9_:-]. Names with other characters are rejected.

Skill Discovery

The discover_skills() function scans all three directories and returns a BTreeMap<String, SkillSummary> of available skills:

FieldDescription
nameSkill name
descriptionFrom frontmatter
user_invocableWhether the skill can be invoked by users

Discovery is sorted alphabetically for consistent ordering.

Skill Resolution

The resolve() function finds a skill by name and returns a fully-resolved SkillDefinition:

FieldDescription
pathFile path where the skill was found
frontmatterParsed SkillFrontmatter
bodySkill body text (with frontmatter stripped)