# prompt-engineering-guidance

Guides Claude Code in applying Microsoft Research's Guidance framework. It enforces structured LLM output using regular expressions and context-free grammars.

- skill · `type=skill` · Claude Code · 237 installs
- Author: Orchestra Research
- License: MIT · policy=link-only · description only; the file stays with the author
- Source: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/prompt-engineering-guidance
- Updated: 2026-10-24
- HTML: https://affpapa.org/en/nevibecode/skills/prompt-engineering-guidance

## What it 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.

## Install

### Claude Code (native platform)

1. **claude-code-templates**
```bash
npx claude-code-templates@latest --skill ai-research/prompt-engineering-guidance
```

2. **Skills CLI (Vercel)**
```bash
npx skills add davila7/claude-code-templates --skill prompt-engineering-guidance -a claude-code
```

3. **Manually: put the files in place**
- File: `~/.claude/skills/prompt-engineering-guidance/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/prompt-engineering-guidance/

### Codex

**Manually: put the files in place**
- File: `.agents/skills/prompt-engineering-guidance/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

**Manually: put the files in place**
- File: `.cursor/skills/prompt-engineering-guidance/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install davila7/claude-code-templates prompt-engineering-guidance
```

2. **Manually: put the files in place**
- File: `.github/skills/prompt-engineering-guidance/SKILL.md`

### Gemini CLI

**Platform CLI**
```bash
gemini skills install https://github.com/davila7/claude-code-templates --path cli-tool/components/skills/ai-research/prompt-engineering-guidance
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/prompt-engineering-guidance/SKILL.md` — The legacy .windsurf/skills/ path still works

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/davila7/claude-code-templates/tree/HEAD/cli-tool/components/skills/ai-research/prompt-engineering-guidance

## When to use it
- 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 `@guidance` decorator
- Generate valid JSON structures without broken syntax

## Example prompts
- 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

## Similar
- [skill-creator](https://affpapa.org/en/nevibecode/skills/skill-creator.md) — skill · 414180 installs
- [writing-for-agents](https://affpapa.org/en/nevibecode/skills/writing-for-agents.md) — skill · 466719 installs
- [media-use](https://affpapa.org/en/nevibecode/skills/media-use.md) — skill · 1100000 installs
- [mcp-builder](https://affpapa.org/en/nevibecode/skills/mcp-builder.md) — skill · 130949 installs
- [subagent-driven-development](https://affpapa.org/en/nevibecode/skills/subagent-driven-development.md) — skill · 237746 installs
- [orchestration](https://affpapa.org/en/nevibecode/skills/orchestration.md) — skill · 350300 installs

From the same set: [davila7/claude-code-templates](https://affpapa.org/en/nevibecode/by/davila7/claude-code-templates.md) — 804 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
