Dynamic Context in Skills
Skills are static SKILL.md files — but they can pull live data at invocation time. Add a ## Context block and Claude Code will evaluate shell commands and inject the results before Claude even reads your instructions.
What is dynamic context?
When Claude Code runs a skill, it processes the SKILL.md file before sending anything to Claude. If you include a ## Context section with shell substitution expressions, Claude Code evaluates them and injects the real output into the prompt.
This means your skills can automatically know:
$CURRENT_DATE$(git branch --show-current)$(git diff --cached --name-only)$(git diff --cached)$(git log -1 --pretty='%h %s')$(echo $NODE_ENV)How it works
Before and after — /standup
The simplest way to see the value of dynamic context is to compare the same skill with and without it.
/standup — live output
Below is what the terminal looks like when you run /standup with dynamic context enabled.
Example — /review with staged diff
Injecting the full staged diff means Claude reviews exactly the code you are about to commit — not the whole file, not a pasted snippet.
git diff --cached -- src/auth.ts to a single file.Example — /deploy-check with multiple sources
A pre-deployment checklist skill can pull the branch, last commit, and working-tree status all in one go.
Dynamic context syntax reference
| Expression | What it injects | Works in |
|---|---|---|
$CURRENT_DATE | Today's date (YYYY-MM-DD) | Claude Code |
$(git branch --show-current) | Active branch name | Claude Code |
$(git diff --cached --name-only) | List of staged file paths | Claude Code |
$(git diff --cached) | Full staged diff (use carefully with large changes) | Claude Code |
$(git log -1 --pretty='%h %s') | Hash + message of last commit | Claude Code |
$(git status --short) | Uncommitted changes (porcelain format) | Claude Code |
$(echo $NODE_ENV) | Any environment variable value | Claude Code |
$(cat package.json | head -5) | First 5 lines of any file | Claude Code |
Best practices
$CURRENT_DATE and $(git branch --show-current). They are low-risk, always relevant, and immediately make your skills feel much smarter. Add the staged diff only when the skill genuinely needs to read code.What's Next
Dynamic context unlocks real-time data. Next: combine skills with sub-agents to orchestrate multi-step, parallel workflows.