You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
docs(command-development): document bash ! prefix for pre-execution syntax
Document the `!`command`` syntax required for bash pre-execution in
actual command files:
- Add "Syntax: The `!` Prefix" section explaining how pre-execution
works
- Document that `!`command`` executes before Claude sees the prompt
- Explain why skill examples omit `!` (would execute when loaded)
- Update reference file examples to use `!` prefix consistently
Users copying examples from the reference file into actual command
files will now have the correct syntax.
Fixes#46
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: plugins/plugin-dev/skills/command-development/SKILL.md
+41-1Lines changed: 41 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -334,14 +334,54 @@ Ensure:
334
334
335
335
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.
336
336
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
+
337
377
**When to use:**
338
378
339
379
- Include dynamic context (git status, environment vars, etc.)
340
380
- Gather project/repository state
341
381
- Build context-aware workflows
342
382
343
383
**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`
0 commit comments