Back to Blog

Inject shell output into a skill before the model reads it

A !`command` in a SKILL.md injects its output into the prompt before the model ever sees the file. Front-load the context your skill needs and skip the tool-call round-trip.

claude-code skills context-engineering agents

One of the most useful features in skills is dynamic content: a !`command` in a SKILL.md — or any slash-command .md file — injects its output into the prompt before the model ever sees the file.
Claude Code runs each !`…` command the moment the skill loads, and replaces the token with the output itself.
The model never sees the ! syntax — only the text that came out of it.
No tool-call cost, and the model reasons over all the data in its first pass.

- Current branch: !`git branch --show-current`
- Staged diff: !`git diff --cached`
Review this diff against the project conventions.

When a skill always needs the same few pieces of cheap, dynamic context — the branch, the diff, CI status, log tails.
Without it, the model wastes tool calls gathering context it could have had from the start.
The benefit is token savings and context efficiency: when a skill needs context, the model has to go and fetch it — but if you inject it through a script, it’s just there.

The test for what belongs there: is the command fixed (no dependency on a value computed earlier) and unconditional (runs on every invocation)?
git status qualifies; git log $LAST_SHA..HEAD doesn’t, unless you collapse the whole thing into one command.
And really — does the model’s first decision need this data? If not, leave it where it’s needed.

There’s also the related ${ARGUMENTS} / $1 — a placeholder for passing arguments into a command.
Different mechanism, but often used alongside !`cmd`.

Skills I use this in

deploy-gcp — Deploys services to Cloud Run with pre-flight checks that stop a wrong-environment deploy.

The first question is always “which account and project am I pointed at, and is the tree clean?”
By the time the model reads the skill, it already knows.
It can refuse a deploy to prod in its first sentence, instead of running gcloud, reading the output, then deciding.
The whole safety value rests on that state existing before it acts.

deploy-delta — Computes the real commit backlog between the last deploy and local HEAD (“how far behind is prod”).

HEAD and the branch are the anchors the whole diff is measured against.
Pre-loading them means the comparison starts on the first beat.

tech-debt — End-of-session cleanup that finds duplication and dead code, then consolidates.

skillify — Turns the current session into a reusable skill.

It needs the transcript to know what process to capture.
A script extracts that and drops it straight in, so there’s no “let me reconstruct what we just did” detour.

standup — Loads context at the start of a session: where was I, what was I working on.

This is the clearest case.
The whole skill is answering from context — the recent commits, uncommitted work, and stashes are the answer.
Pre-loading them collapses about five tool calls to zero.
The model writes the summary right away.

Each of them front-loads the input its first decision depends on.
The payoff comes in two shapes: in standup and tech-debt, the injected context is the deliverable — loading it is most of the work the skill does.
In deploy-gcp it gates a decision — it lets the model judge or refuse before it acts.
The skill opens with the context already in hand. Anywhere the data is available and always needed — it’s worth using.