claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Skill loading executes inline bash patterns from documentation examples

Open sjnims opened this issue 2 months ago • 5 comments

Bug Description

When loading a skill via the Skill tool, inline bash execution patterns (!`...`) within the skill's markdown content are being executed, even when they appear inside fenced code blocks as documentation examples.

Steps to Reproduce

  1. Create or use a skill that contains example command documentation with inline bash patterns
  2. Load the skill using the Skill tool
  3. Observe that bash patterns in code examples are executed

Example

The plugin-dev:command-development skill contains this documentation example in SKILL.md at line 496:

### Workflow Pattern

```markdown
---
description: Complete PR workflow
argument-hint: [pr-number]
allowed-tools: Bash(gh:*), Read
---

PR #$1 Workflow:

1. Fetch PR: !`gh pr view $1`
```

When this skill is loaded, the !`gh pr view $1` pattern executes despite being:

  1. Inside a fenced code block (meant as documentation)
  2. Containing an unsubstituted $1 placeholder

Actual Behavior

Error: Bash command failed for pattern "!`gh pr view $1`": [stderr]
no pull requests found for branch "main"

The skill partially loads but errors because the example bash pattern executed.

Expected Behavior

Inline bash patterns (!`...`) inside fenced code blocks should NOT be executed when loading skills. They are documentation examples, not executable instructions.

Affected Files

  • /plugins/plugin-dev/skills/command-development/SKILL.md (line 496)
  • /plugins/plugin-dev/skills/command-development/references/advanced-workflows.md (line 25)

Workaround

Escape the patterns in documentation using backslashes or alternative formatting to prevent execution during skill loading.

Environment

  • Claude Code CLI
  • macOS

🤖 Generated with Claude Code

sjnims avatar Dec 01 '25 02:12 sjnims

Still occurring as of v2.x (Dec 2025). The command-development skill hits multiple patterns during activation:

Error: Bash command failed for pattern "!npm test $1" Error: Bash command failed for pattern "!bash ${CLAUDE_PLUGIN_ROOT}/scripts/script.sh"

This creates a catch-22 for skill authors: skills teaching command syntax cannot show the real !cmd pattern without triggering execution. Escaping the examples would cause LLMs to learn incorrect syntax from the skill's own documentation.

The parser should respect markdown code fence boundaries when scanning for executable patterns.

alexfazio avatar Dec 12 '25 13:12 alexfazio

Workaround: Use [BANG] placeholder in skill documentation

For plugin developers experiencing this issue with skill files, here's a workaround:

Problem: Skill files containing ! followed by backticks (the pre-execution syntax for slash commands) trigger bash execution errors when the skill content is loaded into Claude's context.

Solution: Replace ! with a placeholder like [BANG] in your skill documentation:

# Instead of this (causes execution errors):
Current branch: !`git branch --show-current`

# Use this:
Current branch: [BANG]`git branch --show-current`

When Claude explains the concept to users, it correctly interprets and renders the actual ! syntax they should use in their command files.

Example PR: https://github.com/sjnims/plugin-dev/pull/142

sjnims avatar Dec 12 '25 23:12 sjnims

Thanks - I was going to raise this but see you've done so already. The state of the official plugins are shocking eh, so many errors. Tangentially related:

  • https://github.com/anthropics/claude-code/issues/13331
  • https://github.com/anthropics/claude-code/issues/13344

kylesnowschwartz avatar Dec 16 '25 08:12 kylesnowschwartz