Skip to content

Commit bcac5a5

Browse files
sjnimsclaude
andauthored
docs(command-development): document bash ! prefix for pre-execution syntax (#55)
## Summary - Document the `!`command`` syntax required for bash pre-execution in actual command files - Explain that pre-execution happens before Claude sees the command - Clarify why skill examples intentionally omit `!` (would execute when loaded into context) - Update reference file examples to use correct `!` prefix for copy-paste use ## Problem Fixes #46 The command-development skill didn't document the `!` prefix syntax required for bash pre-execution in actual command files. Users following the examples would write `\`git status\`` instead of `!\`git status\``, resulting in non-functional commands. ## Solution 1. Added "Syntax: The `!` Prefix" section to SKILL.md explaining: - The exact `!`command`` syntax - How pre-execution works (before Claude sees the prompt) - Example showing input and expanded output 2. Added "Why Skill Examples Omit `!`" section explaining the intentional omission in skill documentation 3. Updated all bash examples in `plugin-features-reference.md` to use the `!` prefix, since users copy these into actual command files ### Alternatives Considered - Adding HTML comments to examples: Less visible, easily overlooked - Creating separate "for copying" examples: Would duplicate content ## Changes - `plugins/plugin-dev/skills/command-development/SKILL.md`: Added 40 lines documenting the `!` prefix syntax - `plugins/plugin-dev/skills/command-development/references/plugin-features-reference.md`: Updated 21 bash examples to use `!` prefix ## Testing - [x] Markdown linting passes - [x] Documentation is clear and complete - [x] Examples show correct syntax for actual command files --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 12b328a commit bcac5a5

3 files changed

Lines changed: 69 additions & 300 deletions

File tree

plugins/plugin-dev/skills/command-development/README.md

Lines changed: 0 additions & 272 deletions
This file was deleted.

plugins/plugin-dev/skills/command-development/SKILL.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,14 +334,54 @@ Ensure:
334334

335335
Commands can execute bash commands inline to dynamically gather context before Claude processes the command. This is useful for including repository state, environment information, or project-specific context.
336336

337+
### Syntax: The `!` Prefix
338+
339+
In actual command files, use the `!` prefix before backticks for pre-execution:
340+
341+
```markdown
342+
Current branch: !`git branch --show-current`
343+
Files changed: !`git diff --name-only`
344+
Environment: !`echo $NODE_ENV`
345+
```
346+
347+
**How it works:**
348+
349+
1. Before Claude sees the command, Claude Code executes `!`command`` blocks
350+
2. The bash output replaces the entire `!`command`` expression
351+
3. Claude receives the expanded prompt with actual values
352+
353+
**Example expansion:**
354+
355+
Command file contains:
356+
357+
```markdown
358+
Review the !`git diff --name-only | wc -l | tr -d ' '` changed files on branch !`git branch --show-current`.
359+
```
360+
361+
Claude receives (after pre-execution):
362+
363+
```markdown
364+
Review the 3 changed files on branch feature/add-auth.
365+
```
366+
367+
### Why Skill Examples Omit `!`
368+
369+
Examples in skill documentation use plain backticks without `!`:
370+
371+
```markdown
372+
Files changed: `git diff --name-only`
373+
```
374+
375+
This is intentional. When skill content loads into Claude's context, `!`command`` would actually execute. Skill examples show the conceptual pattern; add the `!` prefix when writing actual command files.
376+
337377
**When to use:**
338378

339379
- Include dynamic context (git status, environment vars, etc.)
340380
- Gather project/repository state
341381
- Build context-aware workflows
342382

343383
**Implementation details:**
344-
For complete syntax, examples, and best practices, see `references/plugin-features-reference.md` section on bash execution. The reference includes the exact syntax and multiple working examples to avoid execution issues
384+
For advanced patterns, environment-specific configurations, and plugin integration, see `references/plugin-features-reference.md`
345385

346386
## Command Organization
347387

0 commit comments

Comments
 (0)