Agent Skills Cheatsheet

Single-page quick reference for everything you need while building agent skills.

Skill File Structure

Skill directory layout
my-skill/
  SKILL.md          # Main skill file (required)
  templates/        # Supporting templates (optional)
  config/           # Supporting configs (optional)
  scripts/          # Helper scripts (optional)
SKILL.md anatomy
---
description: Short summary of what the skill does
allowed-tools:                    # optional
  - Read
  - Write
  - Bash(npm run *)
context:                          # optional
  - file: path/to/file
  - command: shell-command
---

# Skill Title

Instructions for the agent go here. Use Markdown.
Reference $ARGUMENTS and other substitution variables.

Frontmatter Fields

FieldTypeRequiredPurpose
descriptionstringYesDiscovery and display text. Keep under 100 chars, start with a verb.
allowed-toolsstring[]NoRestrict which tools the skill can use. Omit for full access.
contextobject[]NoInject file contents or command output at load time.

Substitution Variables

VariableSourceDescription
$ARGUMENTSUserFull text after skill name
$1 - $9UserWhitespace-split positional args
${CLAUDE_SESSION_ID}Built-inUnique session identifier
${SKILL_DIR}Built-inAbsolute path to skill directory
!`cmd`DynamicShell command output injected at load time
ℹ️Processing order
String substitutions ($ARGUMENTS, $1-$9, built-ins) are applied first, then !`command` expressions execute with the substituted values.

Allowed Tools Syntax

SyntaxMeaning
ReadAllow the Read tool (no arguments needed)
WriteAllow the Write tool
EditAllow the Edit tool
GlobAllow the Glob tool
GrepAllow the Grep tool
Bash(exact cmd)Allow only this exact shell command
Bash(git *)Allow any git subcommand (glob pattern)
Bash(npm run *)Allow any npm script
Bash(*)Unrestricted shell access (use with caution)
WebSearchAllow web search
WebFetchAllow fetching URLs
TaskAllow subtask creation

Skill Locations (Priority Order)

PriorityLocationScopeUse Case
1 (highest)Enterprise managed settingsOrganizationEnforced standards, cannot be overridden
2~/.claude/skills/User (all projects)Personal workflows that follow you everywhere
3.claude/skills/Project (team)Shared skills committed to version control
4 (lowest)Plugin skillsExternalThird-party skills from registries or packages
💡Same name = highest priority wins
When skills share the same name across locations, the higher-priority location takes precedence. Enterprise skills always win.

Common Patterns

Read-Only Analysis

Pattern: read-only
---
description: Analyze code complexity and suggest refactoring targets
allowed-tools:
  - Read
  - Glob
  - Grep
---

Scoped Shell Access

Pattern: scoped shell
---
description: Run tests for a specific module
allowed-tools:
  - Bash(npm test -- --filter $1)
  - Bash(npm run lint -- $1)
  - Read
---

File Generation with Templates

Pattern: templated generation
---
description: Generate a new component from project templates
allowed-tools:
  - Read
  - Write
  - Glob
context:
  - file: .templates/component.tsx.hbs
---

Read the template from context. Create a new component
named $1 in src/components/$1/.

Git-Aware Workflow

Pattern: git-aware
---
description: Generate release notes from recent commits
allowed-tools:
  - Bash(git *)
  - Write
---

Current branch: !`git branch --show-current`
Commits since last tag:
!`git log $(git describe --tags --abbrev=0)..HEAD --oneline`

Generate release notes grouped by conventional commit type.

Dynamic Tool Scoping

Pattern: dynamic scoping
---
description: Work with a specific service
allowed-tools:
  - Bash(docker compose * $1)
  - Bash(docker logs $1)
  - Read
---

Manage the **$1** service in the Docker Compose stack.

Supporting Files

Pattern: supporting files
---
description: Create an API endpoint following our conventions
allowed-tools:
  - Read
  - Write
---

Read the route template from:
${SKILL_DIR}/templates/route.ts.hbs

Read the test template from:
${SKILL_DIR}/templates/route.test.ts.hbs

Create a new endpoint for $ARGUMENTS using these templates.