# Context Injection

Reference for `!` (bash) and `@` (file) operators.

## Bash Injection (!)

Execute a shell command and inject its stdout into the prompt.

### Syntax

```markdown
!command [args]
```

### Examples

```markdown
# Current git status
!git status

# Staged changes
!git diff --staged

# Recent commits
!git log -5 --oneline

# List files
!ls -la src/

# Environment info
!node --version
```

### Security Requirement

Commands used with `!` must be in `allowed-tools`:

```yaml
---
allowed-tools:
  - Bash(git *)
  - Bash(ls *)
  - Bash(node --version)
---

!git diff --staged
!ls src/
```

## File Injection (@)

Read file contents and inject into the prompt.

### Syntax

```markdown
@path/to/file
```

### Examples

```markdown
# Project guidelines
@docs/CONTRIBUTING.md

# Configuration
@.eslintrc.json

# Style guide
@docs/STYLE_GUIDE.md

# Specific source file
@src/components/Button.tsx
```

### Relative Paths

Paths are relative to the project root (where `.claude/` is located).

## Combined Usage

```markdown
---
description: Review staged changes against style guide
allowed-tools:
  - Bash(git diff *)
  - Read
---

# Code Review

## Style Guide
@docs/STYLE_GUIDE.md

## Staged Changes
!git diff --staged

## Task
Review the staged changes against the style guide.
Output findings as a Markdown table.
```

## Best Practices

| Do | Don't |
|----|-------|
| Fetch context automatically | Ask users to paste |
| Use specific commands | Use `Bash(*)` wildcard |
| Reference existing docs | Duplicate content |
| Keep injections focused | Inject entire codebases |
