Get the FREE Ultimate OpenClaw Setup Guide →

creating-skills

Scanned
npx machina-cli add skill fvadicamo/dev-agent-skills/creating-skills --openclaw
Files (1)
SKILL.md
5.9 KB

Creating skills

Guide for creating Claude Code skills following Anthropic's official best practices.

Quick start

# 1. Create skill directory
mkdir -p ~/.claude/skills/<skill-name>

# 2. Create SKILL.md with frontmatter
cat > ~/.claude/skills/<skill-name>/SKILL.md << 'EOF'
---
name: <skill-name>
description: <What it does>. Use when <trigger phrases>. <Key capabilities>.
---

# <Skill title>

<Instructions for the skill workflow>
EOF

# 3. Add optional resources as needed
mkdir -p ~/.claude/skills/<skill-name>/{scripts,references,assets}

SKILL.md structure

Frontmatter (YAML between --- markers)

FieldRequiredDescription
nameNoDisplay name. Defaults to directory name. Lowercase, hyphens, max 64 chars.
descriptionRecommendedWhat + when + capabilities. Max 1024 chars. Determines when Claude activates the skill.
allowed-toolsNoTools Claude can use without asking permission when skill is active.
argument-hintNoAutocomplete hint for arguments. Example: [issue-number]
disable-model-invocationNotrue to prevent auto-invocation (manual /name only).
user-invocableNofalse to hide from / menu (background knowledge only).
modelNoModel override when skill is active.
contextNofork to run in isolated subagent context.
agentNoSubagent type when context: fork. Built-in: Explore, Plan, general-purpose.
hooksNoLifecycle hooks scoped to this skill.

Invocation control matrix

ConfigurationUser can invokeClaude can invoke
(defaults)YesYes
disable-model-invocation: trueYesNo
user-invocable: falseNoYes

Description formula

<What it does>. Use when <trigger phrases>. <Key capabilities>.

Include action verbs ("create", "handle"), user intent ("wants to", "needs to"), and domain keywords users would say.

Directory structure

skill-name/
├── SKILL.md              # Required: instructions (keep under 500 lines)
├── scripts/              # Optional: executable code (deterministic, token-efficient)
├── references/           # Optional: docs loaded into context on demand
└── assets/               # Optional: files used in output, NOT loaded into context
                          #   (templates, images, fonts, boilerplate)

Progressive disclosure (3-level loading)

  1. Metadata (name + description) - always in context (~100 tokens per skill)
  2. SKILL.md body - loaded when skill triggers (keep under 5k words)
  3. Bundled resources - loaded as needed by Claude

Reference supporting files from SKILL.md so Claude knows they exist. Keep references one level deep. For files over 100 lines, include a table of contents.

Scripts vs references vs assets

TypePurposeLoaded into context?
scripts/Deterministic operations, complex processingNo (executed via bash)
references/Documentation Claude reads while workingYes, on demand
assets/Templates, images, fonts for outputNo (copied/used in output)

Only create scripts when they add value: complex multi-step processing, repeated code generation, deterministic reliability. Not for single-command wrappers.

Dynamic features

Context injection

Inject shell command output into skill content before loading:

## Recent commits
!`git log --oneline -5 2>/dev/null`

The output replaces the directive when the skill loads.

String substitutions

Pass arguments to skills invoked via /skill-name arg1 arg2:

VariableValue
$ARGUMENTSFull argument string
$ARGUMENTS[0], $ARGUMENTS[1]Individual arguments
$1, $2Shorthand for $ARGUMENTS[N]

Subagent execution

Run a skill in isolated context with context: fork:

---
name: deep-research
description: Research a topic thoroughly.
context: fork
agent: Explore
---

Degrees of freedom

Match specificity to the task's fragility:

LevelWhen to useExample
High (text instructions)Multiple valid approaches, context-dependent"Analyze the code and suggest improvements"
Medium (pseudocode/scripts with params)Preferred pattern exists, some variation OKScript with configurable parameters
Low (specific scripts, few params)Fragile operations, consistency criticalExact sequence of API calls

Naming conventions

  • Lowercase, hyphens between words, max 64 chars
  • Styles: gerund (processing-pdfs), noun phrase (github-pr-creation), prefixed group (github-pr-*)

Important rules

  • ALWAYS write descriptions that include WHAT + WHEN triggers + capabilities
  • ALWAYS keep SKILL.md under 500 lines, split to references when approaching
  • ALWAYS reference bundled files from SKILL.md so Claude discovers them
  • NEVER duplicate info between SKILL.md and reference files
  • NEVER create wrapper scripts for single commands
  • NEVER include extraneous files (README.md, CHANGELOG.md, INSTALLATION_GUIDE.md, QUICK_REFERENCE.md)
  • NEVER explain things Claude already knows (standard libraries, common tools, basic patterns)

References

  • references/official_best_practices.md - Principles, anti-patterns, quality checklist, testing
  • references/skill_examples.md - Concrete skill examples with new features

Source

git clone https://github.com/fvadicamo/dev-agent-skills/blob/main/skills/creating-skills/SKILL.mdView on GitHub

Overview

This skill provides practical guidelines and templates for building Claude Code skills. It covers SKILL.md frontmatter, naming conventions, directory structure, and modern features like dynamic context injection and subagent execution to standardize skill creation and updates.

How This Skill Works

The skill describes a structured workflow: set up a skill directory, create SKILL.md with a defined frontmatter, and organize optional resources (scripts, references, assets). It also explains progressive disclosure, an invocation matrix, and how dynamic features like context injection and subagent execution integrate into skill behavior.

When to Use It

  • Starting a new Claude Code skill from scratch
  • Writing or updating SKILL.md with proper frontmatter and guidance
  • Defining naming conventions, metadata, and directory structure
  • Configuring dynamic context injection or subagent execution
  • Documenting guidelines and best practices for teams

Quick Start

  1. Step 1: mkdir -p ~/.claude/skills/<skill-name>
  2. Step 2: Create SKILL.md with frontmatter and guidance
  3. Step 3: Add optional resources (scripts, references, assets) as needed

Best Practices

  • Follow the frontmatter schema and naming rules (lowercase, hyphens, max 64 chars).
  • Keep SKILL.md under 500 lines and describe capabilities clearly to control activation.
  • Use progressive disclosure: metadata, body, then bundled resources to manage context load.
  • Use scripts for deterministic tasks and load references on demand to minimize context load.
  • Explicitly document dynamic features (context injection, subagents) with examples in SKILL.md.

Example Use Cases

  • Create a new Claude Code skill to scaffold other skills automatically.
  • A skill that injects recent git history into prompts via context injection.
  • A skill that delegates tasks to a subagent (Plan/Explore) for task planning.
  • A skill that loads external references on demand during execution.
  • A skill that enforces SKILL.md naming conventions across a repository.

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers