Substitution Variables

Complete reference for every substitution variable available in SKILL.md files. Variables are replaced with actual values at skill load time, before the agent sees the content.

VariableCategoryDescriptionWorks In
$ARGUMENTSUser InputFull argument string after the skill name. Everything the user typed after /skill-name.Frontmatter + Body
$1 through $9User InputPositional arguments. The argument string is split on whitespace and assigned to $1, $2, ... $9.Frontmatter + Body
${CLAUDE_SESSION_ID}Built-inUnique identifier for the current agent session. Useful for creating unique temp files or directories.Frontmatter + Body
${SKILL_DIR}Built-inAbsolute filesystem path to the directory containing the current skill's SKILL.md. Essential for referencing supporting files.Frontmatter + Body
!`command`DynamicRuns a shell command at load time and replaces the expression with the command's stdout. Not technically a variable, but a substitution mechanism.Frontmatter + Body

$ARGUMENTS

Contains everything the user typed after the skill name, as a single string. This is the most common substitution variable and works well for free-form input.

explain/SKILL.md
---
description: Explain a concept in simple terms
---

The user wants you to explain the following topic:

$ARGUMENTS

Explain it as if teaching a junior developer.

Invocation: /explain dependency injection
Result: $ARGUMENTS becomes "dependency injection"

💡Handle empty arguments
If the user provides no arguments, $ARGUMENTS is replaced with an empty string. Write your instructions so the agent does something reasonable in both cases.

$1 through $9

Positional arguments are created by splitting the argument string on whitespace. Use these when your skill expects structured input with distinct parameters.

rename-component/SKILL.md
---
description: Rename a component across the codebase
---

Rename the React component from **$1** to **$2** across the entire codebase.

## Steps

1. Find all files that import or reference `$1`
2. Update the component name in its definition file
3. Update all import statements
4. Rename the file from `$1.tsx` to `$2.tsx`
Invocation$ARGUMENTS$1$2$3
/skill foo bar bazfoo bar bazfoobarbaz
/skill hellohellohello(empty)(empty)
/skill(empty)(empty)(empty)(empty)
âš ī¸No quoting mechanism
Arguments are split on whitespace. There is no way for a user to pass a multi-word value as a single positional argument. If your skill needs multi-word input, use $ARGUMENTS and parse it in the instructions.

${CLAUDE_SESSION_ID}

A unique identifier for the current agent session. Use this for creating temporary files or directories without naming collisions across sessions.

benchmark/SKILL.md
---
description: Run benchmarks and save results
allowed-tools:
  - Bash(*)
  - Write
---

Run the project benchmarks and save results to a unique file:

`benchmark-results-${CLAUDE_SESSION_ID}.json`

This ensures each session's results don't overwrite previous runs.

${SKILL_DIR}

The absolute filesystem path to the directory containing the current skill's SKILL.md. Always resolves to an absolute path regardless of where the agent was launched from.

api-docs/SKILL.md
---
description: Generate API documentation from OpenAPI spec
allowed-tools:
  - Read
  - Write
---

Read the documentation template from:
${SKILL_DIR}/templates/api-doc.md.hbs

Read the styling config from:
${SKILL_DIR}/config/doc-style.json

Use these to generate documentation for $ARGUMENTS.
â„šī¸Essential for supporting files
${SKILL_DIR} is the standard way to reference templates, configs, and other supporting files that live alongside the SKILL.md. Without it, your paths would break if the skill is installed in a different location.

!`command` — Dynamic Context

Runs a shell command at skill load time and replaces the expression with the command's stdout. This is a preprocessor step, not a tool invocation — it happens before the agent sees the skill content.

review-changes/SKILL.md
---
description: Review the current git changes
---

Current branch: !`git branch --show-current`

Staged changes:
!`git diff --cached`

Review these changes and suggest improvements.

Key Behaviors

  • Executes at load time (Tier 2) — before the agent starts processing the skill.
  • Runs once per invocation — invoking the same skill twice runs commands again.
  • Sequential execution — commands run top to bottom. Slow commands delay loading.
  • Combinable with variables — substitutions ($ARGUMENTS, $1, etc.) are applied first, then dynamic context commands execute.
file-history/SKILL.md
---
description: Analyze the history of a specific file
---

Recent changes to $1:
!`git log --oneline -10 -- $1`

Last author: !`git log -1 --format='%an (%ar)' -- $1`

Analyze the change history and identify patterns.
âš ī¸Security consideration
Commands in !`...` run with your shell permissions. Only use skills from sources you trust, and review any third-party skill that uses dynamic context.

Processing Order

StepWhat HappensExample
1String substitutions ($ARGUMENTS, $1-$9, ${CLAUDE_SESSION_ID}, ${SKILL_DIR}) are replaced with their values.git log -- $1 becomes git log -- src/auth.ts
2Dynamic context (!`...`) commands are executed and their output replaces the expressions.!`git log -- src/auth.ts` becomes the actual log output
3The fully resolved content is loaded into the agent's context.The agent sees the final text with all values filled in