fix(create-agent-skills): remove literal dynamic context directives that break skill loading
The `create-agent-skills` SKILL.md contained literal `!`command`` dynamic
context injection directives as documentation examples. Claude Code's
preprocessor executes these directives as plain text before the skill
content is sent to the model — it does not parse markdown, so fenced code
blocks and inline code spans offer no protection.
When loading this skill, the preprocessor attempted to run `command`,
`gh pr diff`, and `gh pr diff --name-only` as shell commands, producing:
Bash command failed for pattern "!`command`":
(eval):1: redirection with no command
This caused the skill to fail silently or error on every invocation.
Fix: replace the literal directives with a prose description of the
syntax, add a warning about the preprocessor behavior, and link to
`references/official-spec.md` § "Dynamic Context Injection" for the
concrete example (reference files are loaded on-demand by Claude via the
Read tool and are not preprocessed).
Upstream context:
- anthropics/claude-code#27149 (closed, wontfix): preprocessor correctly
executes bare text; workaround is to describe the syntax in prose
- anthropics/claude-code#28024 (closed as duplicate of #13655)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -97,22 +97,11 @@ Access individual args: `$ARGUMENTS[0]` or shorthand `$0`, `$1`, `$2`.
|
||||
|
||||
### Dynamic Context Injection
|
||||
|
||||
The `` !`command` `` syntax runs shell commands before content is sent to Claude:
|
||||
Skills support dynamic context injection: prefix a backtick-wrapped shell command with an exclamation mark, and the preprocessor executes it at load time, replacing the directive with stdout. Write an exclamation mark immediately before the opening backtick of the command you want executed (for example, to inject the current git branch, write the exclamation mark followed by `git branch --show-current` wrapped in backticks).
|
||||
|
||||
```yaml
|
||||
---
|
||||
name: pr-summary
|
||||
description: Summarize changes in a pull request
|
||||
context: fork
|
||||
agent: Explore
|
||||
---
|
||||
**Important:** The preprocessor scans the entire SKILL.md as plain text — it does not parse markdown. Directives inside fenced code blocks or inline code spans are still executed. If a skill documents this syntax with literal examples, the preprocessor will attempt to run them, causing load failures. To safely document this feature, describe it in prose (as done here) or place examples in a reference file, which is loaded on-demand by Claude and not preprocessed.
|
||||
|
||||
## Context
|
||||
- PR diff: !`gh pr diff`
|
||||
- Changed files: !`gh pr diff --name-only`
|
||||
|
||||
Summarize this pull request...
|
||||
```
|
||||
For a concrete example of dynamic context injection in a skill, see [official-spec.md](references/official-spec.md) § "Dynamic Context Injection".
|
||||
|
||||
### Running in a Subagent
|
||||
|
||||
|
||||
Reference in New Issue
Block a user