Aller au contenu principal

Skill: writing-skills

Fork

Guide for creating new skills for the Claude Code foundation. Trigger when the user wants to create a skill, add a command, or extend the foundation.

Configuration

PropertyValue
Contextfork
Allowed toolsRead, Write, Edit, Glob, Grep
Keywordswriting, skills

Detailed description

Creating New Skills

Objective

Framework for creating quality skills for the Claude Code foundation, respecting the existing conventions and structure.

Skill structure

.claude/skills/<skill-name>/
└── SKILL.md

SKILL.md format

---
name: my-skill
description: Clear description of the skill. Trigger when [activation context].
allowed-tools:
- Read
- Write # If the skill modifies files
- Edit # If the skill edits existing files
- Bash # If the skill executes commands
- Glob # File search
- Grep # Content search
context: fork # Always fork for isolation
---

# Skill Title

## Objective
[Clear description of what the skill does]

## Instructions
[Detailed instructions, structured in steps]

## Expected output
[Expected output format]

## Rules
[Mandatory rules for the skill]

Available Frontmatter Fields (Claude Code 2.1+)

All fields available in the YAML frontmatter of a skill:

FieldRequiredDescription
nameNoSkill name (default: folder name). Lowercase, digits, hyphens (max 64 chars)
descriptionRecommendedWhat the skill does and when to use it. Claude uses this to decide when to load the skill
allowed-toolsNoTools authorized without permission prompt
contextNofork for execution in an isolated sub-agent
modelNoModel to use: sonnet, opus, haiku, inherit (default: inherits from context)
agentNoSub-agent type when context: fork (Explore, Plan, general-purpose, or custom agent)
disable-model-invocationNotrue = manual invocation only (Claude cannot auto-load). Default: false
user-invocableNofalse = invisible in the / menu (background skills). Default: true
argument-hintNoAutocompletion hint shown in the / menu. E.g.: [issue-number] or [filename] [format]
hooksNoHooks scoped to the skill lifecycle (PreToolUse, PostToolUse, Stop)

Variable substitutions

VariableDescription
$ARGUMENTSAll arguments passed to the skill
$ARGUMENTS[N]Argument by index (0-based)
$NShortcut for $ARGUMENTS[N]
${CLAUDE_SESSION_ID}Current session ID

Dynamic context injection

Use the backtick-bang syntax to inject live data:

  • Example: ! followed by backtick then gh pr diff then backtick
  • The command runs BEFORE Claude sees the content
  • The result replaces the placeholder

Example:

## PR Context
- Diff: !`gh pr diff`
- Files: !`gh pr diff --name-only`

Frontmatter best practices

  • SKILL.md < 500 lines (move detail to reference files via supporting files)
  • Description budget: 15,000 chars max (variable SLASH_COMMAND_TOOL_CHAR_BUDGET)
  • Supporting files: examples/, scripts/, reference.md in the skill folder
  • Use disable-model-invocation: true for skills that should only be launched manually (e.g.: commit, PR, plan)
  • Use user-invocable: false for context/background skills that Claude loads automatically (state-management, api-mocking)
  • Use model: sonnet for complex skills requiring deep reasoning (debug, security, TDD, perf)
  • Use argument-hint to guide the user on the expected parameters

Skill quality checklist

Structure

[ ] Valid YAML frontmatter (name, description, allowed-tools, context)
[ ] kebab-case name
[ ] Description with trigger context
[ ] Minimal necessary tools (principle of least privilege)
[ ] context: fork (isolation)

Content

[ ] Clear objective in 1-2 sentences
[ ] Instructions structured as numbered steps
[ ] Relevant code examples
[ ] Expected output with template
[ ] Explicit rules and constraints
[ ] ASCII diagram if complex workflow

Quality

[ ] Actionable (not just informative)
[ ] Specific (not generic)
[ ] Testable (verifiable results)
[ ] Standalone (no dependency on other skills)
[ ] Consistent with the foundation's conventions

Foundation conventions

Naming

TypeConventionExamples
Dev skillsdev-*dev-tdd, dev-debug, dev-api
QA skillsqa-*qa-review, qa-security
Ops skillsops-*ops-docker, ops-ci
Doc skillsdoc-*doc-generate, doc-changelog
Growth skillsgrowth-*growth-seo, growth-cro
Biz skillsbiz-*biz-model, biz-mvp
Legal skillslegal-*legal-rgpd
Data skillsdata-*data-pipeline
Workflow skillswork-*work-explore, work-plan
Meta skillsDescriptive nameparallel-agents, session-handoff

Content patterns

1. ASCII workflow diagram (if applicable)
2. Numbered steps with subsections
3. Tables for quick references
4. Code blocks with specified language
5. "Expected output" section with template
6. "Rules" section with IMPORTANT/NEVER/YOU MUST

Tools by skill type

Skill typeRecommended tools
Read-only (audit, review)Read, Glob, Grep
DevelopmentRead, Write, Edit, Bash, Glob, Grep
InfrastructureRead, Write, Edit, Bash, Glob, Grep
DocumentationRead, Write, Edit, Glob, Grep
AnalysisRead, Glob, Grep

Also create the associated files

Command (optional)

.claude/commands/<domain>/<name>.md

Format: detailed prompt with $ARGUMENTS, workflow, expected output, related agents.

Agent (optional)

.claude/agents/<name>.md

Format: YAML frontmatter with model, permissionMode, disallowedTools, skills, hooks.

Rule (optional)

.claude/rules/<name>.md

Format: frontmatter with paths, contextual rules per file type.

Creation workflow

1. IDENTIFY the need (which problem does this skill solve?)
2. NAME according to conventions (domain-action)
3. DEFINE the necessary tools (principle of least privilege)
4. WRITE the SKILL.md with the template
5. CREATE the associated command if manual invocation is needed
6. CREATE the associated agent if isolated execution is needed
7. TEST the skill (invoke it and verify the result)
8. DOCUMENT in CLAUDE.md (skills table)

Rules

  • One skill = one single responsibility
  • Description with mandatory trigger context
  • Minimal tools (no Write if the skill doesn't modify anything)
  • Always use context: fork for isolation
  • Concrete examples, no abstract theory
  • Expected output clearly defined

Automatic triggering

This skill is automatically activated when:

  • The matching keywords are detected in the conversation
  • The task context matches the skill's domain

Triggering examples

  • "I want to writing..."
  • "I want to skills..."

Context fork

Fork means the skill runs in an isolated context:

  • Does not pollute the main conversation
  • Results are returned cleanly
  • Ideal for autonomous tasks

See also