prompt-engineering-guidance — Claude Code skill: how to install
Guides Claude Code in applying Microsoft Research's Guidance framework. It enforces structured LLM output using regular expressions and context-free grammars.
npx claude-code-templates@latest --skill ai-research/prompt-engineering-guidanceWhat prompt-engineering-guidance does
This skill provides practical patterns for Microsoft Research's Guidance library. Instead of relying on unconstrained text completion, it filters tokens at runtime. As a result, the model returns guaranteed JSON structures, specific multiple-choice values, or text matching a regular expression.
The guidance covers backends for Anthropic Claude, OpenAI, and local setups using Transformers or llama.cpp. It also explains token healing, which backs up one token to fix unnatural whitespace boundaries. Running these workflows requires Python along with the guidance package installed in your project environment.
What it helps with
- Force LLM outputs to match a strict regex for emails or phone numbers
- Restrict model choices to a predefined list using
select - Build multi-step agent workflows with the
@guidancedecorator - Generate valid JSON structures without broken syntax
Example prompts for the agent
- Show me how to constrain Claude output to an email format with Guidance regex
- Write a Guidance script using select to pick from four predefined answers
- Create a multi-step agent with the @guidance decorator for tool execution
How to install prompt-engineering-guidance
1claude-code-templates
npx claude-code-templates@latest --skill ai-research/prompt-engineering-guidance2Skills CLI (Vercel)
npx skills add davila7/claude-code-templates --skill prompt-engineering-guidance -a claude-code3Manually: put the files in place
~/.claude/skills/prompt-engineering-guidance/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/prompt-engineering-guidance/
Manually: put the files in place
.agents/skills/prompt-engineering-guidance/SKILL.mdFor all projects use ~/.agents/skills/
Manually: put the files in place
.cursor/skills/prompt-engineering-guidance/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install davila7/claude-code-templates prompt-engineering-guidance2Manually: put the files in place
.github/skills/prompt-engineering-guidance/SKILL.mdPlatform CLI
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/ai-research/prompt-engineering-guidanceManually: put the files in place
.devin/skills/prompt-engineering-guidance/SKILL.mdThe legacy .windsurf/skills/ path still works
Claude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about prompt-engineering-guidance
How do I install prompt-engineering-guidance in Claude Code?
Run npx claude-code-templates@latest --skill ai-research/prompt-engineering-guidance or npx skills add davila7/claude-code-templates --skill prompt-engineering-guidance -a claude-code. Alternatively, place the file into ~/.claude/skills/prompt-engineering-guidance/SKILL.md.
What is prompt-engineering-guidance?
It is a skill that instructs Claude Code on writing constrained generation code with the Guidance library. It guarantees syntax validation during model output.
What backends does Guidance support?
The skill outlines integration with Anthropic Claude and OpenAI APIs, alongside local models through Hugging Face Transformers or llama.cpp.