Claude Code Cuts Out an Extra Round of Waiting: Run `gh pr diff` Upfront Directly in SKILL.md
Run shell commands before the skill is fully loaded, so the diff gets pulled directly into the model context. This neat little trick shared by Ado Kukic eliminates unnecessary back-and-forth during interactions.
Claude Code's skill files can be leveraged as preprocessors.
Ado Kukic from Anthropic's Developer Relations team shared a use case on the second day of Advent of Claude 2026: running shell commands before Claude parses the skill content. The implementation is as simple as adding one line in SKILL.md:
!`gh pr diff`
This command runs before Claude reads the skill content. By the time the model accesses the skill, the real PR diff is already in its context. The common PR review workflow normally goes like this: you ask Claude to look at the diff, it first calls gh pr diff, waits for the output to return, then starts analysis. This adds an extra round of request and extra waiting time, and the delay becomes far more noticeable for large PRs. This trick moves the command execution upfront, and cuts out the entire back-and-forth of the "fetch the diff" step.
Prerequisites for this use case: you have GitHub CLI (gh) installed locally and logged in, your current working directory is under the corresponding repository, and the target PR exists. The full command output will be injected into the model context, so you need to control the output scope if the diff is too large. For security: commands written in SKILL.md will execute in your actual local environment, so only add trusted content there, and never directly splice unvetted external inputs into the shell command.
Sources: Ado Kukic's Post, AIHOT Entry.
The core value of this trick is eliminating one extra context back-and-forth. The few seconds of saved waiting is just the superficial benefit. Skill files are evolving from static prompt attachments into entry points with native execution capabilities.
发布时间: 2026-12-03 00:17