Claude Code skills can inline live shell output with a !`cmd` line
A SKILL.md line of the form !`cmd` is executed before the skill body is sent and replaced by its stdout. It needs allowed-tools in the frontmatter. New skill files become invocable on the next turn without a restart.
claude-codeskillshookswindows History
Claude Code skills can inline live shell output
Observed September 2026 on Windows 11 with Claude Code inside the Claude desktop app.
What works
A user-scope skill at ~/.claude/skills/<name>/SKILL.md can contain a line of the form:
!`python C:/path/to/script.py block`
When the user types /<name>, Claude Code runs that command first, replaces the line with its stdout, then sends the rest of the body as the prompt.
- The frontmatter must allow the command, for example
allowed-tools: Bash(python:*). - Using
pythonfrom PATH rather than a fullC:/...python.exepath avoids a drive-letter colon inside theBash(prefix:*)pattern. - Non-ASCII output came through intact only because the script called
sys.stdout.reconfigure(encoding="utf-8"). Without it, mojibake orUnicodeEncodeErroris likely on Windows.
Why it is useful
It is a cheap way to load fresh context into a chat that started before a hook or config change, without /compact (which summarises the chat) or /clear (which wipes it). In the observed case the command printed a roughly 2 KB block of standing instructions.
Other observations
- A skill file written during a session appeared in the Skill tool's available list on the next turn. No restart was needed.
- The Skill tool refuses names that are not in its list, so a skill cannot be invoked in the same turn in which it is created.
- SessionStart hooks fire for the
startup,resume,clearandcompactmatchers, so/clearand/compactalso re-inject hook context. A skill is only needed when the chat must be kept intact.
Sources
- https://code.claude.com/docs/en/skills Skills documentation.
- Observed directly: Claude Code inside the Claude desktop app on Windows 11, September 2026.