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
background: false # Fork skills run DETACHED by default since CC 2.1.218 (async result, narrower tool set, edits skip /rewind checkpoints) — workflow skills must block
---
# 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:
| Field |
Required |
Description |
name |
No |
Skill name (default: folder name). Lowercase, digits, hyphens (max 64 chars) |
description |
Recommended |
What the skill does and when to use it. Claude uses this to decide when to load the skill |
allowed-tools |
No |
Tools authorized without permission prompt |
context |
No |
fork for execution in an isolated sub-agent |
background |
No |
With context: fork only. Since CC 2.1.218 forked skills run in the BACKGROUND by default (async result, narrower background tool set, edits bypass /rewind checkpoints). Set false to block in-turn — the foundation default for workflow skills |
model |
No |
Model to use: sonnet, opus, haiku, inherit (default: inherits from context) |
agent |
No |
Sub-agent type when context: fork (Explore, Plan, general-purpose, or custom agent) |
disable-model-invocation |
No |
true = manual invocation only (Claude cannot auto-load). Default: false |
user-invocable |
No |
false = invisible in the / menu (background skills). Default: true |
argument-hint |
No |
Autocompletion hint shown in the / menu. E.g.: [issue-number] or [filename] [format] |
hooks |
No |
Hooks scoped to the skill lifecycle (PreToolUse, PostToolUse, Stop) |
Variable substitutions
| Variable |
Description |
$ARGUMENTS |
All arguments passed to the skill |
$ARGUMENTS[N] |
Argument by index (0-based) |
$N |
Shortcut 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)
[ ] background: false (block in-turn; omit only for a deliberately detached skill)
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
| Type |
Convention |
Examples |
| Dev skills |
dev-* |
dev-tdd, dev-debug, dev-api |
| QA skills |
qa-* |
qa-review, qa-security |
| Ops skills |
ops-* |
ops-docker, ops-ci |
| Doc skills |
doc-* |
doc-generate, doc-changelog |
| Growth skills |
growth-* |
growth-seo, growth-cro |
| Biz skills |
biz-* |
biz-model, biz-mvp |
| Legal skills |
legal-* |
legal-rgpd |
| Data skills |
data-* |
data-pipeline |
| Workflow skills |
work-* |
work-explore, work-plan |
| Meta skills |
Descriptive name |
parallel-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 type |
Recommended tools |
| Read-only (audit, review) |
Read, Glob, Grep |
| Development |
Read, Write, Edit, Bash, Glob, Grep |
| Infrastructure |
Read, Write, Edit, Bash, Glob, Grep |
| Documentation |
Read, Write, Edit, Glob, Grep |
| Analysis |
Read, 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
1---2name: writing-skills3description: 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.4---56# Creating New Skills78## Objective910Framework for creating quality skills for the Claude Code foundation, respecting the existing conventions and structure.1112## Skill structure1314```15.claude/skills/<skill-name>/16└── SKILL.md17```1819### SKILL.md format2021```yaml22---23name: my-skill24description: Clear description of the skill. Trigger when [activation context].25allowed-tools:26 - Read27 - Write # If the skill modifies files28 - Edit # If the skill edits existing files29 - Bash # If the skill executes commands30 - Glob # File search31 - Grep # Content search32context: fork # Always fork for isolation33background: false # Fork skills run DETACHED by default since CC 2.1.218 (async result, narrower tool set, edits skip /rewind checkpoints) — workflow skills must block34---3536# Skill Title3738## Objective39[Clear description of what the skill does]4041## Instructions42[Detailed instructions, structured in steps]4344## Expected output45[Expected output format]4647## Rules48[Mandatory rules for the skill]49```5051## Available Frontmatter Fields (Claude Code 2.1+)5253All fields available in the YAML frontmatter of a skill:5455| Field | Required | Description |56|-------|----------|-------------|57| `name` | No | Skill name (default: folder name). Lowercase, digits, hyphens (max 64 chars) |58| `description` | Recommended | What the skill does and when to use it. Claude uses this to decide when to load the skill |59| `allowed-tools` | No | Tools authorized without permission prompt |60| `context` | No | `fork` for execution in an isolated sub-agent |61| `background` | No | With `context: fork` only. Since CC 2.1.218 forked skills run in the BACKGROUND by default (async result, narrower background tool set, edits bypass `/rewind` checkpoints). Set `false` to block in-turn — the foundation default for workflow skills |62| `model` | No | Model to use: `sonnet`, `opus`, `haiku`, `inherit` (default: inherits from context) |63| `agent` | No | Sub-agent type when `context: fork` (`Explore`, `Plan`, `general-purpose`, or custom agent) |64| `disable-model-invocation` | No | `true` = manual invocation only (Claude cannot auto-load). Default: `false` |65| `user-invocable` | No | `false` = invisible in the `/` menu (background skills). Default: `true` |66| `argument-hint` | No | Autocompletion hint shown in the `/` menu. E.g.: `[issue-number]` or `[filename] [format]` |67| `hooks` | No | Hooks scoped to the skill lifecycle (PreToolUse, PostToolUse, Stop) |6869### Variable substitutions7071| Variable | Description |72|----------|-------------|73| `$ARGUMENTS` | All arguments passed to the skill |74| `$ARGUMENTS[N]` | Argument by index (0-based) |75| `$N` | Shortcut for `$ARGUMENTS[N]` |76| `${CLAUDE_SESSION_ID}` | Current session ID |7778### Dynamic context injection7980Use the backtick-bang syntax to inject live data:81- Example: `!` followed by backtick then `gh pr diff` then backtick82- The command runs BEFORE Claude sees the content83- The result replaces the placeholder8485Example:86```markdown87## PR Context88- Diff: !`gh pr diff`89- Files: !`gh pr diff --name-only`90```9192### Frontmatter best practices9394- SKILL.md < 500 lines (move detail to reference files via `supporting files`)95- Description budget: 15,000 chars max (variable `SLASH_COMMAND_TOOL_CHAR_BUDGET`)96- Supporting files: `examples/`, `scripts/`, `reference.md` in the skill folder97- Use `disable-model-invocation: true` for skills that should only be launched manually (e.g.: commit, PR, plan)98- Use `user-invocable: false` for context/background skills that Claude loads automatically (state-management, api-mocking)99- Use `model: sonnet` for complex skills requiring deep reasoning (debug, security, TDD, perf)100- Use `argument-hint` to guide the user on the expected parameters101102## Skill quality checklist103104### Structure105106```107[ ] Valid YAML frontmatter (name, description, allowed-tools, context)108[ ] kebab-case name109[ ] Description with trigger context110[ ] Minimal necessary tools (principle of least privilege)111[ ] context: fork (isolation)112[ ] background: false (block in-turn; omit only for a deliberately detached skill)113```114115### Content116117```118[ ] Clear objective in 1-2 sentences119[ ] Instructions structured as numbered steps120[ ] Relevant code examples121[ ] Expected output with template122[ ] Explicit rules and constraints123[ ] ASCII diagram if complex workflow124```125126### Quality127128```129[ ] Actionable (not just informative)130[ ] Specific (not generic)131[ ] Testable (verifiable results)132[ ] Standalone (no dependency on other skills)133[ ] Consistent with the foundation's conventions134```135136## Foundation conventions137138### Naming139140| Type | Convention | Examples |141|------|------------|----------|142| Dev skills | `dev-*` | `dev-tdd`, `dev-debug`, `dev-api` |143| QA skills | `qa-*` | `qa-review`, `qa-security` |144| Ops skills | `ops-*` | `ops-docker`, `ops-ci` |145| Doc skills | `doc-*` | `doc-generate`, `doc-changelog` |146| Growth skills | `growth-*` | `growth-seo`, `growth-cro` |147| Biz skills | `biz-*` | `biz-model`, `biz-mvp` |148| Legal skills | `legal-*` | `legal-rgpd` |149| Data skills | `data-*` | `data-pipeline` |150| Workflow skills | `work-*` | `work-explore`, `work-plan` |151| Meta skills | Descriptive name | `parallel-agents`, `session-handoff` |152153### Content patterns154155```1561. ASCII workflow diagram (if applicable)1572. Numbered steps with subsections1583. Tables for quick references1594. Code blocks with specified language1605. "Expected output" section with template1616. "Rules" section with IMPORTANT/NEVER/YOU MUST162```163164### Tools by skill type165166| Skill type | Recommended tools |167|------------|-------------------|168| Read-only (audit, review) | Read, Glob, Grep |169| Development | Read, Write, Edit, Bash, Glob, Grep |170| Infrastructure | Read, Write, Edit, Bash, Glob, Grep |171| Documentation | Read, Write, Edit, Glob, Grep |172| Analysis | Read, Glob, Grep |173174## Also create the associated files175176### Command (optional)177178```179.claude/commands/<domain>/<name>.md180```181182Format: detailed prompt with `$ARGUMENTS`, workflow, expected output, related agents.183184### Agent (optional)185186```187.claude/agents/<name>.md188```189190Format: YAML frontmatter with model, permissionMode, disallowedTools, skills, hooks.191192### Rule (optional)193194```195.claude/rules/<name>.md196```197198Format: frontmatter with paths, contextual rules per file type.199200## Creation workflow201202```2031. IDENTIFY the need (which problem does this skill solve?)2042. NAME according to conventions (domain-action)2053. DEFINE the necessary tools (principle of least privilege)2064. WRITE the SKILL.md with the template2075. CREATE the associated command if manual invocation is needed2086. CREATE the associated agent if isolated execution is needed2097. TEST the skill (invoke it and verify the result)2108. DOCUMENT in CLAUDE.md (skills table)211```212213## Rules214215- One skill = one single responsibility216- Description with mandatory trigger context217- Minimal tools (no Write if the skill doesn't modify anything)218- Always use `context: fork` for isolation219- Concrete examples, no abstract theory220- Expected output clearly defined