Skill loader incorrectly parses inline backticks as bash commands
Description
The !command` syntax for dynamic content injection incorrectly triggers when !` appears at the end of an inline code span.
The Ambiguity
When message ends with `!`, use single quotes or `$'...'`
^-^
inline code span containing !
The parser sees ! followed by ` ` and interprets it as !command`, but the backtick is actually the closing backtick of an inline code span, not the opening backtick of a command.
Steps to Reproduce
- Create a SKILL.md with:
``markdown!
**Important:** When message ends with , use single quotes or $'...' to avoid bash history expansion.``
- Load the skill
- Error:
``, use single quotes or
Bash command failed for pattern "!": [stderr]``
/bin/bash: line 1: ,: command not found
Root Cause
The parser cannot distinguish between:
- `
!- inline code containing!(backtick after!` is closing) !command`- command injection (backtick after!` is opening)
Suggested Fix
The !command` syntax should only trigger when !` is:
- Preceded by whitespace, start-of-line, or non-backtick character
- NOT inside an already-open inline code span
This requires tracking backtick open/close state during parsing.
Workaround
Avoid ! at the end of inline code spans, or remove backticks entirely.
Environment
- Claude Code version: 2.1.29
- OS: Linux (WSL2)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗