Skip to content

SOP 006: Dynamic Context Injection

Fresh
FieldValue
SOP ID006
Version1.0
StatusActive
Last Updated2026-02-14

Purpose

Use the !command`` syntax to run shell commands before skill content is sent to Claude, injecting live data into the prompt.

How It Works

Important

This is preprocessing, not something Claude executes. Claude only sees the final result with command output already inserted.

Procedure

Step 1: Add Shell Commands to Skill Content

Use the !command`` syntax anywhere in your SKILL.md:

yaml
---
name: pr-summary
description: Summarize changes in a pull request
context: fork
agent: Explore
allowed-tools: Bash(gh *)
---

## Pull request context
- PR diff: !`gh pr diff`
- PR comments: !`gh pr view --comments`
- Changed files: !`gh pr diff --name-only`

## Your task
Summarize this pull request...

Step 2: Understand the Execution Order

  1. Each !command`` executes immediately (before Claude sees anything)
  2. The output replaces the placeholder in the skill content
  3. Claude receives the fully-rendered prompt with actual data

Step 3: Combine with Arguments

yaml
---
name: review-file
description: Review a specific file with git context
---

## File to review
!`cat $ARGUMENTS`

## Recent changes
!`git log --oneline -5 -- $ARGUMENTS`

## Your task
Review this file for issues...

Step 4: Enable Extended Thinking

Include the word "ultrathink" anywhere in your skill content to enable extended thinking mode:

yaml
---
name: deep-analysis
description: Perform deep code analysis with extended thinking
---

ultrathink

Analyze the following codebase thoroughly...

Verification Checklist

  • [ ] Shell commands use correct !command`` syntax
  • [ ] Commands work standalone in terminal before adding to skill
  • [ ] Combined with context: fork if skill runs in isolation
  • [ ] allowed-tools includes required Bash patterns
  • [ ] Tested that output renders correctly in Claude's context

See Also

Built with VitePress + Claude Code Skills RAG Chat