fix(create-agent-skills): remove literal dynamic context directives that break skill loading#252
Open
kirvahe wants to merge 1 commit intoEveryInc:mainfrom
Open
Conversation
…hat 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
create-agent-skillsskill fails to load via the Skill tool with:Root cause
The SKILL.md file contained literal
!commanddynamic context injection directives as documentation examples (lines 100, 111–112). Claude Code's preprocessor scans the **entire** SKILL.md as plain text before sending it to the model — it does not parse markdown. Fenced code blocks (` ```yaml `) and inline code spans () offer no protection from execution.When loading this skill, the preprocessor attempted to execute three directives:
!`command`→ shell error (commandis not a valid command)!`gh pr diff`→ fails outside a PR context!`gh pr diff --name-only`→ sameThis caused the skill to fail on every invocation, forcing Claude to fall back to manually reading the SKILL.md file — losing the benefits of skill-based loading.
Upstream references
!command`` directives inside markdown code spans" (closed, wontfix). Resolution: "The double backtick escaping was broken, so the content was never actually inside a code span. The preprocessor was correctly executing bare text. Workaround: describe the syntax in prose instead of using the literal syntax."Fix
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 at skill load timeWhy reference files are safe
When Claude encounters a link like
[official-spec.md](references/official-spec.md)in a skill, it reads that file on-demand using the Read tool. The preprocessor only processes the top-level SKILL.md content. This makes reference files the correct place for documentation that includes literal dynamic context directives.Scope
plugins/compound-engineering/skills/create-agent-skills/SKILL.mdofficial-spec.mdalready contains a safe concrete exampleTest plan
/compound-engineering:create-agent-skillsvia the Skill tool — should load without errors!command`` directives:grep -rl '!\x60' plugins/*/skills/*/SKILL.mdshould return empty🤖 Generated with Claude Code